Guide to the WMO Table Driven Code Form Usedfor the Representation and Exchange of Regularly
Spaced Data In Binary Form:

FM 92 GRIB Edition 2

Layer 1: Basic Aspects of FM 92 GRIB Edition 2 (GRIB2)
Layer 2:

Structure and Uses of GRIB2 Messages

Layer 3:

Detailed Description of GRIB2

Geneva, 1 January 2003

Preface

This guide has been prepared to assist experts who wish to use the WMO Table Driven Data
Representation Form FM 92 GRIB Edition 2 (GRIB2).
This guide is designed in three layers to accommodate users who require different levels of
understanding.
Layer 1 is a general description designed for those who need to become familiar with the table
driven code form but do not need a detailed understanding.
Layer 2 focuses on the functionality and application of GRIB2, and is intended for those who mustuse software that encodes and/or decodes GRIB2, but will not actually write the software.
Layer 3 is intended for those who must actually write GRIB2 encoding and/or decoding software,although those wishing to study the code form in depth, will find it equally useful.
The WMO gratefully acknowledges the contributions of the experts who developed this guidancematerial. The Guide was prepared by Dr. Clifford H. Dey of the U. S. A. National Centre forEnvironmental Prediction. Contributions were also received in particular from Charles Sanders Australia, Jean Clochard - Meteo-France, John Hennessy - ECMWF and Simon Elliott EUMETSAT.

Contents
PAGE

Layer 1: Basic Aspects of GRIB2
1.1 Overview ....................................................................................................................................1
1.2 General Description ...................................................................................................................3
1.2.1 Code Structure ............................................................................................................................................. 3
1.2.1.1 Code Sections ................................................................................................................................... 3
1.2.1.2 Iterating the Sections ...................................................................................................................... 4
1.2.2 Code Templates .......................................................................................................................................... 6
1.2.3 Tables ............................................................................................................................................................. 6
1.2.3.1 Template Tables ............................................................................................................................... 6
1.2.3.2 Code and Flag Tables .................................................................................................................... 7
1.2.4 Identification of Parameters ..................................................................................................................... 7
1.3 Updating the Code Form .................................................................................................................................. 9
1.3.1 General Procedures ................................................................................................................................... 9
1.3.2 Changes Requiring Software Modifications .......................................................................................10
1.3.2.1 Example of a Change to the Code Structure..........................................................................10
1.3.3 Changes Not Requiring Software Modifications ...............................................................................11
1.3.3.1 Example of Adding a New Parameter ......................................................................................11
1.3.4 Validation of Updates ................................................................................................................................12

Layer 2: Structure and Use of GRIB2 Messages
2.1 Sections of a GRIB2 Message ......................................................................................................................132.1.1 Section 0: Indicator Section ....................................................................................................................132.1.2 Section 1: Identification Section ............................................................................................................142.1.3 Section 2: Local Use Section..................................................................................................................172.1.4 Section 3: Grid Definition Section .........................................................................................................17
2.1.5 Section 4: Product Definition Section...................................................................................................21
2.1.6 Section 5: Data representation Section ...............................................................................................23
2.1.7 Section 6: Bit-Map Section ......................................................................................................................24
2.1.8 Section 7: Data Section ............................................................................................................................24
2.1.9 Section 8: End Section .............................................................................................................................25
2.2 GRIB2 Templates ..............................................................................................................................................25
2.2.1 Grid Definition Templates ........................................................................................................................25
2.2.2 Product Definition Templates .................................................................................................................29
2.2.3 Data Representation Data Templates .................................................................................................33
2.2.4 Data Templates...........................................................................................................................................34
2.3 GRIB2 Compression Schemes .....................................................................................................................35
2.3.1 Grid point data - Simple Packing ...........................................................................................................36
2.3.2 Grid point data - Complex Packing .......................................................................................................39
2.3.3 Grid point data - Complex Packing and Spatial Differencing .......................................................43
2.3.4 Spectral Truncation....................................................................................................................................45
2.3.5 Spectral Data – Simple Packing ............................................................................................................46
2.3.6 Spectral Data – Complex Packing ........................................................................................................47I2.4 The Structure of GRIB2 Messages ..............................................................................................................49
2.4.1 Structure of A GRIB2 Message with One Data Set .........................................................................49
2.4.2 Structure of A GRIB2 Message with Multiple Data Sets ................................................................53
2.5 Uses of GRIB2 Messages...............................................................................................................................61
2.6 Available GRIB2 Software ..............................................................................................................................66

Layer 3: Detailed Description of GRIB2
3.1 Quasi-regular Grids ...........................................................................................................................................67
3.2 Hybrid Vertical Coordinates............................................................................................................................73
3.3 Data Compression.............................................................................................................................................76
3.3.1 Complex Packing Schemes ....................................................................................................................76
3.3.1.1 Example of using Complex Packing in a GRIB2 Message with One Data Set ...........76
3.3.2 Complex Packing and Spatial Differencing Schemes ....................................................................81
3.3.2.1 Example of using Complex Packing and Spatial Differencing in a GRIB2 Message ina GRIB2 Message with One Data Set ......................................................................................81
3.4 Structure of A GRIB2 Message with Multiple Data Sets .......................................................................86
3.4.1 Iterating the Sections ................................................................................................................................86
3.4.2 Example of a GRIB2 Message with Multiple Grid Definition, Product Definition and Data
Representation Sections ..........................................................................................................................86
3.4.3 Example of a GRIB2 Message with Multiple Grid Definition, Product Definition, Data
Representation and Local Use Sections .............................................................................................93IILayer 1:
1.1

Basic Aspects of GRIB2

Overview

The World Meteorological Organization (WMO) Commission for Basic Systems (CBS)Extraordinary Meeting Number VIII (1985) approved a general purpose, bit-oriented dataexchange format, designated FM 92-VIII Ext. GRIB (GRIdded Binary). The expanded name of thecode form was "Processed data in the form of grid-point values expressed in binary form". It is anefficient vehicle for transmitting large volumes of gridded data to automated centres over highspeed telecommunication lines using modern protocols. By packing information into the GRIB
code, messages can be made more compact than character oriented bulletins, which will produce
faster computer-to-computer transmissions. GRIB can equally well serve as a data storage
format, generating the same efficiencies relative to information storage and retrieval devices.
Changes and extensions to GRIB were approved at the regular meeting of the WMO/CBS in
February 1988; additional changes were made in May 1989 and October 1990. The 1990
changes were of such structural magnitude as to require a new edition of GRIB, Edition1(hereafter referred to as GRIB1). The Subgroup on Data Representation and Codes (SGDRC)
made augmentations several more times during the 1990s. These changes involved only
additions to some of the tables. Therefore, the version number was incremented each time.
However, since the code structure did not change, the Edition Number did not change either, andit therefore remained at 1.
As the end of the 20th century approached, however, it had become apparent that GRIB1 could notsatisfy all the requirements for representation of regularly spaced data in binary form that wereplaced upon it. Most obvious was that the internationally coordinated portion of GRIB1 Code
Table 2 (Indicator of Parameter) was completely full. This forced WMO Members to add newparameters to their own local use portion of Table 2. Indeed, some Members found it necessary
to define several local versions of Table 2 to accommodate all the needed parameters. Morefundamentally, however, GRIB1 was designed with a single overall structure for identifying
products. Although this structure had some flexibility, it was not sufficient to represent many of the
new products, such as those from ensemble predictions, that were becoming available by the endof the 1990s. WMO Members responded to this situation by creating their own local extensions to
GRIB Edition 1. This situation was inhibiting the exchange of numerical products in GRIB1. It was
clear that a basic revision of GRIB was now needed to meet the requirements placed upon it.
Consequently, the CBS Implementation Co-ordination Team on Data representation and Codes
ICT/DRC began developing a revised GRIB code form that would contain the flexibility needed tomeet the requirements that GRIB1 could not. Since this involved a basic restructuring of GRIB, it
was assigned Edition 2 (hereafter referred to as GRIB2). A new expanded name was given to thecode form: "General Regularly-distributed Information in Binary form". The Extraordinary Meetingof the WMO/CBS in October 1998 (CBS EXT. (98)) approved GRIB2 for experimental use. After aperiod of further refinement and testing, the ICT/DRC recommended in April 2000 that GRIB2 beapproved for operational use. The regular meeting of the WMO/CBS in December 2000 (CBS XII)
approved this Recommendation. Because ICAO requested continuation of GRIB1, however, theUnited Kingdom and United States World Area Forecast System centres agreed to continue
production of data sets in GRIB1 as long as required by ICAO. It is expected that both GRIB1 andGRIB2 data sets will be in use for some time.
The purpose of this document is to describe the GRIB Edition 2 Code Form and its accompanying
tables. The document is divided into three layers. Layer 1 is a general description designed for
those who need to become familiar with the table/template driven code form but do not need adetailed understanding. Layer 2 describes the structure and use of GRIB2, and is intended for1those who must use software that encodes and/or decodes GRIB2 but will not actually write theencoding and/or decoding software. Layer 3 is intended for those who must actually write GRIB2
software, although those wishing to study the table/template driven code form in depth, will find it
equally useful.
A Caveat: The Official International Documentation for GRIB2 is the WMO Manual on codes(WMO Publication No. 306, Vol. 1, Part B, Secretariat of the WMO, Geneva, Switzerland, 2001).
This document is intended to be a guide to the use of GRIB2 and may not include all the features
currently found in the Manual. The features described here are intended to be a completely
consistent sub-set of the full WMO documentation; if there are any discrepancies the Manual on
Codes is the final authority.

2

1.2
1.2.1
1.2.1.1

General Description
Code Structure
Code Sections

Each GRIB2 message intended for either transmission or storage contains one or moreparameters with values located at an array of grid points or represented as a set of spectral
coefficients. Logical divisions of the message are designated as sections, each of which provides
control information and/or data. There are nine different types of sections, one of which is
optional. The nine sections and their general contents are:
SectionNumberSection Name

Section Contents

Section 0: Indicator Section
Section 1:

Section 2:
Section 3:

Section 4:
Section 5:
Section 6:

Section 7:
Section 8:“GRIB”, Discipline, GRIB Edition number,
length of message
Identification Section
Length of section, section number,characteristics that apply to all processed datain the GRIB message
Local Use Section (optional)
Length of section, section number, additional
items for local use by originating centres
Grid Definition Section
Length of section, section number, definition ofgrid surface and geometry of data values within
the surface
Product Definition Section Length of Section, section number, descriptionof the nature of the data
Data Representation Section
Length of section, section number, descriptionof how the data values are represented
Bit-Map Section
Length of section, section number, indicationof presence or absence of data at each grid
point, as applicable
Data Section
Length of section, section number, data values
End Section“7777”All but the Local Use Section must appear at least once in every GRIB2 message.

The GRIB2 Indicator, Grid Definition, Bit-Map, Data, and End Sections map directly to theircounterparts in GRIB1, although their contents in GRIB2 are somewhat different than in GRIB1.
However, the GRIB2 Identification, Product Definition, and Data Representation Sections all map
into the GRIB1 Product Definition Section, and the GRIB2 Sections contain substantially more
information than in GRIB1. The GRIB2 Local Use Section is not present in GRIB1. This mapping
is presented schematically below:

3

GRIB2 Sections

GRIB1 Sections

Indicator Section <----------------------------------> Indicator Section
No counterpart <-------------------------------------> Local Use Section¦-------> Identification Section
Product Definition Section <---------------¦-------> Product Definition Section¦-------> Data Representation Section
Grid Description Section <-------------------------> Grid Definition Section
Bit-Map Section <------------------------------------> Bit-Map Section
Binary Data Section <-------------------------------> Data Section
End Section <-----------------------------------------> End Section
The subdivision of the GRIB1 Product Definition Section into the GRIB2 Identification, ProductDefinition, and Data Representation Sections is one of the fundamental differences between
GRIB1 and GRIB2. This, combined with the option for iterating the Sections (described next) andexpansion of the concept of templates (described in Item 1.2.2), are what provide GRIB2 with its
substantially enhanced flexibility over what is possible in GRIB1.

1.2.1.2Iterating the Sections
GRIB1 only permits one field to be represented by a single GRIB1 message. However, GRIB2
achieves additional flexibility by allowing more than one field to be represented in a single GRIB2
message. This is allowed by permitting specific groups of sections to be repeated within a GRIB2
message. Consider the sections of a GRIB2 message referred to above:
Section 0:
Section 1:
Section 2:
Section 3:
Section 4:
Section 5:
Section 6:
Section 7:
Section 8:

Indicator Section
Identification Section
Local Use Section (optional)
Grid Definition Section
Product Definition Section
Data Representation Section
Bit-Map Section
Data Section
End Section|| repeated
|
|

|
|
|
|
|
|repeated |repeated||||

The GRIB2 regulations state that (A) Sequences of GRIB2 sections 2 to 7, 3 to 7, or 4 to 7 may berepeated within a single GRIB2 message, (B) All sections within such repeated sequences must
be present and shall appear in the numerical order noted above, and (C) Unrepeated sections
remain in effect until redefined. This is denoted schematically in the above table by the threegroups of vertical bars.
Consider, for example, 500 hPa height field forecasts on a Northern Hemisphere polarstereographic grid produced by a particular numerical model at forecast hours 12, 24, 36, and 48.
These four fields could be represented by a single GRIB2 message by repeating the sequence ofSections 4 to 7 four times, making the appropriate forecast time changes in the Product Definition
Section in each iteration of the sequence. This GRIB2 message would appear schematically as
follows:

4

Section 0:
Section 1:
Section 2:
Section 3:
Section 4:
Section 5:
Section 6:
Section 7:
Section 4:
Section 5:
Section 6:
Section 7:
Section 4:
Section 5:
Section 6:
Section 7:
Section 4:
Section 5:
Section 6:
Section 7:
Section 8:

Indicator Section
Identification Section
Local Use Section (optional)
Grid Definition Section
Product Definition Section (hour = 12)| repetition 1
Data Representation Section|
Bit-Map Section|
Data Section|
Product Definition Section(hour = 24)| repetition 2
Data Representation Section|
Bit-Map Section|
Data Section
Product Definition Section(hour = 36)| repetition 3
Data Representation Section|
Bit-Map Section|
Data Section|
Product Definition Section(hour = 48)| repetition 4
Data Representation Section|
Bit-Map Section|
Data Section|
End Section

Note that since the Grid Definition Section is not repeated, it remains in effect for all four forecast
hours.
As another example, consider 500 hPa height field forecasts produced at forecast 24 hours onfour different grid projections. These could be represented in a single GRIB2 message by
repeating the sequence of Sections 3 to 7 four times, making the appropriate changes in the Grid
Definition Section in each sequence, but leaving the Product Definition Section, and therefore theforecast hour, unchanged. In this case, the GRIB2 message would appear schematically as:
Section 0:
Section 1:
Section 2:
Section 3:
Section 4:
Section 5:
Section 6:
Section 7:
Section 3:
Section 4:
Section 5:
Section 6:
Section 7:
Section 3:
Section 4:
Section 5:
Section 6:
Section 7:
Section 3:
Section 4:
Section 5:
Section 6:
Section 7:
Section 8:

Indicator Section
Identification Section
Local Use Section (optional)
Grid Definition Section (grid #1)| repetition 1
Product Definition Section (hour = 24) |Data Representation Section|
Bit-Map Section|
Data Section|
Grid Definition Section(grid #2)
| repetition 2
Product Definition Section(hour = 24)|
Data Representation Section|
Bit-Map Section|
Data Section|
Grid Definition Section(grid #3)
| repetition 3
Product Definition Section(hour = 24)|
Data Representation Section|
Bit-Map Section|
Data Section|
Grid Definition Section(grid #4)
| repetition 4
Product Definition Section(hour = 24)|
Data Representation Section|
Bit-Map Section|
Data Section|
End Section

51.2.2

Code Templates

Although not referred to as such, the template concept is used in GRIB1 in the Grid Description
Section, where octets 6 – 32 are defined as follows:
Octet 6
Octets 7 – 32

Data representation type (see Table 6)
Grid definition (according to data representation type – octet 6
above)

Thus, the contents of octets 7 – 32 are not explicitly defined. Rather, the value in octet 6 refers toan entry in GRIB1 Table 6, and that entry defines the contents of octets 7 – 32. In thenomenclature of GRIB2, the contents of octet 6 would be referred to as the template number, andthe contents of octets 7 – 32 would be referred to as the template. In GRIB2, this powerfulconcept has been retained in the Grid Definition Section, but expanded to product definition anddata representation as well. It has also been made more flexible by leaving variable the number ofoctets used for the template. The separation of identification, product definition and data
representation into separate sections facilitates this application of the template concept in GRIB2.
Thus, there are three categories of GRIB2 templates – Grid Definition Templates, ProductDefinition Templates, and Data Representation Templates. They are identified by the Grid
Definition Template Number, Product Definition Template Number, and Data Representation
Template Number, respectively. These template numbers are coded in the appropriate section.
Two octets are allocated for each template number, ensuring table space will not become
exhausted.
When a new product, new grid, or new type of data representation is needed, one has to simply
define the appropriate new template(s) and submit them to the ICT/DRC for approval (the approval
process is described in Section 1.3 of this Layer). With ample table space allowed, GRIB2 thus
possesses the flexibility to represent virtually any product using virtually any type of data
representation on virtually any type of grid projection both now and in the future.
The templates themselves are somewhat complicated. They are described in detail in Layer 2 ofthis Guide.

1.2.3

TablesBecause of the extensive use of templates, there are two categories of tables in GRIB2 –Template Tables and Code and Flag Tables. The tables in both categories are numerous and, attimes, complicated. In fact, the tables form by far the largest part of the documentation of GRIB2
in the Manual on Codes. Both types of tables are described briefly below and in detail in Layer 2of this Guide.
1.2.3.1Template Tables
All templates are described in the Template Tables. These Tables are categorized by the Section
number in which the templates are found. In the tables, the templates themselves are labelledm.n, where m is the number of the section is which the template is found and n is the template
number coded in the appropriate section. The name of the template is given by a code table andis also referred to by the template number n. The first quantity in each template is in the octet
specified in its respective section. Although the templates have variable lengths, the last octet of
the template can always be calculated from values coded in the section.

6

1.2.3.2

Code and Flag Tables

A code table is a list of choices where only one of the choices can be selected at a given time.
The selection is accomplished by coding the number of the desired entry in the appropriate placein the GRIB2 Section. A flag table, on the other hand, is a list of choices where any combinationof the choices can be selected at a given time. The combination is accomplished by turning bitsof a bit string on or off. Code and Flag tables are also categorised by the Section number in which
the code or flag table is referred to. There are far more code and flag tables in GRIB2 that there
are in GRIB1. Many of these are used for the representation of the parameters (discussed in thenext Section).

1.2.4 Identification of Parameters
As noted in the Overview (Section 1.1), the identification of parameters has been a serious
problem with GRIB1 for some time. The problem arose because GRIB1 only allocated one octet
for the “Indicator of parameter” (GRIB1 Table 2). With only one octet, GRIB1 Table 2 has only 256
entries: entries 0 – 127 are allocated for international coordination, entries 128 – 254 are allocatedfor originating centre use, and entry 255 indicates a missing parameter. As early as the mid1990s, it was clear that allocating only 128 entries for international coordination was going tobecome a serious problem and that proved to be the case. For this reason, the developers of
GRIB2 made a special effort to rectify this problem. Their solution is a different approach to theidentification of parameter than in GRIB1, and therefore deserves special mention.
The most straightforward solution would have been to simply allocate 2 octets for the identificationof parameters in GRIB2. This would have been a table with 65536 entries, and would havecertainly had an ample number of entries. However, it was decided that a single table of such size
would prove to be difficult to organise in a way that would allow users to easily find the parameter
they desired. Rather, it was decided to use a branching structure based on three parameters –discipline, category, and name. The first of these parameters – discipline – is given in octet 7 of
the Indicator Section. That octet refers to Code Table 0.0. The current Code Table 0.0 is thefollowing:

Code Table 0.0 – Discipline of processed data in the GRIB message
Code Figure
0
1
2
3
4-9
10
11-191
192-254
255

Meaning
Meteorological products
Hydrological products
Land surface productsSpace products
Reserved
Oceanographic products
Reserved
Reserved for local use
Missing

Code Table 4.1 – Category of parameters by product discipline – provides the next branch. Table
4.1 has a list of parameter categories for each of the product disciplines given in Table 0.0. To
give only one example, the sub-table for Discipline 0 – Meteorological products – is currently thefollowing:
Code Table 4.1:

Category of parameters by product discipline7

Product discipline 0:

Meteorological products

Category

Description

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20-189190
191
192-254
255

Temperature
Moisture
Momentum
Mass
Short-wave Radiation
Long-wave Radiation
Cloud
Thermodynamic Stability indicies
Kinematic Stability indicesTemperature Probabilities
Moisture Probabilities
Momentum Probabilities
Mass Probabilities
Aerosols
Trace gases (e.g., ozone, CO2)Radar
Forecast Radar Imagery
Electro-dynamics
Nuclear/radiology
Physical atmospheric properties
Reserved
CCITTIA5 string
MiscellaneousReserved for local use
Missing

Code Table 4.2 – Parameter number by product discipline and parameter category - provides thethird branch. Table 4.2 has a list of parameter numbers and names for each product discipline
given in Table 0.0 and each parameter category given in Table 4.1. As an example, the sub-tablefor Discipline 0 (Meteorological products), Category 0 (Temperature) is currently the following:
Code Table 4.2:

Parameter number by product discipline and parameter category

Product discipline 0:
Category
0
1
2
3
4
5
6
7
8
9
10
11
12
13

Meteorological products,

Product category 0: Temperature

Description

Units

Temperature
Virtual temperature
Potential temperature
Pseudo-adiabatic potential temperatureor equivalent potential temperature
Maximum temperature
Minimum temperature
Dew point temperature
Dew point depression (or deficit)
Lapse rate
Temperature anomaly
Latent heat net flux
Sensible heat net flux
Heat index
Wind chill factor

K
K
K
K

8

K
K
K
K
K m-1
K
W m-2
W m-2
K
K

14
15
16
17-191
192-254
255

Minimum dew point depression
Virtual potential temperature
Snow phase change heat flux
Reserved
Reserved for local use
Missing

K
K
W m-2

As with any branching structure such as this, a possible problem is that one of the sub-categories
of either Table 4.1 or Table 4.2 could become saturated even though there are a huge number ofunused entries in other parts of the table. It is felt, however, that this is unlikely for a long time tocome, and that this approach will therefore provide enough table space for new parameters for theforseeable future. Hopefully, finding desired entries in this branching structure will also prove
more user-friendly that finding desired entries in a single table of 65536 entries.

1.3

Updating the Code Form

1.3.1

General Procedures

There are two general categories of changes to table-driven code forms – changes that require
corresponding modifications to processing software and changes that that do not. Although bothcategories of changes must undergo a validation process (described in section 1.3.4) before being
approved, the required software modifications must be available for use in the validation process
for changes in the former category, while existing software may be used in the latter. Changes
requiring software modifications are therefore more complicated to validate than changes that do
not require software modification.
Changes to the code structure always require corresponding modifications to processing softwareand are assigned a new Edition Number. Furthermore, code structure changes are seldom
required with urgency. Consequently, changes to the code structure are made very infrequently.
As noted above, GRIB1 was approved in October 1990 and GRIB2 in December 2000, 10 years
later.
Changes that do not require corresponding modifications to processing software are far lessdisruptive, are easier to validate, and are often required with greater urgency. Therefore, thesechanges are made with greater frequency. In the case of BUFR and CREX, changes to the
supporting tables do not require corresponding modifications to processing software.
Consequently, additions to the BUFR tables have been made 9 times since 1988.
However, this is not necessarily the case with GRIB. Additions to the GRIB2 product discipline,
product category, and parameter name tables indeed do not require corresponding software
modifications. As with BUFR and CREX table additions, their validation is simpler and can bemade more frequently. On the other hand, additions of a new template or grid projection, while
seeming at first glance to be only simple table additions, do require software modifications in orderto process information using these new features. Nevertheless, such changes would have far
greater urgency than most code structure changes. Therefore, although these changes must also
undergo the more complicated validation process that is required for code structure changes, they
may well have to be implemented on a timelier basis than code structure changes. This is likely to
be a challenge the WMO will have to deal with.
All amendments to BUFR and CREX must be proposed in writing to the WMO Secretariat. The
proposal must specify the needs, purposes and requirements, target dates for effective use, andinclude information on a contact point for technical matters. An Expert Team on Data
Representation and Codes (ET/DRC) under the Commission for Basic Systems (CBS) Open
Programme Area Group on Information Systems and Services (OPAG/ISS), supported by the9Secretariat, then validates the stated requirements and develops a draft recommendation to
respond to the requirements as appropriate.
What happens next depends on whether the draft recommendation involves changes to the
supporting software or not.

1.3.2

Changes Requiring Software Modifications

When the recommended solution developed by the ET/DRC requires corresponding changes tosoftware encoding data into or decoding data out of the code form, both the full CBS and the full
WMO Executive Council must approve the recommendation. However, the Chairperson of
OPAG/ISS must first endorse it prior to its consideration by CBS. This must be done early enoughthat the draft recommendation can be published as a CBS pre-session document at least threemonths prior to the CBS Session. If the full CBS approves the draft recommendation, it issubmitted to the full WMO Executive Council (EC) for approval. If the EC approves therecommendation, the recommendation will be implemented on the first Wednesday following thefirst of November of the year following the CBS Session.

1.3.2.1

Example of a Change to the Code Structure

Let us consider a worst-case timeline for such a change. CBS met in an extraordinary session in
December 2002. Suppose a requirement for a new feature is stated in writing to the WMO
Secretariat on 1 January 2003. The Secretariat passes the requirement to the ET/DRC, who thenmust validate the stated requirements and develop a draft recommendation that will meet thestated requirement. For the purpose of this example, we will assume the ET/DRC draft
recommendation calls for a change to the GRIB2 code structure. In this case, both the full CBS
and the full EC must therefore approve the ET/DRC draft recommendation. The next meeting of
the CBS will be in the fall of 2004 and the next meeting of the EC in early 2005. If both approvethe draft recommendation, it will take effect on the first Wednesday following the first of November
in 2005, nearly three years after the WMO Secretariat originally received the requirement.
Now consider the best-case timeline for such a change. Recall that the draft recommendationmust be prepared in time to be published as a CBS pre-session document at least three months
prior the full CBS meeting. Allowing three additional months for translation of the draft
recommendation into the various WMO languages, it should be given to the Secretariat six monthprior to the CBS session, no later than mid-June in this case. Allowing five months for the
ET/DRC to validate the requirements and prepare the draft recommendation, the original proposal
would need to be received by the Secretariat in January 2004 if it is to be considered by CBS in
the fall of 2004, and take effect on the first Wednesday after the first of November 2005. This is
still almost 2 years after the Secretariat received the statement of requirement.
The bottom line is that changes to GRIB2 requiring corresponding changes to processing software
will usually take from 2 to 3 years (the alert reader may have noted it could take more than 3
years) following their receipt to be implemented. These timelines may seem to some unduly long.
However, it must be stressed that the necessity for careful preparation, validation, and approval ofsuch recommendations, along with the realities of the workload faced by national meteorologicalservices that must perform the necessary software modifications, require such long lead times.
1.3.3 Changes Not Requiring Software Modifications
Changes not requiring software modifications can follow the same approval process as changes
that do. However, as noted previously, such changes are not only far less disruptive than code
structure changes, they are also required more frequently and often with greater urgency.
Therefore, a special approval process has been developed by the WMO Secretariat to ensure the10necessary flexibility is available to respond to urgent requirements of users during intersessional
periods (i.e., between Sessions of CBS). This approval process is referred to as the "Fast Track".
Once requests for changes have been received, justified, and deemed to not require softwarechanges, the “Fast Track” procedure is as follows:• The requests are dealt with in session or via correspondence by the ET/DRC, which
allocates the available table entries.
• The recommendation is submitted for information to the requesting source, focal points oncode matters, Chairperson of the OPAG/ISS and President of CBS, through e-mail andposted on the WMO web server.
• Associated documents kept on the WMO web server will include associated pairs: a first
document to record the request, the second one for descriptors themselves, target
validation date and target operational date.
• Upon successful completion of the validation and approval by the chairs of ET/DRC andOPAG/ISS and the President of CBS, the recommendation is “Approved for PreOperational implementation”.
• Upon approval by the Full CBS and the full EC, the recommendation is “Approved for Full
Operational Implementation”.
• These table entries are reviewed at least twice a year and will thus be in one of the threestages reflected in three different lists or tables:o Awaiting Validationo Approved for Pre-Operational Implementation: fully validated and approved by thechairs of ET/DRC and OPAG/ISS and the President of CBS
o Approved for Full Operational Implementation: approved by the full CS and full EC.
These Table Entries will then appear in the Manual on Codes
By making the recommended new table entries available on the WMO web server, centres withurgent needs can use the new entries as soon as they are declared “Available for Pre-Operational
Implementation”. This can be substantially earlier than the “Full Implementation” date. As notedin the previous section, the actual date of full operational implementation is the first Wednesday
following the first of November of the year following the CBS Session that officially approved therecommended new table entries.
1.3.3.1

Example of Adding a New Parameter

An example of a change not requiring corresponding modifications to processing software is the
addition of a new parameter to GRIB2 Table 4.2 (Parameter number by product discipline andparameter category). As in the previous section, let us consider a timeline for such a change.
Suppose a requirement for addition of a new parameter to GRIB Table 4.2 is stated in writing to
the WMO Secretariat on 1 January 2003. As before, the Secretariat passes the requirement to the
ET/DRC, who then must validate the stated requirements and develop a draft recommendationthat will meet it. In this example, the ET/DRC recommendation will not call for a change to the
GRIB2 code structure, and therefore can be approved via the “Fast Track”.
In this case the request is dealt with in session or via correspondence by the ET/DRC, which
allocates the available table entries. The ET/DRC Recommendation is then submitted for
information via e-mail to the requesting source, the focal points on code matters, the chair of the
OPAG/ISS and the President of CBS and posted on the WMO web server. Then the associateddocuments are put on the WMO web server. When first put on the web server, theRecommendation will be marked as “Awaiting Validation”. The validation in this case is rather
simple, and usually can be accomplished in two months. Once validated, the chairs of ET/DRC
and OPAG/ISS and the President of CS must approve the Recommendation. Allowing time forcorrespondence, perhaps by 1 April 2003 the status of the Recommendation can be changed to“Approved for Pre-Operational Implementation”. This would allow time for operational centres toimplement the new table entries into their processing systems on the first Wednesday following thefirst of November 2003. Although it will not be approved for full operational implementation until
the first Wednesday following the first of November 2005, the year following the next CBS Session,
11

the new table entries can be used operationally a full two years before the “Full Operational
Implementation” date. In this light, the significance of the “Full Operational Implementation” dateis to mark the publication of the changes in the WMO Manual on Codes.
1.3.4 Validation of Updates
Whether requiring corresponding modifications to processing software or not, all changes must be
validated by a procedure required by the CBS. Under this procedure, proposed changes shouldbe tested by the use of two independently developed encoders and two independently developed
decoders that incorporate the proposed change. However, where the data originated from anecessarily unique source (e.g., the data stream from an experimental satellite), the successful
testing of a single encoder with at least two independent decoders is considered adequate.
For those recommendations that are considered by the full CBS for approval, CBS may either
approve or not approve but not alter them. All changes to the WMO table-driven code forms
BUFR, CREX, and GRIB are documented in the form of supplements to the WMO Manual on
Codes. However, these supplements are issued no more than once a year.
In the above discussion, a distinction was made between the validation process for those changes
that require corresponding changes to processing software and those changes that do not.
Existing software can be used to validate table additions that do not require software changes.
Consequently, they are relatively simple to validate. The first step is to verify the table entries are
consistent with the original request, a simple pencil and paper exercise. Then, sample data canbe prepared and tested with existing software as indicated above.
The effort needed to validate changes that do require corresponding modifications to processing
software, however, can vary widely. A fairly simple example is the addition of a new grid or
product definition template. Most computer software is sufficiently modular that such changes canbe isolated and tested as required by the CBS rather easily. On the other hand, the validating of
GRIB2 is perhaps one of the most complex examples of validation. Although sharing many
aspects with GRIB1, the structure of GRIB2 is sufficiently different that virtually new processing
software is required. This software had to be written and tested before the validations could be
done. The validations that were performed for the GRIB2 Code Form involved not two centres but
six. Furthermore, at least two independent encoders and two independent decoders tested eachof the 53 templates of GRIB2. Consequently, the GRIB2 validation process took many computerruns by six centres over a period of over two years. Clearly, this testing effort was several ordersof magnitude greater that that which will be required for the addition of a single template.

12

Layer 2:
2.1

Structure and Use of GRIB2 Messages

Sections of a GRIB2 Message

Each GRIB2 message intended for either transmission or storage contains one or moreparameters with values located at an array of grid points or represented as a set of spectral
coefficients. Logical divisions of the message are designated as sections, each of which provides
control information and/or data. There are nine different types of sections in a GRIB2 message,
one of which is optional. The nine sections and their general contents are:
SectionNumberSection Name

Section Contents

Section 0: Indicator Section
Section 1:

Section 2:
Section 3:

Section 4:
Section 5:
Section 6:

Section 7:
Section 8:“GRIB”, Discipline, GRIB Edition number,
length of message
Identification Section
Length of section, section number,characteristics that apply to all processed datain the GRIB message
Local Use Section (optional)
Length of section, section number, additional
items for local use by originating centres
Grid Definition Section
Length of section, section number, definition ofgrid surface and geometry of data values within
the surface
Product Definition Section Length of Section, section number, descriptionof the nature of the data
Data Representation Section
Length of section, section number, descriptionof how the data values are represented
Bit-Map Section
Length of section, section number, indicationof presence or absence of data at each grid
point, as applicable
Data Section
Length of section, section number, data values
End Section“7777”All but the Local Use Section must appear at least once in every GRIB2 message. With the
exception of the first four octets of the Indicator Section and the End Section, all octets containbinary values. All sections end on an octet boundary; the sections are padded with bits set to zeroas necessary to accomplish this. These extra bits must be accounted for in finding one’s way
through the sections; their content should be ignored.

2.1.1 Section 0: Indicator Section
The Indicator Section serves to: identify the start of the GRIB2 message in a human readable
form, describe the “Discipline” of the information contained in the message, indicate the Edition
Number of GRIB (2 in the case of GRIB2) used to encode the message, and the total length of themessage. The section is always 16 octets long. The contents of the Indicator Section are:13

Contents“GRIB” (coded according to the International Alphabet No. 5)
Reserved
Discipline – GRIB Master Table Number (see Code Table 0.0)
GRIB Edition Number (currently 2)
Total length of GRIB message in octets (including Section 0)

Octet No.
1-4
5-6
7
8
9-16

It was noted in Layer 1 that the identification of parameters in GRIB 2 uses a branching structure
based on three parameters – Discipline, Category, and Name. Octet 7 contains the first of thesethree branches – Discipline. The contents of octet 7 are defined by Code Table 0.0, which iscurrently defined as follows:

Code Table 0.0:

Code figure
0
1
2
3
4-9
10
11-191
192-254
255

Discipline of processed data in the GRIB message, number of GRIB
Master Table

Meaning
Meteorological products
Hydrological products
Land surface productsSpace products
Reserved
Oceanographic products
Reserved
Reserved for local use
Missing

For example, Discipline = 0 indicates this GRIB2 message contains Meteorological Products,
while Discipline = 10 indicates this message contains Oceanographic Products. Code table 0.0
gives all the currently defined disciplines. It might be useful at this point to note that all GRIB2
Code Tables are referred to as Code Table m.n, where m is the number of the Section that refers
to the Code Table and n is the number of the Code Table within that Section.
The GRIB Edition Number, which is always 2 for GRIB2, is in octet 8. Finally, since GRIB2
permits multiple fields in a single message, it was decided to allocate 8 octets for the length of a
GRIB2 message. This permits lengths of up to 264 – 2, which should be more than enough forreasonable GRIB2 messages.

2.1.2 Section 1: Identification Section
The Identification Section contains characteristics that apply to all processed data in the GRIB
message. These characteristics identify the originating centre and sub-centre, indicate the GRIB
Master Table and Local Table versions used, and give the reference time, the production status,
and the type of processed data contained in this GRIB message. The contents of the Section are:Octet No.
1-4
5
6-7
8-9
10
11
12
13-14

Contents
Length of section in octets (21 or nn)
Number of Section (“1”)
Identification of originating/generating centre (see Common Code Table C-1)
Identification of originating/generating sub-centre (allocated by originating/generating centre)
GRIB Master Tables Version Number (see Code Table 1.0)
GRIB Local Tables Version Number (see Code Table 1.1)
Significance of Reference Time (see Code Table 1.2)
Year (4 digits)
|
14

15
16
17
18
19
20
21
22-nn

Month
|
Day
|
Reference time of data
Hour|
Minute|Second|Production status of processed data in this GRIB message (see Code Table 1.3)
Type of processed data in this GRIB message (see Code Table 1.4)
Reserved: need not be present

Note that octets beyond 21 of the Identification Section are reserved for future use and need not
be present. Users of GRIB messages are strongly urged to always use the length of section given
in octets 1 – 4 of sections 1 - 7 to determine where the next section begins. Never assume a fixed
octet length of any section other than the Indicator Section (Section 0 – always 16 octets long) andthe End Section (Section 8 – always 4 octets long). Also note that the Section number is given in
octet 5. This is true for sections 1 – 7. It is required in order to identify Sections in a GRIB
message containing multiple data sets.
Octets 6-7 and 8-9 identify the centre that originated the data contained in the GRIB message.
Octets 6-7 indicate the originating/generating centre. The value contained in octets 6-7 refers to
Common Code Table C-11 – Identification of originating/generating centre – maintained by the
WMO Secretariat. A subset of Common Code Table C-11 is reproduced below:

Octets 6-7

00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085

Originating/generating centre
74-99: Centres in Region VI
UK Meteorological Office - Bracknell(RSMC))
Moscow (RSMC/RAFC)
Reserved
Offenbach (RSMC))
Rome (RSMC))
Norrköping
)Reserved
Toulouse (RSMC)

Thus, if octets 6-7 contain the number 74, Table C-11 indicates the originating/generating centre is
the UK Meteorological Office in Bracknell. However, octets 8-9 must be considered as well. They
indicate the originating/generating sub-centre. The originating/generating centre indicated byoctets 6-7 allocates these values. If octets 8-9 contain the number 0, the centre defined by octets
6-7 – the UK Meteorological Office in Bracknell in this case - did in fact originate the data the GRIB
message. However, if octets 8-9 contain a number other than zero, a sub-centre of the UK
Meteorological Office actually originated the data in the GRIB message. For example, if octets 89 contain the number 1, a sub-centre of the UK Meteorological Office named Shanwick Oceanic
Area Control Centre actually originated the data contained in the GRIB message. In general, onemust consider Common Table C-12 or contact the originating/generating centre to find the subcentre referred to in octets 8-9.
It is necessary to access the proper tables in order to correctly decode a GRIB message. These
are identified by octets 10 and 11. These octets refer to Code Tables 1.0 and 1.1, respectively,
which are currently defined as:15

Code Table 1.0: GRIB Master Tables Version Number
Code figure
0
1
2
3
4
5
6-254
255

Meaning
Experimental
Version implemented on 7 November 2001
Version implemented on 4 November 2003
Version implemented on 2 November 2005
Version implemented on 7 November 2007
Pre-operational to be implemented by next amendment
Future versions
Missing value

Code Table 1.1: GRIB Local Tables Version Number
Code figure
0
1-254
255

Meaning
Local tables not used. Only table entries and templates from the current Master table are valid.
Number of local tables version used
Missing

The WMO Secretariat maintains all versions of the GRIB Master Table. Octet 10 contains theversion number of the Master Table used to generate the data contained in the GRIB message. If
octet 10 contains the value 255, however, a local table was used. In this case, the value in octet
11 – Local Table Version Number – is the relevant one. However, to obtain the local table version
referred to by octet 11, one must contact the centre that originated the data in the GRIB message
as identified by octets 6-7 and 8-9. If local tables were not used, octet 11 will contain the value 0.
The meaning of the Reference Time of the Data in GRIB1 was a source of some confusion
because it was not clearly defined. In an attempt to be more precise, the Reference Time of theData in GRIB2 is given in terms of both a date/time and its significance. The significance of thereference time – contained in octet 12 – refers to Code Table 1.2, currently defined as:
Code Table 1.2:
Code figure
0
1
2
3
4-191
192-254
255

Significance of Reference Time

Meaning
AnalysisStart of forecast
Verifying time of forecast
Observation time
Reserved
Reserved for local use
Missing

This parameter identifies, for example, whether the Reference Date/Time refers to the time of ananalysis (octet 12 = 0), the start of a forecast (octet 12 = 1), the verifying time of a forecast (octet
12 = 2), etc. The precise time of the data itself is found by combining the Reference Date/Time
itself, contained in octets 13 – 19, with additional time information given in the Product Definition
Section (Section 4).

16

Finally, octets 20 and 21 give additional information about the data in the GRIB message via Code
Tables 1.3 and 1.4:

Code Table 1.3:
Code figure
0
1
2
3
4-191
192-254255

Production status of data

Meaning
Operational products
Operational test products
Research products
Re-analysis products
Reserved
Reserved for local use
Missing

Code Table 1.4:

Type of data

Code figure
0
1
2
3
4
5
6
7
8-191
192-254
255

Meaning
Analysis products
Forecast products
Analysis and forecast products
Control forecast products
Perturbed forecast products
Control and perturbed forecast products
Processed satellite observations
Processed radar observations
Reserved
Reserved for local use
Missing

Note:

An initialised analysis is considered a zero hour forecast

The production status (octet 20) refers to whether the data are an operational product, an
operational test product, a research product, etc. The Type of data (octet 21) indicates whether
the data are an analysis product, a forecast product, a perturbed forecast products, etc.

2.1.3 Section 2: Local Use Section
The purpose of the Local Use Section is just what the Section name implies – information for local
use by the originating/generating centre. The originating/generating centre can put anything it
desires in this Section. The contents of Section 2 are:Octet No.
1-4
5
6-nn

Contents
Length of section in octets (nn)Number of Section (“2”)
Local use

2.1.4 Section 3: Grid Definition Section
The purpose of the Grid Definition Section is to define the grid surface and geometry of the data
values within the surface for the data contained in the next occurrence of the Data Section.
GRIB2 retains the powerful GRIB1 concept of a template in this Section and extends it to the17Product Definition, Data Representation, and Data Sections as well. Use of a template means
there are very few values common to all Grid Definition Sections possible in GRIB2. Rather, thenumber of the Grid Definition Template used is encoded. The values that must follow are thoserequired by that particular Grid Definition Template. The contents of Section 3 are:Octet No.
1-4
5
6
7-10
11
12
13-14
15-xx
[xx+1]-nn

Contents
Length of section in octets (nn)Number of Section (“3”)
Source of grid definition (see Code Table 3.0 and Note 1)
Number of data points
Number of octets for optional list of numbers defining number of points (seeNote 2)
Interpretation of list of numbers defining number of points (see Code Table
3.11)
Grid Definition Template Number (N) (see Code Table 3.1)
Grid Definition Template (see Template 3.N, where N is the Grid Definition
Template Number given in octets 13-14)
Optional list of numbers defining number of points (see Notes 2, 3, and 4)

Notes:
1.
If octet 6 is not zero, octets 15-xx (15-nn if octet 11 is zero) may not be supplied. Thisshould be documented with all bits set to 1 (missing value) in the Grid Definition Template
Number.
2.
An optional list of numbers defining the number of points is used to document a quasiregular grid, where the number of points may vary from one row to another (row being defined asadjacent points in a coordinate line, so this is dependent on the data layout). In such a case, octet
11 is non-zero, and gives the number of octets on which each number of points is encoded. For
all other cases, such as regular grids, octets 11 and 12 are zero and no list is appended to the
Grid Definition Template.
3.
If a list of numbers defining the number of points is present, it is appended at the end of theGrid Definition Template (or directly after the Grid Definition Template Number if the template is
missing), and the length of the list is given by the grid definition. When the Grid Definition
Template is present, the length is given according to bit 3 of the scanning mode flag octet (thelength is Nj or Ny for flag value 0). List ordering is implied by data scanning.
4.
Depending on the code value given in octet 12, the list of numbers defining the number ofpoints corresponds either to the coordinate lines as given in the grid definition, or to a full circle.
The somewhat forbidding appearance of the contents and notes of the Grid Definition Section isdue to several special cases defined by octets 6, 11, and 12. Octet 6 refers to Code Table 3.0:18

Code Table 3.0:

Source of Grid Definition

Code figure

Meaning

0
1
2-191
192-254
255

Specified in Code table 3.1
Predetermined grid definition Defined by originating centre
Reserved
Reserved for local use
A grid definition does not apply to this productComments

First, when octet 6 is not zero, Note 1 applies. In this case, either a predetermined grid definition
defined by the originating/generating centre is used (octet 6 = 1) or a grid definition does not apply
to this product (octet 6 = 255). The former case should be avoided if at all possible, for then users
must contact the originating/generating centre to determine the meaning of the values in octets 15- xx: it will not be found in the WMO Code Manual. In the latter case, there is no Grid Definition
Template at all. This is documented by setting octets 13 - 14 to missing (all bits set to 1).
Octets 11 and 12 and Notes 2, 3, and 4 account for the possibility of a quasi-regular grid. This is
one in which the number of grid points varies from grid row to grid row. As the notes suggest, thiscan be complicated, so discussion of this case is reserved for Layer 3.
The large majority of GRIB2 messages will not utilize these special cases. Therefore, if one canmentally remove them from the contents of Section 3, the Grid Definition Section becomes
simpler: following the standard length and number of section in octets 1 – 5, the number of points
is given, then the Grid Definition Template Number, followed by the values required by the Grid
Definition Template of that number. The particular Grid Definition template used thus describes
the large majority of the values found in Section 3.
As an example, suppose the value in octets 13 - 14 is 20. One then refers to Code Table 3.1:
Code Table 3.1:

Grid Definition Template Number

Code figure

Meaning

Comments

0Latitude/longitude

Also called equidistant cylindrical,
or Plate Carree.

1
2
3
4-9
10
11-19
20
21-29
30

Rotated latitude/longitude
Stretched latitude/longitude
Stretched and rotated latitude/longitude
Reserved
Mercator
Reserved
Polar stereographic
Reserved
Lambert Conformal

31-39
40
41
42
43
44-49
50
51

Reserved
Gaussian latitude/longitude
Rotated Gaussian latitude/longitude
Stretched Gaussian latitude/longitude
Stretched and rotated Gaussian latitude/longitude
Reserved
Spherical harmonic coefficients
Rotated spherical harmonic coefficients19

can be south or north.
can be secant or tangent, conicalor bipolar. (Also called Albers
equal-area.)52
Stretched spherical harmonic coefficients
53
Stretched and rotated spherical harmonic coefficients
54-89
Reserved
90
Space view perspective orthographic.
91-99
Reserved
100
Triangular grid based on an icosahedron
101-109
Reserved
110
Equatorial azimuthal equidistant projection
111-119
Reserved
120
Azimuth-range projection
121- 999
Reserved
1000
Cross-section grid, with points equally spaced on the horizontal
1001-1099
Reserved
1100
Hovmöller diagram grid, with points equally spaced on the horizontal
1101- 1199 Reserved
1200
Time section grid1201-32767 Reserved
32768-65534 Reserved for local use
65535
Missing

Inspection of Code Table 3.1 reveals that 20 corresponds to a Polar Stereographic grid projection.
One then looks up Grid Definition Template 3.20 to find the contents of the remainder of the Grid
Description Section. In this case, Template 3.20 requires use of octets 15 – 65, and describes indetail what the contents of octets 15 – 65 are. On the other hand, if the value in octets 13 – 14
were 30, Code Table 3.1 indicates this would correspond to a Lambert Conformal grid projection.
Inspection of Grid Definition Template 3.30 reveals that octets 15 – 81 would be needed to define
this grid projection. Furthermore, much of the contents of octets 15 – 81 describing a Lambert
Conformal grid projection would be different than the contents of octets 15 – 65 describing a Polar
Stereographic grid projection.
Use of the template concept allows virtually any grid to be defined in GRIB2 – if an existing
template does not define it; one develops a new template and submits it to the WMO for approvalthrough the official channels described in Layer 1. Utilisation of the template concept also defersmuch of the complexity in this and the Product Definition, Data Representation, and Data Sections
to the discussion of the templates themselves – found in Section 2.2 of this Layer. The various
Templates themselves refer to a number of Code and Flag Tables. However, although thisdocument attempts to reproduce enough GRIB2 Code and Flag tables to explain the examples
given, it does not seek to reproduce them all. The reader must refer to the WMO GRIB2 CodeManual itself for Code and Flag Tables not reproduced here.

202.1.5 Section 4: Product Definition Section
The purpose of the Product Definition Section is to describe the nature of the data contained in
the next occurrence of the Data Section. The contents of Section 4 are:Octet No.
1-4
5
6-7
8-9
10-xx
[xx+1]-nn

Contents
Length of section in octets (nn)Number of Section (“4”)
Number of coordinate values after Template (see Note 1)
Product Definition Template Number (see Code Table 4.0)
Product Definition Template (see Template 4.X, where X is the ProductDefinition Template Number given in octets 8-9)
Optional list of coordinate values (see Notes 2 and 3)

Notes:
1.
Coordinate values are intended to document the vertical discretisation associated withmodel data on hybrid vertical coordinate levels. A number of zero in octets 6-7 indicates that nosuch values are present. Otherwise, the number corresponds to the whole set of values.
2.
Hybrid systems, in this context, employ a means of representing vertical coordinates interms of a mathematical combination of pressure and sigma coordinates. When used inconjunction with a surface pressure field and an appropriate mathematical expression, the verticalcoordinate parameters may be used to interpret the hybrid vertical coordinate.
3.
Hybrid vertical coordinate values, if present, should be encoded in IEEE 32-bit floating point
format. They are intended to be encoded as pairs.
Once again, a special case adds some complexity to the list of contents of Section 4. Here, thespecial case is the possible use of a hybrid vertical coordinate system. As Note 2 indicates, ahybrid vertical coordinate system is a mathematical combination of pressure and sigma verticalcoordinates. In this case, a series of pairs of numbers, indicating the combination of the twovertical coordinate systems for each coordinate level, must be given. Octets 6-7 and the Notes
describe adjustments that must be made to the Product Definition Section in this event.
When hybrid vertical coordinates are not used (which is far more common), Section 4 contains
simply the length and number of section in octets 1 – 5, the number zero to indicate hybrid
coordinates are not used, the Product Definition Template Number, and the values required by the
Product Definition Template of that number. For example, suppose the value in octets 8 - 9 is 0.
One then refers to Code Table 4.0:21

Code Table 4.0:
Number
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15-19
20
21-29
30
31-253254
255-999
1000
1001
1002
1003-1099
1100
1101
1102-32767
32768-65534
65535

Product Definition Template Number
Description
Analysis or forecast at a horizontal level or in a horizontal layer at a point in time
Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at apoint in time
Derived forecast based on all ensemble members at a horizontal level or in a horizontal layer at apoint in time
Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal
level or in a horizontal layer at a point in time
Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level orin a horizontal layer at a point in time
Probability forecasts at a horizontal level or in a horizontal layer at a point in time
Percentile forecasts at a horizontal level or in a horizontal layer at a point in time
Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time
Average, accumulation, extreme values or other statistically processed values at a horizontal level orin a horizontal layer in a continuous or non-continuous time interval
Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous
time interval
Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous
time interval
Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in acontinuous or non-continuous interval
Derived forecasts based in all ensemble members at a horizontal level or in a horizontal layer, in acontinuous or non-continuous interval
Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal
level or in a horizontal layer, in a continuous or non-continuous interval
Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level orin a horizontal layer, in a continuous or non-continuous interval
Reserved
Radar productReserved
Satellite productReserved
CCITT IA5 character string
Reserved
Cross section of analysis and forecast at a point in time
Cross section of averaged or otherwise statistically processed analysis or forecast over a range of time
Cross-section of analysis and forecast, averaged or otherwise statistically processed
Reserved
Hovmöller-type grid with no averaging or other statistical processing
Hovmöller-type grid with averaging or other statistical processing
Reserved
Reserved for local use
Missing

Code Table 4.0 indicates a value of 0 corresponds to an analysis or forecast at a horizontal level
or in a horizontal layer at a point in time. Product Definition Template 4.0 then utilises octets 10 34 to specify precisely what the product in the next occurrence of the Data Section is.
The subdivision of the GRIB1 Product Definition Section into the GRIB2 Identification, ProductDefinition, and Data Representation Sections permits each of these sections to focus on a single
aspect of data set description. The extension of the template concept to the GRIB2 ProductDefinition and Data Representation sections adds enormous flexibility to the GRIB2 code form. As
with the Grid Definition Section, the complexity of the Product Definition Section is in the values
required by the various templates, discussed in Section 2.2 of this guide.

22

2.1.6 Section 5: Data Representation Section
The purpose of the Data Representation Section is to describe how the data values are
represented in the next occurrence of the Data Section. The contents of Section 5 are:Octet No.
1-4
5
6-9

10-11
12-nn

Contents
Length of section in octets (nn)Number of Section (“5”)
Number of data points where one or more values are specified in Section 7
when a bit map is present, total number of data points when a bit map isabsentData Representation Template Number (see code Table 5.0)
Data Representation Template (see Template 5.X, where X is the Data
Representation Template Number given in octets 10-11)

The pattern taken by the contents of a section that uses a template may be becoming familiar by
now. In this Section, the special case noted in the description of the contents of octets 6 - 9 has to
do with the use of a bit map. The value in octets 6 - 9 indicates to the user how many data pointvalues are to be found in the Data Section. However, when a bit map is used (this is discussed in
Section 2.1.7), the number of data point values to be found in the data Section (given by octets 6 9 of the Data Representation Section) may be smaller than the number. The number of data pointvalues to be found in the data Section (given by octets 6 - 9 of the Data Representation Section)
may therefore be fewer than the number of data points themselves (given by octets 7 - 10 of theGrid Definition Section).
As an example of the Data Representation Section, suppose the value in octets 10 - 11 is 0. We
now refer to Code Table 5.0:
Code Table 5.0:
Code figure Meaning
0
1
2
3
4
5-39
40
41
42-49
50
51
52-60
61
62-49151
49152-65534
65535

Data Representation Template Number
Grid point data - simple packing
Matrix value - simple packing
Grid point data - complex packing
Grid point data - complex packing and spatial differencing
Grid point data – IEEE floating point data
Reserved
Grid point data – JPEG 2000 Code Stream Format
Grid point data – Portable Network Graphics (PNG)
Reserved
Spectral data -simple packing
Spherical harmonics data - complex packing
Reserved
Grid point data - simple packing with logarithm pre-processing
Reserved
Reserved for local use
Missing

The Code Table indicates a value of 0 corresponds to grid point values with simple packing. Data
Representation Template 5.0 then indicates that octets 12 – 21 are required to describe this typeof data representation, and what the contents of those octets are.

23

2.1.7 Section 6: Bit-Map Section
The purpose of the Bit-Map Section is to indicate the presence or absence of data at each of thegrid points, as applicable, in the next occurrence of the Data Section. The contents of Section 6
are:Octet No.
1-4
5
6
7-nn

Contents
Length of section in octets (nn)Number of Section (“6”)
Bit-map indicator (see code Table 6.0 and Note 1)
Bit-map - Contiguous bits with a bit to data point correspondence, ordered as
defined in Section 3. A bit set equal to 1 implies the presence of a data value
at the corresponding data point, whereas a value of 0 implies the absence ofsuch a value.

Notes:
1.

If octet 6 is not zero, the length of the Section is 6 and octets 7 - nn are not present.

We noted in the discussion of the Data Representation Section the possibility that not every data
point will have a corresponding value in the Data Section. Consider, for example, a precipitation
field. There will be many data points in a precipitation field with a zero value – no precipitation. In
order to conserve space, a bit map can be used to efficiently indicate those data points with a zeroprecipitation value that does not appear in the Data Section. This is accomplished by generating a
bit string with one bit corresponding to each data point. A bit set to one implies the presence of adata value at that data point, while a bit set to zero implies the absence of a data value at that data
point. Those data points for which the bit is set to zero will not have a corresponding value in the
Data Section.
The Bit-map indicator in octet 6 refers to Code Table 6.0:
Code Table 6.0:
Code figure0
1 - 253
254
255

Bit Map Indicator

Meaning
A bit map applies to this product and is specified in this Section
A bit map pre-determined by the originating/generating Centre applies to thisproduct and is not specified in this Section.
A bit map defined previously in the same "GRIB" message applies to this product.
A bit map does not apply to this product.

The Code Table indicates a value of zero in octet 6 means a Bit-map is specified in octets 7 - nn.
However, other choices are available as well. A bit-map that applies to this product may be predetermined by the originating/generating centre (octet 6 = 1 - 253), a bit-map previously definedin the same GRIB2 message may apply (octet 6 = 254: recall that GRIB2 permits encoding
multiple data sets in a single message), or a bit-map may not apply at all (octet 6 = 255). In allthese cases, octets 7 – nn are absent and the length of the Section is 6.
2.1.8

Section 7: Data Section

The Data Section contains the data values themselves. The contents of Section 7 are:Octet No.
1-4
5
6-nn

Contents
Length of section in octets (nn)Number of Section (“7”)
Data in a format described by Data Template 7.X, where X is the Data
Representation Template number given in octets 10-11 of Section 5

24

The various data compression schemes have not been discussed as yet. They are discussed in
Section 2.3 of this Layer, and in more detail in Layer 3. At this point, suffice it to say that there areseveral approaches to data compression used in GRIB2, including simple packing, complex
packing, spatial differencing, JPEG2000 and PNG. If only simple packing is used, the data values
in octets 6 - nn are in the form of a binary string, filled with bits set to zero to ensure the Section
ends on an octet boundary. However, if Complex packing and/or spatial differencing is used, thestorage of the data values in the Data Section is more complicated, and is described by theappropriate Data Template, as indicated in the Contents above. Note the implied link between
Data Representation Template 5.X and Data Template 7.X, where X in both cases is the Data
Representation Template Number given in octets 10 - 11 of the Data Representation Section.
Data storage in these cases is discussed more fully with the discussion of the compression
schemes.
Recall that GRIB2 permits multiple data sets to be encoded in a single GRIB2 message. This was
described briefly in Layer 1, where it was noted that multiple data sets implies multiple
occurrences of the Grid Description, Product Definition, Data Representation, and Bit-Map
Sections. However, it was also noted that this did not require each of these four sections be
repeated for each occurrence of the Data Section. Rather, the contents of the most recent
occurrences of the Grid Description, Product Definition, Data Representation, and Bit-Map
Sections prior to any individual occurrence of the Data Section are those that describe thecontents of that occurrence of that Data Section.

2.1.9

Section 8: End Section

The End Section serves to identify the end of the GRIB2 message in a human readable form. The
contents of Section 7 are:Octet No.
1-4

Contents“7777” (coded according to the International Alphabet No. 5)

The End Section is always 4 octets long. The Indicator (16 octets long) and End Sections are theonly fixed-length sections in a GRIB2 message.

2.2

GRIB2 Templates

The use of the GRIB1 concept of templates to describe the GRIB2 grid definition, productdefinition, and data representation aspects of a data set are one of the most importantenhancements of GRIB2 over GRIB1. The developers of GRIB2 anticipated that the added
flexibility arising from this more extensive use of the template concept would allow GRIB2 to adapt
to new and as yet unforeseen requirements for data representation. This Section of the Guide
describes the templates and their use.

2.2.1

Grid Definition Templates

Recall that the purpose of the Grid Definition Section is to define the grid surface and geometry ofthe data values within the surface for the data contained in the next occurrence of the Data
Section. Most of the information necessary to accomplish this is within the Grid Definition
Template. As noted in Section 2.1.4 above, the contents of Section 3 are:25

Octet No.
1-4
5
6
7-10
11
12
13-14
15-xx
[xx+1]-nn

Contents
Length of section in octets (nn)Number of Section (“3”)
Source of grid definition (see Code Table 3.0 and Note 1)
Number of data points
Number of octets for optional list of numbers defining number of points (seeNote 2)
Interpretation of list of numbers defining number of points (see Code Table
3.11)
Grid Definition Template Number (=N) (see Code Table 3.1)
Grid Definition Template (see Template 3.N, where N is the Grid Definition
Template Number given in octets 13-14)
Optional list of numbers defining number of points (see Notes 2, 3, and 4)

Let us assume the values in octets 6, 11, and 12 are all zero, thus eliminating the special cases
described in Section 2.1.4, and the value in octets 13 - 14 is 20. Code Table 3.1 reveals that 20
corresponds to a Polar Stereographic grid projection. It is described by Grid Definition template
3.20. We now insert Grid Definition Template 3.20 into octets 15-xx. The contents of the Grid
Definition Section then become:Octet No.
1-4
5
6
7-10
11
12
13-14
15
16
17-20
21
22-25
26
27-30
31-34
35-38
39-42
43-46
47
48-51
52-55
56-59
60-63
64
65

Contents
Length of section in octets (nn)Number of Section (“3”)
Source of grid definition (see Code Table 3.0 and Note 1)
Number of data points
Number of octets for optional list of numbers defining number of points (seeNote 2)
Interpretation of list of numbers defining number of points (see Code Table
3.11)
Grid Definition Template Number (=N) (see Code Table 3.1)
Shape of the earth (see Code Table 3.2)
Scale factor of radius of spherical earth
Scaled value of radius of spherical earth
Scale factor of major axis of oblate spheroid earth
Scaled value of major axis of oblate spheroid earth
Scale factor of minor axis of oblate spheroid earth
Scaled value of minor axis of oblate spheroid earth
Nx – number of points along X-axis
Ny – number of points along Y-axis
La1 – latitude of first grid point
Lo1 – longitude of first grid point
Resolution and component flag (see flag table 3.3 and Note 1)
LaD – Latitude where Dx and Dy are specified
LoV – orientation of the grid (see note 2)
Dx – X direction grid length (see Note 3)
Dy – Y direction grid length (see Note 3)
Projection centre flag (see Flag Table 3.5)
Scanning mode (see Flag Table 3.4)

The four notes referred to in Grid Definition Template 3.20 are:
1.
2.

3.

The resolution flag (bit 3-4 of Flag Table 3.3) is not applicable.
LoV is the longitude value of the meridian that is parallel to the Y-axis (or columnsof the grid) along which latitude increases as the Y-coordinate increases (theorientation longitude may or may not appear on a particular grid).
Grid length is in units of 10-3 m at the latitude specified by LaD.
26

4.
5.

Bit 2 of the projection flag is not applicable to the polar stereographic projection.
A scaled value of radius of spherical Earth, or major or minor axis of oblate spheroid Earthis derived from applying appropriate scale factor to the value expressed in metres.

Octets 15 – 30 establish the shape and size of the earth. GRIB1 only allowed two possibilities - a
spherical earth with radius 6367.47 km or an oblate spheroid earth with the major axis 6378.160
km, minor axis 6356.775 km and f = 1/297.0. This proved to cause problems, for data producers
were using other than these sets of values, and GRIB1 had no procedures for specifying them.
Octet 15 permits a wider variety of choices via Code Table 3.2:

Code Table 3.2:
Code figure
0
1
2
3
4
5
6
7
8
9-191
192-254255

Shape of the EarthMeaning
Earth assumed spherical with radius = 6,367,470.0 m
Earth assumed spherical with radius specified (in m) by data producer
Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6,378,160.0 m,
minor axis = 6,356,775.0 m, f = 1/297.0)
Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer
Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6,378,137.0 m, minor
axis = 6,356,752.314 m, f = 1/298.257222101)
Earth assumed represented by WGS84 (as used by ICAO since 1998)
Earth assumed spherical with radius of 6,371,229.0 m
Earth assumed oblate spheroid with major and minor axes specified (in m) by data producer
Earth model assumed spherical with radius 6371200 m, but the horizontal datum of the resulting
latitude/longitude field is the WGS84 reference frame
Reserved
Reserved for local use
Missing

Note:
WGS84 is a geodetic system that uses IAG-GRS80 as basis.

Note that GRIB2 still permits the two GRIB1 choices: the former by setting octet 15 to 0 and thelatter by setting octet 15 to 2. When either of these two choices is selected, octets 16 – 30 are set
to missing (all bits on). GRIB2 also allows a spherical (octet 15 = 6) and an oblate spheroid (octet
15 = 4) earth with another set of pre-set values. However, far more flexibility is achieved byallowing the data producer to encode into octets 16 – 30 the values for either a spherical earth(octet 15 = 1, octets 16-20 define the radius, and octets 21-30 are set to missing)) or an oblate
spheroid earth (octet 15 = 3, octets 16-20 are set to missing, and octets 21-30 define the major
and minor axes). Many Grid Definition Templates have the same parameters in octets 15 – 30.
After the shape and size of the earth has been established, octets 31 – 65 describe the grid itself.
Several things need to be noted here. First, octet 47 refers to Flag Table 3.3:

Flag Table 3.3:
Bit
Number
1-2
3
4
5

Resolution and Component Flags

Value Meaning
Reserved
0
i direction increments not given
1
i direction increments given0
j direction increments not given
1
j direction increments given0
Resolved u- and v- components of vector quantities relative to easterly andnortherly directions27

1

Resolved u- and v- components of vector quantities relative to the defined
grid in the direction of increasing x and y (or i and j) coordinates respectively
Reserved - set to zero

6-8

A flag table is a string of bits, where each bit can be turned on (i.e., set to 1) or off (i.e., set to 0).
Thus any combination of the possible choices can be selected. This means that the contents ofoctet 47 should not be interpreted as a value, for that is meaningless in this case. Rather, theindividual bits must be inspected.
Second, Code Table 3.4 indicates the order of the “scanning” of the grid points. I.e., which is thefirst grid encoded, the second, the third, and etc.
Flag Table 3.4:
Bit
Number1
2
3
4

Scanning Mode

Value
0
1
0
1
0
1
0
1

Meaning
Points of first row or column scan in the +i (+x) direction
Points of first row or column scan in the -i (-x) direction
Points of first row or column scan in the -j (-y) direction
Points of first row or column scan in the +j (+y) direction
Adjacent points in i (x) direction are consecutive
Adjacent points in j (y) direction is consecutive
All rows scan in the same direction
Adjacent rows scan in opposite directions
Reserved

5-8

Notes:(1)i direction: west to east along a parallel or left to right along an X-axis(2)
j direction: south to north along a meridian, or bottom to top along a Y-axis(3)
If bit number 4 is set, the first row scan is as defined by previous flags
GRIB2 permits selection of scanning patterns not allowed in GRIB1. In particular, when bit 4 is set
to 1, adjacent rows scan in opposite directions. This scanning mode is useful when the complex
packing and spatial differencing compression scheme is used. This will be discussed in moredetail in Section 2.3.3 of Layer 2.
Third, Flag Table 3.5 is used to indicate whether the polar stereographic projection is a northernhemisphere or southern hemisphere one.
Flag Table 3.5:
Bit
Number
1
2

Projection Centre

Value
0
1
0
1

Meaning
North Pole is on the projection plane
South Pole is on the projection plane
Only one projection centre is used
Projection is bi-polar and symmetric

Fourth, note that all latitudes, longitudes, and angles are given in units of 10-6 degrees, except for
specific cases explicitly stated in some grid definitions.

2.2.2

Product Definition Templates

The purpose of the Product Definition Section is to describe the nature of the data contained in thenext occurrence of the Data Section. Most of the information necessary to accomplish this is28

within the Product Definition Template. As noted in Section 2.1.5 above, the contents of Section 4
are:Octet No.
1-4
5
6-7
8-9
10-xx
[xx+1]-nn

Contents
Length of section in octets (nn)Number of Section (“4”)
Number of coordinate values after Template (see Note 1)
Product Definition Template Number (see Code Table 4.0)
Product Definition Template (see Template 4.X, where X is the ProductDefinition Template Number given in octets 8-9)
Optional list of coordinate values (see Notes 2 and 3)

We will assume that octets 6 – 7 contain the value zero (meaning hybrid vertical coordinates are
not used and octets [xx+1] – nn are therefore absent), and the value in octets 8 - 9 is 0, indicating
Product Definition Template 4.0 is to be used. Code Table 4.0 indicates this corresponds to an
analysis or forecast at a horizontal level or in a horizontal layer at a point in time. ProductDefinition Template 4.0 utilises octets 10 - 34 to specify precisely what the product in the next
occurrence of the Data Section is. We now insert Product Definition Template 4.0 into octets 10 xx. The contents of the Product Definition Section then become:Octet No.
1-4
5
6-7
8-9
10
11
12
13
14
15-16
17
18
19-22
23
24
25-28
29
30
31-34

Contents
Length of section in octets (nn)Number of Section (“4”)
Number of coordinate values after Template (see Note 1)
Product Definition Template Number (see Code Table 4.0)
Parameter Category (see Code Table 4.1)
Parameter number (see Code Table 4.2)
Type of generating process (see code Table 4.3)
Background generating process identifier (defined by originating centre)
Analysis or forecast generating process identifier (defined by originating
centre)Hours of observational data cut-off after reference time (see Note 1)
Minutes of observational data cut-off after reference time
Indicator of unit of time range (see Code Table 4.4)
Forecast time in units defined by octet 18
Type of first fixed surface (see Code Table 4.5)
Scale factor of first fixed surface
Scaled value of first fixed surface
Type of second fixed surface (see Code Table 4.5)
Scale factor of second fixed surface
Scaled value of second fixed surface

There is one note to this product definition template:

Product Definition Template Note:
1.

Hours greater than 65534 will be coded as 65534.

Octets 10 and 11 complete identification of the parameter. Recall that the identification ofparameters in GRIB 2 uses a branching structure based on three parameters – Discipline,
Category, and Name. Octet 7 of the Indicator Section contains the first of these three branches –Discipline via Code Table 0.0. As an example, Discipline = 0 would indicate this GRIB2 message
contains Meteorological Products. Octets 10 and 11 contain the other two branches, Category
and Name, respectively. Octet 10 refers to Code Table 4.1 – Category of Parameters by ProductDiscipline:29

Code Table 4.1:

Category of parameters by product discipline

Product Discipline 0: Meteorological products
Category
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20-189190
191
192-254
255

Description
Temperature
Moisture
Momentum
Mass
Short-wave Radiation
Long-wave Radiation
Cloud
Thermodynamic Stability indices
Kinematic Stability indicesTemperature Probabilities
Moisture Probabilities
Momentum Probabilities
Mass Probabilities
Aerosols
Trace gases (e.g., ozone, CO2)Radar
Forecast Radar Imagery
Electro-dynamics
Nuclear/radiology
Physical atmospheric properties
Reserved
CCITT IA5 string
MiscellaneousReserved for local use
MissingThus, if octet 10 contains a value of 3, Code Table 4.1 indicates that for Product Discipline 0(Meteorological Products), Category 3 is Mass. Also note that Code Table 4.1 is broken down into
sections. Although only the section applicable for Product Discipline 0 – Meteorological Products– is shown above, the full Code Table 4.1 contains sections for Product Disciplines 1 (Hydrological
Products), 2 (Land Surface Products), 3 (Space Products), and 10 (Oceanographic Products) as
well. As more Product Disciplines are added to Code Table 0.0, appropriate sections will be
added to Code Table 4.1.
Octet 11 refers to Code Table 4.2 – Parameter Number by Product Discipline and Parameter
Category:30

Code Table 4.2

Parameter number by product discipline and parameter category

Product Discipline 0: Meteorological products,
Parameter Category 3: Mass
Parameter
Units
Number0
PressurePa
1
Pressure reduced to MSL
Pa
2Pressure tendency
Pa s-1
3
ICAO Standard Atmosphere Reference Heightm
4
Geopotential
m2 s-25
Geopotential height
gpm
6
Geometric heightm7Standard deviation of heightm
8
Pressure anomaly
Pa
9
Geopotential height anomaly
gpm
10
Density
kg m-3
11
Altimeter settingPa
12
Thicknessm
13
Pressure altitudem
14
Density altitudem
15-191
Reserved
192-254
Reserved for local use
255
MissingIf octet 11 contains a value of 5, then Code Table 4.2 indicates that for this product discipline andcategory, the parameter name is geopotential height and the units are geopotential meters. Code
Table 4.2 is also broken into sections, one section for each combination of Product Discipline andParameter Category currently defined. Each such section contains all the parameters currently
defined for that particular combination of Product Discipline and Parameter Category. As one canimagine, Code Table 4.2 is already extensive and promises to grow much more over time.
Nevertheless the developers of GRIB2 felt that a hierarchical system such as this will prove far
easier for the user to use and the WMO to manage than a single code table eventually containing
perhaps thousands of entries.
Note also the units given in the right hand column of Code Table 4.2. GRIB1 and GRIB2 both use
SI Standard Units. For the convenience of the user, these units are listed in this column for eachparameter in the table.
Octets 12 – 14 describe the type of process that generated the data field of geopotential heightvalues. Code Table 4.3, referred to by octet 12, is fairly general:
Code table 4.3:
Type of generating process
Code figure Meaning
0
Analysis
1
Initialization2
Forecast
3
Bias corrected forecast
4
Ensemble forecast
5
Probability forecast
6
Forecast error
7
Analysis error
8
Observation
9-191
Reserved
192-254
Reserved for local use
255
Missing31

For example, a value of 2 in octet 12 would indicate only that a forecast generated this particulargeopotential height field. However, this general description can be refined by information in octets
13 and 14 if the generating centre chooses to do so. For example, octet 14 could state what kindof forecast model generated the geopotential height forecast. Note that to understand themeaning of values in octets 13 and 14, a user of a GRIB message must to contact theoriginating/generating centre.
Octets 15 – 17 describe the data cut-off for the analysis or forecast used to generate this particular
forecast field. This information was added to GRIB2 because it was found to be useful informationthat GRIB1 was not capable of describing. The Production Definition Template Note 1 indicatesthe largest value possible in octets 15 – 16 is 65534. Thus, the largest data cut-off value possible
is 65534 hours (or 2730 days, or almost 7.5 years) after analysis time, surely adequate for almost
all applications.
Octets 18 – 22 describe the time of the forecast field in a rather general way via Code Table 4.4:
Code Table 4.4:
Code figure
0
1
2
3
4
5
6
7
8-9
10
11
12
13
14-191
192-254
255

Indicator of unit of time range

Meaning
Minute
Hour
Day
Month
Year
Decade (10 years)
Normal (30 years)
Century (100 years)
Reserved
3 hours
6 hours
12 hours
SecondReserved
Reserved for local use
Missing

A forecast time of almost any length can be defined by combining the wide variety of time units
with the 2 octets allowed for the value itself. For example, a forecast time of 65534 centuries, or
6,553,400 years can currently be described.
Octets 23 – 34 describe the level or layer applicable for this particular forecast field. Code Table
4.5 defines the type of fixed surface used:32

Code table 4.5:
Code
Figure
0
1
2
3
4
5
6
7
8
9
10-19
20
21-99
100
101
102
103
104
105
106
107
108
109
110
111
112-116
117
118-159160
161-191
192-254
255

Fixed surface types and units

Meaning
Units
Reserved
Ground or water surface
Cloud base level
Level of cloud tops
Level of 0o C isotherm
Level of adiabatic condensation lifted from the surface
Maximum wind level
Tropopause
Nominal top of the atmosphereSea bottom
Reserved
Isothermal level
K
Reserved
Isobaric surface
Pa
Mean sea level
Specific altitude above mean sea levelmSpecified height level above groundm
Sigma level“sigma” value
Hybrid level
Depth below land surfacemIsentropic (theta) level
K
Level at specified pressure difference from ground to level Pa
Potential vorticity surface
K m2 kg-1 s-1
Reserved
Eta* level
Reserved
Mixed layer depthm
Reserved
Depth below sea levelm
Reserved
Reserved for local use
Missing

Code Table 4.5 is used to define both a level and a layer. To define a level, octets 23-28 havevalues and octets 29-34 are set to missing. To define a layer, octets 23-34 are all used.

2.2.3

Data Representation Templates

The purpose of the Data Representation Section is to describe how the data values contained in
the next occurrence of the Data Section are represented. As with the Grid Definition and ProductDefinition sections, most of the information necessary to accomplish this is contained in the Data
Representation Definition Template. As noted in Section 2.1.6 above, the contents of Section 5
are:

33

Contents
Length of section in octets (nn)Number of Section (“5”)
Number of data points where one or more values are specified in Section 7
when a bit map is present, total number of data points when a bit map isabsentData Representation Template Number (see code Table 5.0)
Data Representation Template (see Template 5.X, where X is the Data
Representation Template Number given in octets 10-11)

Octet No.
1-4
5
6-9

10-11
12-nn

We will assume the value in octets 10 - 11 is 0, indicating Data Representation Template 5.0 is to
be used. Code Table 5.0 indicates this corresponds to grid point data - simple packing. Data
Representation Template 5.0 uses octets 12 – 21 to describe this type of data representation, andwhat the contents of those octets are. We now insert Data Representation Template 4.0 into
octets 12 - xx. The contents of the Data Representation Section then become:Octet No.
1-4
5
6-9

Contents
Length of section in octets (nn)Number of Section (“5”)
Number of data points where one or more values are specified in Section 7
when a bit map is present, total number of data points when a bit map isabsentData Representation Template Number (see code Table 5.0)
Reference value (R) (IEEE 32-bit floating-point value)
Binary Scale Factor (E)Decimal Scale Factor (D)Number of bits used for each packed value for simple packing, or for eachgroup reference value for complex packing or spatial differencing
Type of original field values (see Code Table 5.1)

10-11
12-15
16-17
18-19
20
21

The use of R, E, and D in grid point data - simple packing and the IEEE representation of R, as
well as the organization of the Data Representation Section for other compression schemes
allowed in GRIB2, are discussed in Section 2.3 of this Layer. The type of original field values isgiven by octet 21 and defined by Code Table 5.1:
Code Table 5.1:
Code figure
0
1
2-191
192-254255

Type of original field values

Meaning
Floating point
Integer
Reserved
Reserved for local use
MissingThus, it is currently possible to define only floating point or integer original field values. There is,however, ample space for other options to be added in the future.

2.2.4

Data Templates

The Data Section contains the data values themselves. As noted in Section 2.1.8 above, thecontents of Section 7 are:Octet No.
1-4

Contents
Length of section in octets (nn)
34

5
6-nn

Number of Section (“7”)
Data in a format described by Data Template 7.X, where X is the Data
Representation Template Number given in octets 10-11 of Section 5

Note the X part of the Data Template Number used in Section 7 is the same as the X part of theData Representation Template Number given in Section 5. This is because the organization of thedata values in the Data Section depends on the Data Representation Template used in Section 5.
In the example given in Section 2.2.3, Data Representation Template 5.0 was used. To continue
this example, Data Template 7.0 must therefore be used in Section 7, and both refer to Grid point
data – simple packing. Inserting Data Template 7.0 into octets 6-nn, the contents of the Data
Section become:Octet No.
1-4
5
6-nn

Contents
Length of section in octets (nn)Number of Section (“7”)
Binary data values – binary string, with each (scaled) value data value.

Data Template 7.0 is particularly simple. However, if Data Representation Template 5.2 had beenused in the Data Representation Section, the more complicated Data Template 7.2 would have
had to be used in the Data Section, and both would have referred to Grid point data – complex
packing. Examples of the organization of the data section for some of the data compression
schemes allowed in GRIB2 are discussed in Section 2.3 of this Layer.

2.3

GRIB2 Compression Schemes

As with GRIB1, GRIB2 represents numeric data as a series of binary digits, or bits. Such data
representation is independent of any particular machine representation; by convention, data
lengths are measured in octets, where an octet is a string of 8 bits. Data are coded as binary
integers using the minimum number of bits required for the desired precision. Numeric values, in
SI Standard Units as shown in the right hand column of Code Table 4.2, may first be scaled by apower of ten to achieve an appropriate decimal precision. A reference value may be thensubtracted from them to reduce redundancy and eliminate negative numbers. They may be thenbe further scaled by a power of two to pack them into a pre-selected word length. The two scaling
operations are independent; which, or both, are used in any given case depends upon choices
made as to the method of packing. This is described in some detail later in this section.
An original data value Y (in SI Standard Units as shown in Code Table 4.2) can be recovered withthe formula:Y * 10D = R + (X1 + X2) * 2E ,For simple packing
D
E
R
X1
X2

=
=
=
=
=

Decimal scale factor
Binary scale factor
Reference value of the whole field0
Scaled (encoded) value

For complex grid point packing schemes, D, E, and R are as above, but
X1 =
X2 =

Reference value (scaled integer) of the group the data value belongs to,
Scaled (encoded) value with the group reference value (X1) removed.

35

The reference value R is placed in the data section as an IEEE 32-bit floating-point value, andhence occupies 4 octets. The IEEE representation of the reference value R used in GRIB2 is a
departure from GRIB1, which used the standard IBM representation for a 32-bit real floating-point
number. 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 isseeeeeee emmmmmmm mmmmmmmm mmmmmmmm
wheres 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 following table gives the value of R:
e…e

m…m

Value of R0Any(-1)s(m…m)2-232-126 = (-1)s(m…m)2-149

1…254

Any

(-1)s(1.0 + (m…m)2-23)2((e…e)-127)

255

0

positive (s = 0) or negative (s = 1) infinity

255

>0

NaN (Not A valid Number, result of illegal operations)

Normally, only biased exponent values from 1 to 254 inclusive are used, except for positive or
negative zero that 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 firstoctet. 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 bycomputing the floating-point value directly using the above formulae.
The uses of D, E, R, X1, and X2 in the various compression schemes allowed in GRIB2 are
discussed in the remainder of this section.

2.3.1

Grid Point Data - Simple Packing

As we found in Section 2.2.3, when the Grid Point Data - Simple Packing compression scheme isused, the Data Representation Section becomes:

36

Contents
Length of section in octets (nn)Number of Section (“5”)
Number of data points where one or more values are specified in Section 7
when a bit map is present, total number of data points when a bit map isabsentData Representation Template Number (see code Table 5.0)
Reference value (R) (IEEE 32-bit floating-point value)
Binary Scale Factor (E)Decimal Scale Factor (D)Number of bits used for each packed value for simple packing, or for eachgroup reference value for complex packing or spatial differencing
Type of original field values (see Code Table 5.1)

Octet No.
1-4
5
6-9

10-11
12-15
16-17
18-19
20
21

The contents of the Data Section are correspondingly:
Octet No.
1-4
5
6-nn

Contents
Length of section in octets (nn)Number of Section (“7”)
Binary data values - binary string, with each (scaled) data value (X2).

Step 1: The first step, if necessary, is to convert the original field into the SI Standard Units givenin the right hand column of Code Table 4.2. Some of these units may seem a little peculiar (forexample, kg m-2 is equivalent to a water depth of 1 mm) and others may seem inappropriate (Pafor pressure, for example, implies substantially greater precision than is typical in meteorologicalusage, but inverse seconds are not nearly precise enough for divergence and vorticity), but they
are all self-consistent. Furthermore, the precision of the parameters, as actually packed in a
GRIB2 message, can be set to any desired degree through the appropriate use of the power-often (“D”) scaling and the power-of-two (“E”) scaling to be described momentarily. Code Table 5.1
defines the type of original field values (Y):Code Table 5.1:
Code figure
0
1
2-191
192-254255

Type of original field values

Meaning
Floating point
Integer
Reserved
Reserved for local use
Missing

The appropriate entry from Code Table 5.1 is stored in octet 21 of the Data Representation
Section
Step 2: At this point there is a choice to be made. If it is desired to use a pre-selected number ofbits (the “word” bit-length) for each of the packed variables, then just proceed on to the next step.
However, if a variable number of bits are used, where the “word” bit-length is calculated toaccommodate the data values, then it is necessary to undertake the power of ten, or “D”, scaling.
In this case, the D value should be selected such that when the original data, in the Standard SI
Units of Code Table 4.2, is multiplied by 10D, the integer part of the result will have enoughprecision to contain all the appropriate information of the variable. Anticipating things a little bit,the (scaled) value will be rounded to an integer as a part of the packing process; thus the“significant part” of the value of the variable has to be moved to the left of the decimal point prior to
the rounding. For example, temperature might be scaled with D = 1, thus changing the units fromdegrees Kelvin to tenths of degrees Kelvin. Pressure, on the other hand, might be scaled with D =-2, actually reducing the precision from Pascals to hundreds of Pascals, or HectoPascals, a more37

reasonable precision for meteorological use. Vorticity would be scaled up by using D = 8, and etc.
The value of D selected is stored in octets 18-19 of the Data Representation Section.
Step 3: The third step in the packing operation is to scan through the field, which may or may nothave been D scaled at this point, to find the minimum value of the parameter, create largest IEEE
32 bit representation value which is smaller or equal than minimum value and subtract thatminimum – the reference value R – from all the data points, leaving a residual of non-negative
numbers. To overcome some precision limitations of the reference value, decimal scaling should
be applied if the range of the values is not significantly greater than the epsilon of the reference
value (minimum difference between two values in the precision of the reference value). This step
has two benefits. The first of these is convenience – making all the data points non-negative
bypasses problems with different computer hardware that represent negatives in various ways.
The GRIB message is rendered just that more machine independent by being non-negative
throughout. The second benefit is more consequential: It can result in a substantial compressionof the bulletin size without any loss of information content. If a field has an appreciable bias awayfrom zero, the residuals formed by the minimum removal operation will all be much smaller
numbers than otherwise. Thus they will need fewer bits to contain them when they are,eventually, packed as integers. The value of R is stored in octets 12-15 of the Data
Representation Section.
Step 4: The fourth step begins with a simple scan through the field of non-negative residuals tofind the maximum value.
At this point another choice must be made, similar to the one made previously. This time, if a
calculated “word” bit-length is to be used, it is necessary to calculate how many bits are going to
be needed to contain the largest data value when the latter has been rounded to an integer.
Recall that at the previous decision point, the variables were D scaled such that a rounding
operation will preserve all the significant part of the information. Discovering how many bits areneeded is a simple scan through a table of powers of two. This number of bits - the calculated“word” bit-length - is stored in octet 20 of the Data Representation Section. Since the power of two
scaling is not employed in this case, E is set equal to 0 and stored in octets 16-17 of the Data
Representation Section.
If, alternatively, it is desired to use a pre-selected “word” bit-length, the data must now be scaled
by a power of two (the “E” scaling) sufficient to either reduce the maximum value down to just fit
into the available number of bits or enlarge the value to just fit. The latter possibility takes care of
the problem of small numbers where the precision is all in the fractional part of the number. How
much precision is retained for the eventual rounding is a function of the pre-selected “word” bitlength and the typical range, or maximum value with the minimum removed, of the particularvariable. The choice of the pre-selected “word” bit-length (which is, of course, made ahead oftime) must be made with full knowledge of the characteristics of the particular variable that is to bepacked and a prior assumption of how much precision needs to be retained for the largest likely
value. The pre-selected “word” bit-length is stored in octet 20 of the Data Representation Section,and the value of E is stored in octets 16-17 of the Data Representation Section.
Step 5: The fifth steps is to round all the values to integers, now that they have all been scaled toappropriate units, and pack each of them into the specified “word” bit-length. In the terminology
introduced at the beginning of this section, these are the X2 values (when using simple packing,the X1 values are always zero and hence are not stored in this case), and are stored in octets 6nn of the Data Section. If when this is completed the binary string does not end on an octet
boundary, sufficient bits set to zero must be appended to the end of the binary string so that it
does end on an octet boundary.
Advantages And Disadvantages of the Two Methods: We have described two alternate
approaches to constructing GRIB messages: a pre-selected “word” bit-length and a calculated38

“word” bit-length method. The choice of which to use depends of the relative advantages anddisadvantages of each method with regards to message length and precision.
Message length: the pre-selected “word” bit-length messages are always the same length for agiven parameter, while the calculated “word” bit-length messages are variable. The variation isdriven by the range of the value of the parameter over the field (or the maximum value), which canchange from day to day. Whether variations in message length is a problem or not depends ofthe computer systems used to work with the GRIB messages.
Precision: The calculated “word” bit-length bulletins have affixed and unchanging precision,
determined by the D scaling. This assures that the same information content is available day afterday. It is straightforward to change the precision in a familiar manner, that is, simply by orders ofmagnitude, just by altering the D value. This comes at a cost, of course, for increasing the
precision by a power of 10 adds about 3.3 bits (on average) to each data point in the message.
The pre-selected “word” bit-length messages show a variable precision which is case by case data
driven and is determined by the E scaling that was used to fit the values into the available space.
This can happen even with the same data, on the same date, but at adjacent grid areas. If one
area shows a low variability and the neighbouring one a high variability such that a power-or-two
scaling is needed in the two areas, then, unfortunately, the values on a common boundary will not
be exactly equal after they are unpacked. This can be disconcerting and a cause for confusion.
Note that this will not happen if only D scaling is employed. On the other hand, the variable
precision can be viewed as a strength: a data field with a low variability will be encoded at ahigher precision, thus preserving the character of the field; a high variability field will be
represented with less precision, but that is not a problem as the small, and possibly lost, variations
will not matter in the presence of the large ones. The precision of the encoded field can beincreased by adding bits to the fixed “word” bit length, but the degree of change (a power of two
for each bit) may not be as easy to deal with (or explain to people) as the simple order ofmagnitude change afforded by the D scaling method.
No matter which compression method was employed, a proper GRIB2 decoding program, one thattakes account of the transmitted values of both D and E, would return the correct unpacked
numbers, regardless of which packing method was employed. It would be transparent to the user
except for the questions of precision outlined above.

2.3.2

Grid Point Data - Complex Packing

When the Grid Point Data - Complex Packing compression scheme is used, the relevant Data
Representation Template is 5.2. It is the same as Data Representation Template 5.0 (Grid Point
Data – Simple Packing) for octets 12 – 21, but contains additional information in octets 22 – 47.
Upon insertion of Template 5.2, the Data Representation Section becomes:
Octet No.
1-4
5
6-9

10-11
12-15
16-17
18-19
20
21

Contents
Length of section in octets (nn)Number of Section (“5”)
Number of data points where one or more values are specified in Section 7
when a bit map is present, total number of data points when a bit map isabsentData Representation Template Number (see code Table 5.0)
Reference value (R) (IEEE 32-bit floating-point value)
Binary Scale Factor (E)Decimal Scale Factor (D)Number of bits used for each packed value for simple packing, or for eachgroup reference value for complex packing or spatial differencing
Type of original field values (see Code Table 5.1)
39

22
23
24-27
28-31
32-35
36
37
38-41
42
43-46
47

Group splitting method used (see Code Table 5.4)
Missing value management used (see Code Table 5.5)
Primary missing value substituteSecondary missing value substituteNG - Number of groups of data values into which field is split
Reference for group widths (see Note 12)
Number of bits used for the group widths (after the reference value in octet 36
has been removed)
Reference for group lengths (see Note 13)
Length increment for the group lengths (see Note 14)
True length of last group
Number of bits used for the scaled group lengths (after subtraction of thereference value given in octets 38-41 and division by the length increment
given in octet 42)

The corresponding Data Template is 7.2.
becomes:
Octet No.
1-4
5
6-xx

[xx+1]-yy[yy+1]-zz[zz+1]-nn

Upon insertion of Template 7.2, the Data Section

Contents
Length of section in octets (nn)Number of Section (“7”)
NG group reference values (XI in the decoding formula), each of which is
encoded using the number of bits specified in octet 20 of Data Representation
Template 5.0. Bits set to zero shall be appended as necessary to ensure thissequence of numbers ends on an octet boundary.
NG group widths, each of which is encoded using the number of bits specified
in octet 37 of Data Representation Template 5.2. Bits set to zero shall beappended as necessary to ensure this sequence of numbers ends on an octet
boundary.
NG scaled group lengths, each of which is encoded using the number of bits
specified in octet 47 of Data Representation Template 5.2. Bits set to zero
shall be appended as necessary to ensure this sequence of numbers ends onan octet boundary. (see Note 14 of Data Representation Template 5.2)
Packed values (X2 in the decoding formula), where each value is a deviationfrom its respective group reference value.

Before laying out where the various second order values, sub-parameters, counters, and what
have you, go, it is appropriate to describe the complex packing scheme for grid point values in analgorithmic manner.
In comparison with the description of the simple packing scheme for grid point values in theprevious section, the encoding method for complex packing is the same up to part way through thefifth step, after the scaled values have been rounded to scaled integers but before the scaled
integers are actually packed into either pre-selected bit-length “words” or calculated bit-length“words”. The basic outline of complex packing is to scan through the array of scaled integers (oneper grid point, or, possibly less than that if the Bit Map Section has been employed to discardsome of the null value points) and seek out sub-sections exhibiting relatively low variability. One
then finds the (local) minimum value in that sub-section and subtracts it from the (“first order”)
integers in that sub-section, which leave a set of “second-order” integers. These numbers arethan scanned to find the maximum value, which in turn is used to calculate the minimum numberof bits necessary for a “word” to contain the sub-section set of second order numbers.
The term “first order” in this context refers to the integer variables that result from subtracting theoverall (*global) minimum from the original variables (in Step 3) and then doing all scaling androunding; “second order” refers to the variables that result from subtracting the local minimum fromthe sub-set of first order variables. No further scaling is necessary or appropriate.
40

The sub-section set of numbers is then packed into “words” of the just determined bit-length. The
overall savings in space comes about because the second order values are, usually, smaller thantheir firs order counterparts. The have, after all, had two minima subtracted from the originalvalues, the overall minimum and the local minimum, where the first order values have had only theoverall minimum subtracted out. There is no guarantee, however, that the second order packing
will compress a given field to a greater degree than the first order packing. If the first order field of
integers is highly variable, or generally close to zero, then there will be no gain in compression.
But if the field shows long runs of small variation, particularly if some of the runs are constant (zerovariability), then the second order packing will contribute to the compression.
The process then repeats and a whole collection of sub-sections is found, their local minima are
subtracted out, etc. One of the tricky parts of this process is defining just what is meant by a “subsection of low variability”. The WMO Manual is silent on this as it only describes how the subsections and their ancillary data are to be packed in the message. A number of Meteorological
Services have designed selection criteria and built them into their GRIB encoder. It is beyond thescope of this document to attempt to describe the selection criteria in any detail. However, severalof these groups have expressed their willingness to share their GRIB encoders with any who ask
for them. This is discussed in Section 2.6 of this Layer.
Before laying out where the second order values are placed in a message, we had best review justwhat information has to be saved. We need to include the following information:
1)
2)
3)
4)
5)
6)
7)
8)
9)

How many sub-sections there are;
The treatment of missing values;
Where does each sub-section begin;
Where does each sub-section end; or, how many data points are in eachsub-section;
What is the local minimum value (a first order value) that was found for eachsub-section;
What is the bit width of the collection of first order values (the local minima)
found for each sub-section;
What are the second order values for each sub-section;
What are the bit widths of the second order values appropriate for all the subsections; and finally,
Sufficient information to specify where the above information is located.

A moment’s consideration (OK, maybe a long moment) will satisfy the reader that the information
given will be sufficient to reconstruct the original data field. Now we consider where theinformation needed for these points is stored in GRIB2 to satisfy Point 9.
Point 1: The number of sub-sections is referred to in the WMO Manual as the number of groups(NG). This value is stored in octets 32-35 of the Data Representation Section. The selection
criteria used to determine the groups is documented by entering a code figure from Code Table
5.4 into octet 22 of the Data Representation Section. Currently, this code table contains only twovery general categories:

41

Code Table 5.4:
Code figure
0
1
2-191
192-254
255

Group Splitting Method

Meaning
Row by row splitting
General group splitting
Reserved
Reserved for local use
Missing

Row by row splitting is where each row of grid points is chosen to be a group. All group splitting
strategies fall into the General group splitting category.
Point 2: In addition to specifying a bit map in the Bit Map Section, missing data can be managed
explicitly in the Data Representation and Data Sections. This alternative permits added flexibility
in the description of missing data by distinguishing between a primary missing value and asecondary missing value via reference to Code Table 5.5:
Code Table 5.5
Code figure
0
1
2
3-191
192-254
255

Missing Value Management for Complex Packing

Meaning
No explicit missing values included within data values
Primary missing values included within data values
Primary and secondary missing values included within data values
Reserved
Reserved for local use
Missing

This concept may be useful, for example, to distinguish a missing value due to a land/sea maskfrom a missing value for some other reason. If this approach is used, the appropriate code figure
from Code Table 5.5 is entered into octet 23 of the Data Representation Section, and the primaryand secondary missing value substitutes into octets 24-27 and 28-31, respectively. One way toimplement the use of a primary and secondary missing value would be to define the global
maximum field value +2 as the primary missing value, the global maximum field value +1 as thesecondary missing value, and make appropriate adjustments.
Points 5 and 6: Once the groups have been determined as noted under Point 1) above, thesmallest value in every group – the group reference value - are determined. The largest of thegroup reference values is then found and the number of bits required to represent it is determined.
This number of bits is stored in octet 20 of the Data Representation Section. The group reference
values themselves - the X1 values in the GRIB2 compression formula - are stored in octets 6 – xxof the Data Section.
Point 7 and 8: For each group, the group reference value calculated to provide the informationneeded to satisfy Points 5) and 6) is subtracted from the Scaled Integers calculated under Step 5of the Simple Packing method. These are the scaled values with the reference value removed the X2 values in the GRIB2 compression formula. They are stored in octets [zz + 1] – nn of theData Section using the appropriate group width calculated under Point 3 below.
Points 3 and 4: Group width is defined as the number of bits used for every second-order value ina group. For each group, this is the number of bits required to represent the largest of the X2values in that group. Group widths are calculated for all the groups in a field of grid point values.
The smallest of these group widths is stored in octet 36 of the Data Representation Section. This
minimum group width is then subtracted from every group width leaving an array of group width
increments. The number of bits required to represent the largest of these group width(increments) is stored in octet 37 of the Data Representation Section. The group width42

(increments) themselves are then stored in octets [xx+1] – yy of the Data Section using thenumber of bits given in octet 37 of the Data Representation Section for each value.
Group length is defined as the number of values in a group. Group lengths (Ln) .can be calculated
from the formula Ln = ref + Kn*len_inc, where n = 1,NG. Thus, Kn = (Ln – ref) / len_inc. The
group lengths themselves (Ln) are calculated for every group in the field of grid point values. The
smallest of these group lengths (ref) is then found and stored in octets 38-41 of the Data
Representation Section, and len_inc is stored in octet 42 of the Data Representation Section. The
Kn values - the scaled group lengths - are stored in octets [yy+1] – zz of the Data Section. Using
the values of ref and len_inc from the Data Representation Section and the scaled group lengths
Kn from the Data Section, the true group lengths (the Ln values) can be calculated from theformula.
Combining the group widths and the group lengths enables a computer program to calculate thebeginning point and ending point of each group.
2.3.3

Grid Point Data - Complex Packing and Spatial Differencing

When the Grid Point Data - Complex Packing and Spatial Differencing compression scheme isused, the relevant Data Representation Template is 5.3. It is the same as Data Representation
Template 5.2 (Grid Point Data – Complex Packing), but contains additional information in octets
48 and 49. Upon insertion of Template 5.3, the Data Representation Section becomes:
Octet No.
1-4
5
6-9

10-11
12-15
16-17
18-19
20
21
22
23
24-27
28-31
32-35
36
37
38-41
42
43-46
47

48
49

Contents
Length of section in octets (nn)Number of Section (“5”)
Number of data points where one or more values are specified in Section 7
when a bit map is present, total number of data points when a bit map isabsentData Representation Template Number (see code Table 5.0)
Reference value (R) (IEEE 32-bit floating-point value)
Binary Scale Factor (E)Decimal Scale Factor (D)Number of bits used for each packed value for simple packing, or for eachgroup reference value for complex packing or spatial differencing
Type of original field values (see Code Table 5.1)
Group splitting method used (see Code Table 5.4)
Missing value management used (see Code Table 5.5)
Primary missing value substituteSecondary missing value substituteNG - Number of groups of data values into which field is split
Reference for group widths (see Note 12)
Number of bits used for the group widths (after the reference value in octet 36
has been removed)
Reference for group lengths (see Note 13)
Length increment for the group lengths (see Note 14)
True length of last group
Number of bits used for the scaled group lengths (after subtraction of thereference value given in octets 38-41 and division by the length increment
given in octet 42)
Order of Spatial Differencing (see Code Table 5.6)
Number of octets required in the Data Section to specify the extra descriptors
needed for spatial differencing (octets 6-ww in Data template 7.3)

43

In this case, the relevant template is Data Template 7.3, which is the same as Data Template 7.2,
except octets 6-xx are replaced with new information. Upon insertion of Template 7.3, the Data
Section becomes:

Octet No.
1-4
5
6-ww

[ww+1]-xx[xx+1]-yy[yy+1]-zz[zz+1]-nn

Contents
Length of section in octets (nn)Number of Section (“7”)
First value(s) of original (undifferenced) scaled data values, followed by theoverall minimum of the differences. The number of values stored is 1 greaterthan the order of differentiation, and the field width is described in octet 49 of
Data Representation Template 5.3
NG group reference values (X1 in the decoding formula), each of which is
encoded using the number of bits specified in octet 20 of Data Representation
Template 5.0. Bits set to zero shall be appended where necessary to ensure
this sequence of numbers ends on an octet boundary.
NG group widths, each of which is encoded using the number of bits specified
in octet 37 of Data Representation Template 5.2. Bits set to zero shall beappended as necessary to ensure this sequence of numbers ends on an octet
boundary.
NG scaled group lengths, each of which is encoded using the number of bits
specified in octet 47 of Data Representation Template 5.2. Bits set to zero
shall be appended as necessary to ensure this sequence of numbers ends onan octet boundary. (see Note 14 of Data Representation Template 5.2)
Packed values (X2 in the decoding formula), where each value is a deviationfrom its respective group reference value.

Spatial differencing is a pre-processing before group splitting at encoding time. It is intended toreduce the size of sufficiently smooth fields, when combined with a splitting scheme as describedin Data Representation Template 5.2. The order of the spatial differencing is documented in octet
48 by reference to Code Table 5.6:
Code Table 5.6:
Code Figure
0
1
2
3-191
192-254
255

Order of Spatial Differencing

Meaning
Reserved
First-order spatial differencing
Second-order spatial differencing
Reserved
Reserved for local use
Missing

For first order spatial differencing, an initial field of values f is replaced by a new field of values g,
where g1 = f1, g2 = f2 – f1, …, gn = fn – fn-1. For second order spatial differencing, the field of values
g is itself replaced by a new field of values h, where h1 = f1, h2 = f2, h3 = g3 – g2, …, hn = gn – gn-1.
Spatial differencing is a useful addition to data compression when the field is smoothly varying.
However, even though a field may be smoothly varying, the scanning mode used can disrupt theefficiency of the spatial differencing scheme. For example, when using row-by-row scanning, one
usually thinks of scanning row 1 from points 1 to n, then row 2 from points 1 to n, and etc.
However, on a typical rectangular grid, point n of row 1 and point 1 of row 2 often have quite
different values because they are physically far apart. The consequence would be a large
difference at the end of each row, and this would decrease the efficiency of the compression
scheme. However, recall now Code Table 3.4 discussed earlier:
Flag Table 3.4:

Scanning Mode
44

Bit
Number
1
2
3
4

Value
0
1
0
1
0
1
0
1

Meaning
Points of first row or column scan in the +i (+x) direction
Points of first row or column scan in the -i (-x) direction
Points of first row or column scan in the -j (-y) direction
Points of first row or column scan in the +j (+y) direction
Adjacent points in i (x) direction are consecutive
Adjacent points in j (y) direction is consecutive
All rows scan in the same direction
Adjacent rows scan in opposite directions
Reserved

5-8

Notes:(1)i direction: west to east along a parallel or left to right along an X-axis(2)
j direction: south to north along a meridian, or bottom to top along a Y-axis(3)
If bit number 4 is set, the first row scan is as defined by previous flags
The scanning mode described above would have bit 1 set to 0, bit 3 set to 0, and bit 4 set to 0.
However, GRIB2 allows alternate rows to scan in opposite directions. This useful alternative,referred to as boustrophedonic scanning, is invoked by setting bit 4 to 1. As a consequence, pointn in row 1 would be followed by point n in row 2, point 1 in row 2 would be followed by point 1 inrow 3, and etc. The boustrophedonic scanning pattern is not permitted in GRIB1.

2.3.4

Spectral Truncation

Using the associated Legendre Polynomials of the First Kind, Pnm, as expansion functions, a field
F(λ,μ),can be represented by
M

N (m)

F (λ , μ ) = ∑ ∑ Fnm Pnm (μ )e imλ ,m=− m n= m

where λ is the longitude, μ is the sine of latitude, and Fn− m is the complex conjugate of Fnm .
In the summations, M is the maximum zonal wave number that is to be included, and K and J
together define the maximum meridional total wave number N(m) (note that N is a function of m).
A sketch shows the relationships:

45

In this figure, the ordinate (n) is the total meridional wave number, the abscissa (m) is the zonal
wave number, the vertical line at m = M is the zonal truncation, and the diagonal passing through(0,0) is the line n = m. The Legendre Polynomials are defined only on or above this line, that is forn greater than or equal to m. On the n axis, the horizontal line at n = K indicates the upper limit ton values, and the diagonal that intersects the n-axis at n = J indicates the upper limit of the area inwhich the Polynomials are defined. The shaded irregular pentagon defined by the n-axis, thediagonal from n = J, the horizontal n = K, the vertical m = M, and the other diagonal n = msurrounds the region of the (n x m) plane containing the Legendre Polynomials used in the
expansion.
This general pentagonal truncation reduces to some more familiar common truncations as special
cases:
Triangular:
Rhomboidal:
Trapezoidal:

K = J = M and N(m) = J
K = J + M and N(m) = J + m
K = J, K > M and N(m) = J

In all of the above, m can take on negative values to represent the imaginary part of the spectral
coefficients.
IN the following two sections, simple and complex packing schemes are described for spectral
data, i.e., for the coefficients of the Legendre Polynomials, the complex numbers Fnm .

2.3.5

Spectral Data – Simple Packing

The relevant Data Representation Template number for the Spectral Data – Simple Packing
compression scheme is 5.50. In this case, the Data Representation Section becomes:
Octet No.
1-4
5
6-9

10-11
12-15
16-17
18-19
20
21-24

Contents
Length of section in octets (nn)Number of Section (“5”)
Number of data points where one or more values are specified in Section 7
when a bit map is present, total number of data points when a bit map isabsentData Representation Template Number (see code Table 5.0)
Reference value R (IEEE 32-bit floating-point value)
Binary scale factor (E)Decimal scale factor (D)Number of bits used for each packed value (field width)
Real part of the (0,0) coefficient (IEEE 32-bit floating point value)

The corresponding Data Section Template is 7.50. Using this template, the Data Section is:
Octet No.
1-4
5
6-nn

Contents
Length of section in octets (nn)Number of Section (“7”)
Binary data values - binary string, with each (scaled) value data value

The real part of the Fnm coefficient for n = m = 0 is usually much lager than all other coefficients,
and is stored in the Data Representation Section as a floating-point number in the same way as
the global reference value. This is intended to reduce the variability of the coefficients stored in
the Data Section and consequently improve that Section’s packing efficiency. The imaginary partof the Fnm coefficient for n = m = 0 is always zero and therefore not stored. The remaining46

complex numbers Fnm are stored in the Data Section as pairs of real numbers Re ( Fnm ), Im( Fnm )ordered with n increasing from m to N(m) for m = 1, 2, …, M.

2.3.6

Spectral Data – Complex Packing

The relevant Data Representation Template number for the Spectral Data – Complex Packing
compression scheme is 5.51. Template 5.51 is the same as Template 5.50 for octets 12-20, but
contains different information in octets 21-24 and additional information in octets 25-35. In thiscase, the Data Representation Section becomes:
Octet No.
1-4
5
6-9

10-11
12-15
16-17
18-19
20
21-24
25-26
26-28
29-30
31-34
35

Contents
Length of section in octets (nn)Number of Section (“5”)
Number of data points where one or more values are specified in Section 7
when a bit map is present, total number of data points when a bit map isabsentData Representation Template Number (see code Table 5.0)
Reference value R (IEEE 32-bit floating-point value)
Binary scale factor (E)Decimal scale factor (D)Number of bits used for each packed value (field width)
P – Laplacian scaling factor (expressed in 10-6 units)
Js – pentagonal resolution parameter of the unpacked subset (see Note 1)
Ks – pentagonal resolution parameter of the unpacked subset (see Note 1)
Ms – pentagonal resolution parameter of the unpacked subset (see Note 1)
Ts - total number of values in the unpacked subset
Precision of the unpacked subset (see Code Table 5.7)

Notes:(1)
The unpacked subset is a set of values defined in the same way as the full set of values(on a spectrum limited to Js, Ks, and Ms), but on which scaling and packing are not applied.
Associated values are stored in octets 6 onwards of Section 7.
(2)
The remaining coefficients are multiplied by (n*(n+1))p, scaled and packed. The operator
associated with this multiplication is derived from the Laplacian operator on the sphere(3)

The retrieval formula for a coefficient of wave number n is then:Y = (R+X2*2E)*10-D*(n*(n+1))-P
where X2 is the packed scaled value associated with the coefficient.

The corresponding Data Section Template is 7.51. Using this template, the Data Section is:
Octet No.
Contents
1-4
Length of section in octets (nn)5
Number of Section (“7”)
6-(5+I*Ts)
Data values from the unpacked subset (IEEE floating-point values on I octets)(6-+I*Ts)-nnBinary data values - binary string, with each (scaled) value data value out of
the unpacked subset
Notes:(1)
Values ordering within the unpacked subset is defined according the source of the griddefinition associated with the data
(2)
The number of octets associated with each value of the unpacked subset (I) is defined in
Code Table 5.7, according to the actual value in octet 35 of Data Representation Template 5.147

(3)Values ordering within the packed data are done according to the source of grid definition,
skipping the values processed in the unpacked subset
When complex packing is used, a subset of values is stored in the data section unpacked (theunpacked subset), i.e., stored as floating-point numbers. GRIB2 allows these floating- point
numbers to be stored at several levels of precision determined by a value from Code Table 5.7
and stored in octet 35 of the Data Representation Section:
Code Table 5.7:

Precision of floating-point numbers

Code figure Meaning0
Reserved
1
IEEE 32-bit (I=4 in Section 7)
2
IEEE 64-bit (I=8 in Section 7)
3
IEEE 128-bit (I=16 in Section 7)
4-254
Reserved
255
Missing
The remaining coefficients are multiplied by (n*(n+1))p, scaled and packed. The operator
associated with this multiplication is derived from the Laplacian operator on the sphere. These
coefficients must be retrieved using the special retrieval formula given in Note 3 to Data
Representation Template 5.51. The order of storing the scaled and packed values is the same as
the storing under simple packing, but with the values from the unpacked subset skipped.

48

2.4

The Structure of GRIB2 Messages

To get better picture of what a GRIB2 message actually looks like we now provide two examples.
Both contain a 500 hPa geopotential height forecast on a 5 X 5 Northern Hemisphere polarstereographic grid with a 100 KM grid increment in both the X and Y directions. The 25
geopotential height values range from a minimum of 5340 geopotential meters (gpm) to a
maximum of 5460 gpm for all forecast(s) included. While perhaps not very realistic, the examples
are chosen to illustrate a real GRIB2 message in a minimum number of octets.

2.4.1

Structure of A GRIB2 Message with One Data Set

The first sample GRIB2 message contains a hypothetical 12-hour 500 hPa geopotential height
forecast. The example incorporates many of the features described previously in the discussionsof the sections, templates, and compression schemes.
Before presenting the example, however, a brief description of packing the hypothetical values will
be useful. The grid point data – simple packing scheme is used in this example. The logic of thepacking process is as follows:
Step 1: The values are in geopotential meters (gpm). This is an SI unit, so no unit conversion isneeded.
Step 2: The calculated “word” bit-length method will be chosen. Since the grid point values in thishypothetical forecast range from a minimum of 5340 gpm to a maximum of 5460 gpm and sincedecimal scaling with a D value of 1 is chosen, the scaled values range from 53400 to 54600.
Step 3: The global reference value is therefore 53400. Subtracting this reference value from all
the individual values, the residuals range from 0 to 1200.
Step 4: Since the calculated “word” bit-length method is used, we refer to a table of 2’s and findthat the maximum residual of 1200 can be described by a “word” with a length of 11 bits. This
number of bits - the calculated “word” bit-length - is stored in octet 20 of the Data Representation
Section.
Step 5: All residuals are pack into “words” 11 bits long. Since there are 25 values to be encodedin the Data Section, this will require a bit string 275 bits long, equivalent to 34 octets plus 3 more
bits. However, this would mean the Data Section would be 5 bits short of ending on an octet
boundary. Therefore, 5 additional bits set to zero are appended to the bit- string, bringing it to aneven 35 octets in length.
The full GRIB2 message is presented below. Blank lines have been inserted between eachsection to improve readability. These blank lines would not, of course, appear in the actual GRIB2
message.

49Section
Message
Octet No. Octet No.

Value

1-4
5-7
7
8
9-16

1-4
5-7
7
8
9-16

GRIB
All 1’s
02207“GRIB” (coded according to the International Alphabet No. 5)
Reserved
This GRIB2 message contains meteorological products (the product discipline)
The GRIB Edition Number is 2
The total length of this GRIB message is 207 octets

1-4
5
6-7
8-9
10
11
12
13-14
15
16
17
18
19
20
21

17-20
21
22-23
24-25
26
27
28
29-30
31
32
33
34
35
36
37

21
1
74
0
1
0
1
2003
5
1
0
0
0
0
1

This Section is 21 octets longThis is Section 1
The originating/generating centre is the U.K. Meteorological Office
There is no originating/generating sub-centre
GRIB Master Tables Version Number 1 is used
No GRIB Local Tables are used
The Reference Time is the start of the forecast
Year = 2003|
Month = April|
Day = 1|
Reference time of data
Hour = 0|
Minute = 0|
Second = 0|This GRIB2 message contains operational productsThis GRIB2 message contains forecast products

1-4
5
6
7-10
11
12
13-14
15
16
17-20
21

38-41
42
43
44-47
48
49
50-51
52
53
54-57
68

65
3
0
25
0
0
20
1
3
6350000
all 1’s

This Section is 65 octets longThis is Section 3
This grid is specified in Code Table 3.1
There are 25 data points in this grid
There is no optional list of numbers defining number of points
Since there is no optional list of numbers, no interpretation is needed
The Grid Definition Template Number is 3.20 – a polar stereographic projection
The earth is assumed to be spherical with radius specified by the data producer
The scale factor for the radius of the spherical earth is 3
The scaled value of the radius of the spherical earth is 6350000 km
There is no scale factor for the major axis of an oblate spheroid earth

Meaning50

22-25
26
27-30
31-34
35-38
39-42
43-46
47
48-51
52-55
56-59
60-63
64
65

59-62
63
64-67
68-71
72-75
76-79
80-83
84
85-88
89-92
93-96
97-100101
102

all 1’s
all 1’s
all 1’s
5540000001
349999999
00000000
40000001
0100000000
100000000
00
01000000

There is no scaled value for the major axis of an oblate spheroid earth
There is no scale factor for the minor axis of an oblate spheroid earth
There is no scaled value for the minor axis of an oblate spheroid earth
There are 5 points along the X-axis (Nx)There are 5 points along the Y-axis (Ny)The latitude of the first grid point is 40.000001 0 north (La1)
The longitude of the first grid point is 349.999999 0 east (or 10.000001 0 west) (Lo1)
No resolution and component flag are turned on(see flag table 3.3 and Note 1)
Dx and Dy are specified at 40.000001 0 north ((LaD)
The 0 degree meridian is parallel to the Y-axis (LoV)The X direction grid length is 100.000 km (Dx)
The Y direction grid length is 100.000 km (Dy)The north pole is on the projection plane and only one projection centre is used
Points scan in the +i (+x) direction, rows in the +j (+Y) direction, adjacent points inthe (x) direction are consecutive, and all rows scan in the same direction

1-4
5
6-7
8-9

103-106
107
108-109110-111

34
4
0
0

10
11
12
13
14
15-16
17
18
19-22
23
24
25-28
29
30
31-34

112
113
114
115
116
117-118
119
120
121-124125126
127-130131132
133-1363
5
2
All 1’s
All 1’s
3
30
1
12
100
0
500
All 1’s
All 1’s
All 1’s

This Section is 34 octets longThis is Section 4
There are no coordinate values after the Product Definition Template
The Product Definition Template Number is 4.0 – an analysis or forecast at ahorizontal level or in a horizontal layer at a point in time
The parameter category is 3 – mass products
The parameter number is 5 – geopotential height (in geopotential meters)
A forecast generated this product (the generating process)No information on the background generating process is provided
No further information on the forecast generating process is provided
The observational data cut-off was 3 hours after the reference time
The observational data cut-off was 30 minutes after the observational cut-off hour
The time is given in hours
The forecast time is 12 hours after the reference time
The first fixed surface is a pressure surface
The scale factor of first fixed surface is 0
The scaled value of first fixed surface is 500 (500 hPa)
There is no second fixed surface
The scale factor of the second fixed surface is missing since it is not needed
The scaled value of the second fixed surface is missing since it is not needed

51

1-4
5
6-9
10-11

137-140
141
142-145
146-14721
5250This Section is 21 octets longThis is Section 5
There are 25 data points for which values are specified in Section
The Data Representation Template Number is 5.0 - Grid point data – simple
packing
The reference value (R) is 53400.0 (IEEE 32-bit floating-point value)
The binary scale factor (E) is 0: binary scaling is not used
The decimal scale factor (D) is 1: precision is 0.1 geopotential meters
11 bits are used for each packed value in the Data Section
The original field values were floating point numbers

12-15
16-17
18-19
20
21

148-151
152-153154-155
156
157

53400
0
1
11
0

1-4
5
6
1-4
5
6-40

158-161
162
163
164-167168
169-203

6This Section is 6 octets long
6
This is Section 60
There is no bit-map
40This Section is 40 octets long
7
This is Section 7
25 scaled integers, 25 binary data values, each using 11 bits. The binary values thus occupy 275 bits
last 5 bits set to 0 5 additional bits set to zero are therefore necessary to end on an octet boundary.

1-4

204-2077777“7777” coded according to the International Alphabet No. 5

52

2.4.2

Structure of A GRIB2 Message with Multiple Data Sets

The second sample GRIB2 message contains 4 hypothetical 500 hPa geopotential height
forecasts, for forecast hours 12, 24, 36, and 48, as might be contained on a typical four-panel
graphic product. All other features from the first example are unchanged, including the maximum
and minimum geopotential values for each forecast hour (although the other 23 values would, ofcourse, be different). These four fields are represented by a single GRIB2 message by repeating
the sequence of Sections 4 to 7 four times, making the appropriate forecast time changes in the
Product Definition Section in each iteration of the sequence.
The full GRIB2 message is presented below. As before, blank lines have been inserted between
each section to improve readability. These blank lines would not, of course, appear in the actual
GRIB2 message. Also, the modified lines of the Product Definition Section (to change the forecasthour) and Data Section (to insert the new data field) are typed in bold letters to increase
readability.

53Section
Octet No.

Message
Octet No.

Value

Meaning

1-4
5-7
7
8
9-16

1-4
5-7
7
8
9-16

GRIB
All 1’s
02
511“GRIB” (coded according to the International Alphabet No. 5)
Reserved
This GRIB2 message contains meteorological products (the product discipline)
The GRIB Edition Number is 2
The total length of this GRIB message is 511 octets

1-4
5
6-7
8-9
10
11
12
13-14
15
16
17
18
19
20
21

17-20
21
22-23
24-25
26
27
28
29-30
31
32
33
34
35
36
37

21
1
74
0
1
0
1
2003
5
1
0
0
0
0
1

This Section is 21 octets longThis is Section 1
The originating/generating centre is the U.K. Meteorological Office
There is no originating/generating sub-centre
GRIB Master Tables Version Number 1 is used
No GRIB Local Tables are used
The Reference Time is the start of the forecast
Year = 2003|
Month = April|
Day = 1|
Reference time of data
Hour = 0|
Minute = 0|
Second = 0|This GRIB2 message contains operational productsThis GRIB2 message contains forecast products

1-4
5
6
7-10
11
12
13-14
15
16
17-20
21

38-41
42
43
44-47
48
49
50-51
52
53
54-57
58

65
3
0
25
0
0
20
1
3
6350000
all 1’s

This Section is 65 octets longThis is Section 3
This grid is specified in Code Table 3.1
There are 25 data points in this grid
There is no optional list of numbers defining number of points
Since there is no optional list of numbers, no interpretation is needed
The Grid Definition Template Number is 3.20 – a polar stereographic projection
The earth is assumed to be spherical with radius specified by the data producer
The scale factor for the radius of the spherical earth is 3
The scaled value of the radius of the spherical earth is 6350000 km
There is no scale factor for the major axis of an oblate spheroid earth5422-25
26
27-30
31-34
35-38
39-42
43-46
47
48-51
52-55
56-59
60-63
64
65

59-62
63
64-67
68-71
72-75
76-79
80-83
84
85-88
89-92
93-96
97-100101
102

all 1’s
all 1’s
all 1’s
5540000001
349999999
00000000
40000001
0100000000
100000000
00
01000000

There is no scaled value for the major axis of an oblate spheroid earth
There is no scale factor for the minor axis of an oblate spheroid earth
There is no scaled value for the minor axis of an oblate spheroid earth
There are 5 points along the X-axis (Nx)There are 5 points along the Y-axis (Ny)The latitude of the first grid point is 40.000001 0 north (La1)
The longitude of the first grid point is 349.999999 0 east (or 10.000001 0 west) (Lo1)
No resolution and component flag are turned on(see flag table 3.3 and Note 1)
Dx and Dy are specified at 40.000001 0 north ((LaD)
The 0 degree meridian is parallel to the Y-axis (LoV)The X direction grid length is 100.000 km (Dx)
The Y direction grid length is 100.000 km (Dy)The north pole is on the projection plane and only one projection centre is used
Points scan in the +i (+x) direction, rows in the +j (+Y) direction, adjacent points inthe (x) direction are consecutive, and all rows scan in the same direction

1-4
5
6-7
8-9

104-107108
109-110111-112

34
4
0
0

10
11
12
13
14
15-16
17
18
19-22
23
24
25-28
29
30
31-34

113
114
115
116
117
118-119120
121
122-125126127128-131132
133
134-1363
5
2
All 1’s
All 1’s
3
30
1
12
100
0
500
All 1’s
All 1’s
All 1’s

This Section is 34 octets longThis is Section 4
There are no coordinate values after the Product Definition Template
The Product Definition Template Number is 4.0 – an analysis or forecast at ahorizontal level or in a horizontal layer at a point in time
The parameter category is 3 – mass products
The parameter number is 5 – geopotential height (in geopotential meters)
A forecast generated this product (the generating process)No information on the background generating process is provided
No further information on the forecast generating process is provided
The observational data cut-off was 3 hours after the reference time
The observational data cut-off was 30 minutes after the observational cut-off hour
The time is given in hours
The forecast time is 12 hours after the reference time
The first fixed surface is a pressure surface
The scale factor of first fixed surface is 0
The scaled value of first fixed surface is 500 (500 hPa)
There is no second fixed surface
The scale factor of the second fixed surface is missing since it is not needed
The scaled value of the second fixed surface is missing since it is not needed

55

1-4
5
6-9
10-11
12-15
16-17
18-19
20
21

137-140
141
142-145
146-147
148-151
152-153154-155
156
157

21
5
25
0
5340
0
1
11
0

This Section is 21 octets longThis is Section 5
There are 25 data points for which values are specified in Section
The Data Representation Template Number is 5.0 - Grid point data – simple packing
The reference value (R) is 5240.0 (IEEE 32-bit floating-point value)
The binary scale factor (E) is 0: binary scaling is not used
The decimal scale factor (D) is 1: precision is 0.1 geopotential meters
11 bits are used for each packed value in the Data Section
The original field values were floating point numbers

1-4
5
6

158-161
162
163

6
6
0

This Section is 6 octets longThis is Section 6
There is no bit-map

1-4
5
6-40

164-167168
169-20340
This Section is 40 octets long
7
This is Section 7
25 scaled integers, 25 binary data values, each using 11 bits. The values thus occupy 275 bits .
last 5 bits set to 0 4 additional bits set to zero are necessary for the section to end on an octet
boundary.

1-4
5
6-7
8-9

204-207208
209-210211-212

34
4
0
0

10
11
12
13
14
15-16
17
18
19-22
23

213
214
215
216
217
218-219220
221
222-225226

3
5
2
All 1’s
All 1’s
3
30
1
24
100

This Section is 34 octets longThis is Section 4
There are no coordinate values after the Product Definition Template
The Product Definition Template Number is 4.0 – an analysis or forecast at ahorizontal level or in a horizontal layer at a point in time
The parameter category is 3 – mass products
The parameter number is 5 – geopotential height (in geopotential meters)
A forecast generated this product (the generating process)No information on the background generating process is provided
No further information on the forecast generating process is provided
The observational data cut-off was 3 hours after the reference time
The observational data cut-off was 30 minutes after the observational cut-off hour
The time is given in hours
The forecast time is 24 hours after the reference time
The first fixed surface is a pressure surface

56

24
25-28
29
30
31-34

227
228-231232
233
234-2370500
All 1’s
All 1’s
All 1’s

The scale factor of first fixed surface is 0
The scaled value of first fixed surface is 500 (500 hPa)
There is no second fixed surface
The scale factor of the second fixed surface is missing since it is not needed
The scaled value of the second fixed surface is missing since it is not needed

1-4
5
6-9
10-11
12-15
16-17
18-19
20
21

238-241242
243-246247-248249-252
253-254
255-2456
257
258

21
5
25
0
5340
0
1
11
0

This Section is 21 octets longThis is Section 5
There are 25 data points for which values are specified in Section
The Data Representation Template Number is 5.0 - Grid point data – simple packing
The reference value (R) is 5240.0 (IEEE 32-bit floating-point value)
The binary scale factor (E) is 0: binary scaling is not used
The decimal scale factor (D) is 1: precision is 0.1 geopotential meters
11 bits are used for each packed value in the Data Section
The original field values were floating point numbers

1-4
5
6

259-262
263
264

6
6
0

This Section is 6 octets longThis is Section 6
There is no bit-map

1-4
5
6-40

265-268269
270-30440
This Section is 40 octets long
7
This is Section 7
25 scaled integers, 25 binary data values, each using 11 bits. The values thus occupy 275 bits .
last 5 bits set to 0 5 additional bits set to zero are therefore necessary to end on an octet boundary.

1-4
5
6-7
8-9

305-308309
310-311312-313

34
4
0
0

10
11
12
13
14
15-16

314
315
316
317
318
319-3203
5
2
All 1’s
All 1’s
3This Section is 34 octets longThis is Section 4
There are no coordinate values after the Product Definition Template
The Product Definition Template Number is 4.0 – an analysis or forecast at ahorizontal level or in a horizontal layer at a point in time
The parameter category is 3 – mass products
The parameter number is 5 – geopotential height (in geopotential meters)
A forecast generated this product (the generating process)No information on the background generating process is provided
No further information on the forecast generating process is provided
The observational data cut-off was 3 hours after the reference time

57

17
18
19-22
23
24
25-28
29
30
31-34

321
322
323-326
327
328
329-332333
334
335-338

30
1
36
100
0
500
All 1’s
All 1’s
All 1’s

The observational data cut-off was 30 minutes after the observational cut-off hour
The time is given in hours
The forecast time is 36 hours after the reference time
The first fixed surface is a pressure surface
The scale factor of first fixed surface is 0
The scaled value of first fixed surface is 500 (500 hPa)
There is no second fixed surface
The scale factor of the second fixed surface is missing since it is not needed
The scaled value of the second fixed surface is missing since it is not needed

1-4
5
6-9
10-11

339-342343
344-347348-349

21
5
25
0

12-15
16-17
18-19
20
21

350-353354-355356-357
358
359

5340
0
1
11
0

This Section is 21 octets longThis is Section 5
There are 25 data points for which values are specified in Section
The Data Representation Template Number is 5.0 - Grid point data – simple
packing
The reference value (R) is 5240.0 (IEEE 32-bit floating-point value)
The binary scale factor (E) is 0: binary scaling is not used
The decimal scale factor (D) is 1: precision is 0.1 geopotential meters
11 bits are used for each packed value in the Data Section
The original field values were floating point numbers

1-4
5
6

361-364
365
366

6
6
0

This Section is 6 octets longThis is Section 6
There is no bit-map

1-4
5
6-40

367-370371
372-406

40
This Section is 40 octets long
7
This is Section 7
25 scaled integers, 25 binary data values, each using 11 bits. The values thus occupy 275 bits .
last 5 bits set to 0 5 additional bits set to zero are therefore necessary to end on an octet boundary.

1-4
5
6-7
8-9

407-410411
412-413414-415

34
4
0
0

10

416

3

This Section is 34 octets longThis is Section 4
There are no coordinate values after the Product Definition Template
The Product Definition Template Number is 4.0 – an analysis or forecast at ahorizontal level or in a horizontal layer at a point in time
The parameter category is 3 – mass products
58

11
12
13
14
15-16
17
18
19-22
23
24
25-28
29
30
31-34

417
418
419
420
421-422423
424
425-428429
430
431-434
435
436
437-44052
All 1’s
All 1’s
3
30
1
48
100
0
500
All 1’s
All 1’s
All 1’s

The parameter number is 5 – geopotential height (in geopotential meters)
A forecast generated this product (the generating process)No information on the background generating process is provided
No further information on the forecast generating process is provided
The observational data cut-off was 3 hours after the reference time
The observational data cut-off was 30 minutes after the observational cut-off hour
The time is given in hours
The forecast time is 48 hours after the reference time
The first fixed surface is a pressure surface
The scale factor of first fixed surface is 0
The scaled value of first fixed surface is 500 (500 hPa)
There is no second fixed surface
The scale factor of the second fixed surface is missing since it is not needed
The scaled value of the second fixed surface is missing since it is not needed

1-4
5
6-9
10-11

441-444445
446-449
450-451

21
5
25
0

12-15
16-17
18-19
20
21

452-455
456-457458-459
460
461

5340
0
1
11
0

This Section is 21 octets longThis is Section 5
There are 25 data points for which values are specified in Section
The Data Representation Template Number is 5.0 - Grid point data – simple
packing
The reference value (R) is 5240.0 (encoded as an IEEE 32-bit floating-point value)
The binary scale factor (E) is 0: binary scaling is not used
The decimal scale factor (D) is 1: precision is 0.1 geopotential meters
11 bits are used for each packed value in the Data Section
The original field values were floating point numbers

1-4
5
6

462-465
466
467

6
6
0

This Section is 6 octets longThis is Section 6
There is no bit-map

1-4
5
6-40

468-471472
472-507

40
This Section is 40 octets long
7
This is Section 7
25 scaled integers, 25 binary data values, each using 11 bits. The values thus occupy 275 bits .
last 5 bits set to 0 5 additional bits set to zero are therefore necessary to end on an octet boundary.

1-4

508-5117777“7777” coded according to the International Alphabet No. 5
59

2.5

Uses of GRIB2 Messages

Perhaps the best way to assess the potential uses for GRIB2 is to review the current contents of
the relevant code tables. We begin by extracting from Code Table 4.0 – Product Definition
Template Number – all currently defined Product Definition Templates. There are a total of 19:

60

61

Currently Defined Product Definition Templates
No.
0
1
2
3
4
5
6
7
8
9
10
20
30
254
1000
1001
1002
1100
1101

Name
Analysis or forecast at a horizontal level or in a horizontal layer at a point in time
Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time
Derived forecast based on all ensemble members at a horizontal level or in a horizontal layer at a point in time
Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point intime
Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time
Probability forecasts at a horizontal level or in a horizontal layer at a point in time
Percentile forecasts at a horizontal level or in a horizontal layer at a point in time
Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time
Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or
non-continuous time interval
Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval
Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval
Radar productSatellite product
CCITT IA5 character string
Cross section of analysis and forecast at a point in time
Gross section of averaged or otherwise statistically processed analysis or forecast over a range of time
Cross section of analysis and forecast, averaged or otherwise statistically processed
Hovmöller-type grid with no averaging or other statistical processing
Hovmöller-type grid with averaging or other statistical processing

62

Most of these templates describe a wide variety of individual products. For example, ProductDefinition Template 4.0 - Analysis or forecast at a horizontal level or in a horizontal layer at a point
in time – permits description of a wide variety of individual products via the currently defined
combinations of Product Discipline (from Code Table 0.0), Product Category (from Code Table
4.1), and Product Name (from Code Table 4.2). Code Table 4.2 is rather long for reproduction inits entirety here. Nevertheless, a feeling for the types of individual products can be obtained byextracting the currently defined Product Disciplines and Categories from Code Tables 0.0 and 4.1,
respectively:

Currently Defined Product Disciplines
No.
0
1
2
3
10

Name
Meteorological products
Hydrological products
Land surface productsSpace products
Oceanographic products

Currently Defined Product Categories
Product Discipline 0: Meteorological products
No.
Category0
Temperature
1
Moisture
2
Momentum
3
Mass
4
Short-wave Radiation
5
Long-wave Radiation
6
Cloud
7
Thermodynamic Stability indices8
Kinematic Stability indices9
Temperature Probabilities
10
Moisture Probabilities
11
Momentum Probabilities
12
Mass Probabilities
13
Aerosols
14
Trace gases (e.g., ozone, CO2)
15
Radar
16
Forecast Radar Imagery
17
Electro-dynamics
18
Nuclear/radiology
19
Physical atmospheric properties
190
CCITT IA5 string
191
Miscellaneous
Product Discipline 1: Hydrological products
No.
Category0
Hydrology basic products
1
Hydrology probabilities

Product Discipline 2: Land surface products
No.
Category

63

0
1
2
3

Vegetation/Biomass
Agri-aquacultural Special Products
Transportation-related Products
Soil Products

Product Discipline 3: Space Products
No.
Category
0
Image format products (see Note 1)
1
Quantitative products (see Note 2)
Product Discipline 10: Oceanographic products
No.
Category0
Waves
1
Currents2
Ice
3
Surface Properties
4
Sub-surface Properties
For each of the above Product Categories, there is a Table for Product Names permitting up to 255
entries, of which entries 0-191 are internationally coordinated and entries 192-254 are reserved for
local use.
Finally, a wide variety of grid projections are available for use with these individual products. The
grid projections currently defined in Code Table 3.1 are:

Currently Defined Grid Definition Templates
No.
0
1
2
3
10
20
30
40
41
42
43
50
51
52
53
90
100
110
120
1000
1100
1200

Name
Latitude/longitude
Rotated latitude/longitude
Stretched latitude/longitude
Stretched and rotated latitude/longitude
Mercator
Polar stereographic
Lambert Conformal
Gaussian latitude/longitude
Rotated Gaussian latitude/longitude
Stretched Gaussian latitude/longitude
Stretched and rotated Gaussian latitude/longitude
Spherical harmonic coefficients
Rotated spherical harmonic coefficients
Stretched spherical harmonic coefficients
Stretched and rotated spherical harmonic coefficients
Space view perspective orthographic.
Triangular grid based on an icosahedron
Equatorial azimuthal equidistant projection
Azimuth-range projection
Cross-section grid, with points equally spaced on the horizontal
Hovmöller diagram grid, with points equally spaced on the horizontal
Time section grid

Recall that if some product, grid, or data representation scheme you might need is not yet defined,
GRIB2 can probably accommodate your requirements. You need only to follow the procedures64

outlined in Section 1.3 - Updating the Code Form. It is hopefully clear by now that the developersof GRIB2 have made every effort to allow generous table space for such future expansion.

2.6

Available GRIB2 Software (updated February 2003)

NCEP (USA) has both a Fortran 90 and C version of an encoder/decoder. An experimental project(called National Digital Forecast Database) managed by NWS/TDL makes use of GRIB2, with aparticipation from NCEP.
ECMWF should start migration to GRIB2 and provide EPS probabilities on the GTS in 2003. A
decoder will be available to decode these products.
JMA has separate encoder for specific generated products and decoder for limited products, andan extra package will be developed for domestic use of products of very short range forecast on
precipitation. Provision of 3 and 6 months ensemble forecast products should start next autumn
for national and international users. New products in field form would be considered in GRIB
edition 2.
EUMETSAT is generating Cloud mask products in GRIB2. Satellite images will also be available in
GRIB 2. A decoder for this type of data are available to user at request. It is still to be included in
the PUMA work-station.

65

Layer 3:
3.1

Detailed Description of GRIB2

Quasi-regular Grids

Use of quasi-regular grids is one of the special cases alluded to in the discussion of the Grid
Definition Section in Section 2.1.4 of Layer 2. Now this special case will be described in somedetail. Let us begin by recalling that the contents of Section 3 are:Octet No.
1-4
5
6
7-10
11
12
13-14
15-xx
[xx+1]-nn

Contents
Length of section in octets (nn)Number of Section (“3”)
Source of grid definition (see Code Table 3.0 and Note 1)
Number of data points
Number of octets for optional list of numbers defining number of points (seeNote 2)
Interpretation of list of numbers defining number of points (see Code Table
3.11)
Grid Definition Template Number (N) (see Code Table 3.1)
Grid Definition Template (see Template 3.N, where N is the Grid Definition
Template Number given in octets 13-14)
Optional list of numbers defining number of points (see Notes 2, 3, and 4)

Notes:
1.
If octet 6 is not zero, octets 15-xx (15-nn if octet 11 is zero) may not be supplied. Thisshould be documented with all bits set to 1 (missing value) in the Grid Definition Template
Number.
2.
An optional list of numbers defining the number of points is used to document a quasiregular grid, where the number of points may vary from one row to another (row being defined asadjacent points in a coordinate line, so this is dependent on the data layout). In such a case, octet
11 is non-zero, and gives the number of octets on which each number of points is encoded. For
all other cases, such as regular grids, octets 11 and 12 are zero and no list is appended to the
Grid Definition Template.
3.
If a list of numbers defining the number of points is present, it is appended at the end of theGrid Definition Template (or directly after the Grid Definition Template Number if the template is
missing), and the length of the list is given by the grid definition. When the Grid Definition
Template is present, the length is given according to bit 3 of the scanning mode flag octet (thelength is Nj or Ny for flag value 0). List ordering is implied by data scanning.
4.
Depending on the code value given in octet 12, the list of numbers defining the number ofpoints corresponds either to the coordinate lines as given in the grid definition, or to a full circle.

The quasi-regular grid option is used with latitude-longitude grids. To facilitate this discussion, let
us first consider a 10o X 10o latitude-longitude grid (Grid Definition Template 3.0) without using thequasi-regular grid option. The contents of the Grid Definition Section in this case would be:

66

67

Section
Octet No.

Message
Octet No.

Value

1-4
5
6
7-10
11
12
13-14
15
16
17-20
21
22-25
26
27-30
31-34
35-38
39-42
43-46
47-50

38-41
42
43
44-47
48
49
50-51
52
53
54-57
58
59-62
63
64-67
68-71
72-75
76-79
80-83
84-87

72
3
0
25
0
0
1
1
3
6350000
all 1’s
all 1’s
all 1’s
all 1’s36
19
0
all 1’s
90000000

51-54
55

88-91
92

0000000
00111000

56-59
60-63
64-67
68-71
72

93-96
97-100101-104
105-108109

90000000
350000000
10000000
10000000
01000000

Meaning
This Section is 72 octets longThis is Section 3
This grid is specified in Code Table 3.1
There are 25 data points in this grid
There is no optional list of numbers defining the number of points
Since there is no optional list of numbers, no interpretation is needed
The Grid Definition Template Number is 3.1 a latitude-longitude grid
The earth is assumed to be spherical with radius specified by the data producer
The scale factor for the radius of the spherical earth is 3
The scaled value of the radius of the spherical earth is 6350000 km
There is no scale factor for the major axis of an oblate spheroid earth
There is no scaled value for the major axis of an oblate spheroid earth
There is no scale factor for the minor axis of an oblate spheroid earth
There is no scaled value for the minor axis of an oblate spheroid earth
There are 36 points along a parallel (Ni)There are 19 points along a meridian (Nj)
The basic angle of all latitudes and longitudes is 1 degree
The unit of the basic angle of all latitudes and longitudes is 10-6 degrees
The latitude of the first grid point (La1) is –90.000000o. Bit 1 is set to 1 to indicate
negative (south) latitude.
The longitude of the first grid point (Lo1) is 0.000000o
I and j direction increments are given. Resolved u- and v- components of vector
quantities are relative to the defined grid in the direction of increasing x and ycoordinates respectively.
The latitude of the last grid point is +90.000000o
The longitude of the last grid point is +350.000000o
The i direction increment is 10.000000o
The j direction increment is 10.000000o
Points in the first row scan in the +I (+x) direction. Points in the first column scan in
the +j (+y) direction. Resolved u- and v- components of vector quantities are
relative to easterly and northerly directions.

68Now, let us consider the changes that would be needed to the above Grid Definition Section toindicate that there are 36 points along the equator, but that the number of points in each grid row
away from the equator is reduced by 1. I.e., the rows of grid points along 10o north and south
would have 35 points, the rows of grid points along 20o north and south would have 34 points, andetc.
This change will require an optional list of numbers defining the number of points in each grid row.
In this case, octet 11 is not zero, but gives the number of octets on which each number of points is
encoded. Since the largest number of points is 36, one octet will be sufficient, so octets 11 willcontain the value 1.
Code Table 3.11 gives the interpretation of the numbers in the list:
Code table 3.11

Interpretation of list of numbers defining number of points

Code figure

Meaning01

There is no appended list
Numbers define number of points corresponding to full coordinate circles (i.e.
parallels), coordinate values on each circle are multiple of the circle mesh, andextreme coordinate values given in grid definition (i.e. extreme longitudes) may not
be reached in all rows
Numbers define number of points corresponding to coordinate lines delimited byextreme coordinate values given in grid definition (i.e. extreme longitudes) which arepresent in each row
Reserved
Missing

2

3-254
255

In this case, the numbers correspond to full coordinate circles (i.e., parallels) coordinate values oneach circle are multiple of the circle mesh, and extreme coordinate values given in grid definition
may not be reached in all rows. Therefore, the number 1 is encoded in octet 12.
Finally, the list of numbers itself is encoded following Grid Definition Template 3.1. The length ofthe list of numbers is either Ni (contained in octets 31-34) if bit 3 of octet 72 (Scanning mode) is 1
or Nj (contained in octets 35-38) is bit 3 of octet 72 is 0. In this example, bit 3 of octet 72 is zero,
indicating the adjacent points in the i (x) direction are consecutive. Thus, the number of values isgiven by octets 35-38 (Nj – the number of rows of grid points), or 19 in this case. Since there are
19 numbers and each number occupies 1 octet, there will be 19 additional octets in the Grid
Definition Section.
With these changes, the Grid Definition Section becomes ( modified lines are typed in bold):69

Section
Octet No.

Message
Octet No.

1-4
5
6
7-10
11

38-41
42
43
44-47
48

91
3
0
684
1

12

49

1

13-14
15
16
17-20
21
22-25
26
27-30
31-34
35-38
39-42
43-46
47-50

50-51
52
53
54-57
58
59-62
63
64-67
68-71
72-75
76-79
80-83
84-87

1
1
3
6350000
all 1’s
all 1’s
all 1’s
all 1’s36
19
0
all 1’s
90000000

51-54
55

88-91
92

0000000
00111000

56-59
60-63
64-67

93-96
97-100101-104

90000000
35000000
10000000

Value

Meaning

This Section is 91 octets longThis is Section 3
This grid is specified in Code Table 3.1
There are 684 data points in this grid
There is an optional list of numbers defining the number of points. Eachof the numbers occupies 1 octet.
Numbers define number of points corresponding to full coordinate circles(i.e. parallels), coordinate values on each circle are multiple of the circle
mesh, and extreme coordinate values given in the grid definition (i.e.
extreme longitudes) may not be reached in all rows.
The Grid Definition Template Number is 3.1 a latitude-longitude grid
The earth is assumed to be spherical with radius specified by the data producer
The scale factor for the radius of the spherical earth is 3
The scaled value of the radius of the spherical earth is 6350000 km
There is no scale factor for the major axis of an oblate spheroid earth
There is no scaled value for the major axis of an oblate spheroid earth
There is no scale factor for the minor axis of an oblate spheroid earth
There is no scaled value for the minor axis of an oblate spheroid earth
There are 36 points along a parallel (Ni)There are 19 points along a meridian (Nj)
The basic angle of all latitudes and longitudes is 1 degree
The unit of the basic angle of all latitudes and longitudes is 10-6 degrees
The latitude of the first grid point (La1) is –90.000000o. Bit 1 is set to 1 toindicate negative (south) latitude.
The longitude of the first grid point (Lo1) is +0.000000o
I and j direction increments are given. Resolved u- and v- components ofvector quantities are relative to the defined grid in the direction of increasing x
and y coordinates respectively.
The latitude of the last grid point is +90.000000o
The longitude of the last grid point is +350.000000o
The i direction increment is 10.000000o
7068-71
72

105-108109

10000000
01000000

73-91

110-128

27, 28, 29, 30
31, 32, 33, 34
35, 36, 35, 34
33, 32, 31, 30
29, 28, 27

The j direction increment is 10.000000o
Points in the first row scan in the +I (+x) direction. Points in the first column
scan in the +j (+y) direction. Resolved u- and v- components of vector
quantities are relative to easterly and northerly directions.
Number of points in each grid row. Each number is encoded in one octet.

71

3.2

Hybrid Vertical Coordinates

Use of hybrid vertical coordinates is one of the special cases alluded to in the discussion of the
Product Definition Section in Section 2.1.5 of Layer 2. Now this special case will be described insome detail. Let us begin by recalling that the contents of Section 4 are:Octet No.
1-4
5
6-7
8-9
10-xx
[xx+1]-nn

Contents
Length of section in octets (nn)Number of Section (“4”)
Number of coordinate values after Template (see Note 1)
Product Definition Template Number (see Code Table 4.0)
Product Definition Template (see Template 4.X, where X is the ProductDefinition Template Number given in octets 8-9)
Optional list of coordinate values (see Notes 2 and 3)

Notes:
1.
Coordinate values are intended to document the vertical discretisation associated withmodel data on hybrid vertical coordinate levels. A number of zero in octets 6-7 indicates that nosuch values are present. Otherwise, the number corresponds to the whole set of values.
2.
Hybrid systems, in this context, employ a means of representing vertical coordinates interms of a mathematical combination of pressure and sigma coordinates. When used inconjunction with a surface pressure field and an appropriate mathematical expression, the verticalcoordinate parameters may be used to interpret the hybrid vertical coordinate.
3.
Hybrid vertical coordinate values, if present, should be encoded in IEEE 32-bit floating point
format. They are intended to be encoded as pairs.
As Note 2 indicates, a hybrid vertical coordinate system is a mathematical combination of pressure
and sigma vertical coordinates. Therefore, we begin the discussion with a review of the sigma
coordinate system.
The general formula for the sigma (σ ) coordinate is:Pu - Pσ
σ = -----------,
Pu - Pl
where Pu is the pressure of the upper boundary of the sigma domain, Pl is the pressure of thelower boundary of the sigma domain, and Pσ is the pressure of an individual sigma surface. The
simplest, and perhaps the most common, application of this general formulation is to let the upperboundary of the sigma domain be the top of the atmosphere (Pu = 0) and the lower boundary of
the sigma domain be the surface of the earth (Pl = Psfc ). With these assumptions, the expressionfor σ becomes:
Pσ
σ = ----,
Psfc
Which can be rewritten as
Pσ = σ • Psfc
The hybrid coordinate system has been introduced in numerical models to have both sigma-type
levels near the earth and pressure levels at the top of the atmosphere. The above formula is72generalized as follows:
Ph = ah • Psfc + bh
Hybrid vertical coordinate values, when present, are encoded as the pair of numbers ah and bh inIEEE 32-bit floating point format. Each pair represents a hybrid vertical coordinate level. With thesurface pressure field Psfc, the values of Ph can be calculated from the above formula. Note that
this implies the surface pressure field accompanies data on hybrid vertical coordinates. The
capability of GRIB2 to encode multiple data sets in a single message makes this straightforward toaccomplish.
Since each value in the pair of numbers is in IEEE 32-bit floating point format, each such hybrid
level encoded would require 8 octets. If a hybrid vertical coordinate system with 10 individuallevels were used instead of pressure, the Product Definition Section from the example in Section
2.4.1 of Layer 2 would become (modified lines are typed in bold):

73

1-4
5
6-7
8-9

104-107108
109-110111-112

111
4
20
0

10
11
12
13
14
15-16
17
18
19-22
23
24
25-28

113
114
115
116
117
118-119120
121
122-125126127128-1313
5
2
All 1’s
All 1’s
3
30
1
12
105
0
n (1 – 10)

29
30
31-34
35-111

132
133
134-137
138-214

All 1’s
All 1’s
All 1’s(a1, b1)level 1 ,(a2, b2)level 2 ,(a3, b3)level 3 ,(a4, b4)level 4 ,(a5, b5)level 5 ,(a6, b6)level 6 ,(a7, b7)level 7 ,(a8, b8)level 8 ,(a9, b9)level 9 ,(a10, b10)level 10

This Section is 111 octets longThis is Section 4
There are 20 (10 pairs) of coordinate values after the Product Definition Template
The Product Definition Template Number is 4.0 – an analysis or forecast at ahorizontal level or in a horizontal layer at a point in time
The parameter category is 3 – mass products
The parameter number is 5 – geopotential height (in geopotential meters)
A forecast generated this product (the generating process)No information on the background generating process is provided
No further information on the forecast generating process is provided
The observational data cut-off was 3 hours after the reference time
The observational data cut-off was 30 minutes after the observational cut-off hour
The time is given in hours
The forecast time is 12 hours after the reference time
The first fixed surface is a hybrid coordinate surface
The scale factor of first fixed surface is 0
The scaled value of first fixed surface is n. This represents the nth hybrid
level.
There is no second fixed surface
The scale factor of the second fixed surface is missing since it is not needed
The scaled value of the second fixed surface is missing since it is not needed
Pairs of numbers describing the hybrid vertical coordinate system. Eachindividual number is encoded in IEEE 32-bit floating point format andoccupies 4 octets

74

3.3

Data Compression

3.3.1

Complex Packing Schemes

3.3.1.1

Example of using Complex Packing in a GRIB2 Message
with One Data Set

Recall that the Grid Point Data – Simple Packing compression method was used in the sample
GRIB2 message in Section 2.4.1 of Layer 2. The Data Representation, Bit Map, Data, and End
Sections from that sample GRIB2 message were:75Section
Octet No.

Message
Octet No.

Value

1-4
5
6-9
10-11

138-141142
143-146147-148

21
5
25
0

12-15
16-17
18-19
20
21

149-152
153-154155-156
157
158

5340
0
1
11
0

This Section is 21 octets longThis is Section 5
There are 25 data points for which values are specified in Section
The Data Representation Template Number is 5.0 - Grid point data – simple
packing
The reference value (R) is 5240.0 (IEEE 32-bit floating-point value)
The binary scale factor (E) is 0: binary scaling is not used
The decimal scale factor (D) is 1: precision is 0.1 geopotential meters
11 bits are used for each packed value in the Data Section
The original field values were floating point numbers

1-4
5
6

159-162
163
164

6
6
0

This Section is 6 octets longThis is Section 6
There is no bit-map

1-4
5
6-40

165-168169
170-20440
This Section is 40 octets long
7
This is Section 7
25 scaled integers, 25 binary data values, each using 11 bits. The binary values thus occupy 275 bits
last 5 bits set to 0 5 additional bits set to zero are therefore necessary to end on an octet boundary.

1-4

205-208

7777

Meaning“7777” coded according to the International Alphabet No. 5

76

The Grid Point Data - Complex Packing method was discussed in general terms in Section 2.3.2 ofLayer 2. We will now consider the modifications needed to this sample GRIB2 message when thispacking method is used.
The 25 hypothetical grid point values of 500 hPa geopotential height in that example ranged from3400 gpm to 4600 gpm. In order to illustrate the Grid Point Data – Complex Packing compression
method in more detail, we now will assume the full set of 25 hypothetical geopotential heightvalues, after scaling by a D factor of 1, is:

54560
•

•

54000
•

•

53800
•

54570
•

54580
•

•

•

54200
•

•

•

54000
•

•

53800
•

•

•

53600
•

•

54100

53900
•

53600
•

53700
•

53400
•

•

53500

54590

54600

54300

54400

54100

54200

53900

54000

53700

53800

01190

01200

00900

01000

00700

00800

00500

00600

00300

00400

•

Subtracting the overall global minimum of 53400 results in

01160
•

01170
•

00600
•

•

00400
•

•

00200
•

•

00000
•

•

•

01180
•

•

•

00800
•

•

•

00600
•

•

•

00400
•

•

•

00200
•

•

00700

00500

00300

00100

77

Octet 65 of Grid Definition Template 3.20 (Polar Stereographic Projection) determines thescanning mode by reference to Code Table 3.4 (presented in Section 2.3.3 of Layer 2). For row
by row scanning (the +j(+y) direction), where each row is itself scanned in the +i (+x) direction,octet 65 would contain the bit string 01000000. This scanning mode produces the following stringof values:
00000 00100 00200 00300 00400 00200 00300 00400 00500 00600 00400 00500
00600 00700 00800 00600 00700 00800 00900 01000 01160 01170 01180 01190
01200
Up to now, nothing has changed from the original example. As we saw before, all these values
could be packed into a “word” with a length of 11 bits. 25 such “words” would therefore take a bit
string 275 bits long. However, when we decide to use the complex packing method for this grid
point data instead of the simple packing method, this is where things become different. For
convenience, the appropriate Data Representation and Data sections presented in Section 2.3.2
of Layer 2 are repeated here:
Octet No.
1-4
5
6-9

10-11
12-15
16-17
18-19
20
21
22
23
24-27
28-31
32-35
36
37
38-41
42
43-46
47

Contents
Length of section in octets (nn)Number of Section (“5”)
Number of data points where one or more values are specified in Section 7
when a bit map is present, total number of data points when a bit map isabsentData Representation Template Number (see code Table 5.0)
Reference value (R) (IEEE 32-bit floating-point value)
Binary Scale Factor (E)Decimal Scale Factor (D)Number of bits used for each packed value for simple packing, or for eachgroup reference value for complex packing or spatial differencing
Type of original field values (see Code Table 5.1)
Group splitting method used (see Code Table 5.4)
Missing value management used (see Code Table 5.5)
Primary missing value substituteSecondary missing value substituteNG - Number of groups of data values into which field is split
Reference for group widths (see Note 12)
Number of bits used for the group widths (after the reference value in octet 36
has been removed)
Reference for group lengths (see Note 13)
Length increment for the group lengths (see Note 14)
True length of last group
Number of bits used for the scaled group lengths (after subtraction of thereference value given in octets 38-41 and division by the length increment
given in octet 42)

78

Octet No.
1-4
5
6-xx

[xx+1]-yy[yy+1]-zz[zz+1]-nn

Contents
Length of section in octets (nn)Number of Section (“7”)
NG group reference values (XI in the decoding formula), each of which is
encoded using the number of bits specified in octet 20 of Data Representation
Template 5.0. Bits set to zero shall be appended as necessary to ensure thissequence of numbers ends on an octet boundary.
NG group widths, each of which is encoded using the number of bits specified
in octet 37 of Data Representation Template 5.2. Bits set to zero shall beappended as necessary to ensure
this sequence of numbers ends on anoctetboundary.
NG scaled group lengths, each of which is encoded using the number of bits
specified in octet 47 of Data Representation Template 5.2. Bits set to zero
shall be appended as necessary to ensure this sequence of numbers ends onan octet boundary. (see Note 14 of Data Representation Template 5.2)
Packed values (X2 in the decoding formula), where each value is a deviationfrom its respective group reference value.

We shall consider the first 20 values and the last 5 values as groups. Referring to Code Table 5.4(it was reproduced in Section 2.3.2 of Layer 2), this falls under the category of General groupsplitting, identified by code figure 1. The number 1 is therefore stored in octet 22 of Section 5.
Furthermore, there are only two groups to treated. This number is referred to as NG and is storedin octets 32-35 of Section 5.
This data has no missing values, so the missing value management option is not needed. Code
Table 5.5 (it was also reproduced in Section 2.3.2 of Layer 2) indicates a value of 0 (zero) needs
to be encoded in octet 23 of Section 5 to indicate this. Since the missing value management
option is not used, octets 24-27 and octets 28-31 will be set to all 1’s (missing value).
The 20 values in the first group have a minimum (group reference) of 0 and the 5 values second
group have a minimum of 1160. The largest of these two group references – 1160 - packs in a“word” 10 bits long, so 10 will be stored in octet 20 of the Data Representation Section (note themeaning of the contents of octet 20 is different when complex packing is used than it was whensimple packing was used). The group reference values themselves – 0 and 1160, the X1 values
in the GRIB2 compression formula - are stored in octets 6 – xx of the Data Section. Since 10 bits
are required for each value, this will occupy octets 6 –25 of the Data Section.
Next, each group reference value is subtracted from each of the scaled integers in its respective
group. The resulting residuals in each group are:Group 1:00000 00100 00200 00300 00400 00200 00300 00400 00500 00600
00400 00500 00600 00700 00800 00600 00700 00800 00900 01000

Group 2:00000 00010 00020 00030 00040

These residuals are the scaled values with the reference removed – the second-order (X2) values
in the GRIB2 compression formula. They are stored in octets [zz+1]-nn of Section 7. The valuesof zz and nn will be determined presently.
Group width is defined as the number of bits used for every X2 value in a group. For each group,
this is the number of bits required to represent the largest of the X2 values in that group. In thisexample, the two group widths are 9 (to represent 1000 for Group 1) and 6 (to represent 40 forGroup 2). The smallest of these group widths (6) is stored in octet 36 of the Data Representation
Section. This minimum group width is then subtracted from every group width leaving an array of79

group width increments. In this case, the group width increments are 3 (9 – 6) and 0 (6 – 6). The
number of bits required to represent the largest of these group width increments (2 bits to store 3)
is stored in octet 37 of the Data Representation Section. The group width (increments)
themselves (3 and 0) are then stored in octets [xx+1] – yy of the Data Section (octets 26 – 29)
using the number of bits (2) stored in octet 37 of the Data Representation Section for each value.
Group length (Ln) is defined as the number of values in a group. In this case, Ln is 20 for Group 1
and 5 for Group 2. The smallest of these group lengths (ref) is 5. This value (5) is stored in octets
38-41 of the Data Representation Section.
As pointed out in the GRIB2 Manual, complex packing for grid-point is intended to reduce data
section size as compared to simple packing. This is achieved at the expense of extra descriptors
per group. In order to keep the volume of these descriptors as low as possible, group widths andlengths have their minimum value subtracted. As a complement, lengths may be scaled using thelength increment feature.
This may be used in conjunction with splitting algorithm to determine groups of data. Efficientalgorithms with a good quality/price ratio are based on the determination of groups starting from abasic length, say B, and possible extensions of either B or a shorter (incremental) length I. For
example, B and I could be 15 and 3, respectively.
In such a case, all groups (but the last one) will have a minimum length of B and length increments
multiple of I (assuming B is a multiple of I, which is easy to choose). So B would be stored in octets
38-41, I in octet 42, and the effective length of last groups (reference for group lengths notremoved) in octets 43-46.
Finally, the number of bits NL necessary to store the scaled group lengths (the Kn values in Note
14 of the Manual) will be stored in octet 47. Note that as soon as I is bigger than 1, NL is reduced
relative to using an increment of 1, leading to save space in Data Section.
The Kn values are stored in Data Section for all NG groups. The encoded value of Kn for n= NG is
not relevant for decoding, and a zero value may be used.

3.3.2

Complex Packing and Spatial Differencing Schemes

3.3.2.1

Example of using Complex Packing and Spatial Differencing in a GRIB2 Message
in a GRIB2 Message with One Data Set

Spatial differencing is performed after rounding the scaled values to scaled integers but before
splitting the scaled integers into groups. It is intended to reduce the size of sufficiently smooth
fields. When spatial differencing is used, the relevant Data Representation Template is 5.3.
Template 5.3 is the same as Data Representation Template 5.2 (Grid Point Data – Complex
Packing), but contains additional information in octets 48 and 49 (typed in bold below). When
Template 5.3 is used, the Data representation Section becomes:

80Octet No.
1-4
5
6-9

10-11
12-15
16-17
18-19
20
21
22
23
24-27
28-31
32-35
36
37
38-41
42
43-46
47

48
49

Contents
Length of section in octets (nn)Number of Section (“5”)
Number of data points where one or more values are specified in Section 7
when a bit map is present, total number of data points when a bit map isabsentData Representation Template Number (see code Table 5.0)
Reference value (R) (IEEE 32-bit floating-point value)
Binary Scale Factor (E)Decimal Scale Factor (D)Number of bits used for each packed value for simple packing, or for eachgroup reference value for complex packing or spatial differencing
Type of original field values (see Code Table 5.1)
Group splitting method used (see Code Table 5.4)
Missing value management used (see Code Table 5.5)
Primary missing value substituteSecondary missing value substituteNG - Number of groups of data values into which field is split
Reference for group widths (see Note 12)
Number of bits used for the group widths (after the reference value in octet 36
has been removed)
Reference for group lengths (see Note 13)
Length increment for the group lengths (see Note 14)
True length of last group
Number of bits used for the scaled group lengths (after subtraction of thereference value given in octets 38-41 and division by the length increment
given in octet 42)
Order of Spatial Differencing (see Code Table 5.6)
Number of octets required in the Data Section to specify the extra
descriptors needed for spatial differencing (octets 6-ww in Data
template 7.3)

In this case, the relevant template is Data Template 7.3, which is the same as Data Template 7.2,
except octets 6-xx are replaced with new information (typed in bold below). When Template 7.3 isused, the Data Section becomes:

Octet No.
1-4
5
6-ww

[ww+1]-xx[xx+1]-yy[yy+1]-zz

Contents
Length of section in octets (nn)Number of Section (“7”)
First value(s) of original (undifferenced) scaled data values, followed by
the overall minimum of the differences. The number of values stored is
1 greater than the order of differentiation, and the field width isdescribed in octet 49 of Data Representation Template 5.3
NG group reference values (X1 in the decoding formula), each of which is
encoded using the number of bits specified in octet 20 of Data Representation
Template 5.0. Bits set to zero shall be appended where necessary to ensure
this sequence of numbers ends on an octet boundary.
NG group widths, each of which is encoded using the number of bits specified
in octet 37 of Data Representation Template 5.2. Bits set to zero shall beappended as necessary to ensure this sequence of numbers ends on an octet
boundary.
NG scaled group lengths, each of which is encoded using the number of bits
specified in octet 47 of Data Representation Template 5.2. Bits set to zero
shall be appended as necessary to ensure this sequence of numbers ends on81

an octet boundary. (see Note 14 of Data Representation Template 5.2)
Packed values (X2 in the decoding formula), where each value is a deviationfrom its respective group reference value.

[zz+1]-nn

We begin this illustration by recalling, after scaling by a D factor of 1, the 25 hypothetical grid pointvalues of 500 hPa geopotential height we used to illustrate the complex packing method:

54560
•

•

54000
•

•

53800
•

•

53600
•

•

53400
•

54570
•

54580
•

•

•

54200
•

•

•

54000
•

•

•

53800
•

•

•

53600
•

54100

53900

53700

53500
•

54590

54600

54300

54400

54100

54200

53900

54000

53700

53800

•

The scanning procedure used is determined by referring to Flag Table 3.4:
Flag Table 3.4:
Bit
Number
1
2
3
4
5-8

Value
0
1
0
1
0
1
0
1

Scanning Mode

Meaning
Points of first row or column scan in the +i (+x) direction
Points of first row or column scan in the -i (-x) direction
Points of first row or column scan in the -j (-y) direction
Points of first row or column scan in the +j (+y) direction
Adjacent points in i (x) direction are consecutive
Adjacent points in j (y) direction is consecutive
All rows scan in the same direction
Adjacent rows scan in opposite directions
Reserved

Notes:(1)i direction: west to east along a parallel or left to right along an X-axis(2)
j direction: south to north along a meridian, or bottom to top along a Y-axis(3)
If bit number 4 is set, the first row scan is as defined by previous flags
When spatial differencing is used, the boustrophedonic scanning procedure is often used.
Although not particularly beneficial in this simple example, it will be applied here to illustrate its
use. This would be documented by setting octet 65 of Grid Definition Template 3.20 (Polar
Stereographic Projection) to 01010000. In this event, the string of values would be:
53400 53500 53600 53700 53800 54000 53900 53800 53700 53600 53800 53900
54000 54100 54200 54400 54300 54200 54100 54000 54560 54570 54580 54590

82

54600The order of the spatial differencing is determined by the value encoded in octet 48 of Data
Representation Template 5.3 via reference to Code Table 5.6:
Code Table 5.6:
Code Figure
0
1
2
3-191
192-254
255

Order of Spatial Differencing

Meaning
Reserved
First-order spatial differencing
Second-order spatial differencing
Reserved
Reserved for local use
Missing

For first order spatial differencing, a field of scaled values f (integers) is replaced by a new field ofvalues g, where g1 = f1, g2 = f2 – f1, …, gn = fn – fn-1. For second order spatial differencing, the fieldof values g is itself replaced by a new field of values h, where h1 = f1, h2 = f2, h3 = g3 – g2, …, hn =gn – gn-1. In this illustration, we will use first order spatial differencing. The result is:
53400 00100 00100 00100 00100 00200 -00100 -00100 -00100 -00100 00200 00100
00100 00100 00100 00200 -00100 -00100 -00100 -00100 00560 00010 00010 00010
00010
Since we are using first order differencing, there will be 2 values (one greater than the order ofdifferencing) stored in octets 6-ww of Template 7.3, g1 and the overall minimum of the difference
values. The value of g1 (53400) requires 15 bits to store. The overall minimum of the difference
values will usually be negative therefore the Note (4) of Data Template 7.3 about the sign bit
applies. The number of bits required to store these two values is therefore 47 (15 + 32). This
number of bits is encoded in octet 49 of Data Representation Template 5.3. The two values
themselves (53400 and –00100) are then stored in octets 6-52 of the Data Section (note that ww
is 52 – this will be used later).
Subtracting the overall minimum of –00100 from each of the difference values (but not from thefirst value g1), the string of numbers becomes:
53400 00200 00200 00200 00200 00300 00000 00000 00000 00000 00300 00200
00200 00200 00200 00300 00000 00000 00000 00000 00660 00110 00110 00110
00110
We shall consider the first 19 and the last 5 difference values as groups. As in the previous
Section, this falls under the category of General group splitting, identified by code figure 1, and thenumber 1 is therefore stored in octet 22 of Section 5. Also as before, there are only two groups totreated, so the value of NG is 2 and this value is stored in octets 32-35 of Section 5.
This data also has no missing values, so the missing value management option is not needed. A
value of 0 (zero) is encoded in octet 23 of Section 5 to indicate this. Since the missing value
management option is not used, octets 24-27 and octets 28-31 will be set to all 1’s (missing
value).
The 19 values in the first group have a minimum (group reference) of 00000 and the 5 values
second group have a minimum of 110. The larger of these two group references – 110 - packs ina “word” 6 bits long, so 6 will be stored in octet 20 of the Data Representation Section. The groupreference values themselves – 00000 and 00110, the X1 values in the GRIB2 compression
formula - are stored in the Data Section. Since 6 bits are required for each value, they will occupy83

octets 53 – 64 of the Data Section (octets [ww+1]-xx, where ww is 52 and xx is 64: xx will be usedlater).
Next, each group reference value is subtracted from each of the scaled integers in its respective
group. The resulting residuals in each group are:Group 1:00200 00200 00200 00200 00300 00000 00000 00000 00000 00300
00200 00200 00200 00200 00300 00000 00000 00000 00000

Group 2:00550 00000 00000 00000 00000

These residuals are the scaled values with the reference removed – the second-order (X2) values
in the GRIB2 compression formula. They are stored in octets [zz+1]-nn of Section 7. The valuesof zz and nn will be determined presently.
Group width is defined as the number of bits used for every X2 value in a group. For each group,
this is the number of bits required to represent the largest of the X2 values in that group. In thisexample, the two group widths are 8 (to represent 300 for Group 1) and 9 (to represent 550 forGroup 2). The smallest of these group widths (8) is stored in octet 36 of the Data Representation
Section. This minimum, or reference, group width is then subtracted from every group widthleaving an array of group width increments. In this case, the group width increments are 0 (8 - 8)
and 1 (9 - 8). The number of bits required to represent the largest of these group width increments(1 bit to store 1) is stored in octet 37 of the Data Representation Section. The group width(increments) themselves (0 and 1) are then stored in octets 65 – 66 of the Data Section (octets[xx+1] – yy, where xx is 64 and yy is 66: yy will be used later) using the number of bits (1) storedin octet 37 of the Data Representation Section for each value.
Group length (Ln) is defined as the number of values in a group. In this case, Ln is 19 for Group 1
and 5 for Group 2. The smallest of these group lengths (ref) is 5. This value (5) is stored in octets
38-41 of the Data Representation Section.
As pointed out in the GRIB2 Manual, complex packing for grid-point is intended to reduce data
section size as compared to simple packing. This is achieved at the expense of extra descriptors
per group. In order to keep the volume of these descriptors as low as possible, group widths andlengths have their minimum value subtracted. As a complement, lengths may be scaled using thelength increment feature.
This may be used in conjunction with splitting algorithm to determine groups of data. Efficientalgorithms with a good quality/price ratio are based on the determination of groups starting from abasic length, say B, and possible extensions of either B or a shorter (incremental) length I. For
example, B and I could be 15 and 3, respectively.
In such a case, all groups (but the last one) will have a minimum length of B and length increments
multiple of I (assuming B is a multiple of I, which is easy to choose). So B would be stored in octets
38-41, I in octet 42, and the effective length of last groups (reference for group lengths notremoved) in octets 43-46.
Finally, the number of bits NL necessary to store the scaled group lengths (the Kn values in Note
14 of the Manual) will be stored in octet 47. Note that as soon as I is bigger than 1, NL is reduced
relative to using an increment of 1, leading to save space in Data Section.
The Kn values are stored in Data Section for all NG groups. The encoded value of Kn for n= NG is
not relevant for decoding, and a zero value may be used.

84

3.4

Structure of a GRIB2 Message with Multiple Data Sets

3.4.1

Iterating the Sections

As was discussed in Layer 1, the GRIB2 regulations state that (A) Sequences of GRIB2 Sections
2 to 7, 3 to 7, or 4 to 7 may be repeated within a single GRIB2 message, (B) All Sections withinsuch repeated sequences must be present and shall appear in the numerical order noted above,and (C) Unrepeated Sections remain in effect until redefined. This is denoted schematically in thetable below by the three groups of vertical bars:
Section 0:
Section 1:
Section 2:
Section 3:
Section 4:
Section 5:
Section 6:
Section 7:
Section 8:

Indicator Section
Identification Section
Local Use Section (optional)
Grid Definition Section
Product Definition Section |Data Representation Section
Bit-Map Section
Data Section
End Section||||repeated|||||repeated |repeated||||An example of a GRIB 2 message with multiple Product Definition, Data Representation, Bit-map,and Data Sections was presented in Section 2.4.3 of Layer 2. That example contained 4
hypothetical 500 hPa geopotential height forecasts - for forecast hours 12, 24, 36, and 48 - asmight be contained on a typical four-panel graphic product. In this section, we present examplesof GRIB2 messages with the same hypothetical 500 hPa geopotential height forecast, first withmultiple Grid Definition Sections and second with multiple Local Use Sections

3.4.2

Example of a GRIB2 Message with Multiple Grid Definition, ProductDefinition and Data Representation Sections

This sample GRIB2 message contains the same hypothetical 500 hPa geopotential height forecast
on two grid projections – a 100 km 5 X 5 grid on a polar stereographic projection and a 10 degree
latitude/longitude grid. The Grid Point Data – Simple Packing compression method is used in bothcases. The minimum and maximum values on the 5 X 5 grid are the same as before – 5340 gpm
and 5460 gpm, respectively. We will assume the forecast values on the latitude/longitude grid
have a minimum of 4980 gpm and a maximum of 5840 gpm. The full GRIB2 message ispresented below. As before, blank lines have been inserted between each section to improvereadability.

85

86

Section
Octet No.

Message
Octet No.

Value

1-4
5-7
7
8
9-16

1-4
5-7
7
8
9-16

GRIB
All 1’s
02
1457“GRIB” (coded according to the International Alphabet No. 5)
Reserved
This GRIB2 message contains meteorological products (the product discipline)
The GRIB Edition Number is 2
The total length of this GRIB message is 1457 octets

1-4
5
6-7
8-9
10
11
12
13-14
15
16
17
18
19
20
21

17-20
21
22-23
24-25
26
27
28
29-30
31
32
33
34
35
36
37

21
1
74
0
1
0
1
2003
5
1
0
0
0
0
1

This Section is 21 octets longThis is Section 1
The originating/generating centre is the U.K. Meteorological Office
There is no originating/generating sub-centre
GRIB Master Tables Version Number 1 is used
No GRIB Local Tables are used
The Reference Time is the start of the forecast
Year = 2003|
Month = April|
Day = 1|
Reference time of data
Hour = 0|
Minute = 0|
Second = 0|This GRIB2 message contains operational productsThis GRIB2 message contains forecast products

1-4
5
6
7-10
11
12
13-14
15
16
17-20
21

38-41
42
43
44-47
48
49
50-51
52
53
54-57
58

65
3
0
25
0
0
2
1
3
6350000
all 1’s

This Section is 65 octets longThis is Section 3
This grid is specified in Code Table 3.1
There are 25 data points in this grid
There is no optional list of numbers defining number of points
Since there is no optional list of numbers, no interpretation is needed
The Grid Definition Template Number is 3.20 – a polar stereographic projection
The earth is assumed to be spherical with radius specified by the data producer
The scale factor for the radius of the spherical earth is 3
The scaled value of the radius of the spherical earth is 6350000 km
There is no scale factor for the major axis of an oblate spheroid earth

Meaning87

22-25
26
27-30
31-34
35-38
39-42
43-46
47
48-51
52-55
56-59
60-63
64
65

59-62
63
64-67
68-71
72-75
76-79
80-83
84
85-88
89-92
93-96
97-100101
102

all 1’s
all 1’s
all 1’s
5540000001
349999999
00000000
40000001
0100000000
100000000
00
01000000

There is no scaled value for the major axis of an oblate spheroid earth
There is no scale factor for the minor axis of an oblate spheroid earth
There is no scaled value for the minor axis of an oblate spheroid earth
There are 5 points along the X-axis (Nx)There are 5 points along the Y-axis (Ny)The latitude of the first grid point is 40.000001 0 north (La1)
The longitude of the first grid point is 349.999999 0 east (or 10.000001 0 west) (Lo1)
No resolution and component flag are turned on (see flag table 3.3 and Note 1)
Dx and Dy are specified at 40.000001 0 north ((LaD)
The 0 degree meridian is parallel to the Y-axis (LoV)The X direction grid length is 100.000 km (Dx)
The Y direction grid length is 100.000 km (Dy)The north pole is on the projection plane and only one projection centre is used
Points scan in the +i (+x) direction, rows in the +j (+Y) direction, adjacent points inthe (x) direction are consecutive, and all rows scan in the same direction

1-4
5
6-7
8-9

104-107108
109-110111-112

34
4
0
0

10
11
12
13
14
15-16
17
18
19-22
23
24
25-28
29
30
31-34

113
114
115
116
117
118-119120
121
122-125126127128-131132
133
134-1363
5
2
All 1’s
All 1’s
3
30
1
12
100
0
500
All 1’s
All 1’s
All 1’s

This Section is 34 octets longThis is Section 4
There are no coordinate values after the Product Definition Template
The Product Definition Template Number is 4.0 – an analysis or forecast at ahorizontal level or in a horizontal layer at a point in time
The parameter category is 3 – mass products
The parameter number is 5 – geopotential height (in geopotential meters)
A forecast generated this product (the generating process)No information on the background generating process is provided
No further information on the forecast generating process is provided
The observational data cut-off was 3 hours after the reference time
The observational data cut-off was 30 minutes after the observational cut-off hour
The time is given in hours
The forecast time is 12 hours after the reference time
The first fixed surface is a pressure surface
The scale factor of first fixed surface is 0
The scaled value of first fixed surface is 500 (500 hPa)
There is no second fixed surface
The scale factor of the second fixed surface is missing since it is not needed
The scaled value of the second fixed surface is missing since it is not needed

88

1-4
5
6-9
10-11

137-140
141
142-145
146-147

21
5
25
0

12-15
16-17
18-19
20
21

148-151
152-153154-155
156
157

53400
0
1
11
0

This Section is 21 octets longThis is Section 5
There are 25 data points for which values are specified in Section
The Data Representation Template Number is 5.0 - Grid point data – simple
packing
The reference value (R) is 53400.0 (IEEE 32-bit floating-point value)
The binary scale factor (E) is 0: binary scaling is not used
The decimal scale factor (D) is 1: precision is 0.1 geopotential meters
11 bits are used for each packed value in the Data Section
The original field values were floating point numbers

1-4
5
6

158-161
162
163

6
6
0

This Section is 6 octets longThis is Section 6
There is no bit-map

1-4
5
6-40

164-167168
169-20340
This Section is 40 octets long
7
This is Section 7
25 scaled integers, 25 binary data values, each using 11 bits. The values thus occupy 275 bits .
last 5 bits set to 0 4 additional bits set to zero are necessary for the section to end on an octet
boundary.

1-4
5
6
7-10
11
12
13-14
15
16
17-20
21
22-25
26
27-30

204-207208
209
210-213214
215
216-217218
219
220-223224
225-228229
230-233

72
3
0
684
0
0
1
1
3
6350000
all 1’s
all 1’s
all 1’s
all 1’s

This Section is 72 octets longThis is Section 3
This grid is specified in Code Table 3.1
There are 684 data points in this grid
There is no optional list of numbers defining the number of points
Since there is no optional list of numbers, no interpretation is needed
The Grid Definition Template Number is 3.1 a latitude-longitude grid
The earth is assumed to be spherical with radius specified by the data producer
The scale factor for the radius of the spherical earth is 3
The scaled value of the radius of the spherical earth is 6350000 km
There is no scale factor for the major axis of an oblate spheroid earth
There is no scaled value for the major axis of an oblate spheroid earth
There is no scale factor for the minor axis of an oblate spheroid earth
There is no scaled value for the minor axis of an oblate spheroid earth8931-34
35-38
39-42
43-46
47-50

234-237
238-241242-245
246-249
250-253

36
19
0
all 1’s
90000000

51-54
55

254-257
258

0000000
00111000

56-59
60-63
64-67
68-71
72

259-262263-266267-270271-274275

90000000
350000000
10000000
10000000
01000000

1-4
5
6-7
8-9

276-279280
281-282283-284

34
4
0
0

10
11
12
13
14
15-16
17
18
19-22
23
24
25-28
29

285
286
287
288
289
290-291292
293
294-297298
299
300-303304

3
5
2
All 1’s
All 1’s
3
30
1
12
100
0
500
All 1’s

There are 36 points along a parallel (Ni)There are 19 points along a meridian (Nj)
The basic angle of all latitudes and longitudes is 1 degree
The unit of the basic angle of all latitudes and longitudes is 10-6 degrees
The latitude of the first grid point (La1) is –90.000000o. Bit 1 is set to 1 to indicate
negative (south) latitude.
The longitude of the first grid point (Lo1) is 0.000000o
I and j direction increments are given. Resolved u- and v- components of vector
quantities are relative to the defined grid in the direction of increasing x and ycoordinates respectively.
The latitude of the last grid point is +90.000000o
The longitude of the last grid point is +350.000000o
The i direction increment is 10.000000o
The j direction increment is 10.000000o
Points in the first row scan in the +I (+x) direction. Points in the first column scan in
the +j (+y) direction. Resolved u- and v- components of vector quantities are
relative to easterly and northerly directions.
This Section is 34 octets longThis is Section 4
There are no coordinate values after the Product Definition Template
The Product Definition Template Number is 4.0 – an analysis or forecast at ahorizontal level or in a horizontal layer at a point in time
The parameter category is 3 – mass products
The parameter number is 5 – geopotential height (in geopotential meters)
A forecast generated this product (the generating process)No information on the background generating process is provided
No further information on the forecast generating process is provided
The observational data cut-off was 3 hours after the reference time
The observational data cut-off was 30 minutes after the observational cut-off hour
The time is given in hours
The forecast time is 12 hours after the reference time
The first fixed surface is a pressure surface
The scale factor of first fixed surface is 0
The scaled value of first fixed surface is 500 (500 hPa)
There is no second fixed surface

90

30
31-34

305
306-309

All 1’s
All 1’s

The scale factor of the second fixed surface is missing since it is not needed
The scaled value of the second fixed surface is missing since it is not needed

1-4
5
6-9
10-11

310-313314
315-318319-320

21
5
25
0

12-15
16-17
18-19
20
21

321-324325-326327-328
329
330

49800
0
1
13
0

This Section is 21 octets longThis is Section 5
There are 25 data points for which values are specified in Section
The Data Representation Template Number is 5.0 - Grid point data – simple
packing
The reference value (R) is 49800.0 (IEEE 32-bit floating-point value)
The binary scale factor (E) is 0: binary scaling is not used
The decimal scale factor (D) is 1: precision is 0.1 geopotential meters
13 bits are used for each packed value in the Data Section
The original field values were floating point numbers

1-4
5
6

331-334
335
336

6
6
0

This Section is 6 octets longThis is Section 6
There is no bit-map

1-4
56-1117337-340341
270-1453

1000
This Section is 1000 octets long
7
This is Section 7
684 scaled integers, 684 binary data values (36 X 19), each using 13 bits. The values thus occupy 8892
last 4 bits set to 0 bits, or 1111 octets plus 4 more bits. 4 additional bits set to zero are therefore
necessary to end on an octet boundary.

1-4

1454-11457

7777“7777” coded according to the International Alphabet No. 5

91

3.4.3

Example of a GRIB2 Message with Multiple Grid Definition, Product Definition,
Data Representation and Local Use Sections

The last sample GRIB2 message contains two operational test 48-hour forecasts of 500 hPa
geopotential height on the same 10 degree latitude/longitude grid made by the same forecast
model. It incorporates the Local Use Section to add information that allows the user to distinguishbetween the two forecasts. As in the previous example, simple packing is used, and the forecast
values have a minimum of 4980 gpm and a maximum of 5840 gpm. The full GRIB2 message ispresented below. As before, blank lines have been inserted between each section to improvereadability.

92Section
Octet No.

Message
Octet No.

Value

1-4
5-7
7
8
9-16

1-4
5-7
7
8
9-16

GRIB
All 1’s022694“GRIB” (coded according to the International Alphabet No. 5)
Reserved
This GRIB2 message contains meteorological products (the product discipline)
The GRIB Edition Number is 2
The total length of this GRIB message is 2694 octets

1-4
5
6-7
8-9
10
11
12
13-14
15
16
17
18
19
20
21

17-20
21
22-23
24-25
26
27
28
29-30
31
32
33
34
35
36
37

21
1
74
0
1
0
1
2003
5
1
0
0
0
1
1

This Section is 21 octets longThis is Section 1
The originating/generating centre is the U.K. Meteorological Office
There is no originating/generating sub-centre
GRIB Master Tables Version Number 1 is used
No GRIB Local Tables are used
The Reference Time is the start of the forecast
Year = 2003|
Month = April|
Day = 1|
Reference time of data
Hour = 0|
Minute = 0|
Second = 0|This GRIB2 message contains operational test productsThis GRIB2 message contains forecast products

1-4
5
6-79

38-41
42
43-116

79
2
TEXT MESSAGE

This Section is 79 octets longThis is Section 2“THIS FORECAST WAS MADE WITH THE OPERATIONAL FINITE
DIFFERENCE FORMULATION” (Coded according to the International
Alphabet No. 5)

1-4
5
6
7-10
11

117-120
121122
123-126
127

72
3
0
684
0

This Section is 72 octets longThis is Section 3
This grid is specified in Code Table 3.1
There are 684 data points in this grid
There is no optional list of numbers defining the number of points

Meaning

93

12
13-14
15
16
17-20
21
22-25
26
27-30
31-34
35-38
39-42
43-46
47-50

128
129-130131132
133-136
137
138-141142
143-146147-150
151-154155-158
159-162
163-16601
1
36350000
all 1’s
all 1’s
all 1’s
all 1’s36
19
0
all 1’s
90000000

51-54
55

167-170
1710000000
00111000

56-59
60-63
64-67
68-71
72

172-175
176-179180-183
184-187188

90000000
350000000
10000000
10000000
01000000

1-4
5
6-7
8-9

189-192
193
194-195
196-197

34
4
0
0

10
11
12
13

198
199
200
201

3
5
2
All 1’sSince there is no optional list of numbers, no interpretation is needed
The Grid Definition Template Number is 3.1 a latitude-longitude grid
The earth is assumed to be spherical with radius specified by the data producer
The scale factor for the radius of the spherical earth is 3
The scaled value of the radius of the spherical earth is 6350000 km
There is no scale factor for the major axis of an oblate spheroid earth
There is no scaled value for the major axis of an oblate spheroid earth
There is no scale factor for the minor axis of an oblate spheroid earth
There is no scaled value for the minor axis of an oblate spheroid earth
There are 36 points along a parallel (Ni)There are 19 points along a meridian (Nj)
The basic angle of all latitudes and longitudes is 1 degree
The unit of the basic angle of all latitudes and longitudes is 10-6 degrees
The latitude of the first grid point (La1) is –90.000000o. Bit 1 is set to 1 to indicate
negative (south) latitude.
The longitude of the first grid point (Lo1) is 0.000000o
I and j direction increments are given. Resolved u- and v- components of vector
quantities are relative to the defined grid in the direction of increasing x and ycoordinates respectively.
The latitude of the last grid point is +90.000000o
The longitude of the last grid point is +350.000000o
The i direction increment is 10.000000o
The j direction increment is 10.000000o
Points in the first row scan in the +I (+x) direction. Points in the first column scan in
the +j (+y) direction. Resolved u- and v- components of vector quantities are
relative to easterly and northerly directions.
This Section is 34 octets longThis is Section 4
There are no coordinate values after the Product Definition Template
The Product Definition Template Number is 4.0 – an analysis or forecast at ahorizontal level or in a horizontal layer at a point in time
The parameter category is 3 – mass products
The parameter number is 5 – geopotential height (in geopotential meters)
A forecast generated this product (the generating process)No information on the background generating process is provided

94

14
15-16
17
18
19-22
23
24
25-28
29
30
31-34

202
203-204205
206
207-210211
212
213-216217
218
219-222

All 1’s
3
30
1
48
100
0
500
All 1’s
All 1’s
All 1’s

No further information on the forecast generating process is provided
The observational data cut-off was 3 hours after the reference time
The observational data cut-off was 30 minutes after the observational cut-off hour
The time is given in hours
The forecast time is 48 hours after the reference time
The first fixed surface is a pressure surface
The scale factor of first fixed surface is 0
The scaled value of first fixed surface is 500 (500 hPa)
There is no second fixed surface
The scale factor of the second fixed surface is missing since it is not needed
The scaled value of the second fixed surface is missing since it is not needed

1-4
5
6-9
10-11

223-226227
228-231232-233

21
5
25
0

12-15
16-17
18-19
20
21

234-237
238-239240-241
242
243

49800
0
1
13
0

This Section is 21 octets longThis is Section 5
There are 25 data points for which values are specified in Section
The Data Representation Template Number is 5.0 - Grid point data – simple
packing
The reference value (R) is 49800.0 (IEEE 32-bit floating-point value)
The binary scale factor (E) is 0: binary scaling is not used
The decimal scale factor (D) is 1: precision is 0.1 geopotential meters
13 bits are used for each packed value in the Data Section
The original field values were floating point numbers

1-4
5
6

244-247
248
249

6
6
0

This Section is 6 octets longThis is Section 6
There is no bit-map

1-4
56-1117250-253254
255-1366

1000
This Section is 1000 octets long
7
This is Section 7
684 scaled integers, 684 binary data values (36 X 19), each using 13 bits. The values thus occupy 8892
last 4 bits set to 0 bits, or 1111 octets plus 4 more bits. 4 additional bits set to zero are therefore
necessary to end on an octet boundary.

1-4
5
6-74

1367-1370
1371
1372-1440

74
2
TEXT MESSAGE

This Section is 74 octets longThis is Section 2“THIS FORECAST WAS MADE WITH THE REVISED FINITE

95

DIFFERENCE FORMULATION” (Coded according to the International
Alphabet No. 5)
1-4
5
6
7-10
11
12
13-14
15
16
17-20
21
22-25
26
27-30
31-34
35-38
39-42
43-46
47-50

1441-1444
1445
1446
1447-1450
1451
1452
1453-1454
1455
1456
1457-1460
1461
1462-1465
1466
1467-1470
1471-1474
1475-1478
1479-1482
1483-1486
1487-1490

72
3
0
684
0
0
1
1
3
6350000
all 1’s
all 1’s
all 1’s
all 1’s36
19
0
all 1’s
90000000

51-54
55

1491-1494
1495

0000000
00111000

56-59
60-63
64-67
68-71
72

1496-1499
1500-1503
1504-1507
1508-1511
1512

90000000
350000000
10000000
10000000
01000000

This Section is 72 octets longThis is Section 3
This grid is specified in Code Table 3.1
There are 684 data points in this grid
There is no optional list of numbers defining the number of points
Since there is no optional list of numbers, no interpretation is needed
The Grid Definition Template Number is 3.1 a latitude-longitude grid
The earth is assumed to be spherical with radius specified by the data producer
The scale factor for the radius of the spherical earth is 3
The scaled value of the radius of the spherical earth is 6350000 km
There is no scale factor for the major axis of an oblate spheroid earth
There is no scaled value for the major axis of an oblate spheroid earth
There is no scale factor for the minor axis of an oblate spheroid earth
There is no scaled value for the minor axis of an oblate spheroid earth
There are 36 points along a parallel (Ni)There are 19 points along a meridian (Nj)
The basic angle of all latitudes and longitudes is 1 degree
The unit of the basic angle of all latitudes and longitudes is 10-6 degrees
The latitude of the first grid point (La1) is –90.000000o. Bit 1 is set to 1 to indicate
negative (south) latitude.
The longitude of the first grid point (Lo1) is 0.000000o
I and j direction increments are given. Resolved u- and v- components of vector
quantities are relative to the defined grid in the direction of increasing x and ycoordinates respectively.
The latitude of the last grid point is +90.000000o
The longitude of the last grid point is +350.000000o
The i direction increment is 10.000000o
The j direction increment is 10.000000o
Points in the first row scan in the +I (+x) direction. Points in the first column scan in
the +j (+y) direction. Resolved u- and v- components of vector quantities are
relativeto easterly and northerly directions.

96

1-4
5
6-7
8-9

1513-1516
1517
1518-1519
1520-1521

34
4
0
0
3
5
2
All 1’s
All 1’s
3
30
1
48
100
0
500
All 1’s
All 1’s
All 1’s

This Section is 34 octets longThis is Section 4
There are no coordinate values after the Product Definition Template
The Product Definition Template Number is 4.0 – an analysis or forecast at ahorizontal level or in a horizontal layer at a point in time
The parameter category is 3 – mass products
The parameter number is 5 – geopotential height (in geopotential meters)
A forecast generated this product (the generating process)No information on the background generating process is provided
No further information on the forecast generating process is provided
The observational data cut-off was 3 hours after the reference time
The observational data cut-off was 30 minutes after the observational cut-off hour
The time is given in hours
The forecast time is 48 hours after the reference time
The first fixed surface is a pressure surface
The scale factor of first fixed surface is 0
The scaled value of first fixed surface is 500 (500 hPa)
There is no second fixed surface
The scale factor of the second fixed surface is missing since it is not needed
The scaled value of the second fixed surface is missing since it is not needed

10
11
12
13
14
15-16
17
18
19-22
23
24
25-28
29
30
31-34

1522
1523
1524
1525
1526
1527-1528
1529
1530
1531-1534
1535
1536
1537-1540
1541
1542
1543-1546

1-4
5
6-9
10-11

1547-1550
1551
1552-1555
1556-1557

21
5
25
0

12-15
16-17
18-19
20
21

1558-1561
1562-1563
1564-1565
1566
1567

49800
0
1
13
0

This Section is 21 octets longThis is Section 5
There are 25 data points for which values are specified in Section
The Data Representation Template Number is 5.0 - Grid point data – simple
packing
The reference value (R) is 49800.0 (IEEE 32-bit floating-point value)
The binary scale factor (E) is 0: binary scaling is not used
The decimal scale factor (D) is 1: precision is 0.1 geopotential meters
13 bits are used for each packed value in the Data Section
The original field values were floating point numbers

1-4
5
6

1568-1571
1572
1573

6
6
0

This Section is 6 octets longThis is Section 6
There is no bit-map

97

1-4
5
6-11171574-1577
1578
1579-2690

1000
This Section is 1000 octets long
7
This is Section 7
684 scaled integers, 684 binary data values (36 X 17), each using 13 bits. The values thus occupy 8892
last 4 bits set to 0 bits, or 1111 octets plus 4 more bits. 4 additional bits set to zero are therefore
necessary to end on an octet boundary.

1-4

2691-2694

7777“7777” coded according to the International Alphabet No. 5

98

99