2007 Unidata NetCDF Workshop for Developers and Data Providers > NetCDF APIs
5.1 The C API
The C library is the core implementation on which non-Java
interfaces are built.
The netCDF-3 C interface provides portability, performance, and reliability.
Strengths
- Well-documented: The netCDF C Users Guide is complete and
up-to-date, and reference documentation is maintained in man-page
form.
- Comprehensively tested: A large number of tests are run when
the netCDF C library is installed from source.
- Good support: Since the Unidata developers use the C interface
and provide support for it, answers for many support questions are
already available.
- Many users: The C interface is one of the most widely used
netCDF interfaces.
- Supported by ncgen utility: The ncgen utility, given a CDL file, can
generate the C code needed to
create the file. This is a currently a significant advantage of using
the C interface, if you want to avoid writing the boilerplate code to
create files with lots of variables and attributes.
- OPeNDAP capable: By installing OPeNDAP and relinking C
applications with the OPeNDAP client library, access to data on
OPeNDAP servers is available.
Other Characteristics
- Memory handling and garbage collection: You have to provide memory
space for any netCDF data values and attribute values you read.
- Error handling: The status of every function call must be
checked, which detracts from code clarity.
- Lacks advanced features of the netCDF Java interface.
Examples
Annotated examples of complete C netCDF programs are available from
the program examples page.
2007 Unidata NetCDF Workshop for Developers and Data Providers > NetCDF APIs