2010 Unidata NetCDF Workshop > NetCDF Utilities
5.6 ncdump and ncgen together
Used together, ncdump and ncgen can
accomplish simple netCDF manipulations with little or no programming.
- The ncdump and ncgen utilities
are inverses of each other:
-
To add, delete, or change metadata or data in a binary netCDF file:
- Use ncdump to convert netCDF file to CDL
- Use a text editor to make desired change to CDL
- Use ncgen to turn modified CDL back into
modified netCDF file
- This is not very practical for large netCDF files.
-
To create a new netCDF file with lots of metadata:
-
Use a text editor to write a CDL file with lots of metadata but little or no data.
-
Use ncgen to generate a C or Fortran program that writes the
corresponding binary netCDF file.
- Insert easy "var_put"calls to the netCDF library for the data
writing part of the task.
- Compile and run the program to create the netCDF file
- Use ncdump to verify the desired file is created.
2010 Unidata NetCDF Workshop > NetCDF Utilities