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 > wgrib2api: grb2_mk_inv

wgrib2api: grb2_mk_inv(..)


To read grib using wgrib2api, you need to have an index or inventory file. The index file is used for searching and it is quick to create. The format of the index file keeps expanding as needed. For example, chemical tracers were added to the grib format, so naturally the index file had to include the possibility of a chemical type.

The index file created by grb2_mk_inv('file.grb2', 'file.inv') is the same as created by

  wgrib2 file.grb2 -Match_inv > file.inv

The inv file can be created before the fortran program is run. This may be more efficient if multiple programs need to create the inv of the same file.


    iret = grb2_mk_inv(GRB2, INV)
    iret:  integer
           0 if index file created
           1 if index file not created
    GRB2: character (len=*) existing grib2 file
    INV:  character (len=*) index file that is created
          Note: special files are supported
           @tmp:string      temporary disk file
           @memN            memory file, N=0..8
                            registers 9..19 are reserved for wgrib2api

Advanced Usage: pre-existing wgrib2 inventories

Pre-existing index files (wgrib2 inventories) can be used to save processing time. However, there are two issues. First, the typical inventory will be smaller and fewer valid search terms. Second, the fortran API reference date is YYYYMMDDHHmmss rather than the YYYYMMDDHH and assumed zero minutes and seconds. So the fortran-API inventory replaces the "d=YYYYMMDDHH" by "D=YYYYMMDDHHmmss". It's not a big deal and both formats are accepted by the grb2_wrt routine. The difference would be apparent in a search term that of the form,

  mk_inv: ":D=YYYYMMDDHHmmss:HGT:200 mb:"
  std inv: ":d=YYYYMMDDHH:HGT:200 mb:"
Since the ftn api has added minutes and seconds to the time stamp. Being consistent is nice. By the way, the reference time has to be stored in a 64 bit integer.

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: Oct 3, 2017
Disclaimer Privacy Policy