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.
Ed Hartnett <address@hidden> writes: > Unidata Support <address@hidden> writes: > > > ------- Forwarded Message > > > > >To: address@hidden > > >From: Reto Stockli <address@hidden> > > >Subject: NetCDF Fortran 90 Interface > > >Organization: University Irchel > > >Keywords: 200501181245.j0ICj4v2010748 netCDF 3.6.0 Fortran90 > > > > Dear NetCDF team, > > > > I have compiled the NetCDF 3.6.0 on OSX (GCC and Absoft Fortran 8.0) > > and Linux (GCC and PGF). The library works. However, if I use the new > > NF_90 commands from fortran, I have to feed the netcdf.o during the > > linking process, even though I have linked to the library itself. So > > your example: > > > > http://my.unidata.ucar.edu/content/software/netcdf/docs/netcdf-f90/ > > Compiling-and-Linking-with-the-NetCDF-Library.html#Compiling-and- > > Linking-with-the-NetCDF-Library > > ln -s /usr/local/netcdf/src/f90/netcdf.mod . > > f90 -c mymodule.f90 > > f90 -o myprogram myprogram.o -L/usr/local/netcdf/lib -lnetcdf > > > > gives me undefined symbols. If I link the object file, it works fine. > > This would look like: > > > > ln -s /usr/local/netcdf/src/f90/netcdf.mod . > > f90 -c mymodule.f90 > > f90 -o myprogram myprogram.o > > /usr/local/lib/netcdf-3.6.0/src/f90/netcdf.o -L/usr/local/netcdf/lib > > -lnetcdf > > > > This resolves the problem. The libnetcdf.a is in the directory > > /usr/local/netcdf/lib/, so this is not the problem. How can I compile > > my fortran code without linking the object file itself but indicating > > the library only? Is there something I am missing? > > > > Cheers, > > Reto > > > > -- > > Reto Stöckli > > ETH/IAC (NFS Klima) & NASA/GSFC Code 913 (SSAI) > > Office: University Irchel, Building 25 Room J53 > > Phone: +41 (0)1 635 5209 Fax: +41 (0)1 362 5197 > > Winterthurerstrasse 190 Email: address@hidden > > 8057 Zürich Switzerland address@hidden > > > > http://earthobservatory.nasa.gov > > http://www.iac.ethz.ch/staff/stockli > > > > Howdy! > > Firstly, can I ask if "make test" worked when you installed netcdf? > > If that worked, than the test F90 program is properly linking to the > netcdf library. > > If our test program can do it, so can your application! ;-) > > Please send me the output from make test, if it failed. If it > succeeded, I suggest you take a look at your -L and -l options during > compile, to ensure that they are what they need to be. > > Thanks, > > Ed > -- > Ed Hartnett -- address@hidden -- Ed Hartnett -- address@hidden