Dear All,
Now we are going to see how to install wgrib2 and g2ctl in our linux machine, for the Grib version 2 data.
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 we need to install some dependencies,
$ sudo apt-get install libgrib2c-dev libgrib2c0d (to install wgrib2 correctly)
$ sudo apt-get install grads (for gribmap)
Note : grads version must be equal or higher than the 2.0.a8 (to work correctly for grib2).
If you are using ubuntu 10.04, then grads may be lower than the above version.
So download the source of grads version 2.0.a8 or higher.
$ sudo apt-get install libxmu-dev libxmu-headers x11-common x11-xserver-utils
Extract that downloaded grads source and change directory into that extracted folder.
$ ./configure
$ make && make install
Now it should be installed in that folder called ‘src’.
You can use this grads, gribmap (inside the src folder of the extracted folder of grads2.0.a8) to use the grib2 version.
$ sudo cp -r src /usr/local/grads2.0.a8
Edit your home .bashrc file, add the following lines.
alias grads=’/usr/local/grads2.0.a8/grads’
alias gribmap=/usr/local/grads2.0.a8/gribmap’
step 2:
From the below site we can download the g2ctl.pl perl source code
http://www.cpc.ncep.noaa.gov/products/wesley/g2ctl.html
Look in the bottom of the page.
Try to open all the above links in firefox not in chrome.
Download that g2ctl.pl source code from here ftp://ftp.cpc.ncep.noaa.gov/wd51we/g2ctl/g2ctl save as g2ctl.pl . If that perl source code has viewed by web page itself means, copy that perl code into one text file, and save that as g2ctl.pl file in your home folder itself.
step 3:
Go to the below link to download the wgrib2 tar file
http://www.cpc.ncep.noaa.gov/products/wesley/wgrib2/
From here you can download the wgrib2.tgz source file in the above link.
Go to this section in the above link “Source Code and Compling Hints” .
Download the “wgrib2.tgz” by http way.
After downloaded the wgrib2.tgz file, extract it either by GUI “Extract here” or
$ tar -zxvf wgrib.gz
It should create directory called “grib2″.
Now move this folder into /usr/bin by
$ sudo mv grib2 /usr/bin/
Now go to that directory by
$ cd /usr/bin/grib2
$ sudo make
It takes few minutes to install wgrib2 inside that folder itself.
Note : now our wgrib2 executable path is ” /usr/bin/grib2/wgrib2/wgrib2 “.
step 4:
Now open the g2ctl.pl file,
- Look for the line:
$wgrib2=’wgrib2′;
and change it to point to your wgrib2 path. In our case,
$wgrib2=’/usr/bin/grib2/wgrib2/wgrib2′; - Don’t forget to make the program as executable (chmod 755 g2ctl.pl) and put it on your PATH. i.e $ sudo chmod 755 g2ctl.pl and $ sudo cp g2ctl.pl /usr/bin/
Thats it … !
Now you can access the g2ctl.pl from the bash shell (terminal) itself.
Try the following usage of g2ctl with your analysis and forecasting binary grib files.
Usage
For analyses:
$ g2ctl.pl -0 grib2_file >grib2_file.ctl [ here we passed zero option]
$ gribmap -0 -i grib2_file.ctl [ here we passed zero option]
$ grads
Landscape mode? (no for portrait):
ga-> open grib2_file.ctl
For forecasts:
$ g2ctl.pl grib2_file >grib2_file.ctl
$ gribmap -i grib2_file.ctl
$ grads
Landscape mode? (no for portrait):
ga-> open grib2_file.ctl
The main differences between the syntax of grib2ctl.pl and g2ctl.pl are,
- For grib version 2 files, we are using g2.ctl.pl script to create ctl files. The usage option -0 (zero) are passed for both g2ctl.pl and gribmap commands for analysis files and not for forecast files in the grib version 2.
- For grib version 1 files, we are using grib2ctl.pl script to create ctl files. The usage option -0 (zero) is passed in gribmap command for analysis files and option -verf is passed in grib2ctl.pl command for forecast files. To know more about grib2ctl.pl script, how to install that and how to use that, click here .
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.
Thanks,
Arulalan.T
can u help me
LikeLike
Hello Arulalant,
I have an issue compiling wgrib2, while in grib2, i did the command ‘sudo make’ but i get an error ‘makefile:362: *** ERROR, fortran compiler (enironment vararible FC) is not recognized. Stop.’
what’s the way forward? Thanks
LikeLike
Before “make” in grib2 folder you must enter
export CC=gcc
export FC=gfortran
LikeLike
Thank so much Pogoda33. I have actually tried this your commands but the error ‘makefile:362:*** ERROR, fortran compiler ( environment variable FC) is not recognised. Stop’ persists .
LikeLike
I have the same problem. Did you solve this ?
LikeLike
apt-get install m4 csh netcdf-bin hdf4-tools hdf5-tools jasper libpng-dev build-essential ncl-ncarg gcc gfortran libnetcdf-dev mpich
than
export CC=gcc
export FC=gfortran
make “as root”
LikeLike
Did you solve this problem?I met the same case as you had,please help me!
LikeLike
Hello Ugwoke,did you solve this problem?I met the same case as you had,and I have tried the commands export CC=gcc export FC=gfortran before “make” ,but still error,I am so puzzled.please help me,Thandks very much!
LikeLike
Hello, I had a similar problem and solved it by opening the Makefile and uncommenting the lines:- export CC=gcc, export FC=gfortran. I hope it works for you also
LikeLiked by 1 person
Thanks AnthonyM,you are very warmhearted,I had solved this problem by the means as you said,thank you all the same and hope anyone else who would encounter this problem can see what you put!
LikeLike
when you run “sudo make” makefile cannot see the env var CC and FC so do the following : sudo CC=gcc FC=gfortran make
LikeLike
This was helpful. Thank you!
LikeLike
thank you guy for all you have done
now i want to know how can I install wgrib2 and g2ctl on mac have you got any idea? or should I just follow the same step like in linux?
LikeLike
I didnt give a try on Mac. You just install homebrew command line in Mac and try it.
LikeLike
Hi,
could you please give me your email address? I have a question that its not related to this topic but its about linux.
LikeLike
Thank you sooo much you saved my life T^T
LikeLike
Thanks Arulalan for such a good guide. I am using centos 6.5 and have followed your instructions to install g2ctl.pl and wgrib2. Everything works fine (g2ctl and gribmap run successfully without errors) until I plot my data on GrADS. It gives all undefined values to my data, yet the data is there!
LikeLike
Thanks, this is great help.
I got an error instal wgrib2 :
ed@ed-VirtualBox:/usr/bin/grib2$ sudo make
makefile:358: *** ERROR, did not recognize fortran compiler, cannot use IPOLATES, set FC=f90 compiler. Stop.
Any advice ?
Thanks
Ed
LikeLike
I got this error fixed. In the makefile IPOLATES was by default set to 1, so I changed it to 0. So the installtion works but only up to a point, then it gives me this error
collect2: error: ld returned 1 exit status
make[1]: *** [wgrib2] Error 1
make[1]: Leaving directory `/usr/bin/grib2/wgrib2′
make: *** [wgrib2/wgrib2] Error 2
ed@ed-VirtualBox:/usr/bin/grib2$
Any thoughts?
Thanks
LikeLike
Make sure that wgrib2 executable path /usr/bin/grib2/wgrib2/wgrib2 is working. It seems ld is not working correctly within that folder or not installed properly (make inside grib2).
LikeLike
Thank’s a lot, you are the master…
LikeLike
Dear Arrulan T.
I’m starting the command “make && make install” and i’m getting error below:
gxX.c:20:19: fatal error: cairo.h: No such file or directory
compilation terminated.
How can I install this cairo.h? I’m using ubuntu 12.04
Regards,
Ismoil
LikeLike
Better you do, $ sudo apt-get install grads , instead of install it from source.
It will take care of it. The thing is you need to install cairo package. That also you can install it from sudo apt-get .
LikeLike
Dear Arrulan T.
How can I open the grb2. file that had sent from meteorology center in Linux? Is it as above that you explain? And do you know they can opened in windows 7?
LikeLike
Dear Eyilmaz,
You can use the above steps to access grib2 files in linux. I documented here on how to install/setup to access grib2 files in Ubuntu distribution. Moreover you can follow the same steps in other linux distros also.
I never tried / worked in windows. So I do not know how to setup the same in windows.
Thanks.
LikeLike
Hello Dear Arulalan.T
I am using you configuration steps grib2ctl.pl is working for grib1 but when I tray to use it in grib2 it doesn’t work but I install grads 2.0.a9.1 and wgrib2 but is display the following errors.
bash-4.2$ gribmap -i newforecast.ctl
grib2map: scanning GRIB2 file: gfs_4_20120601_0000_000.grb2
grib2map: Writing out the index file
I am looking your help thank very much for your help
LikeLike
Hai Goitom.,
Are you using grib2ctl.pl or g2ctl.pl ? grib2ctl.pl for grib1 version. g2ctl.pl for grib2 version data.
What error it throws ?
LikeLike
Hello Dear Arulalan.T
I am using g2ctl.pl and wgrib2 for grib2 , additional i am install wrfems 3.4.1.13.33 this is the shell script
#! /bin/csh
cd /home/model/wrfems/runs/ethiopia/emsprd/grib
set yymmdd = `date +%y%m%d`
cat *grb2*>gribdata_$yymmdd-2
mv gribdata_$yymmdd-2 /home/model/ethiowrf/
cd /home/model/ethiowrf/
g2ctl.pl -verf gribdata_$yymmdd-2 >grib.ctl
gribmap -i grib.ctl
and the error is grib2map: Writing out the index file and the index files are not read by grads
thanks for your help
LikeLike
Dear Goitom,
I dont think this is an error “grib2map: Writing out the index file”. It seems like it info print statement. Is that created idx file correctly or not. Instead of writing csh script to create ctl, idx file for the model data, I suggest that you would have try it by your hand itself.
Go to the data directory via terminal and give try to create ctl file and the idx file by there itself. So that will give us more way to find out the error. While you opening “ctl” file in Grads, what error it throws ?
LikeLike
Dear Arulalan.T
the individual grib2 file are working properly but the cat file “gribdata_$yymmdd-2” is not working.
Best regards
Goitom
LikeLike
So its not problem with g2ctl.pl. It is problem with “cat *grb2*>gribdata_$yymmdd-2″ command. You have to find the solution for this. I think you can not use cat command for the binary *grb2* files. Try to use cp [copy] instead of cat.
” cp *grb2*>gribdata_$yymmdd-2″.
If this also fails means you have to find the solution.
Thanks.
LikeLike
Hi.
I work with:
step 3:
Go to the below link to download the wgrib2 tar file……
….
.. but help me with the data http://nomads.ncdc.noaa.gov/data/cfsr-rfl-mmts/oceansst/, but no file.idx.
In GrADS:
clima@lluvia:~/CFSv2$ perl g2ctl oceansst.ensm.jan.cfsv2.data.grb2 >oceansst.ensm.jan.cfsv2.ctl
clima@lluvia:~/CFSv2$ gribmap -i oceansst.ensm.jan.cfsv2.ctl
grib2map: scanning GRIB2 file: oceansst.ensm.jan.cfsv2.data.grb2
grib2map: Writing out the index file
Thanks
LikeLike
Dear Arulalan.T
How to install wgrib2 in Windows XP?
LikeLike
Dear Quangtuan,
I never tried to install grib2ctl in windows.
First of all you need to install perl and perl dependencies packages in windows.
Then you need to install wgrib package also in your windows.
Finally grib2ctl.pl … But I dont know how to install all the above successfully in windows.
Switch to Free Open Source OS / Linux / Ubuntu !
LikeLike
Dear Arulalant,
Do you have a similar step by step procedure for installation of wgrib2 in Windows 7?
How can I install wgrib2 in Windows 7?
Many thanks
Adem
LikeLike
hi, you have same step by step procedure for installation in Windows?
LikeLike
Sorry, I never tried this in windows !
LikeLike
Thanks for the great tutorial, you saved me a lot of googling!
A note: I had to create a symbolic link after step 3 to make my system recognize the wgrib2 command:
sudo ln -s /usr/bin/grib2/wgrib2/wgrib2 /usr/bin
LikeLike
Thanks for your tip !
LikeLike
Thank you very much, saved my life
Greetings from Colombia
LikeLike
Thank you !
LikeLike
Thank you very much
for the useful information
regards
naresh
LikeLike
Many thanks, it worked allright!
Miquel
Spain
LikeLike
Dear Arulalant,
Do you have a similar step by step procedure for installation of wgrib2 in Windows 7?
How can I install wgrib2 in Windows 7?
Many thanks
Adem
LikeLike