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

20030506: compiling netCDF-using Fortran code

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: 20030506: compiling netCDF-using Fortran code
  • Date: Tue, 06 May 2003 10:40:12 -0600

Zahra,

> To: <address@hidden>
> From: "Zahra Bouya" <address@hidden>
> Subject: help
> Organization: UNSW

The above message contained the following:

> I have a fortran code to read netcdf data, but couldn't use the netcdf =
> library. could you please help me on how to compile my code using netcdf =
> library.
> thank you
> Zahra Bouya

Answering such a general question is difficult, but, in general, if
the netCDF package was installed in the directory "opt/netcdf" and you
wanted to compile the Fortran-77 program "foo.F", then you would execute
something like the following command:

    f77 -c -I/opt/netcdf/include foo.F

where "/opt/netcdf/include" is the pathname of the directory that
contains the netCDF Fortran header-file "netcdf.inc".

To link the program "foo", you would, in general, execute something like
the following command:

    f77 -o foo foo.o -L/opt/netcdf/lib -lnetcdf

where "/opt/netcdf/lib" is the pathname of the directory that contains
the netCDF library "libnetcdf.a".

There might be someone at your school who could help you with the
specific details of your computer system.

Regards,
Steve Emmerson