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

Re: 20010808: getting started with netCDF



>To: address@hidden
>From: "William C. Stone" <address@hidden>
>Subject: getting started with netCDF
>Organization: NIST
>Keywords: 200108081450.f78Eod126087

Hi Bill,

> I have a data set that contains a header block of descriptive information
> followed by an i x j array of points.  Each point has (1....n) spatial
> descriptions
> (X1,Y1,Z1)...(Xn,Yn,Zn).   And each spatial description [e.g. (Xn,Yn,Zn)ij ]
> may have 1...m scalar values associated with it.  We have a BNF description
> of our current data format to work with.
> 
> I want to translate our data format to/from netCDF.   I'm fluent in F90.
> In a few
> words, can you lead me to what portions of the F90 netCDF manual (and
> other references) would help me to quickly write a set of I/O routines to
> take our
> files and translate them to/from netCDF?
> 
> Any help/guidance will be greatly appreciated.

You should first try to determine if the array-oriented netCDF data
model is appropriate for the kind of data you have.  It is not
necessarily appropriate for some kinds of data characterized as a
variable number of variable-length records.  When you say "each
spatial description ... *may* have 1...m scalar values associated with
it", it sounds like variable-length data records or "ragged arrays"
that require some indirection to represent in netCDF form.  NetCDF are
scalars or multidimensional rectangular arrays whose shape is fixed
except possibly along one dimension.  You might want to read Section
1.9 "Limitations of NetCDF" and Chapter 2 "Components of a NetCDF
Dataset" in the User's Guide to help determine how appropriate the
netCDF data model is to your application.

If you decide it's appropriate, the next step might be to create (with
a text editor) a "CDL file" that describes the netCDF structure of the
data.  See the section of the manual that describes and shows an
example of the CDL notation for netCDF files at the beginning of
chapter 2 in the Fortran90 manual or in the Fortran-77 manual (where
it's formatted more readably):

  http://www.unidata.ucar.edu/packages/netcdf/guidef/guidef-7.html#HEADING7-0

CDL is just an ASCII notation for binary netCDF files, and there are
utility programs that convert CDL to/from netCDF.

Once you have your CDL file. say foo.cdl, you can use a utility to
generate all the Fortran calls necessary to create the corresponding
netCDF file:

  ncgen -f foo.cdl > foo.f

Looking at foo.f may give you a good start towards understanding the
netCDF access interface, at least for writing netCDF data.  This is
Fortran77 rather than Fortran90, but the interfaces are similar.

Chapter 4 of the User's Guide gives a reasonable overview of how the
interface is used to read and write data, without too much detail
about the actual parameters provided in each function call.

Good luck, and let us know if you have other specific questions about
the interfaces or software.

--Russ

_____________________________________________________________________

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