2012 Unidata NetCDF Workshop > Utilities for NetCDF-4
15.7 Use ncdump and ncgen for netCDF-4
Used together, ncdump and ncgen can
generate and modify netCDF-4 files 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 > Utilities for NetCDF-4