Previous: ncgen Next: ncdump and ncgen together Table of contents Frames 2010 Unidata NetCDF Workshop > NetCDF Utilities

5.5 Examples of ncgen use
Examples of common uses of ncgen
  1. Check a CDL file for any syntax errors:
     ncgen mslp.cdl 
  2. Reverse what ncdump does, converting CDL text file to netCDF:
     ncgen -b mslp.cdl   # Caution, this overwrites mslp.nc if it exists 
     ncgen -o foo.nc mslp.cdl  # To explicitly specify an output file 
     ncgen -k4 -o mslp4.nc mslp.cdl  # Output netCDF-4 classic model file 
  3. Generate a C, Fortran, or Java program which, when compiled and run, will create the binary netCDF file corresponding to the CDL text file.
    ncgen -l c mslp.cdl > mslp.c
    generated C code (129 lines) Show popup
    ncgen -l f77 mslp.cdl > mslp.f    # currently classic model only
    generated Fortran-77 code (176 lines) Show popup
    ncgen -l java mslp.cdl > mslp.java   # currently classic model only
    generated Java code (92 lines) Show popup

 


Previous: ncgen Next: ncdump and ncgen together Table of contents Frames 2010 Unidata NetCDF Workshop > NetCDF Utilities