G95: just say no to second underscore

Mark Hadfield m.hadfield at niwa.co.nz
Tue Jan 30 13:21:05 MST 2007


Ed Hartnett wrote:
> So I am going to leave things as they are, and let g95 users who want
> to work with other packages set the flags as they wish. If you set
> these flags before building netCDF, it will not try to override your
> choices, so knowledgeable users can use the no-second-underscore flag
> if they wish.
>
> I have added the following note to the Porting and Installation Guide:
>
> "GNU compilers, and the g95 fortran compiler, use the f2cFortran
> flag. This is turned on automatically by configure.
>
> Some g95 users recommend instead setting the following, which handles
> the underscores differently, and reportedly works better when
> integrating with other packages or libraries:
>
> @example
> CC=gcc
> FC=g95
> CPPFLAGS=-DpgiFortran
> FFLAGS=-fno-second-underscore
> FCFLAGS=-fno-second-underscore
> @end example
>
> If this approach is taken, all fortran programs which use netCDF must
> be compiled with the -fno-second-underscore flag."
>   
I think that is the best solution.

A clarification: Gfortran, aka Gnu Fortran 95, does *not* use the second 
underscore by default:

    http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gfortran/Code-Gen-Options.html#Code-Gen-Options

Since Gfortran has replaced G77 as the standard Fortran compiler in the 
GCC suite, your statement that "GNU compilers, [...], use the f2cFortran 
flag." is not correct.

As you are aware, the netCDF build system handles Gfortran correctly, 
i.e., it uses -DpgiFortran and generates symbols with a single 
underscore. The resulting library is not compatible with g77. I expect 
this will generate its own set of support questions.

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



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



More information about the netcdfgroup mailing list