I think Jim is right. In fortran/ncfortran.h, there's the following code:
#if defined(f2cFortran) && !defined(pgiFortran) && !defined(gFortran)
. . .
#define nf_inq_libvers nf_inq_libvers_
#define nf_strerror nf_strerror_
. . .
#endif /* f2cFortran */
This #if statement was getting reached by the 4.4.4 compilers, but not the
4.1.2 compilers.
I think this is because of the checking that's done in configure to see whether
gFortran or f2cFortran need to be set.
"gfortran44" isn't recognized (I think), so it slips into the "else" part of a
case statement:
*)
# If it's a gnu compiler, guess f2c.
if test "x$ac_cv_fc_compiler_gnu" = xyes; then
$as_echo "#define f2cFortran 1" >>confdefs.h
fi
--Mary
On Dec 6, 2011, at 2:19 PM, Jim Edwards wrote:
> The tool in netcdf to recognize the compiler is crude at best, I think that
> it just failed to recognize gfortran44 as being gfortran.
>
> On Tue, Dec 6, 2011 at 2:16 PM, Larry Baker <baker@xxxxxxxx> wrote:
> Mary,
>
> There should be a compiler option that controls whether and how many
> underscores get added to external names by the compiler. It sounds like the
> default for that option has changed on you. I am not at work, so I cannot
> check what my gcc says about it. But, you should be able to easily find the
> option. Try gcc --help -v and gfortran --help -v.
>
> Larry Baker
> US Geological Survey
> 650-329-5608
> baker@xxxxxxxx
>
>
>
>
> On Dec 6, 2011, at 10:42 AM, Mary Haley wrote:
>
> >
> > I'm running into an oddity when building NetCDF 4.1.3 on the same Linux
> > system, but with different versions of gcc and gfortran (4.1.2 versus
> > 4.4.4).
> >
> > When I use 4.1.2, I don't get a second underscore after Fortran routine
> > names, when the Fortran routine name already has an underscore. When I use
> > 4.4.4, I get this second underscore, which causes an undefined reference
> > when linking NetCDF with another package.
> >
> > I need to know how I can make sure that second underscore doesn't get
> > appended?
> >
> > --------------------------------------------------------------------------------------------------
> >
> > For gcc/gfortran 4.1.2, I'm using the following settings:
> >
> > setenv CPPFLAGS
> > '-I/glade/proj2/ncldev/install/mirage/netcdf-4.1.3-esmf/include
> > -I/glade/proj2/ncldev/install/mirage/external/include'
> > setenv LDFLAGS '-L/glade/proj2/ncldev/install/mirage/netcdf-4.1.3-esmf/lib
> > -L/glade/proj2/ncldev/install/mirage/external/lib'
> >
> > setenv FC gfortran
> > setenv F77 gfortran
> > setenv F90 gfortran
> > setenv CC gcc
> > setenv CXX g++
> >
> > setenv CFLAGS -fPIC
> > setenv FFLAGS '-fPIC -fno-second-underscore'
> > setenv F90FLAGS '-fPIC -fno-second-underscore'
> > setenv FCFLAGS '-fPIC -fno-second-underscore'
> > setenv CXXFLAGS -fPIC
> >
> > make clean
> > make distclean
> >
> > ./configure --disable-netcdf-4 --disable-dap --enable-f90 --disable-shared
> > --prefix=/glade/proj2/ncldev/install/mirage/netcdf-4.1.3-esmf
> >
> > make all install
> > make install
> >
> > and I get what I'd expect:
> >
> > % nm /glade/proj2/ncldev/install/mirage/netcdf-4.1.3-esmf/lib/libnetcdff.a
> > | grep nf_inq_libvers
> > 0000000000000333 T nf_inq_libvers_
> > U nf_inq_libvers_
> >
> > Note there's only one underscore after "nf_inq_libvers" in both cases.
> >
> > --------------------------------------------------------------------------------------------------
> > For gcc/gfortran 4.4.4, I only change the following settings:
> >
> > setenv FC gfortran44
> > setenv F77 gfortran44
> > setenv F90 gfortran44
> > setenv CC gcc44
> > setenv CXX g++44
> >
> > I then get:
> >
> > % nm /glade/proj2/ncldev/install/mirage/netcdf-4.1.3-esmf/lib/libnetcdff.a
> > | grep nf_inq_libvers
> > 0000000000000301 T nf_inq_libvers__
> > U nf_inq_libvers_
> >
> > Note the second underscore in one case, but not the other.
> >
> > --------------------------------------------------------------------------------------------------
> >
> > Is there some code I can modify to make sure that second underscore doesn't
> > get added?
> >
> > Thanks,
> >
> > --Mary
> >
> > _______________________________________________
> > netcdfgroup mailing list
> > netcdfgroup@xxxxxxxxxxxxxxxx
> > For list information or to unsubscribe, visit:
> > http://www.unidata.ucar.edu/mailing_lists/
>
> _______________________________________________
> netcdfgroup mailing list
> netcdfgroup@xxxxxxxxxxxxxxxx
> For list information or to unsubscribe, visit:
> http://www.unidata.ucar.edu/mailing_lists/
>
>
>
> --
> Jim Edwards
>
>
>