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

wgrib2api: grb2_mk_inv(..)

Introduction

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.

Usage

    iret = grb2_mk_inv(GRB2, INV, options)
    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
    options: optional parameters
          use_ncep_table=.true.            use ncep variable tables 
          use_ncep_table=.false.           use variable tables as determined by center encoded in the file (default)

Some centers such as Canada and ESRL use NCEP grib2 variable tables for some of their files. The optional argument 'use_ncep_table=.true.' can be use to read these files. (requires wgrib2api.f90 from wgrib2 v3.0.0)

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 recent modifications: Oct 3, 2017, Nov 13, 2019
Disclaimer Privacy Policy