Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29487 Discussions

C# float array, how to pass by reference to Fortran ?

tsmithapp-geo-resear
675 Views
Update: I am seeing evidence that this is more of a build error at this time. I am going to close this myself as
answered and re-open if it is not a build error.

I have no trouble passing a simple integer or float by reference or by value to a Fortran subroutine but I
can not do the same with an Array. I get an error that indicates that the subroutine cant be found but it
can be found if i change the arguement to not be an array. Any ideas. Here is some info.

C# sidedeclare Fortran dll:

[DllImport("fortrandll.dll",
CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern void f_array(ref float[] arr1x100);

// declare array
float[] arr1x100 = new float[100];
// Call the the fortran routine vy reference
f_array(ref arr1x100);

!! FORTRAN SIDE:
subroutine f_array( Arr1x100)
IMPLICIT NONE
!DEC$ ATTRIBUTES DLLEXPORT :: f_array
!DEC$ ATTRIBUTES REFERENCE :: Arr1x100


integer, parameter :: maxsize=100
integer :: i
real(4), dimension (maxsize), intent(inout) :: Arr1x100

DO i=1, maxsize
Arr1x100(1:i)=i
END DO

end subroutine


RESULTING ERROR
Unable to find an entry point named 'f_array' in DLL 'fortrandll.dll'.
0 Kudos
0 Replies
Reply