How to install grib2ctl.pl 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

http://grads.iges.org/grads/downloads.html

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 grib2ctl.pl perl source code
http://www.cpc.ncep.noaa.gov/products/wesley/grib2ctl.html

Look in the bottom of the page.

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

Download that grib2ctl.pl source code from here ftp://ftp.cpc.ncep.noaa.gov/wd51we/wgrib.scripts/grib2ctl.pl use firefox.

save that file as grib2ctl.pl .

step 3:

Go to the below link to download the wgrib c code
http://www.cpc.ncep.noaa.gov/products/wesley/wgrib.html

From here you can download the wgrib.c source code ftp://ftp.cpc.ncep.noaa.gov/wd51we/wgrib/wgrib.c 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 grib2ctl.pl file,

  1. Look for the line:
    $wgrib=’wgrib’;
    and change it to point to your copy of wgrib. For example,
    $wgrib=’/usr/local/bin/wgrib’;
  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 grib2ctl.pl) and put it on your PATH. i.e $ sudo cp grib2ctl.pl /usr/local/bin/

Thats it … !

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

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

Usage

For analyses:

$ grib2ctl.pl 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:

$ grib2ctl.pl -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

Thanks,
Arulalan.T

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 grib2ctl.pl and wgrib in linux

  1. Mohammd Rafiq says:

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

    Like

  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 )..

    Like

  3. Trilochan says:

    good job man

    Like

  4. nelson says:

    i have this error:
    grib2ctl.pl 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?

    Like

  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.

    Like

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

    Like

  7. Litta says:

    My machine is 64 bit MPI linux machine. wgrib and grib2ctl.pl has been installed properly
    [root@hcl postprd]# grib2ctl.pl -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……

    Like

  8. Litta says:

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

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

    I have installed wgrib, grads and grib2ctl properly.

    Like

    • Arulalan.T says:

      Hai Litta,

      What is the error ?

      you didnt paste your error here… 🙂

      Like

      • 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
        #include
        ^
        compilation terminated.

        Like

        • 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
          #include
          ^
          compilation terminated.”
          so sudo cp ….. dosen’t work

          Like

Leave a comment