I have successfully called a C routine in a dll from Fortran and a Fortran routine in a dll called from VB many times. This is the first time I've tried using VB to call Fortran to call C.
The simple test routines below try to pass an integer from a Fortran routine called by VB to a C routine.
The value being passed = 12, but when it reaches the C routine, the value = 1239536.
Suggestions?
VB 2010 code:
Declare Sub TEST_FTN Lib "LHM_Fsrc.dll" ()
Call TEST_FTN()
FTN code:
SUBROUTINE TEST_FTN()
!DEC$ ATTRIBUTES DLLEXPORT, STDCALL :: TEST_FTN
!DEC$ ATTRIBUTES ALIAS:'TEST_FTN' :: TEST_FTN
IMPLICIT NONE
INTERFACE
SUBROUTINE Test_Int(i1)
!DEC$ ATTRIBUTES DLLIMPORT :: Test_Int
!DEC$ ATTRIBUTES DECORATE, ALIAS:'Test_Int' :: Test_Int
INTEGER :: i1
END SUBROUTINE Test_Int
END INTERFACE
INTEGER :: i1
i1 = 12
CALL Test_Int(i1)
RETURN
END SUBROUTINE TEST_FTN
C code:
__declspec(dllexport) void Test_Int(long i1);
void Test_Int(long i1)
{
long i2;
i2 = i1;
}
Regards, Mike