C interface
jowr opened this issue · comments
Write an interface in C that allows us to use the same function names on Windows and Linux. Eventually, this will solve most of the header issues and we do not need the scripts to fix the Matlab files.
TODO:
- Write the C interface
- Change all function names in the other files
- Remove additional header files
- Test the code and makefile
I have an even better solution.
In the PASS_FTN.for file, add BIND(C, NAME="SETUPdll") to the end of each subroutine. For instance, setup function would become
c ======================================================================
subroutine SETUPdll (i,hfld,hfm,hrf,ierr,herr) BIND(C, NAME="SETUPdll")
include 'commons.for'
cDEC$ ATTRIBUTES DLLEXPORT, Decorate, Alias: "SETUPdll"::SETUPdll
cDEC$ ATTRIBUTES STDCALL, REFERENCE::SETUPdll
c dll_export SETUPdll
integer*4 i
character*10000 hfld
character*255 hfm, herr
character*3 hrf
call SETUP0 (i,hfld,hfm,hrf,ierr,herr)
end
which would then get exported by gfortran as SETUPdll when compiled with fortran 2003. I'm in contact with Eric Lemmon and I think we can get this change made upstream.
It's pretty easy to search the PASS_FTN.for file to find the subroutine lines, parse them, and then add the BIND(C, ...) output.
I'll give it a try. Thanks for the suggestion. I guess everyone except my group works with fairly new Fortran versions...
This potentially solves so many pitfalls regarding header files and function names for cross-platform development.
Turns out its not quite so straightforward. You have to worry about C
style and FORTRAN style strings. But I think that I am mostly done.
On Wed, Oct 1, 2014 at 7:32 AM, Jorrit Wronski notifications@github.com
wrote:
I'll give it a try. Thanks for the suggestion. I guess everyone except my
group works with fairly new Fortran versions...This potentially solves so many pitfalls regarding header files and
function names for cross-platform development.—
Reply to this email directly or view it on GitHub
#17 (comment).
Thanks. You are mostly done? Means I should hold my horses? Looking
forward to have a solution presented by you ;-)
I would say that this has been solved by the new header files.