g2_unpack7.c(3)

NAME
g2_unpack7.c - Unpack Section 7 (Data Section) of a GRIB2 message.

SYNOPSIS

#include 'grib2_int.h'
#include <memory.h>
#include <string.h>

  Functions

g2int g2_unpack7 (unsigned char *cgrib, g2int *iofst, g2int igdsnum, g2int *igdstmpl, g2int idrsnum, g2int *idrstmpl, g2int ndpts, float **fld)
This subroutine unpacks Section 7 (Data Section) of a GRIB2 message.
int g2c_unpack7 (unsigned char *cgrib, int igdsnum, int gds_tmpl_len, long long int *gdstmpl, int idrsnum, int drs_tmpl_len, long long int *drstmpl, int ndpts, float *fld)
This subroutine unpacks Section 7 (Data Section) of a GRIB2 message.
static g2int g2c_unpack7_int (unsigned char *cgrib, g2int *iofst, g2int igdsnum, g2int *igdstmpl, g2int idrsnum, g2int *idrstmpl, g2int ndpts, int v1, float **fld)
Unpacks Section 7 (Data Section) of a GRIB2 message.

Detailed Description

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

Author
    Stephen Gilbert

Date
    2002-10-31

  Program History Log
Date Programmer Comments 2002-10-31 Gilbert Initial 2002-12-20 Gilbert Added GDT info to arguments and added 5.51 processing. 2003-08-29 Gilbert New templates using PNG and JPEG2000 algorithms/templates. 2004-11-29 Gilbert JPEG2000 now allowed to use WMO Template 5.40 PNG allowed to use 5.41 2004-12-16 Taylor Added check on comunpack return code. 2008-12-23 Wesley Initialize Number of data points unpacked. 2022-10-04 Hartnett Added g2c_unpack7(). 2023-10-16 Engle Added support for DRT 5.42, AEC compression.

Definition in file g2_unpack7.c.

Function Documentation

  g2int g2_unpack7 (unsigned char * cgrib, g2int * iofst, g2int igdsnum, g2int * igdstmpl, g2int idrsnum, g2int * idrstmpl, g2int ndpts, float ** fld)

This subroutine unpacks Section 7 (Data Section) of a GRIB2 message. This function is maintained for backward compatibility. Users may wish to use the newer g2c_unpack7() function instead.

Parameters
    cgrib char array containing Section 7 of the GRIB2 message
    iofst Pointer to a bit offset of the beginning of Section 7 in cgrib. This is updated by this function to reflect the data read in this function. After this function is successfully called, the value pointed to by iofst will be the number of bits to the end of section 7 in cbuf.
    igdsnum Grid Definition Template Number (see Code Table 3.0). (Only used for DRS Template 5.51.)
    igdstmpl Pointer 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 used for DRS Template 5.51).
    idrsnum Data Representation Template Number (see Code Table 5.0).
    idrstmpl Pointer to an integer array containing 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 Data Representation Template 5.N
    ndpts Number of data points to be unpacked and returned.
    fld Pointer to a float pointer which gets a pointer to an array allocated by this function to hold the unpacked data. This memory must be freed by the caller.

Returns

    •   G2_NO_ERROR No error.

    •   G2_UNPACK_BAD_SEC Array passed had incorrect section number.

    •   G2_UNPACK7_BAD_DRT Unrecognized Data Representation Template.

    •   G2_UNPACK7_WRONG_GDT need one of GDT 3.50 through 3.53 to decode DRT 5.51

    •   G2_UNPACK_NO_MEM Memory allocation error.

    •   G2_UNPACK7_CORRUPT_SEC Corrupt section 7.

Author
    Stephen Gilbert

Date
    2002-10-31

Definition at line 214 of file g2_unpack7.c.

References g2c_unpack7_int().

Referenced by g2_getfld().

  int g2c_unpack7 (unsigned char * cgrib, int igdsnum, int gds_tmpl_len, long long int * gdstmpl, int idrsnum, int drs_tmpl_len, long long int * drstmpl, int ndpts, float * fld)

This subroutine unpacks Section 7 (Data Section) of a GRIB2 message. This function is the newer version of g2_unpack7().

Parameters
    cgrib char array containing Section 7 of the GRIB2 message
    igdsnum Grid Definition Template Number (see Code Table 3.0). (Only used for DRS Template 5.51.) May be zero for other templates.
    gds_tmpl_len Number of elements in the GDS template.
    gdstmpl Pointer 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 used for DRS Template 5.51). May be NULL.
    idrsnum Data Representation Template Number (see Code Table 5.0).
    drs_tmpl_len Number of elements in the DRS template.
    drstmpl Pointer to an integer array containing 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 Data Representation Template 5.N
    ndpts Number of data points to be unpacked and returned.
    fld Pointer which the data. Memory must be allocated in advance by caller.

Returns

    •   G2_NO_ERROR No error.

    •   G2_UNPACK_BAD_SEC Array passed had incorrect section number.

    •   G2_UNPACK7_BAD_DRT Unrecognized Data Representation Template.

    •   G2_UNPACK7_WRONG_GDT need one of GDT 3.50 through 3.53 to decode DRT 5.51

    •   G2_UNPACK_NO_MEM Memory allocation error.

    •   G2_UNPACK7_CORRUPT_SEC Corrupt section 7.

Author
    Stephen Gilbert

Date
    2002-10-31

Definition at line 259 of file g2_unpack7.c.

References G2C_EINVAL, G2C_ENOMEM, g2c_unpack7_int(), and LOG.

Referenced by g2c_get_prod().

  g2int g2c_unpack7_int (unsigned char * cgrib, g2int * iofst, g2int igdsnum, g2int * igdstmpl, g2int idrsnum, g2int * idrstmpl, g2int ndpts, int v1, float ** fld) [static]

Unpacks Section 7 (Data Section) of a GRIB2 message. This function is the internal function called by both g2_unpack7() and g2c_unpack7().

Parameters
    cgrib char array containing Section 7 of the GRIB2 message
    iofst Pointer to a bit offset of the beginning of Section 7 in cgrib. This is updated by this function to reflect the data read in this function. After this function is successfully called, the value pointed to by iofst will be the number of bits to the end of section 7 in cbuf.
    igdsnum Grid Definition Template Number (see Code Table 3.0). (Only used for DRS Template 5.51. May be 0 for other templates.)
    igdstmpl Pointer 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 used for DRS Template 5.51, may be NULL for other templates).
    idrsnum Data Representation Template Number (see Code Table 5.0).
    idrstmpl Pointer to an integer array containing 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 Data Representation Template 5.N
    ndpts Number of data points to be unpacked and returned.
    v1 If non-zero, then act like the V1 G2C API. This includes:

    •   printing error messages to stderr in the event of error.

    •   returning V1 error codes.

    fld Pointer to a float pointer which gets a pointer to an array allocated by this function to hold the unpacked data. This memory must be freed by the caller.

Returns

    •   G2_NO_ERROR No error.

    •   G2_UNPACK_BAD_SEC Array passed had incorrect section number.

    •   G2_UNPACK7_BAD_DRT Unrecognized Data Representation Template.

    •   G2_UNPACK7_WRONG_GDT need one of GDT 3.50 through 3.53 to decode DRT 5.51

    •   G2_UNPACK_NO_MEM Memory allocation error.

    •   G2_UNPACK7_CORRUPT_SEC Corrupt section 7.

Author
    Stephen Gilbert

Date
    2002-10-31

Definition at line 67 of file g2_unpack7.c.

References aecunpack(), comunpack(), G2_NO_ERROR, G2_UNPACK7_BAD_DRT, G2_UNPACK7_CORRUPT_SEC, G2_UNPACK7_WRONG_GDT, G2_UNPACK_BAD_SEC, G2_UNPACK_NO_MEM, gbit(), jpcunpack(), LOG, pngunpack(), rdieee(), simunpack(), and specunpack().

Referenced by g2_unpack7(), and g2c_unpack7().

Author

Generated automatically by Doxygen for NCEPLIBS-g2c from the source code.