Regulations

92.1   General

92.1.1   The GRIB code shall be used for the exchange of processed data expressed in binary form.

92.1.2   The GRIB code shall always contain an even number of octets.

92.1.3   The beginning and the end of the code shall be identified by 4 octets coded according to the International Alphabet No. 5 to represent, respectively, the indicators GRIB and 7777 in Indicator section 0 and End section 5. All other octets included in the code shall represent data in binary form.

92.1.4   Each section included in the code shall always contain an even number of octets. This rule shall be applied by appending bits set to zero to the section where necessary.

92.2   Section 0 -- Indicator section

92.2.1   Section 0 shall always be 8 octets long.

92.2.2   The first four octets shall always be character coded according to the International Alphabet No. 5 as GRIB.

92.2.3   The remainder of the section shall contain the length of the entire GRIB message (including the Indicator section) expressed in binary form over the left-most 3 octets (i.e. 24 bits), followed by the GRIB edition number, in binary, in the remaining octet.

92.3   Section 1 -- Product definition section

92.3.1   The length of the section, in units of octets, shall be expressed in binary form over the group of the first three octets of the section, that is, over 24 bits.

92.3.2   Octet 8 of the section shall be used to indicate the inclusion or the omission of Sections 2 or 3 or of both of them.

92.3.3   Octets 29-40 are reserved for future use and need not be present. Octets 41 and following are set aside for use by the originating centre.

92.4   Section 2 -- Grid description section

92.4.1   Regulation 92.3.1 shall apply.

92.5   Section 3 -- Bit-map section

92.5.1   Regulation 92.3.1 shall apply.

92.5.2   Octets 5 and 6 shall be used to indicate that the bit-map is either predetermined and not explicitly included, or that the bit-map follows.

92.6   Section 4 -- Binary data section

92.6.1   Regulation 92.3.1 shall apply.

92.6.2   Data shall be coded using the minimum number of bits necessary to provide for the accuracy required by international agreement. This required accuracy/precision shall be achieved by scaling the data by multiplication by an appropriate power of 10 (which may be 0) prior to forming the non-negative differences, and then using the binary scaling to select the precision of the transmitted value.

92.6.3   Data shall be coded in the form of non-negative scaled differences from a reference value.
NOTES:
(1)  The reference value is normally the minimum value of the data set which is represented.
(2)  The actual value Y (in the units of Code table 2) is linked to the coded value X, the reference value R, the binary scale factor E and the decimal scale factor D by means of the following formula:

Y x 10D= R + X x 2E

(3)  When second-order grid-point packing is indicated, the actual value Y (in the units of Code table 2) is linked to the coded values Xi and Xj, the reference value R, the binary scale factor E and the decimal scale factor D by means of the following formula:

Y x 10D = R + (Xi + Xj) x 2E

92.6.4   The reference value shall be represented over 4 octets as a single precision floating point number, consisting of a leading sign bit, a 7-bit characteristic and a 24-bit binary fraction.
NOTES:
(1)  The characteristic is convertible to a power of 16 by subtracting 64 from its 7-bit representation.
(2)  The reference value R is linked to the binary numbers s, A, B, representing the sign (1 bit) positive coded as "0", negative coded as "1", a biased exponent (exponent + 64) (7 bits), and the mantissa (24 bits), by means of the following formula:

R=(-1)s x 2(-24) x B x 16(A-64)

92.7   Section 5 -- End section
The End section shall always be 4 octets long, character coded according to the International Alphabet No. 5 as 7777.