Home

ncgen

ncgen is a command-line utility in the NetCDF software ecosystem used to convert a CDL (netCDF Description Language) description into source code that can create a NetCDF dataset. The CDL file describes the structure of a dataset, including its dimensions, variables, attributes, and, for NetCDF-4, groups. When ncgen processes the CDL file, it outputs a program in a target language (typically C) that, once compiled and linked with the NetCDF library, will create a NetCDF file that matches the specification in the CDL.

The typical workflow involves writing a CDL file that captures the desired data model and metadata, then

ncgen is part of the NetCDF toolkit and has historically been used to generate example programs or

invoking
ncgen
to
produce
source
code.
The
generated
code
contains
calls
to
NetCDF
library
routines
to
define
dimensions,
variables,
and
attributes
and
to
write
data
where
the
CDL
specifies
initial
values.
Users
can
redirect
the
output
to
a
file
or
to
standard
output,
and
then
compile
the
resulting
code
with
an
appropriate
compiler
and
linked
NetCDF
libraries
to
produce
an
executable
that
creates
the
dataset.
skeleton
code
for
data
creation
and
testing.
It
complements
other
NetCDF
utilities
such
as
ncdump,
which
translates
NetCDF
datasets
back
into
CDL,
and
the
broader
NetCDF
API
libraries
that
support
reading
and
writing
NetCDF
data
in
multiple
languages.