Fortran dll calling another fortran dll

Fortran dll calling another fortran dll

Imagen de Aijt A.

Hi,

I am having trouble with subA from fortran1.dll calling subB of fortran2.dll. I linked fortran1.dll against lib of fortran2.dll. If subC from fortran3.exe calls, subB of fortran2.dll, it works fine. Just calling from fortran1.dll is giving me a strange fortran1.dll not found error. 

I am calling subA of fortran1.dll from excel vba. I could not find any relevant sample (fortrandll->fortrandll). I am using IVF compiler 10.0.027 with visual studio 2005 (only environment available to me right now).

Here is a code excerpt:

fortran2.dll: realname FIODLL.dll

subroutine fiodll()
implicit none
cDEC$ ATTRIBUTES DLLEXPORT, STDCALL, REFERENCE, ALIAS:"FIODLL" :: FIODLL
OPEN (77, FILE = 'C:\FIODLLOutput.txt', STATUS='REPLACE')
WRITE (77, *) "linked FIO Run Started."
CLOSE (77, STATUS = 'SAVE')
end

fortran1.dl: realname TCRACK.dll

subroutine tcrack(LengthINARR,LengthOUTARR,INARR,OUTARR)
IMPLICIT DOUBLE PRECISION(A-H,O-Z), INTEGER(I-N)

cDEC$ ATTRIBUTES DLLEXPORT, STDCALL, REFERENCE, ALIAS:"TCRACK" :: TCRACK

integer*2, intent(in) :: LengthINARR
integer*2, intent(in) :: LengthOUTARR
real*8, intent(in) :: INARR(LengthINARR)
real*8, intent(out) :: OUTARR(LengthOUTARR)
cDEC$ ATTRIBUTES REFERENCE :: InArray
cDEC$ ATTRIBUTES REFERENCE :: OUTARR

cDEC$ ATTRIBUTES DLLIMPORT, STDCALL, REFERENCE, ALIAS:"FIODLL" :: FIODLL

OPEN (88, FILE = 'C:\TCRACKTEST\TCRACKOutput.txt', STATUS='REPLACE')
WRITE (88, *) "TCRACK Run Started."
CLOSE (88, STATUS = 'SAVE')

call FIODLL()

end subroutine tcrack

Thanks,

-Ajit

publicaciones de 6 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.
Imagen de Steve Lionel (Intel)

The error message that Excel gives you can be misleading. It will tell you "fortran1.dll not found" when what it really means is that one of the DLLs that fortran1.dll depends on is not found. Keep in mind that when Windows searches for a DLL referenced by another DLL, it doesn't care where the first DLL is located. It will follow the standard Windows search rules:

  • Current default folder
  • Folder where the EXE was found (this means EXCEL.EXE)
  • Folders mentioned on PATH
  • Windows folder
  • Windows System folder

If Fortran2.dll is in the same place as Fortran1.dll, but you gave an explicit path to Fortran1.dll in VBA, Fortran2.dll will not be found.

Either you have to add the location(s) of your DLL(s) to PATH or perhaps merge the code into a single DLL.

Steve
Imagen de Aijt A.

Thanks you for pointing me in the right direction. Indeed, when I add the folder path to PATH variable, things work. But this is not desirable. I played a little with MixedLanguage\Excel sample. I cannot get the sample working with following declaration in vba:

Declare Sub FortranCall Lib "Fcall.dll" (r1 As Long, ByVal num As String)

(even when I have thd dll in the same folder as the excel file). When I use the full path of Fcall.dll, the sample works. What am I missing. I am sure there are parallels in sample and my code regarding this dll path.

Thank you,

-Ajit

but when I put the full path 

Imagen de Steve Lionel (Intel)

The Excel file is not relevant - you'd have to put the DLL in the same folder as EXCEL.EXE, which is obviously impractical. You'll note that for that sample it copies the DLL to C:\Temp folder and access it from that, hoping it exists....

Steve
Imagen de Aijt A.

Thanks Steve. My code works now (after adjusting the PATH variable). I will live with what I have.

Yes, FORTRAN is not dead yet.

-Ajit

Imagen de Steve Lionel (Intel)

Well, FORTRAN is dead, but Fortran lives!

Steve

Inicie sesión para dejar un comentario.