wgrib2: -if, -not_if
Introduction
The -if option returns true or false. If true, then
all the options up to and and including the next "output" option is executed.
Otherwise those options are igored. The -not_if
option does the opposite of -if.
Note, the effects of nesting of -if
and -not_if are not defined. Future
versions of wgrib2 may allow nesting.
Note, the "if" flag is reset after processing the record.
The -if option can be used to process
the file once and create several output files. For example,
old: wgrib2 -match_inv gribfile >inv
egrep ":(UGRD|VGRD):" inv | wgrib2 -i gribfile -grib winds.grb
grep ":TMP:" inv | wgrib2 -i gribfile -grib tmp.grb
In the above example, the UGRD/VGRD fields are written into winds.grb and
the TMP is written into the tmp.grb file. The above 3 lines can be
rewritten as
new:
wgrib2 gribfile -if ":(UGRD|VGRD):" -grib winds.grb -if ":TMP:" -grib tmp.grb
In the above example, the UGRD/VGRD fields are written into winds.grb and the TMP is written
into the tmp.grb file. Note that you can use any number of
-if options and they use the same output file.
wgrib2 gribfile -if ":(UGRD|VGRD):" -grib save.grb -if ":TMP:" -grib save.grb
The maximum number of -if options on a command
line is limited by (1) system limit of open files
(2) maximum length of a command line,
(3) maximum number of regular expressions allowed MAX_MATCH (wgrib.h),
and (4) maximum number of parsed arguments N_ARGLIST (wgrib.h).
The -if option can be to selectively
modify grib fields. See -fi.
Usage
-if X
X is a regular expression
See also: -not,
-end,
-match.
-i.
-fi.
|