Hi,
I have a Fortran subroutine which allocates an array and assign values to components:
subroutine ExampleSub (array) !DEC$ ATTRIBUTES STDCAll, DLLEXPORT::ExampleSub !DEC$ ATTRIBUTES ALIAS:"ExampleSub" :: ExampleSub !DEC$ ATTRIBUTES REFERENCE :: array integer, allocatable, dimension(:), intent (out):: array allocate (array(3)) array(1) = 111 array(2) = 222 array(3) = 333 return end subroutine
I've created a DLL from this subroutine and try to call it in VB.NET. My VB code looks like this:
Declare Sub ExampleSub Lib "C:\Users\Myaddress\Dll1.dll" Alias "ExampleSub" _ (ByVal array() As Integer) Sub Main() Dim array1(2) As Integer Call ExampleSub(array1) End Sub
The VB scripts runs without any errors however it produces wrong values for the array. Each time I run, it gives different results for the array.
Is it even possible to make this work in VB.NET while the Fortran DLL contains an allocatable array?
Thanks,
Arash