How to install and wgrib in linux

Dear All,

Now we are going to see how to install wgrib and grib2ctl in our linux machine.

step 1:

First of we need to install GRADS

From the above link we can get the source.

In ubuntu $ sudo apt-get install grads

step 2:

From the below site we can download the perl source code

Look in the bottom of the page.

Try to open all the above links in firefox not in chrome.

Download that source code from here use firefox.

save that file as .

step 3:

Go to the below link to download the wgrib c code

From here you can download the wgrib.c source code use firefox.

save it as wgrib.c.

$ gcc wgrib.c -o wgrib

We are generating the wgrib object file.

$ sudo cp wgrib /usr/local/bin/

We are moving that binary wgrib file in to the system path /usr/loca/bin

step 4:

Now open the file,

  1. Look for the line:
    and change it to point to your copy of wgrib. For example,
  2. (Optional) Look for the line:
    $pdef_dir=’/usr/local/lib/grads’;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.
  3. Don’t forget to make the program executable (chmod 755 and put it on your PATH. i.e $ sudo cp /usr/local/bin/

Thats it … !

Now you can access the from the bash shell (terminal) itself.

Try the following usage of grib2ctl with your analysis and forecasting binary grib files.


For 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 forecasts:

$ -verf grib_file >grib_file.ctl
$ gribmap -i grib_file.ctl

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

To understand, what is grib and ctl file formate

grib is the one of binary file formate to store the analysis and forecast data in some kind of structured manner.
ctl means control file in ascii formate. we can read it. Both these formates are usually used in atmospheric and meteorological departments.

The generated ctl files can be read and visualized by GRADS , CDAT and other meteorological softwares.

Both Grads and CDAT are open source software.

More over many other foss applications are available for the same kind of stuff.

In that one more thing is cdo – Climate Data Operators

you can install cdo in ubuntu by $ sudo apt-get install cdo



About arulalant

Currently working as "Project Scientist – C" in National Centre for Medium Range Weather Forecasting (NCMRWF), MoES, Noida, India
This entry was posted in CDAT, Uncategorized and tagged , , , , . Bookmark the permalink.

16 Responses to How to install and wgrib in linux

  1. Mohammd Rafiq says:

    Hi Arulalan
    i got the error -bash: /usr/local/bin/ Permission denied
    whien trying to conver the test GRIb file /home/mohammd/Desktop/test.grb >test.ctl
    -bash: /usr/local/bin/ Permission denied
    please help me with


  2. dony says:

    I sorry sir out of topic…I have instaled grads in ubuntu, but some command i can use in here… like cbarn.. and some function other..can you help me for repaired it..? ( I newbe in linux sir )..


  3. Trilochan says:

    good job man


  4. nelson says:

    i have this error: gfs.t00z.pgrbf00.grib2>D2.ctl
    grib2 message ignored (use wgrib2)
    Big problem: Possible causes:
    gfs.t00z.pgrbf00.grib2 does not exist (bad name? wrong directory?)
    gfs.t00z.pgrbf00.grib2 is not a grib file
    cannot write a temporary file /tmp/g3856.tmp (permissions? full disk?)
    wgrib was not found (/usr/local/bin/wgrib not on path, wrong directory?)
    /usr/local/bin/wgrib was compiled for a different machine or operating system
    some solution?


  5. Thanos says:

    Hello very helpful guide, thank you very much 🙂 . I had a problem when i tried to execute gribmap

    grib1map error: GRIB file format error (rc = 53)

    Any idea what is wrong or if i am missing anything.


  6. Jaime says:

    hi users…….
    I get the grib2 and wgrib, and I will try to use it with Japanese Model DATA “model_data.ctl”

    wish me luck!!!


  7. Litta says:

    My machine is 64 bit MPI linux machine. wgrib and has been installed properly
    [root@hcl postprd]# -verf all > all.ctl
    could not open file: all
    Big problem:
    either all is missing or not a grib file
    or wgrib is not on your path
    [root@hcl postprd]#
    please help me……


  8. Litta says:

    Good to give a description about and wgrib usage. I have a query about

    I have concatenated different files and made a single file with more than 5 GB. when i tried to use -verf all > all.ctl, its not vcreated ctl file. I am getting the following error.

    I have installed wgrib, grads and grib2ctl properly.


    • Arulalan.T says:

      Hai Litta,

      What is the error ?

      you didnt paste your error here… 🙂


      • Morad Dalal says:

        hi users…
        please i had a problem in the step3
        when i do gcc wgrib.c -o wgrib i had as respond
        “wgrib.c:1:19: fatal error: stdio.h: No such file or directory
        compilation terminated.


        • Morad Dalal says:

          hi users…
          please i had a problem in the step3
          when i do gcc wgrib.c -o wgrib i had as respond
          “wgrib.c:1:19: fatal error: stdio.h: No such file or directory
          compilation terminated.”
          so sudo cp ….. dosen’t work


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s