netCDF  4.3.0
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
NetCDF Example Programs

The netCDF example programs show how to use netCDF.

In the netCDF distribution, the “examples” directory contains examples in C and CDL. The examples create, and then read, example data files of increasing complexity.

There are three sets of netCDF classic example programs; corresponding examples are included with the netCDF Fortran and C++ APIs.

Any existing netCDF applications can be converted to generate netCDF-4/HDF5 files. Simply change the file creation call to include the correct mode flag.

In one of the netCDF classic examples which write a data file, change the nc_create() call so that NC_NETCDF4 is one of the flags set on the create.

The corresponding read example will work without modification; netCDF will notice that the file is a NetCDF-4/HDF5 file, and will read it automatically, just as if it were a netCDF classic format file.

In the example in this section we show some of the advanced features of netCDF-4.

The examples are built and run with the “make check” command. (See Building NetCDF).

The corresponding examples in each language create identical netCDF data files. For example, the C program sfc_pres_temp_wr.c produces the same data file as the Fortran 77 program sfc_pres_temp_wr.f.


Generated on Tue Jul 9 2013 19:18:06 for netCDF. NetCDF is a Unidata library.