NCEPLIBS-g2  3.5.0
compack.F90 File Reference

Pack/unpack a data field with complex packing with or without spatial differences defined in Data Representation Template5.2 and Data Representation Template 5.3. More...

Go to the source code of this file.

Functions/Subroutines

subroutine cmplxpack (fld, ndpts, idrsnum, idrstmpl, cpack, lcpack)
 Pack up a data field using a complex packing algorithm. More...
 
subroutine compack (fld, ndpts, idrsnum, idrstmpl, cpack, lcpack)
 Pack a data field with complex packing with or without spatial differences, defined in Data Representation Template 5.2 and Data Representation Template 5.3. More...
 
subroutine comunpack (cpack, len, lensec, idrsnum, idrstmpl, ndpts, fld, ier)
 Unpack a data field that was packed using a complex packing algorithm as defined in the GRIB2 documention. More...
 
subroutine misspack (fld, ndpts, idrsnum, idrstmpl, cpack, lcpack)
 Pack up a data field using a GRIB2 algorithm with missing value management. More...
 

Detailed Description

Pack/unpack a data field with complex packing with or without spatial differences defined in Data Representation Template5.2 and Data Representation Template 5.3.

Author
Stephen Gilbert
Date
2000-06-21
Author
Ed Hartnett
Date
Mar 5, 2024

Definition in file compack.F90.

Function/Subroutine Documentation

◆ cmplxpack()

subroutine cmplxpack ( real, dimension(ndpts), intent(in)  fld,
integer, intent(in)  ndpts,
integer, intent(in)  idrsnum,
integer, dimension(*), intent(inout)  idrstmpl,
character(len=1), dimension(*), intent(out)  cpack,
integer, intent(out)  lcpack 
)

Pack up a data field using a complex packing algorithm.

This subroutine supports GRIB2 complex packing templates with or without spatial differences, Data Representation Templates (DRT) [GRIB2 - DATA REPRESENTATION TEMPLATE 5.2 - Grid point data - complex packing](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-2.shtml) and [GRIB2 - DATA REPRESENTATION TEMPLATE 5.3 - Grid point data - complex packing and spatial differencing](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-3.shtml).

It also fills in GRIB2 Data Representation Template 5.2 or 5.3 with the appropriate values.

Parameters
[in]fldThe data values to pack.
[in]ndptsThe number of data values in array fld.
[in]idrsnumData Representation Template number. Must equal 2 or 3.
[in,out]idrstmplContains the array of values for Data Representation Template 5.2 or 5.3
  • 1 Reference value - ignored on input
  • 2 Binary Scale Factor
  • 3 Decimal Scale Factor
  • 7 Missing value management
  • 8 Primary missing value
  • 9 Secondary missing value
  • 17 Order of Spatial Differencing (1 or 2)
[out]cpackThe packed data field (character*1 array).
[out]lcpackLength of packed field cpack. -1 is returned if idrstmpl(7) is not set correctly.
Author
Stephen Gilbert
Date
2004-08-27

Definition at line 42 of file compack.F90.

References compack(), and misspack().

Referenced by addfield().

◆ compack()

subroutine compack ( real, dimension(ndpts), intent(in)  fld,
integer, intent(in)  ndpts,
integer, intent(in)  idrsnum,
integer, dimension(*), intent(inout)  idrstmpl,
character(len=1), dimension(*), intent(out)  cpack,
integer, intent(out)  lcpack 
)

Pack a data field with complex packing with or without spatial differences, defined in Data Representation Template 5.2 and Data Representation Template 5.3.

It also fills in Data Representation Template 5.2 or 5.3 with the appropriate values.

Parameters
[in]fldThe data values to pack.
[in]ndptsThe number of data values in array fld.
[in]idrsnumData Representation Template number - must equal 2 or 3.
[in,out]idrstmplThe array of values for Data Representation Template 5.2 or 5.3.
  • 1 Reference value - ignored on input
  • 2 Binary Scale Factor
  • 3 Decimal Scale Factor
  • 7 Missing value management
  • 8 Primary missing value
  • 9 Secondary missing value
  • 17 Order of Spatial Differencing (1 or 2)
[out]cpackThe packed data field (character*1 array).
[out]lcpacklength of packed field cpack.
Author
Stephen Gilbert
Date
2000-06-21

Definition at line 88 of file compack.F90.

References g2_sbytec(), g2_sbytesc(), mkieee(), and pack_gp().

Referenced by cmplxpack().

◆ comunpack()

subroutine comunpack ( character(len=1), dimension(len), intent(in)  cpack,
integer, intent(in)  len,
  lensec,
  idrsnum,
integer, dimension(*), intent(in)  idrstmpl,
integer, intent(in)  ndpts,
real, dimension(ndpts), intent(out)  fld,
  ier 
)

Unpack a data field that was packed using a complex packing algorithm as defined in the GRIB2 documention.

This subroutine Supports GRIB2 complex packing templates with or without spatial differences: It supports GRIB2 complex packing templates with or without spatial differences: Data Representation Tables 5.2 and 5.3).

Parameters
[in]cpackThe packed data field (character*1 array).
[in]lenLength of packed field cpack.
[in]lensecLength of section 7 (used for error checking).
[in]idrsnumData Representation Template number 5.N. Must equal 2 or 3.
[in]idrstmplThe array of values for Data Representation Template 5.2 or 5.3.
[in]ndptsThe number of data values to unpack.
[out]fldContains the unpacked data values.
[out]ierError return:
  • 0 = No error.
  • 1 = Problem - inconsistent group lengths of widths.
Author
Stephen Gilbert
Date
2000-06-21

Definition at line 526 of file compack.F90.

References g2_gbytec(), g2_gbytesc(), and rdieee().

Referenced by getfield(), and gf_unpack7().

◆ misspack()

subroutine misspack ( real, dimension(ndpts), intent(in)  fld,
integer, intent(in)  ndpts,
integer, intent(in)  idrsnum,
integer, dimension(*), intent(inout)  idrstmpl,
character(len=1), dimension(*), intent(out)  cpack,
integer, intent(out)  lcpack 
)

Pack up a data field using a GRIB2 algorithm with missing value management.

This subroutine packs up a data field using a complex packing algorithm as defined in the GRIB2 documention. It supports GRIB2 complex packing templates with or without spatial differences (i.e. Data Representation Tables 5.2 and 5.3).

This subroutine also fills in GRIB2 Data Representation Template 5.2 or 5.3 with the appropriate values. It assumes that Missing Value Management is being used and that 1 or 2 missing values appear in the data.

Parameters
[in]fldContains the data values to pack.
[in]ndptsThe number of data values in array fld.
[in]idrsnumData Representation Template number. Must equal 2 or 3.
[in,out]idrstmplContains the array of values for Data Representation Template 5.2 or 5.3
  • idrstmpl(1) Reference value - ignored on input set by compack routine.
  • idrstmpl(2) Binary Scale Factor.
  • idrstmpl(3) Decimal Scale Factor.
  • idrstmpl(4) number of bits for each data value - ignored on input.
  • idrstmpl(5) Original field type, currently ignored on input, set = 0 on !output, Data values assumed to be reals.
  • idrstmpl(6) = 0 use lossless compression or = 1 use lossy compression.
  • idrstmpl(7) Missing value management.
  • idrstmpl(8) Primary missing value.
  • idrstmpl(9) Secondary missing value.
  • idrstmpl(17) Order of Spatial Differencing (1 or 2).
[out]cpackThe packed data field (character*1 array).
[out]lcpacklength of packed field cpack. -1 is returned if idrstmpl(7) is not set correctly.
Author
Stephen Gilbert
Date
2000-06-21

Definition at line 854 of file compack.F90.

References g2_sbytec(), g2_sbytesc(), mkieee(), pack_gp(), and rdieee().

Referenced by cmplxpack().