Code Form

      Section 0 - Indicator section
      Section 1 - Identification section
      Section 2 - Local use section
      Section 3 - Grid definition section
      Section 4 - Product definition section
      Section 5 - Data representation section
      Section 6 - Bit-map section
      Section 7 - Data section
      Section 8 - End section


      NOTES:

      1. GRIB is the name of a data representation form for general regularly-distributed information in binary.

      2. Data encoded in GRIB consists of a continuous bit-stream made of a sequence of octets (1 octet=8 bits).

      3. The octets of a GRIB message are grouped into sections:
        Section
        number
        NameContents
        0Indicator section"GRIB", discipline, GRIB edition number, length of message
        1Identification sectionLength of section, section number, characteristics that apply to all processed data in the GRIB message
        2Local use section
        (optional)
        Length of section, section number, additional items for local use by originating centers
        3Grid definition sectionLength of section, section number, definition of grid surface and geometry of data values within the surface
        4Product definition sectionLength of section, section number, description of the nature of the data
        5Data representation section (optional)Length of section, section number, description of how the data values are represented
        6Bit-map sectionLength of section, section number, indication of presence or absence of data at ech of the grid points, as applicable
        7Data sectionLength of section, section number, data values
        8End section"7777"


      4. Sequences of GRIB sections 2 to 7, sections 3 to 7, or sections 4 to 7 may be repeated within a single GRIB message. All sections within such repeated sequences must be present and shall appear in the numerical order noted above. Unrepeated sections remain in effect until redefined.

      5. It will be noted that the GRIB code is not suitable for visual data recognition without computer interpretation.

      6. The representation of data by means of series of bits is independent of any particular machine representation.

      7. Message and section lengths are expressed in octets. Octets are numbered 1, 2, 3, etc. starting at the beginning of each section. Therefore, octet numbers in a template refer to the respective section.

      8. Bit positions within octets are referred to as bit 1 to bit 8, where bit 1 is the most significant and bit 8 is the least significant. Thus, an octet with only bit 8 set to 1 would have the integer value 1.

      9. As used in "GRIB", "International Alphabet No. 5" is regarded as an 8-bit alphabet with bit 1 set to zero.

      10. The IEEE single precision floating point representation is specified in the standard ISO/IEC 559-1985 and ANSI/IEEE 754-1985 (R1991), which should be consulted for more details. The representation occupies four octets and is

        seeeeeee emmmmmmmm mmmmmmmmmm mmmmmmmmmm

        where
          s is the sign bit, 0 means positive, 1 negative
          e...e is an 8-bit biased exponent
          m...m is the mantissa, with the first bit deleted

        The value of the number is given by the following table:
        e...em...mValue of number
        0Any(-1)s(m...m)2-232-126 = (-1)s(m...m)2-149
        1...254Any(-1)s(1.0 + (m...m)2-23)2((e...e)-127)
        2550Positive (s=0) or Negative (s=1) infinity
        255>0NaN (Not a valid Number, result of illegal operation)

        Normally, only biased exponent values from 1 through 254 inclusive are used, except for positive or negative zero which are represented by setting both the biased exponent and the mantissa to 0.

        The numbers are stored with the high order octet first. The sign bit will be the first bit of the first octet. The low order bit of the mantissa will be the last (eighth) bit of the fourth octet.

        This floating point representation has been chosen because it is in common use in modern computer hardware. Some computers use this representation with the order of the octets reversed. They will have to convert the representation, either by reversing the octets or by computing the floating point value directly using the above formulae.