g2_unpack7.c(3)
g2_unpack7.c π
okay bestie, welcome to the g2_unpack7.c manual page, a.k.a. the glow-up guide to the GRIB2 Section 7 (that's the Data Section, the one with the actual numbers in it π). this lives in the g2_unpack7.c(3) corner of the library functions manual. let's get into it β¨
β¨ 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.
no cap, that's the whole vibe of this file. it takes the packed-up data section and hands you back actual numbers π¦
Author
Stephen Gilbert
Date
2002-10-31
π Program History Log
the receipts, in order π
2002-10-31β Gilbert β Initial2002-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.412004-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.
bestie heads up: this one is the legacy era. it still works, it's just not the main character anymore β g2c_unpack7() is the newer one. π
Parameters
cgribβ char array containing Section 7 of the GRIB2 messageiofstβ Pointer to a bit offset of the beginning of Section 7 incgrib. This is updated by this function to reflect the data read in this function. After this function is successfully called, the value pointed to byiofstwill be the number of bits to the end of section 7 incbuf.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.Nndptsβ 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.
β οΈ note: that fld memory is allocated by this function and it is on you to free it. don't just walk away from it, bestie π
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.51G2_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().
the upgrade era β¨ if you're writing new code, this is the one you want.
Parameters
cgribβ char array containing Section 7 of the GRIB2 messageigdsnumβ 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 beNULL.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.Nndptsβ Number of data points to be unpacked and returned.fldβ Pointer which the data. Memory must be allocated in advance by caller.
π important glow-up:</> in this version, fld is not allocated for you. the caller has to allocate that memory in advance. different energy from the old one, fr fr.
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.51G2_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().
the backstage icon π both of the other two call into this one. it's static, so it's not out here for public consumption β it's the private group chat.
Parameters
cgribβ char array containing Section 7 of the GRIB2 messageiofstβ Pointer to a bit offset of the beginning of Section 7 incgrib. This is updated by this function to reflect the data read in this function. After this function is successfully called, the value pointed to byiofstwill be the number of bits to the end of section 7 incbuf.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 beNULLfor 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.Nndptsβ 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
stderrin the event of error. - returning V1 error codes.
- printing error messages to
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.
β οΈ yes, this one allocates fld for you too, and yes, you still have to free it. no skipping, bestie π
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.51G2_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.
and that's the whole page, bestie π«Ά this was brought to you by NCEPLIBS-g2c, Version 2.3.0, straight from the g2_unpack7.c(3) manual. slay, stay unpacked, and free your memory πβ¨ππ¦πΈπ
π¦ where this page comes from
- ubuntu resolute: libg2c-dev 2.3.0-4 Β· LGPL-3.0-only
- ubuntu stonking: libg2c-dev 2.3.0-7 Β· LGPL-3.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms