NCEPLIBS-g2  3.5.0
g2unpack.F90 File Reference

Unpack Sections of GRIB2 messages. More...

Go to the source code of this file.

Functions/Subroutines

subroutine gf_unpack1 (cgrib, lcgrib, iofst, ids, idslen, ierr)
 Unpack Section 1 (Identification Section) of a GRIB2 message, starting at octet 6 of that Section. More...
 
subroutine gf_unpack2 (cgrib, lcgrib, iofst, lencsec2, csec2, ierr)
 Unpack Section 2 (Local Use Section) of a GRIB2 message. More...
 
subroutine gf_unpack3 (cgrib, lcgrib, iofst, igds, igdstmpl, mapgridlen, ideflist, idefnum, ierr)
 Unpack Section 3 (Grid Definition Section) of a GRIB2 message, starting at octet 6 of that Section. More...
 
subroutine gf_unpack4 (cgrib, lcgrib, iofst, ipdsnum, ipdstmpl, mappdslen, coordlist, numcoord, ierr)
 Unpack Section 4 (Product Definition Section) of a GRIB2 message, starting at octet 6 of that Section. More...
 
subroutine gf_unpack5 (cgrib, lcgrib, iofst, ndpts, idrsnum, idrstmpl, mapdrslen, ierr)
 Unpack Section 5 (Data Representation Section) of a GRIB2 message, starting at octet 6 of that Section. More...
 
subroutine gf_unpack6 (cgrib, lcgrib, iofst, ngpts, ibmap, bmap, ierr)
 Unpack Section 6 (Bit-Map Section) of a GRIB2 message, starting at octet 6 of that Section. More...
 
subroutine gf_unpack7 (cgrib, lcgrib, iofst, igdsnum, igdstmpl, idrsnum, idrstmpl, ndpts, fld, ierr)
 Unpack Section 7 (Data Section) of a GRIB2 message. More...
 

Detailed Description

Unpack Sections of GRIB2 messages.

Author
Edward Hartnett
Date
Jan 31, 2024

Definition in file g2unpack.F90.

Function/Subroutine Documentation

◆ gf_unpack1()

subroutine gf_unpack1 ( character(len=1), dimension(lcgrib), intent(in)  cgrib,
integer, intent(in)  lcgrib,
integer, intent(inout)  iofst,
integer, dimension(:), pointer  ids,
integer, intent(out)  idslen,
integer, intent(out)  ierr 
)

Unpack Section 1 (Identification Section) of a GRIB2 message, starting at octet 6 of that Section.

Parameters
[in]cgribCharacter array that contains the GRIB2 message.
[in]lcgribLength (in bytes) of GRIB message array cgrib.
[in,out]iofstBit offset of the beginning/end(returned) of Section 1.
[out]idsPointer to integer array containing information read from Section 1, the Identification section.
  • ids(1) Identification of originating Centre (Table 0).
  • ids(2) Identification of originating Sub-centre.(Table C). ).
  • ids(3) GRIB Master Tables Version Number (Code Table 1.0).
  • ids(4) GRIB Local Tables Version Number (Code Table 1.1).
  • ids(5) Significance of Reference Time (Code Table 1.2).
  • ids(6) Year (4 digits).
  • ids(7) Month
  • ids(8) Day
  • ids(9) Hour
  • ids(10) Minute
  • ids(11) Second
  • ids(12) Production status of processed data (Code Table 1.3).
  • ids(13) Type of processed data (Code Table 1.4).
[out]idslenNumber of elements in ids.
[out]ierrError return code.
  • 0 no error.
  • 6 memory allocation error.
Author
Stephen Gilbert
Date
2000-05-26

Definition at line 41 of file g2unpack.F90.

References g2_gbytec().

Referenced by getgb2s2(), and gf_getfld().

◆ gf_unpack2()

subroutine gf_unpack2 ( character(len = 1), dimension(lcgrib), intent(in)  cgrib,
integer, intent(in)  lcgrib,
integer, intent(inout)  iofst,
integer, intent(out)  lencsec2,
character(len = 1), dimension(:), pointer  csec2,
integer, intent(out)  ierr 
)

Unpack Section 2 (Local Use Section) of a GRIB2 message.

Parameters
[in]cgribCharacter array that contains the GRIB2 message.
[in]lcgribLength (in bytes) of GRIB message array cgrib.
[in,out]iofstBit offset of the beginning/end (returned) of Section 2.
[out]lencsec2Length (in octets) of Local Use data.
[out]csec2Pointer to a character*1 array containing local use data. Caller should pass in an unassociated pointer, and must free memory allocated by this subroutine by calling deallocate on this pointer.
[out]ierrError return code.
  • 0 no error.
  • 2 Array passed is not section 2.
  • 6 memory allocation error.
Author
Stephen Gilbert
Date
2002-04-09

Definition at line 99 of file g2unpack.F90.

References g2_gbytec().

Referenced by getgb2l2(), and gf_getfld().

◆ gf_unpack3()

subroutine gf_unpack3 ( character(len = 1), dimension(lcgrib), intent(in)  cgrib,
integer, intent(in)  lcgrib,
integer, intent(inout)  iofst,
integer, dimension(5), intent(out)  igds,
integer, dimension(:), pointer  igdstmpl,
integer, intent(out)  mapgridlen,
integer, dimension(:), pointer  ideflist,
integer, intent(out)  idefnum,
integer, intent(out)  ierr 
)

Unpack Section 3 (Grid Definition Section) of a GRIB2 message, starting at octet 6 of that Section.

Parameters
[in]cgribCharacter array that contains the GRIB2 message.
[in]lcgribLength (in bytes) of GRIB message array cgrib.
[in,out]iofstBit offset of the beginning/end(returned) of Section 3.
[out]igdsContains information read from the appropriate GRIB Grid Definition Section 3 for the field being returned. Must be dimensioned >= 5.
  • igds(1) Source of grid definition (see Code Table 3.0).
  • igds(2) Number of grid points in the defined grid.
  • igds(3) Number of octets needed for each additional grid points definition. Used to define number of points in each row (or column) for non-regular grids. = 0, if using regular grid.
  • igds(4) Interpretation of list for optional points definition (Code Table 3.11).
  • igds(5) Grid Definition Template Number (Code Table 3.1).
[out]igdstmplContains the data values for the specified Grid Definition Template (NN=igds(5)). Each element of this integer array contains an entry (in the order specified) of Grid Defintion Template 3.NN. A safe dimension for this array can be obtained in advance from maxvals(2), which is returned from subroutine gribinfo().
[out]mapgridlenNumber of elements in igdstmpl. i.e. number of entries in Grid Defintion Template 3.NN (NN=igds(5)).
[out]ideflist(Used if igds(3) .ne. 0) This array contains the number of grid points contained in each row (or column). (part of Section 3) A safe dimension for this array can be obtained in advance from maxvals(3), which is returned from subroutine gribinfo().
[out]idefnum(Used if igds(3) .ne. 0) The number of entries in array ideflist. i.e. number of rows (or columns) for which optional grid points are defined.
[out]ierrError return code.
  • 0 no error.
  • 5 "GRIB" message contains an undefined Grid Definition Template.
  • 6 memory allocation error.
Author
Stephen Gilbert
Date
2000-05-26

Definition at line 182 of file g2unpack.F90.

References gridtemplates::extgridtemplate(), g2_gbytec(), g2_gbytesc(), and gridtemplates::getgridtemplate().

Referenced by getdim(), getgb2s2(), getpoly(), and gf_getfld().

◆ gf_unpack4()

subroutine gf_unpack4 ( character(len = 1), dimension(lcgrib), intent(in)  cgrib,
integer, intent(in)  lcgrib,
integer, intent(inout)  iofst,
integer, intent(out)  ipdsnum,
integer, dimension(:), pointer  ipdstmpl,
integer  mappdslen,
real, dimension(:), pointer  coordlist,
integer, intent(out)  numcoord,
integer, intent(out)  ierr 
)

Unpack Section 4 (Product Definition Section) of a GRIB2 message, starting at octet 6 of that Section.

Parameters
[in]cgribCharacter array that contains the GRIB2 message.
[in]lcgribLength (in bytes) of GRIB message array cgrib.
[in,out]iofstBit offset of the beginning/end(returned) of Section 4.
[out]ipdsnumProduct Definition Template Number (Code Table 4.0).
[out]ipdstmplContains the data values for the Product Definition Template specified by ipdsnum. A safe dimension for this array can be obtained in advance from maxvals(4), which is returned from subroutine gribinfo.
[out]mappdslenNumber of elements in ipdstmpl. i.e. number of entries in Product Defintion Template specified by ipdsnum.
[out]coordlistPointer to real array containing floating point values intended to document the vertical discretisation associated to model data on hybrid coordinate vertical levels (part of Section 4). Must be deallocated by caller.
[out]numcoordNumber of values in array coordlist.
[out]ierrError return code.
  • 0 no error.
  • 5 "GRIB" message contains an undefined Grid Definition Template.
  • 6 memory allocation error.
Author
Stephen Gilbert
Date
2000-05-26

Definition at line 332 of file g2unpack.F90.

References pdstemplates::extpdstemplate(), g2_gbytec(), g2_gbytescr(), pdstemplates::getpdstemplate(), and rdieee().

Referenced by getgb2s2(), and gf_getfld().

◆ gf_unpack5()

subroutine gf_unpack5 ( character(len = 1), dimension(lcgrib), intent(in)  cgrib,
integer, intent(in)  lcgrib,
integer, intent(inout)  iofst,
integer, intent(out)  ndpts,
integer, intent(out)  idrsnum,
integer, dimension(:), pointer  idrstmpl,
integer  mapdrslen,
integer, intent(out)  ierr 
)

Unpack Section 5 (Data Representation Section) of a GRIB2 message, starting at octet 6 of that Section.

Parameters
[in]cgribCharacter array that contains the GRIB2 message.
[in]lcgribLength (in bytes) of GRIB message array cgrib.
[in,out]iofstBit offset of the beginning/end(returned) of Section 5.
[out]ndptsNumber of data points unpacked and returned.
[out]idrsnumData Representation Template Number (Code Table 5.0).
[out]idrstmplContains the data values for the specified Data Representation Template (N = idrsnum). Each element of this integer array contains an entry (in the order specified) of Product Defintion Template 5.N A safe dimension for this array can be obtained in advance from maxvals(6), which is returned from subroutine gribinfo.
[out]mapdrslenNumber of elements in idrstmpl. i.e. number of entries in Data Representation Template 5.N (N = idrsnum).
[out]ierrError return code.
  • 0 no error.
  • 6 memory allocation error.
  • 7 "GRIB" message contains an undefined Grid Definition Template.
Author
Stephen Gilbert
Date
2000-05-26

Definition at line 465 of file g2unpack.F90.

References drstemplates::extdrstemplate(), g2_gbytec(), and drstemplates::getdrstemplate().

Referenced by getgb2s2(), and gf_getfld().

◆ gf_unpack6()

subroutine gf_unpack6 ( character(len = 1), dimension(lcgrib), intent(in)  cgrib,
integer, intent(in)  lcgrib,
integer, intent(inout)  iofst,
integer, intent(in)  ngpts,
integer, intent(out)  ibmap,
logical*1, dimension(:), pointer  bmap,
integer, intent(out)  ierr 
)

Unpack Section 6 (Bit-Map Section) of a GRIB2 message, starting at octet 6 of that Section.

Parameters
[in]cgribCharacter array that contains the GRIB2 message.
[in]lcgribLength (in bytes) of GRIB message array cgrib.
[in,out]iofstBit offset of the beginning/end(returned) of Section 6.
[in]ngptsNumber of grid points specified in the bit-map.
[out]ibmapBitmap indicator (see Code Table 6.0)
  • 0 bitmap applies and is included in Section 6.
  • 1-253 Predefined bitmap applies.
  • 254 Previously defined bitmap applies to this field.
  • 255 Bit map does not apply to this product.
[out]bmapLogical*1 array containing decoded bitmap. (if ibmap=0) The dimension of this array can be obtained in advance from maxvals(7), which is returned from subroutine gribinfo().
[out]ierrError return code.
  • 0 no error.
  • 4 Unrecognized pre-defined bit-map.
  • 6 memory allocation error.
Author
Stephen Gilbert
Date
2000-05-26

Definition at line 575 of file g2unpack.F90.

References g2_gbytec(), and g2_gbytesc().

Referenced by getgb2r2(), and gf_getfld().

◆ gf_unpack7()

subroutine gf_unpack7 ( character(len = 1), dimension(lcgrib), intent(in)  cgrib,
integer, intent(in)  lcgrib,
integer, intent(inout)  iofst,
integer, intent(in)  igdsnum,
integer, dimension(:), pointer  igdstmpl,
integer, intent(in)  idrsnum,
integer, dimension(:), pointer  idrstmpl,
integer, intent(in)  ndpts,
real, dimension(:), pointer  fld,
integer, intent(out)  ierr 
)

Unpack Section 7 (Data Section) of a GRIB2 message.

Parameters
[in]cgribCharacter array that contains the GRIB2 message.
[in]lcgribLength (in bytes) of GRIB message array cgrib.
[in,out]iofstBit offset of the beginning/end(returned) of Section 7.
[in]igdsnumGrid Definition Template Number (Code Table 3.0) (Only required to unpack DRT 5.51).
[in]igdstmplPointer to an integer array containing the data values for the specified Grid Definition. Template (N = igdsnum). Each element of this integer array contains an entry (in the order specified) of Grid Definition Template 3.N (Only required to unpack DRT 5.51).
[in]idrsnumData Representation Template Number (Code Table 5.0).
[in]idrstmplPointer to an integer array containing the data values for the Data Representation Template specified by idrsnum. A safe dimension for this array can be obtained in advance from maxvals(6), which is returned from subroutine gribinfo.
[in]ndptsNumber of data points unpacked and returned.
[out]fldPointer to a real array containing the unpacked data field.
[out]ierrError return code.
  • 0 no error.
  • 4 Unrecognized Data Representation Template.
  • 5 One of GDT 3.50 through 3.53 required to unpack DRT 5.51.
  • 6 memory allocation error.
  • 7 corrupt section 7.
Author
Stephen Gilbert
Date
2002-01-24

Definition at line 648 of file g2unpack.F90.

References comunpack(), g2_gbytec(), jpcunpack(), pngunpack(), rdieee(), simunpack(), and specunpack().

Referenced by getgb2r2(), and gf_getfld().