I'm confused by what exactly a CDL file is and what its purpose is. Unidata specifies the syntax of such a CDL file in its netCDF documentation.

Are CDL files designed to be opened by a simple text editor like Notepad or gedit? Or should I use some other tool to open it?

What is its purpose and how is it used?


1 Answer 1


A CDL file is basically a text output from a netcdf file. If you want to know the contents of a netcdf file but don't have the time (or ability) to use programs built to read/write netcdf, you can use the simple text output of "ncdump" and then read/write it with a basic text editor. You can also use "ncgen" to regenerate a netcdf file based on the new CDL file. I've used this process to make simple changes to netcdf files, and it works very quickly compared to generating a netcdf file using programming methods.

See http://www.atmos.washington.edu/ive/ive_help/writing_netCDF_files.html , quoted below:

A CDL (network Common data form Description Language) file is an ASCII descripton of the binary data in a netCDF file that is designed to be easily read by humans. CDL files can be generated from netCDF files via the `ncdump', command. For example,

ncdump -c sample.nc generates the file `sample.cdl' that contains the file name, the dimensions, the specification of the variables, any attributes and the data for any "coordinate variables." A CDL file of this type is shown below. Note that the double slash indicates a comment in the CDL file.

netcdf implicit_grid{

dimensions: lon = 101; lat = 101; level = 5; time = UNLIMITED ; //(7 currently) variables:

float A(time,level,lat,lon); A:units = "meters/second"; float level(level);

level:units = "millibars"; float time(time);

time:units = "hours"; //global attributes:

:x_min = -180.f; :x_max = 180.f; :x_units = "degrees_east"; :x_label = "longitude"; :y_min = -90.f; :y_max = 90.f; :y_units = "degrees_north"; :y_label = "latitude";

:z_label = "level"; :t_label = "time";

data: level = 1000, 850, 700, 500, 300 ; time = 0, 2, 4, 6, 8, 10, 12 ;

The command ncgen' is the inverse ofncdump'; it converts an ASCII CDL file to a binary netCDF file. For example

ncgen -o sample.nc sample.cdl converts the CDL file sample.cdl' to the netCDF filesample.nc'. The easiest way to create a netCDF file is to (1) write all the header data (the name, dimensions, variable and attribute specifications, and the values of any coordinate variables) to a CDL file, (2) convert the CDL file to a netCDF file using ncgen, and (3) continue writing the main data arrays to this netCDF file.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.