CCR Banner CCR Home


Return to the GrADS Overview

The XDFOPEN command is used to open netCDF files when you are opening several files at once that have different time indices or when there is some problem with the file metadata (i.e., lat, lon, time variables).

Multiple Files Open at Once

You may have more than one file open in GrADS at the same time. Files are identified by the order in which they are opened: file 1 is the first file opened, and so on. Files that are opened at the same time should have the same values for coordinate variables. For example, if you try to use data from two files with different time indices, GrADS will give an error message similar to the following:

>d prectmm.1 - prectmm.2

Data Request Warning:  Request beyond file limits
Entire grid contents are set to missing data
Dimension ranges are:  X = 1 48  Y = 1 40  Z = 1 1  T = 1746275
Warning issued for variable = prectmm.2
Cannot contour grid - all undefined values

To get around such a problem, you can use the xdfopen command to open files with different time indices. For example, consider these two files: and

When you open up in GrADS, you can see that the GrADS time index begins at 00Z11FEB479 (use the q time command), whereas the time index of begins at 00Z22JUN454.

If you try to use functions (e.g., oromask, aave) on variables from both files, GrADS will give you an error message as shown above because the time indices of the two files are different. We need to make GrADS believe the time indices in the two files are the same by creating XDF files to "dummy" the time variables for the two files. We will use the time index from to create a XDF file for This will give the two files the same time indices and will allow you to work with both files at the same time.

Here are the contents of two sample XDF files. The text in purple is the text you would find in the xdf text file!

XDF File for ("xdf6kfix")

*DSET path to data
DSET /grove3/iesuw/foam/
* TDEF T_Dimension_Name T_Count LINEAR First_T_Value T_Step
TDEF time 12 LINEAR 00Z11FEB479 30DY

XDF File for ("xdf6k")

*DSET path to data
DSET /grove3/iesuw/foam/
* TDEF T_Dimension_Name T_Count LINEAR First_T_Value T_Step
TDEF time 12 LINEAR 00Z11FEB479 30DY

How do you use the xdf files? Say the first is named "xdf6kfix" and the second is "xdf6k". In your script, in lieu of using sdfopen /path/filename, simply use

xdfopen xdf6kfix
xdfopen xdf6k

Here is another example of a ncdump output of a netcdf file and its accompanying xdfopen file.

File Metadata

GrADS is very picky about the netCDF coordinate variables (such as time, latitude, longitude, level). All coordinate variables must be COARDS-compliant. If you open the data set and get a message like

Data has no discernable x-coordinate

there is a problem with the file metadata. You may be able to fix the metadata using NCO or some other netCDF utility, or you may be able to read the offending file using the xdfopen commmand.

For example, in some of the CSM files (e.g.,, ilev is the first vertical coordinate given, whereas lev is the correct vertical coordinate. GrADS uses the first coordinate variable that is defined vertically as the vertical coordinate. To make GrADS use lev instead of ilev, you need to create a xdf file for the offending netCDF file.


DSET /grove3/iesuw/csm/
ZDEF lev

That's it! That's all you need to put in the xdf file. DSET tells GrADS where the file is, and the ZDEF defines the vertical coordinate as the variable lev in the file.