Re: G95: just say no to second underscore

From the G95 page:

While g95 produces stand-alone executables, it is occasionally desirable to interface with other programs, usually C. The first difficulty that multi-language program will face is the names of the public symbols. G95 follows the f2c convention of adding an underscore to public names, or two underscores if the name contains an underscore. The -fno-second-underscore and -fno-underscoring can be useful to force g95 to produce names compatible with your C compiler.

-Roy

On Jan 29, 2007, at 7:05 PM, Mark Hadfield wrote:

Ed Hartnett wrote:
Howdy Mark!

I am responding to your email rather late, because I just got g95 up
and running in the netCDF nightly build system.
Good.

I have cut out a lot of quoted text here, but basically my original message described how to build netCDF with g95 using the "-fno- second-underscore" convention. I also suggested making this the default...

Can you tell me what the consequences of this are?

Do g95 users have to use -fno-second-underscore when compiling a
fortran program with the netCDF library?

Yes, they would have to do this.
If I just set -Df2cFortran when compiling netCDF, g95 works without
any further fuss. What is wrong with doing that?

Only that g95's default "second-underscore" name mangling complicates building other packages, e.g. the MITgcm ocean model, and you can't mix libraries that use different name mangling conventions. (The same is true of g77.) This can be worked around in each case, of course, but personally I think it's simpler to use "-fno-second-underscore" everywhere.
I have just added g95 to a number of our nightly test platforms. The
intention is to have netCDF 3.6.2 do the "right thing" for g95. Now I
just have to know what the right thing is!

Hmmm. My original message to the group didn't bring a deluge of "I agree" responses, so perhaps you should stick with the default.

My next suggestion was that the test in the configure code for Fortran-C linking could use a subroutine name with an underscore (given that the f2c name-mangling convention behaves differently for names with and without underscores, and all the names in the netCDF-3 Fortran interface have underscores).

At the moment configure automatically sets -Df2cFortran for g95, and
everything seems to work. What's wrong with that?

Well, when you say "automatically" you mean that it works OK because of a lot of special-case code. Just like all the other packages that cope with g77's and g95's perverse name mangling.

But, I guess the sensible approach for you to take is "if it ain't broke don't fix it".

--
Mark Hadfield          "Ka puwaha te tai nei, Hoea tahi tatou"
m.hadfield@xxxxxxxxxx
National Institute for Water and Atmospheric Research (NIWA)



====================================================================== ========
To unsubscribe netcdfgroup, visit:
http://www.unidata.ucar.edu/mailing-list-delete-form.html
====================================================================== ========


**********************
"The contents of this message do not reflect any position of the U.S. Government or NOAA."
**********************
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division 
Southwest Fisheries Science Center
1352 Lighthouse Avenue
Pacific Grove, CA 93950-2097

e-mail: Roy.Mendelssohn@xxxxxxxx (Note new e-mail address)
voice: (831)-648-9029
fax: (831)-648-8440
www: http://www.pfeg.noaa.gov/

"Old age and treachery will overcome youth and skill."



==============================================================================
To unsubscribe netcdfgroup, visit:
http://www.unidata.ucar.edu/mailing-list-delete-form.html
==============================================================================


  • 2007 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: