NCEPLIBS-g2  3.5.0
drstemplates Module Reference

Handles Data Representation Templates used in Section 5. More...

Data Types

type  drstemplate
 This type holds information about a DRS template. More...
 

Functions/Subroutines

subroutine extdrstemplate (number, list, nummap, map)
 Generate the remaining octet map for a given Data Representation Template, if required. More...
 
integer function getdrsindex (number)
 Return the index of specified Data Representation Template in array templates. More...
 
subroutine getdrstemplate (number, nummap, map, needext, iret)
 Return DRS template information for a specified Data Representation Template. More...
 

Variables

integer j
 loop iterator More...
 
integer, parameter maxlen = 200
 maximum number of octets in mapdrs More...
 
integer, parameter maxtemp = 9
 maximum number of entries in the template More...
 
type(drstemplate), dimension(maxtemptemplates
 template in type of drstemplate More...
 

Detailed Description

Handles Data Representation Templates used in Section 5.

(See https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect5.shtml.)

Each Template has three parts:

  1. The number of entries in the template (mapdrslen);
  2. A map of the template (mapdrs), 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.

This module also contains two subroutines. Subroutine getdrstemplate() returns the octet map for a specified Template number, and subroutine extdrstemplate() will calculate the extended octet map of an appropriate template given values for the "static" part of the template.

Note
Array mapdrs contains the number of octets in which the corresponding template values will be stored. A negative value in mapdrs is used to indicate that the corresponding template entry can contain negative values. This information is used later when packing (or 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 octets value in mapdrs indicates that this possibility should be considered. The number of octets used to store the data value in this case would be the absolute value of the negative value in mapdrs.
Author
Stephen Gilbert
Date
2001-04-03

Data Type Documentation

◆ drstemplates::drstemplate

type drstemplates::drstemplate

This type holds information about a DRS template.

Definition at line 41 of file drstemplates.F90.

Data Fields
integer, dimension(maxlen) mapdrs Number of octets in which to pack each value.
integer mapdrslen The number of entries in the template.
logical needext Does template need to be extended?
integer template_num Template number.

Function/Subroutine Documentation

◆ extdrstemplate()

subroutine drstemplates::extdrstemplate ( 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 Data Representation 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.

Currently no templates have been implemented which require an extension.

Parameters
[in]numberNN, indicating the number of the Data Representation Template 5.NN that is being requested.
[in]listThe list of values for each entry in the Data Representation Template 5.NN.
[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-11

Definition at line 201 of file drstemplates.F90.

References getdrsindex(), and templates.

Referenced by gf_unpack5(), and unpack5().

◆ getdrsindex()

integer function drstemplates::getdrsindex ( integer, intent(in)  number)

Return the index of specified Data Representation Template in array templates.

Parameters
[in]numberthe Data Representation Template number.
Returns
Index of DRT 5.NN in array templates, if template exists. = -1, otherwise.
Author
Stephen Gilbert
Date
2001-06-28

Definition at line 121 of file drstemplates.F90.

References j, maxtemp, and templates.

Referenced by extdrstemplate(), and getdrstemplate().

◆ getdrstemplate()

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

Return DRS template information for a specified Data Representation 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 Data Representation Template 5.NN 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 DRS.
[out]needextLogical variable indicating whether the Data Representation Template has to be extended.
[out]iretError return code.
  • 0 = no error
  • 1 = Undefined Data Representation Template number.
Author
Stephen Gilbert
Date
2000-05-11

Definition at line 156 of file drstemplates.F90.

References getdrsindex(), and templates.

Referenced by addfield(), gf_unpack5(), and unpack5().

Variable Documentation

◆ j

integer drstemplates::j

loop iterator

Definition at line 38 of file drstemplates.F90.

Referenced by dec_png(), enc_png(), getdrsindex(), and int_dec_jpeg2000().

◆ maxlen

integer, parameter drstemplates::maxlen = 200

maximum number of octets in mapdrs

Definition at line 36 of file drstemplates.F90.

◆ maxtemp

integer, parameter drstemplates::maxtemp = 9

maximum number of entries in the template

Definition at line 37 of file drstemplates.F90.

Referenced by getdrsindex().

◆ templates

type(drstemplate), dimension(maxtemp) drstemplates::templates

template in type of drstemplate

Simple Packing Complex Packing Complex Packing - Spatial Diff Simple Packing - Spectral Data Complex Packing - Spectral Data JPEG2000 Encoding PNG Encoding JPEG2000 Encoding PNG Encoding

Definition at line 48 of file drstemplates.F90.

Referenced by extdrstemplate(), getdrsindex(), and getdrstemplate().