Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having Trouble Passing Multi-Dimensional .NET Array to Fortran DLL

Status
Not open for further replies.

Bevo3

Technical User
May 26, 2011
4
US

Hello,

I have a simple VB2008 program that calls a Fortran array-valued function via a (*.dll) file. When I try passing a 1-dimensional .NET array to the Fortran function, it accepts it, performs the calculations, and successfully returns the same shape array back to the .NET framework. However, the array elements are garbage. In addition, if I try passing a multi-dimensional .NET array to the Fortran (*.dll) file I throw an exception. Can anyone give me some helpful advise with regard to passing multi-dimensional arrays between a .NET framework and a Fortran (*.dll) file?

Thank you much!
 
How are you declaring the array in VB? I'll have to look up the VB equivalent but in C# it is
Code:
[DllImport("xxx.dll")]
private static extern int routinename (
 [MarshalAs(UnmanagedType.LPArray)]double[] array);
It has to be passed as an unmanaged type.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top