Step-by-step guide

There is an environment variable called ECCODES_DEBUG: If set to -1, it will enable brief debug-level logging messages to be displayed by the library. If set to 1, you will get very verbose output.

For example let's say we want to change the grid type of a GRIB message to be "Lambert Conformal":

% export ECCODES_DEBUG=-1
% grib_set -s gridType=lambert input.grib2 lamb.grib2
ECCODES DEBUG grib_set_string gridType=|lambert|
ECCODES DEBUG grib_set_long gridDefinitionTemplateNumber=30
...

Here the debugging output tells us setting the key "gridType" (whose type is "string") causes a low-level key "gridDefinitionTemplateNumber" (whose type is "long" i.e. integer) to be 30 (Also see http://apps.ecmwf.int/codes/grib/format/grib2/templates/3/30).

Another example showing what happens when you set the "shortName":

% export ECCODES_DEBUG=-1
% grib_set -s shortName=2t in.grib2 out.grib2
ECCODES DEBUG grib_set_string shortName=|2t|
ECCODES DEBUG grib_set_long discipline=0
ECCODES DEBUG grib_set_long parameterCategory=0
ECCODES DEBUG grib_set_long parameterNumber=0
ECCODES DEBUG grib_set_long typeOfFirstFixedSurface=103
ECCODES DEBUG grib_set_long scaleFactorOfFirstFixedSurface=0
ECCODES DEBUG grib_set_long scaledValueOfFirstFixedSurface=2

Now you can see the cascading effect of setting a key which causes other keys to be set. (Have a look here to see how the parameter "2t" is coded in GRIB 2)

Try it when you convert from GRIB1 to GRIB2 to see how much happens behind the scenes!