## Using Templates

Grads allows you use a single data descriptor file to aggregate multiple data files and handle them as if they were one individual file. The individual data files must be identical in all dimensions except time and in a format GrADS can read. The time range of each individual file must be indicated it its filename.

An example might be a timeseries spanning a single month, where each day's worth of hourly data is contained in individual files:

    1may92.dat
    2may92.dat
    ...
    31may92.dat

In order to tell GrADS that there are multiple files in this time series, three records are modified in the data descriptor (.ctl) file:

`DSET %d1%mc%y2.dat
OPTIONS template
TDEF 744 linear 0z1may1992 1hr
`

First, the `DSET` entry has a substitution template instead of a filename. See below for a description of all the possible components of the template. Second, the `OPTIONS` entry contains the `template` keyword. Third, the `TDEF` entry describes the time range for the entire set of data files.

Templating works on the following GrADS data types: gridded binary, GRIB, and station data. If you specify any additional `options` keywords in the data descriptor file, make sure the options apply equally to each file included in the template.

Valid components of the substitution template are as follows:

`%y2` 2 digit year
`%y4` 4 digit year
`%m1` 1 or 2 digit month
`%m2` 2 digit month (leading zero if needed)
`%mc` 3 character month abbreviation
`%d1` 1 or 2 digit day
`%d2` 2 digit day (leading zero if needed)
`%h1` 1 or 2 digit hour
`%h2` 2 digit hour
`%h3` 3 digit hour (e.g., 120 or 012)
`%f2` 2 or 3 digit forecast hour
`%f3` 3 digit forecast hour
`%n2` 2 digit minute (leading zero if needed)

When specifying the initial time (e.g., NWP model output from NMC and FNMOC), use these substitutions:

`%iy2` initial 2 digit year
`%iy4` initial 4 digit year
`%im1` initial 1 or 2 digit month
`%im2` initial 2 digit month (leading zero if needed)
`%in2` initial 2 minute (leading zero if needed)
`%imc` initial 3 character month abbreviation
`%id1` initial 1 or 2 digit day (leading zero if needed)
`%id2` initial 2 digit day
`%ih1` initial 1 or 2 digit hour
`%ih2` initial 2 digit hour
`%ih3` initial 3 digit hour