NCEPLIBS-g2  3.5.0
gridtemplates Module Reference

This Fortran module contains info on all the available GRIB2 Grid Definition Templates used in [Section 3 - the Grid Definition Section (GDS)](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect3.shtml). More...

Data Types

type  gridtemplate
 

Functions/Subroutines

subroutine extgridtemplate (number, list, nummap, map)
 Generate the remaining octet map for a given Grid Definition Template, if required. More...
 
integer function getgdtlen (number)
 This function returns the initial length (number of entries) in the static part of specified Grid Definition Template. More...
 
integer function getgridindex (number)
 Return the index of specified Grid Definition Template. More...
 
subroutine getgridtemplate (number, nummap, map, needext, iret)
 Get the grid template information for a specified Grid Definition Template. More...
 

Variables

integer, parameter maxlen = 200
 maximum number of octets in mapgrid More...
 
integer, parameter maxtemp = 31
 maximum number of entries in the template More...
 
type(gridtemplate), dimension(maxtemptemplates
 a gridtemplate type More...
 

Detailed Description

This Fortran module contains info on all the available GRIB2 Grid Definition Templates used in [Section 3 - the Grid Definition Section (GDS)](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect3.shtml).

Each Template has three parts:

  1. The number of entries in the template (mapgridlen);
  2. A map of the template (mapgrid), which contains the number of octets in which to pack each of the template values;
  3. A logical value (needext) that indicates whether the Template needs to be extended. In some cases the number of entries in a template can vary depending upon values specified in the "static" part of the template. (See Template 3.120 as an example).

This module also contains two subroutines:

Array mapgrid contains the number of bytes in which the corresponding template values will be stored. A negative value in mapgrid is used to indicate that the corresponding template entry can contain negative values. This information is used later when packing/unpacking the template data values.

Negative data values in GRIB are stored with the left most bit set to one, and a negative number of bytes value in mapgrid indicates that this possibility should be considered. The number of bytes used to store the data value in this case would be the absolute value of the negative value in mapgrid.

Author
Stephen Gilbert
Date
2000-05-09

Data Type Documentation

◆ gridtemplates::gridtemplate

type gridtemplates::gridtemplate

Definition at line 45 of file gridtemplates.F90.

Data Fields
integer, dimension(maxlen) mapgrid
integer mapgridlen
logical needext
integer template_num

Function/Subroutine Documentation

◆ extgridtemplate()

subroutine gridtemplates::extgridtemplate ( integer, intent(in)  number,
integer, dimension(*), intent(in)  list,
integer, intent(out)  nummap,
integer, dimension(*), intent(out)  map 
)

Generate the remaining octet map for a given Grid Definition Template, if required.

Some Templates can vary depending on data values given in an earlier part of the Template, and it is necessary to know some of the earlier entry values to generate the full octet map of the Template.

Parameters
[in]numberNN, indicating the number of the Grid Definition Template 3.NN that is being requested.
[in]listThe list of values for each entry in the Grid Definition Template.
[out]nummapNumber of entries in the Template.
[out]mapAn array containing the number of octets that each template entry occupies when packed up into the GDS.
Author
Stephen Gilbert
Date
2000-05-09

Definition at line 332 of file gridtemplates.F90.

References getgridindex(), and templates.

Referenced by addgrid(), gf_unpack3(), and unpack3().

◆ getgdtlen()

integer function gridtemplates::getgdtlen ( integer, intent(in)  number)

This function returns the initial length (number of entries) in the static part of specified Grid Definition Template.

Parameters
[in]numberNN, indicating the number of the Grid Definition Template that is being requested.
Returns
Number of entries in the static part of the grid definition template, or 0, if requested template is not found.
Author
Stephen Gilbert
Date
2004-05-11

Definition at line 400 of file gridtemplates.F90.

References getgridindex(), and templates.

◆ getgridindex()

integer function gridtemplates::getgridindex ( integer, intent(in)  number)

Return the index of specified Grid Definition Template.

Parameters
[in]numberNN, indicating the number of the Grid Definition Template 3.NN that is being requested.
Returns
Index of the grid template in array templates, if template exists. -1, otherwise.
Author
Stephen Gilbert
Date
2001-06-28

Definition at line 255 of file gridtemplates.F90.

References maxtemp, and templates.

Referenced by extgridtemplate(), getgdtlen(), and getgridtemplate().

◆ getgridtemplate()

subroutine gridtemplates::getgridtemplate ( integer, intent(in)  number,
integer, intent(out)  nummap,
integer, dimension(*), intent(out)  map,
logical, intent(out)  needext,
integer, intent(out)  iret 
)

Get the grid template information for a specified Grid Definition Template.

The number of entries in the template is returned along with a map of the number of octets occupied by each entry. Also, a flag is returned to indicate whether the template would need to be extended.

Parameters
[in]numberNN, indicating the number of the Grid Definition Template that is being requested.
[out]nummapNumber of entries in the Template.
[out]mapAn array containing the number of octets that each template entry occupies when packed up into the GDS.
[out]needextLogical variable indicating whether the Grid Defintion Template has to be extended.
[out]iretError return code.
  • 0 no error.
  • 1 Undefine Grid Template number.
Author
Stephen Gilbert
Date
2000-05-09

Definition at line 291 of file gridtemplates.F90.

References getgridindex(), and templates.

Referenced by addgrid(), gf_unpack3(), and unpack3().

Variable Documentation

◆ maxlen

integer, parameter gridtemplates::maxlen = 200

maximum number of octets in mapgrid

Definition at line 42 of file gridtemplates.F90.

◆ maxtemp

integer, parameter gridtemplates::maxtemp = 31

maximum number of entries in the template

Definition at line 43 of file gridtemplates.F90.

Referenced by getgridindex().

◆ templates

type(gridtemplate), dimension(maxtemp) gridtemplates::templates

a gridtemplate type

Definition at line 52 of file gridtemplates.F90.

Referenced by extgridtemplate(), getgdtlen(), getgridindex(), and getgridtemplate().