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

Re: 19950706: netCDF problem with Fortran interface



> Keywords: 199507062354.AA06428

Hi Erick,

> I am trying to install netcdf on our alpha running osf/1.
> 
> All the installation steps seem go ok including the `make test' but
> when I try to compile a fortran program I get link errors which seem to
> relate to being unable to find certain jackets routines.
> Here is a record of the most recent attempt:

 ...

> 3.  make test
> - ------------------- make test log ----------------------
> making `test' in directory /usr/local/netcdf/xdr

 ...

> making `test' in directory /usr/local/netcdf/fortran
> 
> ar rcuv ../libsrc/libnetcdf.a jackets.o
> ranlib ../libsrc/libnetcdf.a
> s - creating symbol hash table. Wait...
> ./fortc -L . -O osf ftest.src > ftest.f
> f77 -c  ftest.f
> f77 ftest.o -L../libsrc -lnetcdf -o ftest
> *** Testing nccre ...

Notice that "-lnetcdf" is needed above to tell f77 the name of the netCDF
library, and "-L." is needed to tell f77 where to find that library.  Since
your "make install" step installs the netcdf library in /usr/local/lib/, you
need to use "-L/usr/local/lib -lnetcdf" on your own f77 or linker command
lines to specify where to find the installed netCDF library and what its
name is.  If you're going to use an "include netcdf.inc" statement to
include Fortran declarations of parameters, you also may need to use a
"-I/usr/local/include" argument to tell the f77 compiler where to look for
include files.

 ...
> - -------------------------------
> 5. The fortran program
> - -------------------------------
>       program fgennc
>       include '/usr/local/include/netcdf.inc'

It is OK to use a long absolute pathname like this, but if you use the -I
argument to f77, as above, you can get away with just

       include 'netcdf.inc'

and make your program immune to changes in the location of the include file.

 ...
> - --------------------------------------------
> 6. f77 fgennc  or  f77 -L/usr/local/netcdf/libsrc fgennc

Try

    f77 -L/usr/local/lib -lnetcdf fgennc

______________________________________________________________________________

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