2012 Unidata NetCDF Workshop > NetCDF Utilities
6.5 ncdump and ncgen together
Used together, ncdump and ncgen can
accomplish simple netCDF manipulations with little or no programming.
ncdump and ncgen
are inverses:
-
To edit metadata or data in a 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
netCDF file
- Note: not practical for huge netCDF files or if modifying
lots of files. For that, need to write a program using netCDF library.
-
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 corresponding C or Fortran program for
writing netCDF.
- Insert appropriate netCDF "var_put" calls for writing
data.
- Compile and run program to create netCDF file.
- Use ncdump to verify result.
2012 Unidata NetCDF Workshop > NetCDF Utilities