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

[netCDF #NQR-841821]: linking to NetCDF library when compiling



Hi Michael,

It's important to know whether the library you installed from a
package manager was just compiled with the C interface or also
included a Fortran interface.  It's possible to build the netCDF
library for use only with C and C++ by specifying a --disable-fortran
flag to the configure script when building the library.

You can find out whether the library includes the Fortran interface
by running a command like

  nm -a /usr/lib/libnetcdf.a | grep nf_open

The output should include a line such as

   00000830 T nf_open_

(the address will be different) that indicates the entry "nf_open_"
is included in the library.  If there is no output, the library doesn't
contain the Fortran interfaces to netCDF.

If the library does contain the Fortran interfaces, you will need to
use a Fortran compiler that matches the conventions used when the
library was built for calling C functions from Fortran subroutines.
If the library was built with g95 or g77 and you use gfortran, the
conventions may not match, so gfortran would complain that it couldn't
find the functions.  An indication that you are using a different
Fortran compiler than was used to build the library would be the
appearance of a different number of trailing underscores in the names
of functions in the library, for example if the output from running the
command above included names with 2 trailing underscores, such as:

  00000830 T nf_open__

There may be flags to gfortran that allow an adjustment to be made, but
it may just be easier to build the netCDF library from source.  On
Ubuntu, this may be as easy as just invoking

  ./configure
  make check
  sudo make install

to install the package in /usr/local.

--Russ



Russ Rew                                         UCAR Unidata Program
address@hidden                     http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: NQR-841821
Department: Support netCDF
Priority: Normal
Status: Closed