Originally wgrib2 used the g2clib library for unpacking the grid point data (GDS).
The first break from a complete dependence on the g2clib was adding support
for ieee-type grib files. Then the optimized grib1-style unpacking from wgrib
was added to the internal routines. Then jpeg, png and complex packing were added
to the internal decoder. Finally more packing schemes that were not in g2lib/g2clib
were added (run-length and log scaling).
As of wgrib2 v1.9.8, a third option was added, use the internal decoder in g2clib
emulation mode. The options were also relabeled. The new default is to use
the internal decoder in g2clib emulation mode (-g2clib 1).
To use use the internal decode you still use -g2clib 0.
To get the g2clib decoder, use -g2clib 2. The changes were
- internal routines are faster or complex packing (1 cpu)
- internal routines are parallelized for complex packing
- some distributions were linking the official g2clib which was causing seg faults
Wgrib2 uses its own routines for encoding grib files. The
encoding follow the WMO standard but are compatible with the NCEP libraries
(g2clib and g2lib).
Differences as of October 2008
The NCEP encoding/decoding routines have a problem
with constant fields. The routines ignore the decimal scaling
and assume it is zero (decimal scaling = multiplication by one).
The packing and unpacking routines are are consistent
with themselves so the problem wasn't noticed for many years.
As of 6/2012 this situation hasn't changed. This same bug
has been found in routine in other software packages. Some
are consistently ignore the decimal scaling for all packing,
others only have the bug for certain packing methods.
The wgrib2 internal decode routines do not have it decimal scaling
problem and follow the WMO standard. The wgrib2 encode routines
will automatically use a decimal scaling = 0 for constant fields
and consequently be compatible with the WMO standard and will
decode correcty with g2clib/g2lib.
The g2clib emulation (default, -g2clib 1) are recommend when
The advantages of the wgrib2 internal code without g2clib emulation (-g2clib 0) when
- The files were created by using g2clib/g2lib libraries
- The files are created using software with the constant-field/non-zero decimal scaling bug
The g2clib routines have the advangtage that they are 100% compatible with the
NCEP g2clib/g2lib. The disadvantages of g2clib (-g2clib=2) are
- grib files follow WMO standard
- Single precision routines
- The routines are slower for large grids (not threaded)
- The routines ar the same speed for small grids
- The g2clib routines "fail" when finds an undefined template.
- Updates to official g2clib are slower. (Archives may link to official g2clib rather than patched archive included with wgrib2.)
The -g2clib option allows you to select the internal/g2clib
decoder. If X is 0, then internal routines are selected.
If X is 1, then the internal decoder with g2clib emulation is selected (g2clib is used with older wgrib2 versions).
When X is 3, then the g2clib decoder is used if the g2clib decoder were compiled into the executable.
Note that g2clib doesn't support ieee, RLE and irregular structure grids.
-g2clib N N = 0, 1 or 3 (3 is available for v1.9.8+)