Passing scalar type by value from C# to Fortran
If the Fortran function or routine wants to receive a scalar type by value the argument should be passed by value of equivalent type in C#.
Fortran subroutine
subroutine TestValProc(IntParm )
!DEC$ ATTRIBUTES DLLEXPORT :: TestValProc
!DEC$ ATTRIBUTES VALUE :: IntParm
integer, intent(in) :: IntParm
end subroutine
C# method prototype
[DllImport("FDLL.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern void TESTVALPROC(int IntParm);
Passing scalar type by reference from C# to Fortran
If the Fortran function or routine wants to receive a scalar type by reference the argument should be passed by reference of equivalent type in C#. By default, Fortran passes all scalar data type by reference so this is the most commonly case.
Fortran subroutine
subroutine TestRefProc(IntParm )
!DEC$ ATTRIBUTES DLLEXPORT :: TestRefProc
integer, intent(inout) :: IntParm
end subroutine
C# method prototype
[DllImport("FDLL.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern void TESTREFPROC(ref int IntParm);
