This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Help compiling again a delphi dll


Hello, I have inherited a piece of code which calls a Delphi function for which I have a dll.  The original code was compiled with an IBM compiler (I think)  and the salient peace of code doing the import then
was:

module overseer
       use kernel32
       interface
               function CluesOvr(scenario,region,soilorder,topography,rainfall,ASoildepth,Snumdairy,Snumsheep,Snumbeef,Snumdeer,AdditionalNitrogen,Supplementrate,SupplementType,Nloss,Ploss,ErrStr)
!DEC$ ATTRIBUTES  VALUE :: scenario,region,soilorder,topography,rainfall,ASoildepth,Snumdairy,Snumsheep,Snumbeef,Snumdeer,AdditionalNitrogen,Supplementrate,SupplementType
!DEC$ ATTRIBUTES  REFERENCE :: Nloss,Ploss,ErrStr
       LOGICAL CluesOvr
               integer*4 scenario,region,soilorder,topography,ASoildepth
               real*8 rainfall,Snumdairy,Snumsheep,Snumbeef,Snumdeer
               real*8 AdditionalNitrogen,Supplementrate
               Integer*4 SupplementType
               real*8 Nloss,Ploss
               character ErrStr(40)
          end function CluesOvr
       end interface
end module

Further down in the code the DLL was loaded into memory with a loadlibrary call and used a pointer to the function

I’ve ported this to gfortran like this:


module overseer
 interface
   LOGICAL (C_BOOL) function CluesOvr(scenario,region,soilorder,topography,rainfall,ASoildepth,Snumdairy,Snumsheep,Snumbeef,Snumdeer,Addi
tionalNitrogen,Supplementrate,SupplementType,Nloss,Ploss,ErrStr) bind (c, name="CluesOvr")
     USE, INTRINSIC :: ISO_C_BINDING
     INTEGER (C_INT), VALUE :: scenario,region,soilorder,topography,ASoildepth
     REAL (C_DOUBLE), VALUE :: rainfall,Snumdairy,Snumsheep,Snumbeef,Snumdeer
     REAL (C_DOUBLE), VALUE :: AdditionalNitrogen,Supplementrate
     INTEGER (C_INT), VALUE :: SupplementType
     REAL (C_DOUBLE) :: Nloss,Ploss
     CHARACTER(C_CHAR) :: ErrStr(40)
   end function CluesOvr
 end interface
end module

and I compile as follows:
gfortran -o cluesmod CluesMod_s.f90  -ffree-line-length-none -mrtd -g -L. OvrClues.dll

I can then run the program, but it does not complete. I get no error message, but it quits about half way.
The interesting thing is that (ultimately) I have to call the whole bloody thing from java using JNA. When I do that, I do get a stack error crash, so that leads me to think
that something weird is happening in memory, and that somehow even my initial attempt to just port the code to gfortran is incorrect.
Any ideas?
Thanx a bunch
Gaby


--
Dr Gabriella Turek
Sr. Software Engineer, Systems Development Team
NIWA Auckland, New Zealand
Tel: +64 9 3754645
www.niwa.co.nz
NIWA - Enhancing the benefit of New Zealand’s natural resources.

--
Please consider the environment before printing this email.
NIWA is the trading name of the National Institute of Water & Atmospheric Research Ltd.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]