Skip Navigation Links www.nws.noaa.gov 
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 > wgrib2 questions
 

Compiling wgrib2

Compiling wgrib2 is easy on a linux system.
1) Download ftp://ftp.cpc.ncep.noaa.gov/wd51we/wgrib2/wgrib2.tgz
2) untar wgrib2.tgz:  tar -xzvf wgrib2.tgz   (use gnu tar)
3) cd to main directory:  cd grib2
4) set the C compiler to use:  export CC=gcc (bash)
5) set the fortran compiler to use:  export FC=gfortran (bash)
6) compile: make  (must use gnu make)
note: you may have to install gcc and gfortran
Compiling wgrib2 with IPOLATES is easy on a linux system.
1) Download ftp://ftp.cpc.ncep.noaa.gov/wd51we/wgrib2/wgrib2.tgz
2) untar wgrib2.tgz:  tar -xzvf wgrib2.tgz   (use gnu tar)
3) cd to main directory:  cd grib2
4) edit makefile and change USE_IPOLATES=0 to USE_IPOLATES=1
5) set the C compiler to use:  export CC=gcc (bash)
6) set the fortran compiler to use:  export FC=gfortran (bash)
7) compile: make  (must use gnu make)
note: you make have to install gcc and gfortran
Compiling wgrib2 is easy on a unix system.
1) Download ftp://ftp.cpc.ncep.noaa.gov/wd51we/wgrib2/wgrib2.tgz
2) untar wgrib2.tgz: gunzip wgrib2.tgz ; tar -xvf wgrib2.tar
3) cd to main directory:  cd grib2
4) set the C compiler to use:  export CC=(name of C compiler) (sh)
5) set the fortran compiler to use:  export FC=(name of fortran compiler) (sh)
6) compile: make      (use gnu make) 
Compiling wgrib2 with clang and gfortran for IPOLATES (wgrib2 v1.9.8+)
1) Download ftp://ftp.cpc.ncep.noaa.gov/wd51we/wgrib2/wgrib2.tgz
2) untar wgrib2.tgz: gunzip wgrib2.tgz ; tar -xvf wgrib2.tar
3) cd to main directory:  cd grib2
4) edit makefile and change USE_IPOLATES=0 to USE_IPOLATES=1
6) set the C compiler to use:  export CC=clang (bash)
6) set the fortran compiler to use:  export FC=gfortran -fplugin=dragonegg
7) compile: make      (use gnu make) 
I get the error message: wgrib2: error while loading shared libraries: libgfortran.so.3: cannot open shared object file: No such file or directory
  This error occurred on a NOAA super computer.  To compile with the gnu 
compilers, you had to use "module load PrgEnv-gnu" to setup your environment
to use the gnu compilers.  Nothing wrong with this and it is actually very
nice.  However, when you are using another programming environment, the gfortran
library is unavailable. To fix the problem, you have to link in the static 
gfortran library.  You have to edit the makefile.

   old: wLDFLAGS+=-lgfortran
   new: wLDFLAGS+=/opt/gcc/4.7.0/snos/lib64/libgfortran.a

Of course, the location of libgfortran.a is not standard.  You have to adjust
the above line with the location of libfortran.a in YOUR computer.
Comments:
  1. For Cygwin, use the linux instructions
  2. Using the included g2clib is strongly recommended (wgrib2 v0.1.9.7a or earlier)
  3. If you use the official g2clib, USE_G2CLIB=0 is recommended for wgrib2 v0.1.9.8+)
  4. Using IPOLATES with UNIX is not difficult for a person with the right skills.
  5. Intel and the Portland compilers are not compatible with the Jasper library and are disabled in the makefile

wgrib2 compile questions

Question:  Why don't the Intel and Portland compilers work with wgrib2?

Answer:  The Jasper libraries compile by icc and pgc produce zero-data jpeg2000 
files.  I tried using the instructions from the Intel dev web site but I couldn't 
get Jasper to work.  I tried the debian updates to the Jasper library and it 
didn't help.  After spending too much time on this problem, I figured that icc 
isn't that important when I can use gcc, openncc and clang on X86 machines.

Question: Why do you build japser with the following flags?

     --disable-libjpeg --disable-opengl

Answer:

Libjpeg is not needed by wgrib2.  The makefile should work when
the system doesn't have libjpeg installed.

Opengl is not needed by wgrib2. Makefile should still work when the 
system doesn't have opengl installed.

The wgrib2 makefile compiles the libraries in a manner optimized for wgrib2.
The libraries are not meant for general use.  For example, the netcdf library
doesn't have a fortran interface because I want the makefile to
work if a user lacks a fortran compiler. 

Question: why do you include zlib, libpng?

Answer:  Not all linux distributions include libpng or they give it a different name.
Some linux distributions may have different versions of zlib installed.

Why don't you make netcdf4 the default netcdf package?

Answer:

The Netcdf4/hdf5 libraries are very big and the end result is a long
download time and a large executable.  Netcdf3 files can be read by
a netcdf4 client.  However, many people routinely compile with netcdf4.

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: May 15, 2005
Disclaimer Privacy Policy