2009 Unidata NetCDF Workshop for Developers and Data Providers > NetCDF Utilities: ncdump and ncgen
5.10 ncdump and ncgen together
Used together, ncdump and ncgen can
accomplish simple netCDF manipulations with little or no programming.
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.
To convert a small classic netCDF file into an equivalent netCDF-4
classic model file:
$ ncdump small.nc > tmp.cdl
$ ncgen -o small4.nc -k 4 tmp.cdl
2009 Unidata NetCDF Workshop for Developers and Data Providers > NetCDF Utilities: ncdump and ncgen