VB6 Crashed calling fortran DLL

VB6 Crashed calling fortran DLL

I can get vb.net (VS2008) to complete calls properly but calls from vb6 to the AddLayer routine causes the vb6 to crash.

Fortran:

 

SUBROUTINE INIT_PARMS ! dll_export :: INIT_PARMS !DEC$ ATTRIBUTES DLLEXPORT, ALIAS:'INIT_PARMS' :: INIT_PARMS include "GENERAL.INC" NEL=0 NLD=0 NXY=0 NZ=0 DO 100 I=1,5 TH(I)=0.0 RA1V(I)=0.0 RA2E(I)=0.0 100 CONTINUE DO 200 I=1,10 RA3XL(I)=0.0 RA4YL(I)=0.0 RA5XP(I)=0.0 RA6YP(I)=0.0 RA7Z(I)=0.0 200 CONTINUE RETURN END SUBROUTINE AddLayer(Thickness,Modulus,Ratio) ! dll_export :: AddLayer !DEC$ ATTRIBUTES DLLEXPORT, ALIAS:'AddLayer' :: AddLayer !DEC$ ATTRIBUTES REFERENCE :: Thickness !DEC$ ATTRIBUTES REFERENCE :: Modulus !DEC$ ATTRIBUTES REFERENCE :: Ratio include "GENERAL.INC" REAL ,intent(in)::Thickness REAL ,intent(in)::Modulus REAL ,intent(in)::Ratio NEL=NEL+1 TH(NEL)=Thickness RA1V(NEL)=Ratio RA2E(NEL)=Modulus RETURN END

VB.NET:

 

Private Declare Sub INIT_PARMS Lib "ERI_ELSYM5.dll" Alias "INIT_PARMS" () Private Declare Sub AddLayer Lib "ERI_ELSYM5.dll" Alias "AddLayer" (ByRef Thickness As Single, ByRef Modulus As Single, ByRef Ratio As Single) Sub Main() Dim Th As Single Dim E As Single Dim Ratio As Single INIT_PARMS() Th = 8.0# E = 4000000.0# Ratio = 0.15 AddLayer(Th, E, Ratio) End Sub

VB6:

Private Declare Sub INIT_PARMS Lib "Debug\ERI_ELSYM5.dll" () Private Declare Sub AddLayer Lib "Debug\ERI_ELSYM5.dll" (ByVal Thickness As Single, ByVal Modulus As Single, ByVal Ratio As Single) Sub Main() Dim Th As Single Dim E As Single Dim Ratio As Single INIT_PARMS Th = 8# E = 4000000# Ratio = 0.15 AddLayer Th, E, Ratio End Sub

 

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

VB6 uses the STDCALL calling convention. By default, ifort uses the C calling convention. To work with VB6 you should add a
[Fortran]
!DEC$ ATTRIBUTES STDCALL :: AddLayer
[/Fortran]
to the body of the AddLayer subroutine.

(Repeat this for the INIT_PARAMS subroutine too.)

In VB.NET I was under the impression that the calling convention was also stdcall too, but perhaps I am wrong.

Leave a Comment

Please sign in to add a comment. Not a member? Join today