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 > Grib2ctl


Grib2ctl takes GRIB-1 files and makes GrADS control files.
For GRIB-2 files, see g2ctl.

Grib2ctl started out as 89-line shell script (not including comments). While limited, it worked well enough to create control files for gigabytes of GRIB data. Since then, the program has grown and has been converted to perl. works on unix/linux and windows 95+. I will not answer questions about using grib2ctl under windows because I lack expertise in this area. (Elves keep grib2ctl compatible with windows.) The GrADS user mailing list is a useful resource. Please check the archives before asking a question.


5/06: version supports thinned (reduced) lat-lon and gaussian grids.
You have to upgrade to wgrib v1.8.0.12, and GrADS v1.9b4. Interpolation to the GrADS working grid (lat-lon) is done by a nearest grid point on the same latitude. People are welcome to write a better interpolation scheme.
12/06: over the last half year, improvements to the code that handles the vertical coordinates. Code is stable again.


Grib files have several time variables: reference time, verification time, start of averaging time, and end of averaging time. The user must select which of these times will used by GrADS. The options for and gribmap must be consistent.

For reference time: (often used by analyses)

$ grib_file >grib_file.ctl
$ gribmap -i grib_file.ctl -0    <-- this is a zero
$ grads
Landscape mode? (no for portrait):
ga-> open grib_file.ctl

For end of averaging time interval or verification time: (often used by forecasts)

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

For example, a 24 forecast started at 00Z 1/1/2013 will have a reference time of 00Z 1/1/2013. It's verification time will be 00Z 1/2/2013 (or 2/1/2013).

For another example, a 24-48 averaged precip orecast started at 00Z 1/1/2013 will have a reference time of 1/1/2013. The start of the averaging period will be 1/2/2013 and the end of the averaging period will be 1/3/2013.

For the beginning of the averaging time interval (often used by monthly means)

GrADS (gribmap) supports the "beginning of the averaging time interval"; however, wgrib does not. So making control files using the "beginning of the averging period will need some manual intervention". In the example, the averaging period is one month. So if you use the end of the averging period, then the Feb1982 data is actually the Jan1982 mean. It makes more sense to use the beginning of the averaging period. To change the control file, we alter the the tdef line by reducing the date code by one month.

$ -verf grib_file >grib_file.ctl
$ vi grib_file.ctl
change the tdef line: old: tdef 420 linear 00Z01feb1982 1mo new: tdef 420 linear 00Z01jan1982 1mo $ gribmap -b -i grib_file.ctl
$ grads
Landscape mode? (no for portrait):
ga-> open grib_file.ctl


Using on windows is like using on linux except

$ (options, grib file and > ctl)
$ perl (options, grib file and > ctl)
The same and options are used for windows, unix and linux. 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.

Template Option now supports the tempplate option (v0.9.12.5p33j). However, grib2ctl only allows template wildcards in the filename.

$ cpc_mon_mean.%y4%m2 >cpc_mon.ctl
The filename uses the standard GrADS wild cards except %mc:
%y2 2 digit year
%y4 4 digit year
%m1 1 or 2 digit month (month=1..12)
%m2 2 digit month (month=01..12)
%d1 1 or 2 digit day (day=1..31)
%d2 2 digit day (day=01..31)
%h1 1 or 2 digit hour (hour=0..23)
%h2 2 digit hour (hour=0..23)
%f2 2 or 3 digit forecast hour
%f3 3 digit forecast hour
Restrictions: (1) a sort of the file names has to put the files in chronological order,
(2) missing files are not handled well.
(3) the wildcards have to form a single date code, %y4_%m2_%d2 is not allowed.
(4) filenames cannot use regular-expression special characters; i.e., +(){}?*[]\

Unix/Linux Installation:

  1. Install wgrib v1.8+ and make sure wgrib is on your path.
  2. Find where they hid perl (eg. /usr/bin/perl). If necessary, obtain perl from a system tape/cd-rom or off the internet.
  3. Run perl with the -v option to determine the version (eg. /usr/bin/perl  -v)
    If you are running version 4 or earlier, curse the universe for having
    to work with obsolete gear and obtain an updated perl.
  4. Change the first line of to
       #!(location of perl)  -w
    For example,
       #!/usr/bin/perl  -w
  5. Look for the line:
    and change it to point to your copy of wgrib. For example,
  6. (Optional) Look for the line:
    and change it to point to your grads directory. In the future, some unviewable grids (ex. thinned grids, native eta) will be handled by interpolation files.
  7. The $pdef_dir is the directory used to store "pdef" files. As of 2/2006, only one grid (221, nearest neighbor) uses the pdef directory.
  8. Don't forget to make the program executable (chmod 755 and put it on your PATH.

Windows Installation (not supported, YMMV):

  1. Install wgrib v1.8+ and make sure wgrib and dll are on your path.
  2. Send an email asking when will be converted into Visual Basic.
  3. Receive an email saying, "Never."
  4. Download perl from the web.
  5. Install perl.
  6. Follow steps 4-7 in Unix/Linux install.
  7. doesn't work? See heading: not supported
  8. hint: make sure perl, wgrib and all the .dll files are on your PATH

Windows Installation using cygwin (not supported, YMMV) from Efren Serra:

  1. Install cygwin
  2. Blow PCGrADS cygwin1.dll away (WNE: PCGrADS has old version?)
  3. Change from $pdef_dir=(something); to $pdef_dir="/cygdrive/c/Program\ Files/PCGrADS';
  4. Change from $ListA="c:\\g$$.tmp"; to $ListA="/cygdrive/c/g$$.tmp";
  5. Change from $TmpFile="c\\h$$tmp"; to $TmpFile="/cygdrive/c/h$$$.tmp";
  6. Make sure to place in /cygdrive/c/Program\ Files/PCGrADS/win32e
Basically Efren's modifications to changes the default temporary directory from "c:\\" to "/cygdrive/c/".

Grib2ctl is a Perl script that tries to make a GrADS .ctl file from a GRIB
file. The script is somewhat restrictive in the form/content of the GRIB
file. Nevertheless this script and earlier versions have made .ctl files for
terrabytes of files. See the documentation for more details.


  1. can get confused by non-NCEP grid definitions
  2. doesn't handle mixed analysis and variance files
  3. missing times are not handled well
  4. doesn't handle multiple vertical coordinates well
  5. doesn't handle "missing" vertical levels well
  6. template wildcards only in the filename
  7. templated files must sort in chronological order



  1. Why doesn't grib2ctl work?
    • for forecasts, use -verf option, gribmap do not use -0 option
    • for analyses, do not use -verf option, gribmap use -0 option
    • only uses variables for the 1st time step (template option)
    • gets confused by uneven time steps
    • some variables are not defined on all time steps. Example, precipitation in model forecasts.
    • unsupported grid
  2. How to get ECMWF reduced Gaussian grids to work?
    1. Get new 5/2006+
    2. Get new wgrib 5/2006+
    3. Get new grads v1.9b4+
    4. Make sure that "wgrib" finds the new version (check your $PATH)
    5. Make sure you can write the pdef to the directory with the data file
      otherwise you will have to specify the pdef file.
    6. use the option -ec_gbl
  3. Can I recycle the pdef files generated by
    • Yes. The pdef file is the same for all files using the same grid.
      However, the pdef files are endian dependent.
  4. Why is the xdef and ydef missing from the .ctl file?
    • Many grids were not included in the script. Send me a copy of the GRIB file, and I see if the grid can be added to the script.
  5. I made a .ctl and .idx file with no problem. Why can't I display anything?
    • One common problem is that grib2ctl uses the initial time rather than the verification time by default. On the other hand, gribmap uses the verification time by default. To use initial time, use the "-0" (zero) option on gribmap. To use the verification time, use "-verf" option on grib2ctl.
  6. Why does grb2ctl option "-verf" require no gribmap option while no grib2ctl option require the "-0" option?
    • In hindsight, the gribmap and grib2ctl options should have been consistent.
  7. How do I get grib2ctl to use the template option?
    • Get version v0.9.12.5p33j+ and use %y4, %m2 etc in the file name.
      for example, $ cpc_mon_mean.%y4%m2 >cpc_mon.ctl

Comments:, updated 6/2009

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: Oct 3, 2017
Disclaimer Privacy Policy