[CMake] Issue with Fortran/C binding with Intel compilers

Michael Jackson mike.jackson at bluequartz.net
Thu Nov 17 15:02:04 EST 2016


Just to add my 2 cents to this. This past year a collaborator of mine 
updated his F95 code to F2003 and the ISO_C_BINDING syntax and this made 
the interaction between our C/C++ codes and their Fortran codes 
extremely easy. No more macros to try to figure out. It oddly, just 
seems to work. Well worth our time investment.
-- 
Mike Jackson  [mike.jackson at bluequartz.net]


Joachim Pouderoux wrote:
> Alan,
>
> Thanks for the advice, I think you are absolutely right, we should update
> to Fortran2003 to allow use of iso_c_binding module.
> Anyway I have actually been able to make CMake FortranCInterface work using
> a more recent version of CMake.
>
> Best,
> Joachim
>
>
> *Joachim Pouderoux*, PhD
>
>     /Technical Expert - Scientific Computing Team/
>     *Kitware SAS <http://www.kitware.fr>*
>
>
> 2016-11-17 15:21 GMT-04:00 Alan W. Irwin <irwin at beluga.phys.uvic.ca
> <mailto:irwin at beluga.phys.uvic.ca>>:
>
>     On 2016-11-17 11:12-0400 Joachim Pouderoux wrote:
>
>         Unfortunately I can't (Fortran95 only), that's why CMake feature is
>         important.
>
>
>     Hi Joachim:
>
>     I have helped convert two projects (PLplot and the ephcom subproject
>     of timeephem) recently to use the iso_c_binding module provided by
>     Fortran 2003, and that approach (at least for providing a Fortran
>     binding to a C library since we have had no need for a C binding to a
>     Fortran library) is absolutely great and works fine with fairly recent
>     versions of the Intel compiler, the gfortran compiler, and likely most
>     importantly from our point of view, the NAG compiler (which advertises
>     itself as being the Fortran compiler that is most demanding concerning
>     compliance with Fortran standards).
>
>     So my advice is to go ahead and at least experimentally provide the
>     option of using the iso_c_binding module to future-proof your work,
>     and once that new interfacing works I would push (assuming Fortran95
>     only is a committee decision) to make an exception for at least the
>     iso_c_binding module so you don't have to maintain some home-brew
>     C/fortran interface forever.
>
>      From my recent very positive experience with the iso_c_binding module,
>     the only reason not to go with that module for C/Fortran interfacing
>     needs is if if it doesn't work for those needs (which is not my
>     experience for a Fortran binding to a C API in the PLplot case with a
>     large variety of types of C calls including callbacks) or if there is
>     a Fortran compiler out there that does not support it.  I haven't
>     found such a compiler yet, but my search has only involved the 3
>     compilers referred to above so obviously has not been exhaustive. Is
>     there some Fortran compiler you are aware of (aside from really old
>     versions of any of them) that does not provide a working iso_c_binding
>     module?  And if such a beast exists that does not even support this
>     important part of Fortran 2003, do you want to cater to this beast
>     indefinitely?  After all, 2003 is quite a few years ago so if a compiler
>     doesn't support that, it is almost by definition unsupported.
>
>     Alan
>     __________________________
>     Alan W. Irwin
>
>     Astronomical research affiliation with Department of Physics and
>     Astronomy,
>     University of Victoria (astrowww.phys.uvic.ca
>     <http://astrowww.phys.uvic.ca>).
>
>     Programming affiliations with the FreeEOS equation-of-state
>     implementation for stellar interiors (freeeos.sf.net
>     <http://freeeos.sf.net>); the Time
>     Ephemerides project (timeephem.sf.net <http://timeephem.sf.net>);
>     PLplot scientific plotting
>     software package (plplot.sf.net <http://plplot.sf.net>); the libLASi
>     project
>     (unifont.org/lasi <http://unifont.org/lasi>); the Loads of Linux
>     Links project (loll.sf.net <http://loll.sf.net>);
>     and the Linux Brochure Project (lbproject.sf.net
>     <http://lbproject.sf.net>).
>     __________________________
>
>     Linux-powered Science
>     __________________________
>
>


More information about the CMake mailing list