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

2016-11-17 Thread Michael Jackson
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.jack...@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 *


2016-11-17 15:21 GMT-04:00 Alan W. Irwin >:

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
).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net
); the Time
Ephemerides project (timeephem.sf.net );
PLplot scientific plotting
software package (plplot.sf.net ); the libLASi
project
(unifont.org/lasi ); the Loads of Linux
Links project (loll.sf.net );
and the Linux Brochure Project (lbproject.sf.net
).
__

Linux-powered Science
__



--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


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

2016-11-17 Thread Joachim Pouderoux
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 *


2016-11-17 15:21 GMT-04:00 Alan W. Irwin :

> 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).
>
> Programming affiliations with the FreeEOS equation-of-state
> implementation for stellar interiors (freeeos.sf.net); the Time
> Ephemerides project (timeephem.sf.net); PLplot scientific plotting
> software package (plplot.sf.net); the libLASi project
> (unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
> and the Linux Brochure Project (lbproject.sf.net).
> __
>
> Linux-powered Science
> __
>
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

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

2016-11-17 Thread Alan W. Irwin

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).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__

Linux-powered Science
__
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


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

2016-11-17 Thread Joachim Pouderoux
Unfortunately I can't (Fortran95 only), that's why CMake feature is
important.

Joachim

*Joachim Pouderoux*, PhD

*Technical Expert - Scientific Computing Team*
*Kitware SAS *


2016-11-17 10:48 GMT-04:00 Elizabeth A. Fischer <
elizabeth.fisc...@columbia.edu>:

> Can you use the Fortran/C interop that is now an ISO standard for Fortran
> 2003 and beyond?  That should eliminate the issues you're facing here.
>
> https://gcc.gnu.org/onlinedocs/gfortran/Interoperability-with-C.html
>
>
> On Thu, Nov 17, 2016 at 8:50 AM, Joachim Pouderoux <
> joachim.pouder...@kitware.com> wrote:
>
>> Hi,
>>
>> I am using something like this in my CMake script:
>>   enable_language(Fortran)
>>   include(FortranCInterface)
>>   FortranCInterface_VERIFY()
>>   FortranCInterface_HEADER(${CMAKE_CURRENT_BINARY_DIR}/FortranBinding.h
>> MACRO_NAMESPACE "FC_"
>> SYMBOL_NAMESPACE "FC_")
>>
>> So far, with gfortran/gcc/clang, I never had any issues and the generated
>> FortranBinding.h is correct, defining FC_GLOBAL, FC_GLOBAL_, FC_MODULE
>> and FC_MODULE_ macros.
>> However, I am facing issues with Intel compilers (icc+ifort) (I am using
>> v17.0.0), VERIFY macro claims that it is OK but then, the
>> FortranBinding.h header is empty (only the #ifndef,#define,#endif
>> stuff), no macro definition.
>> Any idea?
>>
>> Thanks!
>> Best,
>>
>> *Joachim Pouderoux*, PhD
>>
>> *Technical Expert - Scientific Computing Team*
>> *Kitware SAS *
>>
>>
>> --
>>
>> Powered by www.kitware.com
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Kitware offers various services to support the CMake community. For more
>> information on each offering, please visit:
>>
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/cmake
>>
>
>
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

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

2016-11-17 Thread Elizabeth A. Fischer
Can you use the Fortran/C interop that is now an ISO standard for Fortran
2003 and beyond?  That should eliminate the issues you're facing here.

https://gcc.gnu.org/onlinedocs/gfortran/Interoperability-with-C.html


On Thu, Nov 17, 2016 at 8:50 AM, Joachim Pouderoux <
joachim.pouder...@kitware.com> wrote:

> Hi,
>
> I am using something like this in my CMake script:
>   enable_language(Fortran)
>   include(FortranCInterface)
>   FortranCInterface_VERIFY()
>   FortranCInterface_HEADER(${CMAKE_CURRENT_BINARY_DIR}/FortranBinding.h
> MACRO_NAMESPACE "FC_"
> SYMBOL_NAMESPACE "FC_")
>
> So far, with gfortran/gcc/clang, I never had any issues and the generated
> FortranBinding.h is correct, defining FC_GLOBAL, FC_GLOBAL_, FC_MODULE and
> FC_MODULE_ macros.
> However, I am facing issues with Intel compilers (icc+ifort) (I am using
> v17.0.0), VERIFY macro claims that it is OK but then, the FortranBinding.h
> header is empty (only the #ifndef,#define,#endif stuff), no macro
> definition.
> Any idea?
>
> Thanks!
> Best,
>
> *Joachim Pouderoux*, PhD
>
> *Technical Expert - Scientific Computing Team*
> *Kitware SAS *
>
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
>
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake