NCEPLIBS-g2c 2.0.0
Loading...
Searching...
No Matches
g2_unpack7.c File Reference

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

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

Go to the source code of this file.

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

◆ g2_unpack7()

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
cgribchar array containing Section 7 of the GRIB2 message
iofstPointer 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.
igdsnumGrid Definition Template Number (see Code Table 3.0). (Only used for DRS Template 5.51.)
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 used for DRS Template 5.51).
idrsnumData Representation Template Number (see Code Table 5.0).
idrstmplPointer 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
ndptsNumber of data points to be unpacked and returned.
fldPointer 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
Author
Stephen Gilbert
Date
2002-10-31

Definition at line 214 of file g2_unpack7.c.

References g2c_unpack7_int().

Referenced by g2_getfld().

◆ g2c_unpack7()

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
cgribchar array containing Section 7 of the GRIB2 message
igdsnumGrid Definition Template Number (see Code Table 3.0). (Only used for DRS Template 5.51.) May be zero for other templates.
gds_tmpl_lenNumber of elements in the GDS template.
gdstmplPointer 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.
idrsnumData Representation Template Number (see Code Table 5.0).
drs_tmpl_lenNumber of elements in the DRS template.
drstmplPointer 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
ndptsNumber of data points to be unpacked and returned.
fldPointer which the data. Memory must be allocated in advance by caller.
Returns
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().

◆ g2c_unpack7_int()

static 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
cgribchar array containing Section 7 of the GRIB2 message
iofstPointer 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.
igdsnumGrid Definition Template Number (see Code Table 3.0). (Only used for DRS Template 5.51. May be 0 for other templates.)
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 used for DRS Template 5.51, may be NULL for other templates).
idrsnumData Representation Template Number (see Code Table 5.0).
idrstmplPointer 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
ndptsNumber of data points to be unpacked and returned.
v1If 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.
fldPointer 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
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().