[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #LQZ-375894]: Problem(s) using netcdf fortran library 4.4.2

This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.


  • Subject: [netCDF #LQZ-375894]: Problem(s) using netcdf fortran library 4.4.2
  • Date: Mon, 21 Dec 2015 10:41:29 -0700

Hello Sourish,

You are correct that the netcdf fortran and C interfaces have been separated 
out; however, the former still has a dependency upon the latter.  The C library 
(libnetcdf) is the `core` library, and the various interfaces (Fortran, C++, 
Python, etc) require the core C library.  Installing the C library should 
resolve the issue for you!

I hope this helps, please let me know if there are still issues!

Have a great day,

-Ward

> Hello,
> 
> I'm trying to build a fortran application using the netcdf fortran
> library 4.4.2, but I am running up against several errors. I've been
> using the netcdf fortran library for a couple of years now (I was using
> 4.3.x before this), and these new errors are baffling to me.  First off,
> my configure line was:
> 
> ./configure --prefix=/u/sbasu1/packages/netcdf-fortran/4.4.2 --enable-f03 
> CC=icc FC=ifort F77=ifort CFLAGS='-m64 -O3 -xSSE4.2 -fPIC -ftz -fp-model 
> strict -g' FFLAGS='-m64 -O3 -xSSE4.2 -fPIC -ftz -fp-model strict -g' 
> FCFLAGS='-m64 -O3 -xSSE4.2 -fPIC -ftz
> -fp-model strict -g'
> 
> Things worked as expected during the "make && make install"
> phase. HOWEVER, the first indication of trouble is the following:
> 
> $ nf-config --flibs -L/u/sbasu1/packages/netcdf-fortran/4.4.2/lib -lnetcdff 
> -lnetcdf
> $ ls /u/sbasu1/packages/netcdf-fortran/4.4.2/lib libnetcdff.a libnetcdff.la 
> libnetcdff.so libnetcdff.so.6 libnetcdff.so.6.0.1 pkgconfig
> 
> i.e., 'nf-config --flibs' wants me to use '-lnetcdf', but there is
> no libnetcdf.* in the lib folder. Sure enough, when I try to compile
> a test program (attached) with the recommended linker line:
> 
> $ ifort -I/u/sbasu1/packages/netcdf-fortran/4.4.2/include -o nf90_error.exe 
> nf90_error.F90 -L/u/sbasu1/packages/netcdf-fortran/4.4.2/lib -lnetcdff 
> -lnetcdf
> ld: cannot find -lnetcdf
> 
> HOWEVER, if I leave out the '-lnetcdf', then:
> 
> $ ifort -I/u/sbasu1/packages/netcdf-fortran/4.4.2/include -o nf90_error.exe 
> nf90_error.F90 -L/u/sbasu1/packages/netcdf-fortran/4.4.2/lib -lnetcdff
> /tmp/ifortUIAUG6.o: In function `MAIN__':
> nf90_error.F90:(.text+0x65): undefined reference to `nf90_inq_ncid_' 
> /u/sbasu1/packages/netcdf-fortran/4.4.2/lib/libnetcdff.so:
> undefined reference to `nc_put_vara_short' 
> /u/sbasu1/packages/netcdf-fortran/4.4.2/lib/libnetcdff.so:
> undefined reference to `nc_get_vara_short' 
> /u/sbasu1/packages/netcdf-fortran/4.4.2/lib/libnetcdff.so:
> undefined reference to `nc_get_att_float' 
> /u/sbasu1/packages/netcdf-fortran/4.4.2/lib/libnetcdff.so:
> undefined reference to `nc_get_vara_schar' 
> /u/sbasu1/packages/netcdf-fortran/4.4.2/lib/libnetcdff.so:
> undefined reference to `nc_inq_attname'
> ...
> ...
> 
> I thought the C and Fortran libraries were separated several versions
> ago, and I should no longer need the C library to use the Fortran
> library. Or...?
> 
> Please help :-)
> 
> Thanks,
> Sourish
> 
> Sourish Basu
> National Oceanic and Atmospheric Administration
> Global Monitoring Division
> 325 Broadway St, R/GMD
> Boulder, CO 80305, USA
> Phone: +1 303 497 6650
> Fax: +1 303 497 6290
> 
> 


Ticket Details
===================
Ticket ID: LQZ-375894
Department: Support netCDF
Priority: Normal
Status: Closed