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

Strings in Intel fortran and VB.net: Help needed

g_krishnan1
Beginner
318 Views
I'm trying to pass a string into a fortran dll, modify it , and then pass it back to vb.net. I have only been succesful in passing the string to the fortran dll, but not in retrieving a modified string in vb.net from the dll. The relevant code follows (taken from a previous example):

form1.vb:
Call DLL_ROUT(DBL_IN(1), DBL_OUT(1), STRING_IN, STRING_IN.Length, STRING_OUT)

modul1.vb
Declare Sub DLL_ROUT Lib "FCALL.DLL" (ByRef DBL_IN As Double, ByRef DBL_OUT As Double, ByVal STRING_IN As String, ByRef STRING_LNG As Integer, ByRef STRING_OUT As String)

fcall.f90:
SUBROUTINE DLL_ROUT (DBL_IN, DBL_OUT, STRING_IN, STRING_LNG, STRING_OUT)
!SUBROUTINE DLL_ROUT (DBL_IN, DBL_OUT, STRING_IN, STRING_LNG)
IMPLICIT NONE
! Specify that DLL_ROUT is exported to a DLL
! and that the external name is 'DLL_ROUT'
!DEC$ ATTRIBUTES DLLEXPORT, STDCALL :: DLL_ROUT
!DEC$ ATTRIBUTES ALIAS:'DLL_ROUT' :: DLL_ROUT
!DEC$ ATTRIBUTES REFERENCE :: STRING_IN, STRING_LNG, STRING_OUT

REAL(8), INTENT(IN) :: DBL_IN(4)
REAL(8), INTENT(OUT) :: DBL_OUT(4)
INTEGER(4), INTENT(IN) :: STRING_LNG
character(STRING_LNG), intent(IN) :: STRING_IN
!length of string?
character(8), intent(OUT) :: STRING_OUT

!open(unit=2, "joel.out",status='unknown')
write(2, *)STRING_IN//"_fortran"
DBL_OUT = 2.0_8 * DBL_IN
STRING_OUT = "fortran"

RETURN
END
Regards
GK
0 Kudos
0 Replies
Reply