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


Preliminary documentation:

GRIBW library:

GRIBW is library for writing GRIB. The library has GRIB reading routines but I decided I didn't like the name GRIBrw, so the name stays. The library is written in C and currently is in beta test and will remain in beta as long as the documentation is so lacking. (The documentation is sufficient if you can read C and know GRIB.)

For now, if you want the code, you will be getting a snapshot of my current working directory. Since the library is in "beta", I would appreciate all comments. The location of the code and sample programs/scripts is at

A real program shows how easy it is to write a grib file.

GRIBW utility:

An version of gribw exists and it functions as the inverse of wgrib. It expects one arguement, a binary file with the gridded data, and the PDS/GDS data in stdin. For example one could execute,

wgrib gribfile | wgrib gribfile -i -PDS -GDS -o bindump | \
gribw bindump -o gribfile2

and recreate the original gribfile. The format of the PDS/GDS data is compatible the -PDS, -GDS, -PDS10 and -GDS10 output from wgrib. The previous example doesn't do any useful work but illustrates how easy it is to write a GRIB file. All you need is a binary file (formatted, sequential in UNIX Fortran) and a text file with the PDS and GDS information.


Encoding a sequential formatted file in GRIB

Reducing file size by reducing the domain size

Changing the Precision of a GRIB File

Sometimes a GRIB file is stored with more precision than is necessary. The only disadvantage of too much precision is that the files take up more space than is necessary. The precision can be changed to n binary bits by,

wgrib gribfile | wgrib gribfile -i -PDS -GDS -o bindump | \
gribw bindump -o gribfile2 -prec n


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