netCDF  4.2.1.1
ncgen

The ncgen tool generates a netCDF file or a C or FORTRAN program that creates a netCDF dataset.

If no options are specified in invoking ncgen, the program merely checks the syntax of the CDL input, producing error messages for any violations of CDL syntax.

The ncgen tool is now is capable of producing netcdf-4 files. It operates essentially identically to the original ncgen.

The CDL input to ncgen may include data model constructs from the netcdf- data model. In particular, it includes new primitive types such as unsigned integers and strings, opaque data, enumerations, and user-defined constructs using vlen and compound types. The ncgen man page should be consulted for more detailed information.

UNIX syntax for invoking ncgen:

     ncgen [-b] [-o netcdf-file] [-c] [-f] [-k<kind>] [-l<language>] [-x] [input-file]

where:

-b
Create a (binary) netCDF file. If the '-o' option is absent, a default
file name will be constructed from the netCDF name (specified after
the netcdf keyword in the input) by appending the '.nc'
extension. Warning: if a file already exists with the specified name
it will be overwritten.
-o netcdf-file
Name for the netCDF file created. If this option is specified, it
implies the '-b' option. (This option is necessary because netCDF
files are direct-access files created with seek calls, and hence
cannot be written to standard output.)
-c
Generate C source code that will create a netCDF dataset matching the
netCDF specification. The C source code is written to standard
output. This is only useful for relatively small CDL files, since all
the data is included in variable initializations in the generated
program. The -c flag is deprecated and the -lc flag should be used
intstead.
-f
Generate FORTRAN source code that will create a netCDF dataset
matching the netCDF specification. The FORTRAN source code is written
to standard output. This is only useful for relatively small CDL
files, since all the data is included in variable initializations in
the generated program. The -f flag is deprecated and the -lf77 flag
should be used intstead.
-k
The -k file specifies the kind of netCDF file to generate. The
arguments to the -k flag can be as follows.
        1, classic – Produce a netcdf classic file format file.
        2, 64-bit-offset, '64-bit offset' – Produce a netcdf 64 bit classic file format file.
        3, hdf5, netCDF-4, enhanced – Produce a netcdf-4 format file.
        4, hdf5-nc3, 'netCDF-4 classic model', enhanced-nc3 – Produce a netcdf-4 file format, but restricted to netcdf-3 classic CDL input.
Note that the -v flag is a deprecated alias for -k.
-l
The -l file specifies that ncgen should output (to standard output)
the text of a program that, when compiled and executed, will produce
the corresponding binary .nc file. The arguments to the -l flag can be
as follows.
        c|C => C language output.
        f77|fortran77 => FORTRAN 77 language output; note that currently only the classic model is supported for fortran output.
-x
Use “no fill” mode, omitting the initialization of variable values
with fill values. This can make the creation of large files much
faster, but it will also eliminate the possibility of detecting the
inadvertent reading of values that haven't been written.

Examples

Check the syntax of the CDL file foo.cdl:

     ncgen foo.cdl

From the CDL file foo.cdl, generate an equivalent binary netCDF file named bar.nc:

     ncgen -o bar.nc foo.cdl

From the CDL file foo.cdl, generate a C program containing netCDF function invocations that will create an equivalent binary netCDF dataset:

     ncgen -l c foo.cdl > foo.c
 All Data Structures Files Functions Variables Typedefs Defines

Generated on Fri Sep 14 2012 07:36:40 for netCDF. NetCDF is a Unidata library.