Page History
DESCRIPTION
Compare grib GRIB messages contained in two files. If some differences are found it fails returning an error code. Floating-point values are compared exactly by default, different tolerance can be defined see -P -A -R. Default behaviour: absolute error=0, bit-by-bit compare, same order in files.
...
grib_compare [options] grib_file file1 grib_file file2
OPTIONS
...
Compare files in which the messages are not in the same order. This option is time expensive.
...
Edition independent compare. It is used to compare grib GRIB edition 1 and 2.
...
Enable two-way comparison.
...
Only the listed keys or namespaces (:n) are compared. The optional letter after the colon is used to force the type in the comparison: li->integer, d->float, s->string, n->namespace. See -a option. Incompatible with -H option.
...
Compare only message headers (everything except data and bitmap). Bit-by-bit compare on. Incompatible with -c option.
...
Compare floating-point values using the relative error as tolerance. key1=relative_error error1 will compare key1 using relative_error1. all=relative_error will compare all the floating-point keys using relative_error. Default all=0.
...
Compare floating-point values using the absolute error as tolerance. Default is absolute error=0
...
Compare data values using factor multiplied by the tolerance specified in options -P -R -A.
...
Where clause. Grib messages Messages are processed only if they match all the key/value constraints. A valid constraint is of type key=value or key!=value. For each key a string (key:s) or , a double (key:d) or a long an integer (key:li) type can be specified. Default type is string. In the value you can also use the forward-slash character '/' to specify an OR condition (i.e. a logical disjunction) Note: only one -w clause is allowed.
...
Force. Force the execution not to fail on error.
...
Verbose.
grib_compare examples
The default behaviour for grib_compare without any option is to perform a bit by bit comparison of the two messages. If the messages are found to be bitwise different then grib_compare switches to a "key based" mode to find out which coded keys are different. To see how grib_compare works we first set the shortName=2d (2 metre dew point temperature) in the file regular_latlon_surface.grib1
Code Block > grib_set -s shortName=2d regular_latlon_surface.grib1 2d.grib1