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)
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.