[MITgcm-support] G95 build issue: f2c name mangling

Ed Hill ed at eh3.com
Mon Oct 9 16:17:44 EDT 2006


On Mon, 09 Oct 2006 12:16:48 -0400 David Ferreira <dfer at ocean.mit.edu>
wrote:

> Hi,
> 
> I run into exactly the same problem as Mark with g95 (including the
> -fnosecond-unsderscore solving the MITgcm compilation but screwing
> up the netcdf package)
> 
> So I tried the -ignoretime option of genmake2 and it didn't change
> anything: there is still an error with a "_user_time__" in timers.o
> (.F) and a "_user_time_"
> in timer_stats.o (.c)
> 
> -ignoretime triggers a -DIGNORE_TIME flag which only appears
> in timers.F. This flag seems to disable the functionality of the
> time stuff, but not the definitions of the variables.
> However adding a "ifndef  IGNORE_TIME" around the definitions
> seems to do the trick, but that would need to be checked in (and the
> time utilities are lost)


*sigh*

Yes, exactly.

The authors of "MITgcm/eesupp/src/timer_stats.c" did two things that
compound each other.  First, the name-mangling fails for some compilers
due to the choice of names.  And second, they did not honor the
genmake2 "-ignoretime" flag.  Its that simple.

<rant>

Its a shame that the ISO C and ISO Fortran committees started to
consider a standard for cross-language binding some years ago but
failed to produce anything.  And its doubly annoying because there are
so many useful (especially "systems programming") routines that are
readily available in C, C++, and many other languages but either
unavailable in Fortran or only available through non-standard language
extensions or cross-language linking tricks.

There are many ways to deal with the Fortran-C cross-linking issue and
here are three common approaches:

 1) do it yourself -- this can range from simple hard-coded names to
    tangles of per-platform #define-s to arbitrarily complicated
    frameworks that involve pre-processing, macros, stubs, etc.

 2) use the "cfortran.h" collection of macros as done by many other 
    projects (eg. NetCDF) that do cross-language binding:

    http://www-zeus.desy.de/~burow/cfortran/

 3) use the Gnu autotools ("AC_FC_FUNC") macro facilities:

    http://www.gnu.org/software/autoconf/manual/html_node/Fortran-Compiler.html


I recently worked on some code that mixed C++ and F77 bits and was
happy with the Gnu autotools macros (#3).  But it was a small number of
routines and I have not had the time to test it with a lot of different
compilers.

</rant>

Ed

-- 
Edward H. Hill III, PhD  |  ed at eh3.com  |  http://eh3.com/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mitgcm.org/pipermail/mitgcm-support/attachments/20061009/d99d9933/attachment.sig>


More information about the MITgcm-support mailing list