jowr / librefprop.so

Create a shared library from the Fortran sources provided by Refprop from NIST. This project provides an alternative to the refprop.dll that comes with the software. Please use the official instructions if possible
https://github.com/usnistgov/REFPROP-cmake
32 stars 8 forks source link

C interface #17

Closed jowr closed 8 years ago

jowr commented 10 years ago

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.

jowr commented 10 years ago

TODO:

ibell commented 9 years ago

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.

jowr commented 9 years ago

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.

ibell commented 9 years ago

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 https://github.com/jowr/librefprop.so/issues/17#issuecomment-57420870.

jowr commented 9 years ago

Thanks. You are mostly done? Means I should hold my horses? Looking forward to have a solution presented by you ;-)

jowr commented 8 years ago

I would say that this has been solved by the new header files.