wgrib2: init, inv, out, misc
Each option on the wgrib2 command line is translated into a subroutine call by
wgrib2. In some sense, the command line is actually a simple program as it describes
the order of the subroutine calls. As with most languages, the order is important and
subroutines can be called more than once. Wgrib2 handles the subroutine calls differently
from most languages. First, there is an init phase, each subroutine is called in order
with mode = INIT. This allows the subroutines to do the needed initialization
procedures such as opening files and initializing variables. Then there is the data
phase. Each subroutine is called in order with a pointer to the current grib message.
Finally there is the cleanup phase. Each subroutine is called with mode = CLEANUP.
Wgrib2 has four classes of options: init, inv, out and misc.
| type || when run
| init || run only on init phase || used for setting flags
| inv || run on init, data and cleanup phases || writes to the stdout (inventory)
| out || run on init, data and cleanup phases || writes to files
| misc || run on init, data and cleanup phases || none of the above