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

Re: 19990209: question about netcdf



>To: address@hidden
>From: address@hidden (Xiaoqing Wu)
>Subject: question about netcdf 
>Organization: UCAR
>Keywords: 199902092055.NAA25729

Hi Xiaoqing Wu,

> I have a netcdf format dataset (i.e., data.nc),
> and I want to get a fortran code to read the dataset (data.nc).
> Could you tell me how to generate the code?

See the user-contributed program named "GENNET.F" from Barry
Schwartz:

 ftp://ftp.unidata.ucar.edu/pub/netcdf/contrib/gennet.f

This Fortran program will generate Fortran to read any netCDF file.
However, the code it generates uses the netCDF version 2 Fortran
interface.  The version 2 interface is still supported by the current
netCDF software library, but the netCDF documentation now documents
the netCDF-3 Fortran interface.  Hence if you want to understand and
modify the generated Fortran program, you will need to refer to the
older netCDF-2 User's Guide at

  http://www.unidata.ucar.edu/packages/netcdf/guide_toc.html

or the more concise reference documentation for netCDF version 2 at

  http://www.unidata.ucar.edu/cgi-bin/man-cgi?netcdf2+-s3f

Please note that gennet.f is user-contributed software, so we cannot
support it directly; it is made available "as is".  For more
information about user-contributed netCDF software, please see

  http://www.unidata.ucar.edu/packages/netcdf/contrib.html

I am not aware of software for generating Fortran to read a netCDF
file using the netcdf-3 Fortran interface.  However, it is possible to
use the ncgen utility, available as part of the netCDF package, to
generate Fortran to write a netCDF file:

  $ ncdump data.nc > data.cdl
  $ ncgen -f data.cdl > writedata.f

For more information about this, see the ncgen documentation at

  http://www.unidata.ucar.edu/cgi-bin/man-cgi?ncgen

It might be possible to modify the resulting code to write the netCDF
file so that it reads the file instead, by changing the "put" calls to
"get" calls and deleting the calls that define the dimensions,
variables, and attributes.

_____________________________________________________________________

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