Skip Navigation Links 
NOAA logo - Click to go to the NOAA home page National Weather Service   NWS logo - Click to go to the NWS home page
Climate Prediction Center

About Us
   Our Mission
   Who We Are

Contact Us
   CPC Information
   CPC Web Team

HOME > Monitoring_and_Data > Oceanic and Atmospheric Data > Reanalysis: Atmospheric Data > g2ctl


g2ctl takes GRIB2 files and makes GrADS control files. For grib-1 files, see grib2ctl. Once you have made a control file and index file, GrADS can read grib2 files. Note that whenever you update g2ctl, you must update wgrib2.

There is an alternative to the g2ctl/gribmap for making ctl/index for GrADS. alt_g2ctl/alt_gmp were written to handle large datasets and extended grib variable names.

1/25/2008 First public release

For analyses:

$ g2ctl -O grib2_file >grib2_file.ctl
$ gribmap -O -i grib2_file.ctl
$ grads
Landscape mode? (no for portrait):
ga-> open grib2_file.ctl

For forecasts (end of averaging period):

$ g2ctl grib2_file >grib2_file.ctl
$ gribmap -i grib2_file.ctl
$ grads
Landscape mode? (no for portrait):
ga-> open grib2_file.ctl

For forecasts (start of averaging period):

$ g2ctl -b grib2_file >grib2_file.ctl
$ gribmap -b -i grib2_file.ctl
$ grads
Landscape mode? (no for portrait):
ga-> open grib2_file.ctl

Important Options

-0 .. use analysis times
-b .. use start of averaging/accumulation period
-365 .. use 365 day calendar
-no_profile .. no z coordinate
-raw .. use a raw grid
-ens "e1,..,en" .. a list of quoted ensemble names


g2ctl works under Windows. You just have to put a perl before g2ctl.

linux: $ g2ctl (rest of line)
windows: $ perl g2ctl (rest of line)

You have to keep in mind the Window filename conventions are different from Unix/Linux. g2ctl is written for the unix standard. Windows considers upper case A to be the same as a lower case a. Unix allows multiple periods in a filename. Some Windows systems only allow one period in the filename. If you having problems with g2ctl, convert the input and output filenames to 8.3 and move all the files to the current directory.

I have tested g2ctl using the cygwin system and I had no problems. Haven't tried it using another perl and the default windows shell. Other people have done it.


Use the GrADS templating names for creating templated ctl files. For example,
g2ctl pgb.2008010100.f%f3 >forecast.ctl
gribmap -i forecast.ctl
g2ctl -0 pgb.%y4%m2%d2%h2.f00 >analysis.ctl
gribmap -0 -i analysis.ctl
g2ctl -ens "e1,e2,e3" %e.2008010100.%f2 >ens.ctl
gribmap -i ens.ctl
The supported template names are:
%y4 - four digit year code
%y2 - two digit year code
%m2 - two digit month code
%m1 - one or two digit month code
%d2 - two digit day code
%d1 - one or two digit day code
%h2 - two digit hour code
%h1 - one or two digit hour code
%f3 - three digit forecast hour code
%f2 - two or three digit forecast hour code
%e - ensemble name (specified by -ens option)

Restriction of the Templating Option

With templating, a control file can refer to a thousand files. A "careful" g2ctl would have to search all thousand files for unique variables and time stamps. However, I am impatient person and I only have g2ctl scan the first, second and last files (in the directory listing). From these three files, g2ctl finds the variables, initial time (smallest time stamp), time increment (second smallest time stamp - smallest time stamp) and the ending time (largest time time stamp). This time-saving strategy can fail for many reasons including,

  1. Apr comes before Jan in a directory listing. Consequently the file may not have the intial time. (Cannot use names of months with g2ctl.)
  2. Template= rain%d2-%m2-%y4.grb. First file may not have the initial time. The order must be year, month, date and hour.
  3. Template= rain%y2.grb. rain00.grb comes before rain99.grb in a directory listing. First file may not have the intial time. Do not use the %y2 option if the data spans the century mark.
  4. A varying forecast hour and varying date are not allowed.
  5. A file data with two date codes (not allowed by GrADS)
    • -0 option used, two different reference times
      to see: wgrib2 IN.grb | cut -f3 -d: | sort -u
    • no -0 option, two different verification times
      to see: wgrib2 IN.grb -verf | cut -f3 -d: | sort -u
  6. land mask or an other constant field has a time stamp that is unrelated to the forecast or assimilation time stamp
  7. time increament is not fixed (GrADS uses fixed time step)
  8. second time step is missing and the second file is actually the third file.
  9. There are more situations that are not handled.

If a templated control file can not be made automatically, make the control file for one file and edit the control file to add templating.


Grads v2 now supports ensembles. Ensemble files come in two flavors. All the ensemble members are within one file or each ensemble member is in its own file. For the first case, g2ctl should handle it it correctly. For the second case, you have to specify the ensemble names and use the template option.
g2ctl -ens "e1,e2,e3" %e.2008010100.%f2 >ens.ctl
gribmap -i ens.ctl
Note that the first ensemble member specified sets the time range.


The current versions of wgrib2 GrADS v2.0+, perl and the g2ctl script

Checking for Aliased Variables

The GRIB data model is larger than the GrADS data model. For example, a GrADS field has a single time value. A GRIB field could have one time value (ex. analysis), two time values (ex. 6 hour forecast: start of forecast and the valid time) or even three time values (ex. 12-24 hour precipitation forecast: start of forecast, start of valid period, and end of valid period). Consequently two different grib fields may have the same GrADS time value (ex. analysis valid at 2010-01-01-00, 6 hour forecast started from 2010-01-01-00 and a 6 hour forecast started from 2009-12-31-18 and valid at 2010-01-01-00 will have problem no matter which gribmap options are used).

The GrADS data model has grown. Originally GrADS didn't know the difference between the 6-hour forecast of LHTFL and the 0-6 hour average forecast of LHTFL. As a result, the two quantities could get aliased. The current situation (4-2010) is that the older grib2ctl will alias the two fields and the newer g2ctl will not. However, the GrADS data model still has limitation with respect to averaging. For example, the monthly average of the 6 hour forecast LHTFL will be aliased with the monthly average of the 0-6 hour forecast LHTFL because they are both monthly averages.

The only way to deal with aliased variables is to store the variables in separate files and make separate control files.

You can discover some types of aliasing by using the -no_profile option with grib2ctl or g2ctl. The control file will list the number of variables that it found. That number can be compared with the expected number.


  • make sure you have grib2 files (test with wgrib2)
  • make sure wgrib2 is current and on your path
  • make sure gribmap is version 2
  • make sure GrADS is version 2
  • only some grids are supported
  • Have a time series of forecasts (ex 12 hour forecast with varying starting time) which has an ensemble identifier (ex control forecast). You have to use the EDEF section in the control file but there is no fixed starting time of the control forecast.
    AFAIK you have to use alt_g2ctl and alt_gmp to handle this situation.


Both g2ctl and alt_g2ctl are supported as most of the code is common to both control file makers. I (WNE) use alt_g2ctl more than g2ctl.


NOAA/ National Weather Service
National Centers for Environmental Prediction
Climate Prediction Center
5830 University Research Court
College Park, Maryland 20740
Climate Prediction Center Web Team
Page last modified: Jan 23, 2017
Disclaimer Privacy Policy