Calling Fortran DLL

Aliyoos1

New member
Joined
May 11, 2011
Messages
1
Programming Experience
Beginner
Hi Everyone,
I need help with the following, I appreciate if someone can help.

I have problem with calling a Fortran DLL from VB.net Program. The VB program provide the GUI while the Fortran DLL does the calculations.

The Fortran DLL opens and reads from data files supplied by the VB program. however, DLL program displays a message that says it can not open the file.

this is VB declaration of the DLL:

Declare Sub WIDTH_SUB Lib "C:\ALI\Namoi_TM\Data\Test\WIDTH_SUB.DLL" (ByVal Rating As String, ByVal Rating_Len As Integer, _
ByVal Height As String, ByVal Height_Len As Integer, _
ByVal Output As String, ByVal Output_Len As Integer)

and here the call statement in the VB program

Call WIDTH_SUB(Rating, Len(Rating), height, Len(height), output, Len(output))

This is where fortran DLL can't pass
SUBROUTINE WIDTH_SUB(RFILE,GFILE,OUTPUT)
IMPLICIT NONE
DLL_EXPORT WIDTH_SUB
CHARACTER(len=*),INTENT(IN)::gfile,rfile,OUTPUT


OPEN(UNIT=100,FILE=rfile,STATUS='old',iostat=ierr)
if(ierr.ne.0)then
write(*,20) trim(rfile)
20 format('Cannot open file ',a,' for input.')
WRITE(*,*)'ierr= ',ierr
go to 9990
end if


the ierr value is 155


and VB error message is "AcccessViolationException was unhandled: Attempted to read or write protected memory."






 
How come your Fortran function appears to have 3 parameters and your VB method has 6? Also, it's a loooooooong time since I did any Fortran so I don;t know if this could be an issue:
VB.NET:
SUBROUTINE WIDTH_SUB([COLOR="red"]RFILE[/COLOR],[COLOR="blue"]GFILE[/COLOR],OUTPUT)
IMPLICIT NONE
DLL_EXPORT WIDTH_SUB
CHARACTER(len=*),INTENT(IN)::[COLOR="blue"]gfile[/COLOR],[COLOR="red"]rfile[/COLOR],OUTPUT
 
Back
Top