6.0 Using C to read netCDF files

The simplest way to create the C code you need to read a netCDF file is to use the C program cdf2c.c, which can be obtained from the Unidata site or from

http://www-c4.ucsd.edu/~cids/software/visual.html.

This program reads a netCDF file and creates a C program with the required calls to the netCDF libraries. This machine-generated program needs only to be compiled, with the correct include file and netCDF library. When executed this code fragment can then read the netCDF file and is ready for C code to be added to undertake the analysis required by the user. The procedure for installing and compiling is described in the documentation from the web site listed above and is similar in operation to the cdf2fortran program described elsewhere here.

Return to the top of the primer.