.TH "grib2.h" 3 "Version 2.1.0" "NCEPLIBS-g2c" \" -*- nroff -*- .ad l .nh .SH NAME grib2.h \- Header file for NCEPLIBS-g2c library\&. .SH SYNOPSIS .br .PP \fC#include <stdint\&.h>\fP .br \fC#include <stdio\&.h>\fP .br \fC#include <string\&.h>\fP .br \fC#include <sys/types\&.h>\fP .br .SS "Data Structures" .in +1c .ti -1c .RI "struct \fBgribfield\fP" .br .RI "Struct for GRIB2 field\&. " .in -1c .SS "Macros" .in +1c .ti -1c .RI "#define \fBG2_ADD_MSG_COMPLETE\fP \-2" .br .RI "GRIB message already complete\&. " .ti -1c .RI "#define \fBG2_ADD_MSG_INIT\fP \-1" .br .RI "GRIB message was not initialized - call \fBg2_create()\fP first\&. " .ti -1c .RI "#define \fBG2_ADDFIELD_BAD_BITMAP\fP \-8" .br .RI "In \fBg2_addfield()\fP no bitmap in the GRIB message\&. " .ti -1c .RI "#define \fBG2_ADDFIELD_BAD_DRT\fP \-7" .br .RI "In \fBg2_addfield()\fP unsupported Data Representationi Template\&. " .ti -1c .RI "#define \fBG2_ADDFIELD_BAD_GDS\fP \-6" .br .RI "In \fBg2_addfield()\fP section 3 (GDS) not previously defined in message\&. " .ti -1c .RI "#define \fBG2_ADDFIELD_BAD_GDT\fP \-9" .br .RI "In \fBg2_addfield()\fP GDT of one of 5\&.50 through 5\&.53 required when using DRT 5\&.51\&. " .ti -1c .RI "#define \fBG2_ADDFIELD_BAD_PDT\fP \-5" .br .RI "In \fBg2_addfield()\fP could not find requested Product Definition Template\&. " .ti -1c .RI "#define \fBG2_ADDFIELD_ERR\fP \-10" .br .RI "In \fBg2_addfield()\fP error packing data field\&. " .ti -1c .RI "#define \fBG2_ADDGRID_BAD_GDT\fP \-5" .br .RI "In \fBg2_addgrid()\fP Could not find requested Grid Definition Template\&. " .ti -1c .RI "#define \fBG2_AEC_ENABLED\fP 1" .br .RI "Decoding/encoding AEC/CCSDS is enabled\&. " .ti -1c .RI "#define \fBG2_BAD_SEC\fP \-4" .br .RI "Previous Section was unexpected\&. " .ti -1c .RI "#define \fBG2_BAD_SEC_COUNTS\fP \-3" .br .RI "Sum of Section byte counts doesn't add to total byte count\&. " .ti -1c .RI "#define \fBG2_CREATE_GRIB_VERSION\fP \-1" .br .RI "Wrong GRIB version for \fBg2_create()\fP, must be 2\&. " .ti -1c .RI "#define \fBG2_GETFLD_BAD_END\fP 7" .br .RI "\fBg2_getfld()\fP didn't find '7777' at end of message\&. " .ti -1c .RI "#define \fBG2_GETFLD_BAD_SEC1\fP 15" .br .RI "Error in \fBg2_getfld()\fP unpacking section 1\&. " .ti -1c .RI "#define \fBG2_GETFLD_BAD_SEC2\fP 16" .br .RI "Error in \fBg2_getfld()\fP unpacking section 2\&. " .ti -1c .RI "#define \fBG2_GETFLD_BAD_SEC3\fP 10" .br .RI "Error in \fBg2_getfld()\fP unpacking section 3\&. " .ti -1c .RI "#define \fBG2_GETFLD_BAD_SEC4\fP 11" .br .RI "Error in \fBg2_getfld()\fP unpacking section 4\&. " .ti -1c .RI "#define \fBG2_GETFLD_BAD_SEC5\fP 12" .br .RI "Error in \fBg2_getfld()\fP unpacking section 5\&. " .ti -1c .RI "#define \fBG2_GETFLD_BAD_SEC6\fP 13" .br .RI "Error in \fBg2_getfld()\fP unpacking section 6\&. " .ti -1c .RI "#define \fBG2_GETFLD_BAD_SEC7\fP 14" .br .RI "Error in \fBg2_getfld()\fP unpacking section 7\&. " .ti -1c .RI "#define \fBG2_GETFLD_GRIB_VERSION\fP 2" .br .RI "Wrong GRIB version for \fBg2_getfld()\fP, must be 2\&. " .ti -1c .RI "#define \fBG2_GETFLD_INVAL\fP 3" .br .RI "\fBg2_getfld()\fP data field request number was not positive\&. " .ti -1c .RI "#define \fBG2_GETFLD_INVAL_SEC\fP 8" .br .RI "\fBg2_getfld()\fP encountered unrecognized section\&. " .ti -1c .RI "#define \fBG2_GETFLD_NO_BITMAP\fP 17" .br .RI "In \fBg2_getfld()\fP previous bitmap specified, yet none exists\&. " .ti -1c .RI "#define \fBG2_GETFLD_NO_DRT\fP 9" .br .RI "In \fBg2_getfld()\fP, Data Representation Template not implemented\&. " .ti -1c .RI "#define \fBG2_GETFLD_NO_GRIB\fP 1" .br .RI "\fBg2_getfld()\fP can't find beginning characters 'GRIB'\&. " .ti -1c .RI "#define \fBG2_GETFLD_WRONG_END\fP 4" .br .RI "\fBg2_info()\fP found '7777' not where expected\&. " .ti -1c .RI "#define \fBG2_GETFLD_WRONG_NFLDS\fP 6" .br .RI "In \fBg2_getfld()\fP message did not contain the requested number of data fields\&. " .ti -1c .RI "#define \fBG2_GRIBEND_MSG_INIT\fP \-1" .br .RI "In \fBg2_gribend()\fP GRIB message was not initialized - call \fBg2_create()\fP first\&. " .ti -1c .RI "#define \fBG2_INFO_BAD_END\fP 5" .br .RI "\fBg2_info()\fP didn't find '7777' at end of message\&. " .ti -1c .RI "#define \fBG2_INFO_GRIB_VERSION\fP 2" .br .RI "Wrong GRIB version for \fBg2_info()\fP, must be 2\&. " .ti -1c .RI "#define \fBG2_INFO_INVAL_SEC\fP 6" .br .RI "\fBg2_info()\fP found invalid section number\&. " .ti -1c .RI "#define \fBG2_INFO_NO_GRIB\fP 1" .br .RI "\fBg2_info()\fP can't find beginning characters 'GRIB'\&. " .ti -1c .RI "#define \fBG2_INFO_NO_SEC1\fP 3" .br .RI "\fBg2_info()\fP can't find section 1\&. " .ti -1c .RI "#define \fBG2_INFO_WRONG_END\fP 4" .br .RI "\fBg2_info()\fP found '7777' not where expected\&. " .ti -1c .RI "#define \fBG2_JASPER_DECODE\fP \-3" .br .RI "In \fBdec_jpeg2000()\fP error decoding image with jasper\&. " .ti -1c .RI "#define \fBG2_JASPER_DECODE_COLOR\fP \-5" .br .RI "In \fBdec_jpeg2000()\fP decoded image had multiple color components\&. " .ti -1c .RI "#define \fBG2_JASPER_ENCODE\fP \-3" .br .RI "In \fBenc_jpeg2000()\fP error encoding image with jasper\&. " .ti -1c .RI "#define \fBG2_JASPER_INIT\fP \-2" .br .RI "In \fBenc_jpeg2000()\fP/dec_jpeg2000() error initializing jasper library\&. " .ti -1c .RI "#define \fBG2_JPCUNPACK_MEM\fP 1" .br .RI "In \fBjpcunpack()\fP or other unpack function: out of memory\&. " .ti -1c .RI "#define \fBG2_JPEG2000_ENABLED\fP 1" .br .RI "Decoding/encoding JPEG2000 is enabled\&. " .ti -1c .RI "#define \fBG2_NO_ERROR\fP 0" .br .RI "Function succeeded\&. " .ti -1c .RI "#define \fBG2_PNG_ENABLED\fP 1" .br .RI "Decoding/encoding PNG is enabled\&. " .ti -1c .RI "#define \fBG2_SPECUNPACK_TYPE\fP \-3" .br .RI "In \fBspecunpack()\fP Can't handle 64 or 128 bit floats\&. " .ti -1c .RI "#define \fBG2_UNPACK3_BAD_GDT\fP 5" .br .RI "In \fBg2_unpack3()\fP, undefined Grid Definition Template\&. " .ti -1c .RI "#define \fBG2_UNPACK4_BAD_PDT\fP 5" .br .RI "In \fBg2_unpack4()\fP, undefined Product Definition Template\&. " .ti -1c .RI "#define \fBG2_UNPACK5_BAD_DRT\fP 7" .br .RI "In \fBg2_unpack5()\fP, undefined Data Representation Template\&. " .ti -1c .RI "#define \fBG2_UNPACK6_BAD_BITMAP\fP 4" .br .RI "In \fBg2_unpack6()\fP, unrecognized pre-defined bit-map\&. " .ti -1c .RI "#define \fBG2_UNPACK7_BAD_DRT\fP 4" .br .RI "In \fBg2_unpack7()\fP, unrecognized Data Representation Template\&. " .ti -1c .RI "#define \fBG2_UNPACK7_CORRUPT_SEC\fP 7" .br .RI "In \fBg2_unpack7()\fP, corrupt section 7\&. " .ti -1c .RI "#define \fBG2_UNPACK7_WRONG_GDT\fP 5" .br .RI "In \fBg2_unpack7()\fP, need one of GDT 3\&.50 through 3\&.53 to decode DRT 5\&.51\&. " .ti -1c .RI "#define \fBG2_UNPACK_BAD_SEC\fP 2" .br .RI "Bad section number in unpacking function\&. " .ti -1c .RI "#define \fBG2_UNPACK_NO_MEM\fP 6" .br .RI "Error allocating memory in unpack function\&. " .ti -1c .RI "#define \fBG2C_AEC_DRS_TEMPLATE_LEN\fP 8" .br .RI "Length of the idrstmpl array for AEC packing\&. " .ti -1c .RI "#define \fBG2C_BYTE\fP 1" .br .RI "signed 1 byte integer " .ti -1c .RI "#define \fBG2C_CHAR\fP 2" .br .RI "ISO/ASCII character\&. " .ti -1c .RI "#define \fBG2C_CLOBBER\fP 0x0000" .br .RI "Destroy existing file\&. " .ti -1c .RI "#define \fBG2C_DOUBLE\fP 6" .br .RI "double precision floating point number " .ti -1c .RI "#define \fBG2C_EAEC\fP (\-74)" .br .RI "Error encoding/decoding AEC data\&. " .ti -1c .RI "#define \fBG2C_EBADEND\fP (\-65)" .br .RI "End of message in wrong place\&. " .ti -1c .RI "#define \fBG2C_EBADID\fP (\-55)" .br .RI "Bad ID\&. " .ti -1c .RI "#define \fBG2C_EBADSECTION\fP (\-66)" .br .RI "Invalid section number\&. " .ti -1c .RI "#define \fBG2C_EBADTEMPLATE\fP (\-70)" .br .RI "Template problem\&. " .ti -1c .RI "#define \fBG2C_EBADTYPE\fP (\-73)" .br .RI "Type not found\&. " .ti -1c .RI "#define \fBG2C_ECSV\fP (\-75)" .br .RI "CSV error\&. " .ti -1c .RI "#define \fBG2C_EFILE\fP (\-54)" .br .RI "File I/O error\&. " .ti -1c .RI "#define \fBG2C_EINVAL\fP (\-53)" .br .RI "Invalid input\&. " .ti -1c .RI "#define \fBG2C_EJPEG\fP (\-67)" .br .RI "Error encoding/decoding JPEG data\&. " .ti -1c .RI "#define \fBG2C_EMSG\fP (\-58)" .br .RI "Error decoding GRIB message\&. " .ti -1c .RI "#define \fBG2C_EMSGCOMPLETE\fP (\-51)" .br .RI "GRIB message already complete\&. " .ti -1c .RI "#define \fBG2C_ENAMETOOLONG\fP (\-52)" .br .RI "Name too long\&. " .ti -1c .RI "#define \fBG2C_ENOEND\fP (\-64)" .br .RI "Cannot find end of GRIB message\&. " .ti -1c .RI "#define \fBG2C_ENOMEM\fP (\-57)" .br .RI "Out of memory\&. " .ti -1c .RI "#define \fBG2C_ENOMSG\fP (\-59)" .br .RI "No GRIB message found\&. " .ti -1c .RI "#define \fBG2C_ENOPARAM\fP (\-71)" .br .RI "Parameter not found\&. " .ti -1c .RI "#define \fBG2C_ENOPRODUCT\fP (\-72)" .br .RI "Product not found\&. " .ti -1c .RI "#define \fBG2C_ENOSECTION\fP (\-63)" .br .RI "Cannot find section\&. " .ti -1c .RI "#define \fBG2C_ENOTEMPLATE\fP (\-69)" .br .RI "Template not found\&. " .ti -1c .RI "#define \fBG2C_ENOTFOUND\fP (\-61)" .br .RI "Table or entry not found\&. " .ti -1c .RI "#define \fBG2C_ENOTGRIB\fP (\-50)" .br .RI "GRIB header not found\&. " .ti -1c .RI "#define \fBG2C_ENOTGRIB2\fP (\-62)" .br .RI "Not GRIB 2\&. " .ti -1c .RI "#define \fBG2C_EPNG\fP (\-68)" .br .RI "Error encoding/decoding PNG data\&. " .ti -1c .RI "#define \fBG2C_ERROR\fP 1" .br .RI "General error code, returned for some test errors\&. " .ti -1c .RI "#define \fBG2C_ETOOMANYFILES\fP (\-56)" .br .RI "Trying to open too many files\&. " .ti -1c .RI "#define \fBG2C_EXML\fP (\-60)" .br .RI "XML error\&. " .ti -1c .RI "#define \fBG2C_FLOAT\fP 5" .br .RI "single precision floating point number " .ti -1c .RI "#define \fBG2C_INT\fP 4" .br .RI "signed 4 byte integer " .ti -1c .RI "#define \fBG2C_INT64\fP 10" .br .RI "signed 8-byte int " .ti -1c .RI "#define \fBG2C_JASPER_MAX_MEM\fP" .br .RI "Maximum size for the Jasper memory buffer\&. " .ti -1c .RI "#define \fBG2C_JPEG_DRS_TEMPLATE_LEN\fP 7" .br .RI "Length of the idrstmpl array for JPEG packing\&. " .ti -1c .RI "#define \fBG2C_LARGE_FILE_INDEX\fP 0x0008" .br .RI "Create a large file index\&. " .ti -1c .RI "#define \fBG2C_MAX_DRS_TEMPLATE\fP 11" .br .RI "Maximum number of DRS templates\&. " .ti -1c .RI "#define \fBG2C_MAX_DRS_TEMPLATE_MAPLEN\fP 18" .br .RI "Maximum DRS template map length\&. " .ti -1c .RI "#define \fBG2C_MAX_FILES\fP 3" .br .RI "Maximum number of open files\&. " .ti -1c .RI "#define \fBG2C_MAX_GDS_TEMPLATE\fP 38" .br .RI "Maximum number of grid templates\&. " .ti -1c .RI "#define \fBG2C_MAX_GDS_TEMPLATE_MAPLEN\fP 28" .br .RI "Maximum grid template map length\&. " .ti -1c .RI "#define \fBG2C_MAX_GRIB_CODE_LEN\fP 20" .br .RI "Maximum length of code\&. " .ti -1c .RI "#define \fBG2C_MAX_GRIB_DESC_LEN\fP 512" .br .RI "Maximum length of code description\&. " .ti -1c .RI "#define \fBG2C_MAX_GRIB_LEVEL_DESC_LEN\fP 40" .br .RI "Maximum length of level description\&. " .ti -1c .RI "#define \fBG2C_MAX_GRIB_STATUS_LEN\fP 40" .br .RI "Maximum length of code status\&. " .ti -1c .RI "#define \fBG2C_MAX_GRIB_TITLE_LEN\fP 200" .br .RI "Maximum length of code table title\&. " .ti -1c .RI "#define \fBG2C_MAX_NAME\fP 1024" .br .RI "Maximum length of a name\&. " .ti -1c .RI "#define \fBG2C_MAX_NOAA_ABBREV_LEN\fP 8" .br .RI "Maximum length of a NOAA abbreviation of a parameter\&. " .ti -1c .RI "#define \fBG2C_MAX_NOAA_PARAM_LINE_LEN\fP 120" .br .RI "Maximum length of a line in the NOAA abbreviation CSV file\&. " .ti -1c .RI "#define \fBG2C_MAX_NOAA_PARAMS\fP 2000" .br .RI "Maximum number of known parameters with NOAA abbreviations\&. " .ti -1c .RI "#define \fBG2C_MAX_NUM_SECTIONS\fP 1024" .br .RI "Maximum number of sections that can be handled in one message\&. " .ti -1c .RI "#define \fBG2C_MAX_PDS_TEMPLATE\fP 102" .br .RI "Maximum number of PDS templates\&. " .ti -1c .RI "#define \fBG2C_MAX_PDS_TEMPLATE_MAPLEN\fP 50" .br .RI "Maximum template map length\&. " .ti -1c .RI "#define \fBG2C_NOCLOBBER\fP 0x0004" .br .RI "Don't destroy existing file\&. " .ti -1c .RI "#define \fBG2C_NOERROR\fP 0" .br .RI "No error\&. " .ti -1c .RI "#define \fBG2C_NOWRITE\fP 0x0000" .br .RI "Set read-only access for \fBg2c_open()\fP\&. " .ti -1c .RI "#define \fBG2C_PNG_DRS_TEMPLATE_LEN\fP 5" .br .RI "Length of the idrstmpl array for PNG packing\&. " .ti -1c .RI "#define \fBG2C_PNG_HEIGHT_MAX\fP 100000" .br .RI "Maximum height of PNG grid\&. " .ti -1c .RI "#define \fBG2C_PNG_WIDTH_MAX\fP 100000000" .br .RI "Maximum width of PNG grid\&. " .ti -1c .RI "#define \fBG2C_SECTION0_ARRAY_LEN\fP 3" .br .RI "Length of section 0 array\&. " .ti -1c .RI "#define \fBG2C_SECTION0_BYTES\fP 16" .br .RI "Number of bytes in section 0\&. " .ti -1c .RI "#define \fBG2C_SECTION0_LEN\fP 3" .br .RI "Length of section 0 array\&. " .ti -1c .RI "#define \fBG2C_SECTION1_ARRAY_LEN\fP 13" .br .RI "Length of section 1 array\&. " .ti -1c .RI "#define \fBG2C_SECTION1_BYTES\fP 21" .br .RI "Number of bytes in section 1 (not including reserved, optional data at the end of the section)\&. " .ti -1c .RI "#define \fBG2C_SECTION1_LEN\fP 13" .br .RI "Length of section 1 array\&. " .ti -1c .RI "#define \fBG2C_SHORT\fP 3" .br .RI "signed 2 byte integer " .ti -1c .RI "#define \fBG2C_UBYTE\fP 7" .br .RI "unsigned 1 byte int " .ti -1c .RI "#define \fBG2C_UINT\fP 9" .br .RI "unsigned 4-byte int " .ti -1c .RI "#define \fBG2C_UINT64\fP 11" .br .RI "unsigned 8-byte int " .ti -1c .RI "#define \fBG2C_USHORT\fP 8" .br .RI "unsigned 2-byte int " .ti -1c .RI "#define \fBG2C_VERSION\fP '2\&.1\&.0'" .br .RI "Current version of NCEPLIBS-g2c library\&. " .ti -1c .RI "#define \fBG2C_WRITE\fP 0x0001" .br .RI "Set read-write access for \fBg2c_open()\fP\&. " .in -1c .SS "Typedefs" .in +1c .ti -1c .RI "typedef float \fBg2float\fP" .br .RI "Float type\&. " .ti -1c .RI "typedef int64_t \fBg2int\fP" .br .RI "Long integer type\&. " .ti -1c .RI "typedef uint64_t \fBg2intu\fP" .br .RI "Unsigned long integer type\&. " .ti -1c .RI "typedef struct \fBgribfield\fP \fBgribfield\fP" .br .RI "Struct for GRIB field\&. " .in -1c .SS "Functions" .in +1c .ti -1c .RI "\fBg2int\fP \fBg2_addfield\fP (unsigned char *cgrib, \fBg2int\fP ipdsnum, \fBg2int\fP *ipdstmpl, float *coordlist, \fBg2int\fP numcoord, \fBg2int\fP idrsnum, \fBg2int\fP *idrstmpl, float *fld, \fBg2int\fP ngrdpts, \fBg2int\fP ibmap, \fBg2int\fP *bmap)" .br .RI "Pack sections 4 through 7 and adds them to a GRIB2 message\&. " .ti -1c .RI "\fBg2int\fP \fBg2_addgrid\fP (unsigned char *cgrib, \fBg2int\fP *igds, \fBg2int\fP *igdstmpl, \fBg2int\fP *ideflist, \fBg2int\fP idefnum)" .br .RI "Packs a \fCGrid Definition Section (Section 3)\fP and adds it to a GRIB2 message\&. " .ti -1c .RI "\fBg2int\fP \fBg2_addlocal\fP (unsigned char *cgrib, unsigned char *csec2, \fBg2int\fP lcsec2)" .br .RI "Adds a \fCLocal Use Section (Section 2)\fP to a GRIB2 message\&. " .ti -1c .RI "\fBg2int\fP \fBg2_create\fP (unsigned char *cgrib, \fBg2int\fP *listsec0, \fBg2int\fP *listsec1)" .br .RI "Initialize a new GRIB2 message and pack GRIB2 \fCSection 0 (Indicator Section)\fP and \fCSection 1 (Identification Section)\fP\&. " .ti -1c .RI "void \fBg2_free\fP (\fBgribfield\fP *gfld)" .br .RI "Free memory that was allocated for struct \fBgribfield\fP\&. " .ti -1c .RI "\fBg2int\fP \fBg2_getfld\fP (unsigned char *cgrib, \fBg2int\fP ifldnum, \fBg2int\fP unpack, \fBg2int\fP expand, \fBgribfield\fP **gfld)" .br .RI "Return all the metadata, template values, bit-map (if applicable), and the unpacked data for a data field\&. " .ti -1c .RI "\fBg2int\fP \fBg2_gribend\fP (unsigned char *cgrib)" .br .RI "Finalize a GRIB2 message after all grids and fields have been added\&. " .ti -1c .RI "\fBg2int\fP \fBg2_info\fP (unsigned char *cgrib, \fBg2int\fP *listsec0, \fBg2int\fP *listsec1, \fBg2int\fP *numfields, \fBg2int\fP *numlocal)" .br .RI "Search through a GRIB2 message and return the number of gridded fields found in the message and the number (and maximum size) of Local Use Sections\&. " .ti -1c .RI "\fBg2int\fP \fBg2_unpack1\fP (unsigned char *cgrib, \fBg2int\fP *iofst, \fBg2int\fP **ids, \fBg2int\fP *idslen)" .br .RI "Unpacks \fCSection 1 - Identification Section\fP of a GRIB2 message\&. " .ti -1c .RI "\fBg2int\fP \fBg2_unpack2\fP (unsigned char *cgrib, \fBg2int\fP *iofst, \fBg2int\fP *lencsec2, unsigned char **csec2)" .br .RI "Unpack \fCSection 2 (Local Use Section)\fP of a GRIB2 message\&. " .ti -1c .RI "\fBg2int\fP \fBg2_unpack3\fP (unsigned char *cgrib, \fBg2int\fP *iofst, \fBg2int\fP **igds, \fBg2int\fP **igdstmpl, \fBg2int\fP *mapgridlen, \fBg2int\fP **ideflist, \fBg2int\fP *idefnum)" .br .RI "Unpack \fCSection 3 (Grid Definition Section)\fP of a GRIB2 message\&. " .ti -1c .RI "\fBg2int\fP \fBg2_unpack4\fP (unsigned char *cgrib, \fBg2int\fP *iofst, \fBg2int\fP *ipdsnum, \fBg2int\fP **ipdstmpl, \fBg2int\fP *mappdslen, float **coordlist, \fBg2int\fP *numcoord)" .br .RI "Unpack \fCSection 4 (Product Definition Section)\fP of a GRIB2 message\&. " .ti -1c .RI "\fBg2int\fP \fBg2_unpack5\fP (unsigned char *cgrib, \fBg2int\fP *iofst, \fBg2int\fP *ndpts, \fBg2int\fP *idrsnum, \fBg2int\fP **idrstmpl, \fBg2int\fP *mapdrslen)" .br .RI "Unpack Section 5 (Data Representation Section) of a GRIB2 message\&. " .ti -1c .RI "\fBg2int\fP \fBg2_unpack6\fP (unsigned char *cgrib, \fBg2int\fP *iofst, \fBg2int\fP ngpts, \fBg2int\fP *ibmap, \fBg2int\fP **bmap)" .br .RI "Unpack Section 6 (Bit-Map Section) of a GRIB2 message\&. " .ti -1c .RI "\fBg2int\fP \fBg2_unpack7\fP (unsigned char *cgrib, \fBg2int\fP *iofst, \fBg2int\fP igdsnum, \fBg2int\fP *igdstmpl, \fBg2int\fP idrsnum, \fBg2int\fP *idrstmpl, \fBg2int\fP ndpts, float **fld)" .br .RI "This subroutine unpacks Section 7 (Data Section) of a GRIB2 message\&. " .ti -1c .RI "int \fBg2c_aecpackd\fP (double *fld, size_t width, size_t height, int *idrstmpl, unsigned char *cpack, size_t *lcpack)" .br .RI "This function packs up a double array into a AEC code stream\&. " .ti -1c .RI "int \fBg2c_aecpackf\fP (float *fld, size_t width, size_t height, int *idrstmpl, unsigned char *cpack, size_t *lcpack)" .br .RI "This function packs up a float array into a AEC code stream\&. " .ti -1c .RI "int \fBg2c_aecunpackd\fP (unsigned char *cpack, size_t len, int *idrstmpl, size_t ndpts, double *fld)" .br .RI "Unpack AEC compressed data into an array of doubles, using info from the GRIB2 Data Representation \fCTemplate 5\&.42\fP\&. " .ti -1c .RI "int \fBg2c_aecunpackf\fP (unsigned char *cpack, size_t len, int *idrstmpl, size_t ndpts, float *fld)" .br .RI "Unpack AEC compressed data into an array of floats, using info from the GRIB2 Data Representation \fCTemplate 5\&.42\fP\&. " .ti -1c .RI "int \fBg2c_close\fP (int g2cid)" .br .RI "Close a GRIB2 file, freeing resources\&. " .ti -1c .RI "int \fBg2c_compare\fP (int g2cid1, int g2cid2)" .br .RI "Compare the metadata of two open GRIB2 files\&. " .ti -1c .RI "int \fBg2c_csv_init\fP ()" .br .RI "Initialize tables from 'CodeFlag\&.txt'\&. " .ti -1c .RI "int \fBg2c_dec_jpeg2000\fP (char *injpc, size_t bufsize, int *outfld)" .br .RI "Decode a JPEG2000 code stream specified in the JPEG2000 Part-1 standard (i\&.e\&., ISO/IEC 15444-1) using \fCJasPer Software\fP\&. " .ti -1c .RI "int \fBg2c_dec_png\fP (unsigned char *pngbuf, int *width, int *height, unsigned char *cout)" .br .RI "Decode PNG\&. " .ti -1c .RI "int \fBg2c_degrib2\fP (int g2cid, const char *fileout)" .br .RI "Write a summary file like the degrib2 utility\&. " .ti -1c .RI "int \fBg2c_enc_jpeg2000\fP (unsigned char *cin, int width, int height, int nbits, int ltype, int ratio, int retry, char *outjpc, size_t jpclen)" .br .RI "Encode a grayscale image into a JPEG2000 code stream specified in the JPEG2000 Part-1 standard (i\&.e\&., ISO/IEC 15444-1) using \fCJasPer Software\fP\&. " .ti -1c .RI "int \fBg2c_enc_png\fP (unsigned char *data, int width, int height, int nbits, unsigned char *pngbuf)" .br .RI "Encode PNG\&. " .ti -1c .RI "int \fBg2c_find_desc\fP (char *title, int code, char *desc)" .br .RI "Given a table title and an integer code, find a description\&. " .ti -1c .RI "int \fBg2c_find_desc_str\fP (char *title, char *code, char *desc)" .br .RI "Given a table title and a code, find a description\&. " .ti -1c .RI "int \fBg2c_find_msg2\fP (int g2cid, size_t skip_bytes, size_t max_bytes, size_t *bytes_to_msg, size_t *bytes_in_msg)" .br .RI "Search a file for the next GRIB1 or GRIB2 message\&. " .ti -1c .RI "void \fBg2c_free_tables\fP ()" .br .RI "Free table memory\&. " .ti -1c .RI "void \fBg2c_gbit_int\fP (unsigned char *in, int *iout, int iskip, int nbits)" .br .RI "Extract arbitrary size values from a packed bit string, right justifying each value in the unpacked iout array\&. " .ti -1c .RI "int \fBg2c_gbits_int\fP (unsigned char *in, int *iout, int iskip, int nbits, int nskip, int n)" .br .RI "Extract arbitrary size values from a packed bit string, right justifying each value in the unpacked iout array\&. " .ti -1c .RI "int \fBg2c_get_drs_template\fP (int drs_template_num, int *maplen, int *map, int *needext)" .br .RI "Get DRS template information\&. " .ti -1c .RI "int \fBg2c_get_grid_template\fP (int grid_template_num, int *maplen, int *map, int *needext)" .br .RI "Get grid template information\&. " .ti -1c .RI "int \fBg2c_get_grid_template_extension\fP (int grid_template_num, int *g2c_template, int *extlen, int *ext)" .br .RI "Get grid template extension information\&. " .ti -1c .RI "int \fBg2c_get_msg\fP (int g2cid, size_t skip_bytes, size_t max_bytes, size_t *bytes_to_msg, size_t *bytes_in_msg, unsigned char **cbuf)" .br .RI "Search a file for the next GRIB1 or GRIB2 message, and read it, allocating space in memory to hold the message\&. " .ti -1c .RI "int \fBg2c_get_pds_template\fP (int pds_template_num, int *maplen, int *map, int *needext)" .br .RI "Get PDS template information\&. " .ti -1c .RI "int \fBg2c_get_pds_template_extension\fP (int pds_template_num, int *g2c_template, int *extlen, int *ext)" .br .RI "Get pds template extension information\&. " .ti -1c .RI "int \fBg2c_get_prod\fP (int g2cid, int msg_num, int prod_num, int *num_data_points, float *data)" .br .RI "Read the data for a product\&. " .ti -1c .RI "int \fBg2c_inq\fP (int g2cid, int *num_msg)" .br .RI "Learn about a GRIB2 file\&. " .ti -1c .RI "int \fBg2c_inq_dim\fP (int g2cid, int msg_num, int prod_num, int dim_num, size_t *len, char *name, float *val)" .br .RI "Learn about the one of the dimensions of a GRIB2 product\&. " .ti -1c .RI "int \fBg2c_inq_dim_info\fP (int g2cid, int msg_num, int prod_num, int dim_num, size_t *len, char *name)" .br .RI "Learn about the one of the dimensions of a GRIB2 product\&. " .ti -1c .RI "int \fBg2c_inq_msg\fP (int g2cid, int msg_num, unsigned char *discipline, int *num_fields, int *num_local, short *center, short *subcenter, unsigned char *master_version, unsigned char *local_version)" .br .RI "Learn about a GRIB2 message\&. " .ti -1c .RI "int \fBg2c_inq_msg_time\fP (int g2cid, int msg_num, unsigned char *sig_ref_time, short *year, unsigned char *month, unsigned char *day, unsigned char *hour, unsigned char *minute, unsigned char *second)" .br .RI "Learn about the date/time information in a GRIB2 message\&. " .ti -1c .RI "int \fBg2c_inq_prod\fP (int g2cid, int msg_num, int prod_num, int *pds_template_len, long long int *pds_template, int *gds_template_len, long long int *gds_template, int *drs_template_len, long long int *drs_template)" .br .RI "Inquire about a product\&. " .ti -1c .RI "int \fBg2c_jpcpackd\fP (double *fld, size_t width, size_t height, int *idrstmpl, unsigned char *cpack, size_t *lcpack)" .br .RI "This function packs up a double array into a JPEG2000 code stream\&. " .ti -1c .RI "int \fBg2c_jpcpackf\fP (float *fld, size_t width, size_t height, int *idrstmpl, unsigned char *cpack, size_t *lcpack)" .br .RI "This function packs up a float array into a JPEG2000 code stream\&. " .ti -1c .RI "int \fBg2c_jpcunpackd\fP (unsigned char *cpack, size_t len, int *idrstmpl, size_t ndpts, double *fld)" .br .RI "Unpack JPEG2000 compressed data into an array of doubles, using info from the GRIB2 Data Representation \fCTemplate 5\&.40\fP or 5\&.40000\&. " .ti -1c .RI "int \fBg2c_jpcunpackf\fP (unsigned char *cpack, size_t len, int *idrstmpl, size_t ndpts, float *fld)" .br .RI "Unpack JPEG2000 compressed data into an array of floats, using info from the GRIB2 Data Representation \fCTemplate 5\&.40\fP or 5\&.40000\&. " .ti -1c .RI "int \fBg2c_log_file\fP (int g2cid)" .br .RI "Print a summary of the contents of an open GRIB2 file\&. " .ti -1c .RI "int \fBg2c_open\fP (const char *path, int mode, int *g2cid)" .br .RI "Open an existing GRIB2 file\&. " .ti -1c .RI "int \fBg2c_open_index\fP (const char *data_file, const char *index_file, int mode, int *g2cid)" .br .RI "Open a GRIB2 file with the help of an index file\&. " .ti -1c .RI "int \fBg2c_open_index1\fP (const char *index_file)" .br .RI "Open a GRIB1 index file and read the contents\&. " .ti -1c .RI "int \fBg2c_param_abbrev\fP (int g2disc, int g2cat, int g2num, char *abbrev)" .br .RI "Get NOAA abbreviation for a GRIB2 parameter\&. " .ti -1c .RI "int \fBg2c_param_all\fP (int param_idx, int *g1ver, int *g1val, int *g2disc, int *g2cat, int *g2num, char *abbdrev)" .br .RI "Return all the information about a parameter\&. " .ti -1c .RI "int \fBg2c_param_g1tog2\fP (int g1val, int g1ver, int *g2disc, int *g2cat, int *g2num)" .br .RI "Translate GRIB1 parameter to GRIB2 parameter\&. " .ti -1c .RI "int \fBg2c_param_g2tog1\fP (int g2disc, int g2cat, int g2num, int *g1val, int *g1ver)" .br .RI "Translate GRIB2 parameter to GRIB1 parameter\&. " .ti -1c .RI "int \fBg2c_pngpackd\fP (double *fld, size_t width, size_t height, int *idrstmpl, unsigned char *cpack, int *lcpack)" .br .RI "This subroutine packs up a double data field into PNG image format\&. " .ti -1c .RI "int \fBg2c_pngpackf\fP (float *fld, size_t width, size_t height, int *idrstmpl, unsigned char *cpack, int *lcpack)" .br .RI "This subroutine packs up a float data field into PNG image format\&. " .ti -1c .RI "int \fBg2c_pngunpackd\fP (unsigned char *cpack, size_t len, int *idrstmpl, size_t ndpts, double *fld)" .br .RI "This subroutine unpacks a data field that was packed into a PNG image format using info from the GRIB2 Data Representation Template 5\&.41 or 5\&.40010\&. " .ti -1c .RI "int \fBg2c_pngunpackf\fP (unsigned char *cpack, size_t len, int *idrstmpl, size_t ndpts, float *fld)" .br .RI "This subroutine unpacks a data field that was packed into a PNG image format using info from the GRIB2 Data Representation Template 5\&.41 or 5\&.40010\&. " .ti -1c .RI "int \fBg2c_seekmsg\fP (int g2cid, size_t skip, size_t *offset, size_t *msglen)" .br .RI "Search a file for the next GRIB2 Message\&. " .ti -1c .RI "int \fBg2c_set_log_level\fP (int new_level)" .br .RI "Use this to set the global log level\&. " .ti -1c .RI "const char * \fBg2c_strerror\fP (int g2cerr)" .br .RI "Given an error code, return an error message\&. " .ti -1c .RI "int \fBg2c_unpack7\fP (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)" .br .RI "This subroutine unpacks Section 7 (Data Section) of a GRIB2 message\&. " .ti -1c .RI "int \fBg2c_write_index\fP (int g2cid, int mode, const char *index_file)" .br .RI "Create an index file from a GRIB2 file, just like those created by the grb2index utility\&. " .ti -1c .RI "void \fBseekgb\fP (FILE *lugb, \fBg2int\fP iseek, \fBg2int\fP mseek, \fBg2int\fP *lskip, \fBg2int\fP *lgrib)" .br .RI "Search a file for the next GRIB Message\&. " .in -1c .SH "Detailed Description" .PP Header file for NCEPLIBS-g2c library\&. .SS "Program History Log" Date Programmer Comments 2002-10-25 Gilbert Initial 2009-01-14 Vuong Changed struct template to gtemplate 2021-11-9 Ed Hartnett Moved many prototypes to new internal header \fBgrib2_int\&.h\fP\&. 2022-04-15 Ed Hartnett Added error codes related to JPEG\&. 2022-08-15 Ed Hartnett Added compression functions for double\&. 2023-09-10 Eric Engle Added AEC compression\&. .PP \fBAuthor\fP .RS 4 Stephen Gilbert .RE .PP \fBDate\fP .RS 4 2002-10-25 .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP .PP Definition in file \fBgrib2\&.h\fP\&. .SH "Data Type Documentation" .PP .SH "struct gribfield" .PP Struct for GRIB2 field\&. .PP Definition at line \fB45\fP of file \fBgrib2\&.h\fP\&. .PP \fBData Fields:\fP .RS 4 \fBg2int\fP * \fIbmap\fP Integer array containing decoded bitmap, if ibmap=0 or ibap=254\&. .br Otherwise NULL\&. .br .PP float * \fIcoord_list\fP Array containing floating point values intended to document the vertical discretisation associated to model data on hybrid coordinate vertical levels (part of Section 4)\&. .br .PP \fBg2int\fP \fIdiscipline\fP Message Discipline (see \fCTable 0\&.0\fP)\&. .br .PP \fBg2int\fP \fIexpanded\fP Logical value indicating whether the data field was expanded to the grid in the case where a bit-map is present\&. .br If true, the data points in fld match the grid points and zeros were inserted at grid points where data was bit-mapped out\&. If false, the data values in ld were not expanded to the grid and are just a consecutive array of data points corresponding to each value of '1' in bmap\&. .br .PP float * \fIfld\fP Array of ndpts unpacked data points\&. .br .PP \fBg2int\fP \fIgriddef\fP Source of grid definition (see \fCTable 3\&.0\fP)\&. .br .IP "\(bu" 2 0 Specified in \fCTable 3\&.1\fP\&. .IP " \(bu" 4 1 Predetermined grid Defined by originating centre\&. .PP .PP .br .PP \fBg2int\fP \fIibmap\fP Bitmap indicator (see \fCTable 6\&.0\fP)\&. .br .IP "\(bu" 2 0 bitmap applies and is included in Section 6\&. .IP "\(bu" 2 1-253 = Predefined bitmap applies .IP "\(bu" 2 254 = Previously defined bitmap applies to this field .IP "\(bu" 2 255 = Bit map does not apply to this product\&. .PP .br .PP \fBg2int\fP \fIidrtlen\fP Number of elements in idrtmpl\&. .br .PP \fBg2int\fP * \fIidrtmpl\fP Contains the data values for the Data Representation Template specified by idrtnum\&. .br .PP \fBg2int\fP \fIidrtnum\fP Data Representation Template Number (see \fCTable 5\&.0\fP)\&. .br .PP \fBg2int\fP * \fIidsect\fP Contains the entries in the \fCIdentification Section (Section 1)\fP\&. .br .IP "\(bu" 2 idsect[0] Identification of originating Centre (see \fCTable 0\fP)\&. 7 is the identification for the US National Weather Service\&. .IP "\(bu" 2 idsect[1] Identification of originating Sub-centre\&. (See \fCTable C\fP)\&. .IP "\(bu" 2 idsect[2] GRIB Master Tables Version Number (see \fCTable 1\&.0\fP)\&. .IP " \(bu" 4 0 Experimental .IP " \(bu" 4 1 Initial operational version number .PP .IP "\(bu" 2 idsect[3] GRIB Local Tables Version Number (see \fCTable 1\&.1\fP)\&. .IP " \(bu" 4 0 Local tables not used .IP " \(bu" 4 1-254 Number of local tables version used .PP .IP "\(bu" 2 idsect[4] Significance of Reference Time (See \fCTable 1\&.2\fP)\&. .IP " \(bu" 4 0 Analysis .IP " \(bu" 4 1 Start of forecast .IP " \(bu" 4 2 Verifying time of forecast .IP " \(bu" 4 3 Observation time .PP .IP "\(bu" 2 idsect[5] Year (4 digits) .IP "\(bu" 2 idsect[6] Month .IP "\(bu" 2 idsect[7) Day .IP "\(bu" 2 idsect[8] Hour .IP "\(bu" 2 idsect[9] Minute .IP "\(bu" 2 idsect[10] Second .IP "\(bu" 2 idsect[11] Production status of processed data (see \fCTable 1\&.3\fP)\&. .IP " \(bu" 4 0 Operational products .IP " \(bu" 4 1 Operational test products .IP " \(bu" 4 2 Research products .IP " \(bu" 4 3 Re-analysis products .PP .IP "\(bu" 2 idsect[12] Type of processed data (see \fCTable 1\&.4\fP)\&. .IP " \(bu" 4 0 Analysis products .IP " \(bu" 4 1 Forecast products .IP " \(bu" 4 2 Analysis and forecast products .IP " \(bu" 4 3 Control forecast products .IP " \(bu" 4 4 Perturbed forecast products .IP " \(bu" 4 5 Control and perturbed forecast products .IP " \(bu" 4 6 Processed satellite observations .IP " \(bu" 4 7 Processed radar observations .PP .PP .br .PP \fBg2int\fP \fIidsectlen\fP Number of elements in idsect\&. .br .PP \fBg2int\fP \fIifldnum\fP Field number within GRIB message\&. .br .PP \fBg2int\fP \fIigdtlen\fP Number of elements in igdtmpl - i\&.e\&. .br number of entries in Grid Defintion Template\&. .br .PP \fBg2int\fP * \fIigdtmpl\fP Contains the data values for the Grid Definition Template specified by igdtnum\&. .br .PP \fBg2int\fP \fIigdtnum\fP Grid Definition Template Number (See \fCTable 3\&.1\fP)\&. .br .PP \fBg2int\fP \fIinterp_opt\fP Interpretation of list for optional points definition\&. .br (See \fCTable 3\&.11\fP)\&. .br .PP \fBg2int\fP \fIipdtlen\fP Number of elements in ipdtmpl - i\&.e\&. .br number of entries in Product Defintion Template\&. .br .PP \fBg2int\fP * \fIipdtmpl\fP Contains the data values for the Product Definition Template specified by ipdtnum\&. .br .PP \fBg2int\fP \fIipdtnum\fP Product Definition Template Number (see \fCTable 4\&.0\fP)\&. .br .PP \fBg2int\fP * \fIlist_opt\fP (Used if numoct_opt \&.ne\&. .br 0) This array contains the number of grid points contained in each row (or column) (part of Section 3)\&. NULL if numoct_opt = 0\&. .br .PP unsigned char * \fIlocal\fP Pointer to character array containing contents of Local Section 2, if included\&. .br .PP \fBg2int\fP \fIlocallen\fP Length of array local\&. .br .PP \fBg2int\fP \fIndpts\fP Number of data points unpacked and returned\&. .br .PP \fBg2int\fP \fIngrdpts\fP Number of grid points in the defined grid\&. .br .PP \fBg2int\fP \fInum_coord\fP Number of values in array coord_list\&. .br .PP \fBg2int\fP \fInum_opt\fP (Used if numoct_opt \&.ne\&. .br 0) The number of entries in array ideflist - i\&.e\&. number of rows (or columns) for which optional grid points are defined\&. This value is set to zero, if numoct_opt=0\&. .br .PP \fBg2int\fP \fInumoct_opt\fP Number of octets needed for each additional grid points definition\&. .br Used to define number of points in each row (or column) for non-regular grids\&. = 0, if using regular grid\&. .br .PP \fBg2int\fP \fIunpacked\fP Logical value indicating whether the bitmap and data values were unpacked\&. .br If false, bmap and fld pointers are NULL\&. .br .PP \fBg2int\fP \fIversion\fP GRIB edition number (2)\&. .br .PP .RE .PP .SH "Macro Definition Documentation" .PP .SS "#define G2_ADD_MSG_COMPLETE \-2" .PP GRIB message already complete\&. Cannot add new section\&. .PP Definition at line \fB467\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_ADD_MSG_INIT \-1" .PP GRIB message was not initialized - call \fBg2_create()\fP first\&. .PP Definition at line \fB466\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_ADDFIELD_BAD_BITMAP \-8" .PP In \fBg2_addfield()\fP no bitmap in the GRIB message\&. .PP Definition at line \fB472\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_ADDFIELD_BAD_DRT \-7" .PP In \fBg2_addfield()\fP unsupported Data Representationi Template\&. .PP Definition at line \fB471\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_ADDFIELD_BAD_GDS \-6" .PP In \fBg2_addfield()\fP section 3 (GDS) not previously defined in message\&. .PP Definition at line \fB470\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_ADDFIELD_BAD_GDT \-9" .PP In \fBg2_addfield()\fP GDT of one of 5\&.50 through 5\&.53 required when using DRT 5\&.51\&. .PP Definition at line \fB473\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_ADDFIELD_BAD_PDT \-5" .PP In \fBg2_addfield()\fP could not find requested Product Definition Template\&. .PP Definition at line \fB469\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_ADDFIELD_ERR \-10" .PP In \fBg2_addfield()\fP error packing data field\&. .PP Definition at line \fB474\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_ADDGRID_BAD_GDT \-5" .PP In \fBg2_addgrid()\fP Could not find requested Grid Definition Template\&. .PP Definition at line \fB475\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_AEC_ENABLED 1" .PP Decoding/encoding AEC/CCSDS is enabled\&. .PP Definition at line \fB29\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_BAD_SEC \-4" .PP Previous Section was unexpected\&. .PP Definition at line \fB456\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_BAD_SEC_COUNTS \-3" .PP Sum of Section byte counts doesn't add to total byte count\&. .PP Definition at line \fB468\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_CREATE_GRIB_VERSION \-1" .PP Wrong GRIB version for \fBg2_create()\fP, must be 2\&. .PP Definition at line \fB432\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_GETFLD_BAD_END 7" .PP \fBg2_getfld()\fP didn't find '7777' at end of message\&. .PP Definition at line \fB444\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_GETFLD_BAD_SEC1 15" .PP Error in \fBg2_getfld()\fP unpacking section 1\&. .PP Definition at line \fB447\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_GETFLD_BAD_SEC2 16" .PP Error in \fBg2_getfld()\fP unpacking section 2\&. .PP Definition at line \fB448\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_GETFLD_BAD_SEC3 10" .PP Error in \fBg2_getfld()\fP unpacking section 3\&. .PP Definition at line \fB449\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_GETFLD_BAD_SEC4 11" .PP Error in \fBg2_getfld()\fP unpacking section 4\&. .PP Definition at line \fB450\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_GETFLD_BAD_SEC5 12" .PP Error in \fBg2_getfld()\fP unpacking section 5\&. .PP Definition at line \fB451\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_GETFLD_BAD_SEC6 13" .PP Error in \fBg2_getfld()\fP unpacking section 6\&. .PP Definition at line \fB452\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_GETFLD_BAD_SEC7 14" .PP Error in \fBg2_getfld()\fP unpacking section 7\&. .PP Definition at line \fB453\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_GETFLD_GRIB_VERSION 2" .PP Wrong GRIB version for \fBg2_getfld()\fP, must be 2\&. .PP Definition at line \fB440\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_GETFLD_INVAL 3" .PP \fBg2_getfld()\fP data field request number was not positive\&. .PP Definition at line \fB441\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_GETFLD_INVAL_SEC 8" .PP \fBg2_getfld()\fP encountered unrecognized section\&. .PP Definition at line \fB445\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_GETFLD_NO_BITMAP 17" .PP In \fBg2_getfld()\fP previous bitmap specified, yet none exists\&. .PP Definition at line \fB454\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_GETFLD_NO_DRT 9" .PP In \fBg2_getfld()\fP, Data Representation Template not implemented\&. .PP Definition at line \fB446\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_GETFLD_NO_GRIB 1" .PP \fBg2_getfld()\fP can't find beginning characters 'GRIB'\&. .PP Definition at line \fB439\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_GETFLD_WRONG_END 4" .PP \fBg2_info()\fP found '7777' not where expected\&. .PP Definition at line \fB442\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_GETFLD_WRONG_NFLDS 6" .PP In \fBg2_getfld()\fP message did not contain the requested number of data fields\&. .PP Definition at line \fB443\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_GRIBEND_MSG_INIT \-1" .PP In \fBg2_gribend()\fP GRIB message was not initialized - call \fBg2_create()\fP first\&. .PP Definition at line \fB455\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_INFO_BAD_END 5" .PP \fBg2_info()\fP didn't find '7777' at end of message\&. .PP Definition at line \fB437\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_INFO_GRIB_VERSION 2" .PP Wrong GRIB version for \fBg2_info()\fP, must be 2\&. .PP Definition at line \fB434\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_INFO_INVAL_SEC 6" .PP \fBg2_info()\fP found invalid section number\&. .PP Definition at line \fB438\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_INFO_NO_GRIB 1" .PP \fBg2_info()\fP can't find beginning characters 'GRIB'\&. .PP Definition at line \fB433\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_INFO_NO_SEC1 3" .PP \fBg2_info()\fP can't find section 1\&. .PP Definition at line \fB435\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_INFO_WRONG_END 4" .PP \fBg2_info()\fP found '7777' not where expected\&. .PP Definition at line \fB436\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_JASPER_DECODE \-3" .PP In \fBdec_jpeg2000()\fP error decoding image with jasper\&. .PP Definition at line \fB480\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_JASPER_DECODE_COLOR \-5" .PP In \fBdec_jpeg2000()\fP decoded image had multiple color components\&. .PP Definition at line \fB481\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_JASPER_ENCODE \-3" .PP In \fBenc_jpeg2000()\fP error encoding image with jasper\&. .PP Definition at line \fB479\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_JASPER_INIT \-2" .PP In \fBenc_jpeg2000()\fP/dec_jpeg2000() error initializing jasper library\&. .PP Definition at line \fB478\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_JPCUNPACK_MEM 1" .PP In \fBjpcunpack()\fP or other unpack function: out of memory\&. .PP Definition at line \fB476\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_JPEG2000_ENABLED 1" .PP Decoding/encoding JPEG2000 is enabled\&. .PP Definition at line \fB28\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_NO_ERROR 0" .PP Function succeeded\&. .PP Definition at line \fB431\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_PNG_ENABLED 1" .PP Decoding/encoding PNG is enabled\&. .PP Definition at line \fB27\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_SPECUNPACK_TYPE \-3" .PP In \fBspecunpack()\fP Can't handle 64 or 128 bit floats\&. .PP Definition at line \fB477\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_UNPACK3_BAD_GDT 5" .PP In \fBg2_unpack3()\fP, undefined Grid Definition Template\&. .PP Definition at line \fB459\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_UNPACK4_BAD_PDT 5" .PP In \fBg2_unpack4()\fP, undefined Product Definition Template\&. .PP Definition at line \fB460\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_UNPACK5_BAD_DRT 7" .PP In \fBg2_unpack5()\fP, undefined Data Representation Template\&. .PP Definition at line \fB461\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_UNPACK6_BAD_BITMAP 4" .PP In \fBg2_unpack6()\fP, unrecognized pre-defined bit-map\&. .PP Definition at line \fB462\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_UNPACK7_BAD_DRT 4" .PP In \fBg2_unpack7()\fP, unrecognized Data Representation Template\&. .PP Definition at line \fB465\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_UNPACK7_CORRUPT_SEC 7" .PP In \fBg2_unpack7()\fP, corrupt section 7\&. .PP Definition at line \fB463\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_UNPACK7_WRONG_GDT 5" .PP In \fBg2_unpack7()\fP, need one of GDT 3\&.50 through 3\&.53 to decode DRT 5\&.51\&. .PP Definition at line \fB464\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_UNPACK_BAD_SEC 2" .PP Bad section number in unpacking function\&. .PP Definition at line \fB457\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2_UNPACK_NO_MEM 6" .PP Error allocating memory in unpack function\&. .PP Definition at line \fB458\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_AEC_DRS_TEMPLATE_LEN 8" .PP Length of the idrstmpl array for AEC packing\&. .PP Definition at line \fB413\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_BYTE 1" .PP signed 1 byte integer .PP Definition at line \fB260\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_CHAR 2" .PP ISO/ASCII character\&. .PP Definition at line \fB261\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_CLOBBER 0x0000" .PP Destroy existing file\&. Mode flag for g2c_create()\&. .PP Definition at line \fB277\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_DOUBLE 6" .PP double precision floating point number .PP Definition at line \fB265\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_EAEC (\-74)" .PP Error encoding/decoding AEC data\&. .PP Definition at line \fB510\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_EBADEND (\-65)" .PP End of message in wrong place\&. .PP Definition at line \fB501\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_EBADID (\-55)" .PP Bad ID\&. .PP Definition at line \fB491\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_EBADSECTION (\-66)" .PP Invalid section number\&. .PP Definition at line \fB502\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_EBADTEMPLATE (\-70)" .PP Template problem\&. .PP Definition at line \fB506\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_EBADTYPE (\-73)" .PP Type not found\&. .PP Definition at line \fB509\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_ECSV (\-75)" .PP CSV error\&. .PP Definition at line \fB511\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_EFILE (\-54)" .PP File I/O error\&. .PP Definition at line \fB490\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_EINVAL (\-53)" .PP Invalid input\&. .PP Definition at line \fB489\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_EJPEG (\-67)" .PP Error encoding/decoding JPEG data\&. .PP Definition at line \fB503\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_EMSG (\-58)" .PP Error decoding GRIB message\&. .PP Definition at line \fB494\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_EMSGCOMPLETE (\-51)" .PP GRIB message already complete\&. .PP Definition at line \fB487\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_ENAMETOOLONG (\-52)" .PP Name too long\&. .PP Definition at line \fB488\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_ENOEND (\-64)" .PP Cannot find end of GRIB message\&. .PP Definition at line \fB500\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_ENOMEM (\-57)" .PP Out of memory\&. .PP Definition at line \fB493\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_ENOMSG (\-59)" .PP No GRIB message found\&. .PP Definition at line \fB495\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_ENOPARAM (\-71)" .PP Parameter not found\&. .PP Definition at line \fB507\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_ENOPRODUCT (\-72)" .PP Product not found\&. .PP Definition at line \fB508\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_ENOSECTION (\-63)" .PP Cannot find section\&. .PP Definition at line \fB499\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_ENOTEMPLATE (\-69)" .PP Template not found\&. .PP Definition at line \fB505\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_ENOTFOUND (\-61)" .PP Table or entry not found\&. .PP Definition at line \fB497\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_ENOTGRIB (\-50)" .PP GRIB header not found\&. .PP Definition at line \fB486\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_ENOTGRIB2 (\-62)" .PP Not GRIB 2\&. .PP Definition at line \fB498\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_EPNG (\-68)" .PP Error encoding/decoding PNG data\&. .PP Definition at line \fB504\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_ERROR 1" .PP General error code, returned for some test errors\&. .PP Definition at line \fB485\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_ETOOMANYFILES (\-56)" .PP Trying to open too many files\&. .PP Definition at line \fB492\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_EXML (\-60)" .PP XML error\&. .PP Definition at line \fB496\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_FLOAT 5" .PP single precision floating point number .PP Definition at line \fB264\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_INT 4" .PP signed 4 byte integer .PP Definition at line \fB263\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_INT64 10" .PP signed 8-byte int .PP Definition at line \fB269\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_JASPER_MAX_MEM" .PP Maximum size for the Jasper memory buffer\&. .PP Definition at line \fB426\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_JPEG_DRS_TEMPLATE_LEN 7" .PP Length of the idrstmpl array for JPEG packing\&. .PP Definition at line \fB411\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_LARGE_FILE_INDEX 0x0008" .PP Create a large file index\&. Mode flag for \fBg2c_write_index()\fP\&. .PP Definition at line \fB279\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_MAX_DRS_TEMPLATE 11" .PP Maximum number of DRS templates\&. .PP Definition at line \fB296\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_MAX_DRS_TEMPLATE_MAPLEN 18" .PP Maximum DRS template map length\&. .PP Definition at line \fB297\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_MAX_FILES 3" .PP Maximum number of open files\&. .PP Definition at line \fB273\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_MAX_GDS_TEMPLATE 38" .PP Maximum number of grid templates\&. .PP Definition at line \fB292\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_MAX_GDS_TEMPLATE_MAPLEN 28" .PP Maximum grid template map length\&. .PP Definition at line \fB293\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_MAX_GRIB_CODE_LEN 20" .PP Maximum length of code\&. .PP Definition at line \fB418\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_MAX_GRIB_DESC_LEN 512" .PP Maximum length of code description\&. .PP Definition at line \fB415\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_MAX_GRIB_LEVEL_DESC_LEN 40" .PP Maximum length of level description\&. .PP Definition at line \fB417\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_MAX_GRIB_STATUS_LEN 40" .PP Maximum length of code status\&. .PP Definition at line \fB416\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_MAX_GRIB_TITLE_LEN 200" .PP Maximum length of code table title\&. .PP Definition at line \fB419\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_MAX_NAME 1024" .PP Maximum length of a name\&. .PP Definition at line \fB274\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_MAX_NOAA_ABBREV_LEN 8" .PP Maximum length of a NOAA abbreviation of a parameter\&. .PP Definition at line \fB423\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_MAX_NOAA_PARAM_LINE_LEN 120" .PP Maximum length of a line in the NOAA abbreviation CSV file\&. .PP Definition at line \fB424\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_MAX_NOAA_PARAMS 2000" .PP Maximum number of known parameters with NOAA abbreviations\&. .PP Definition at line \fB422\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_MAX_NUM_SECTIONS 1024" .PP Maximum number of sections that can be handled in one message\&. .PP Definition at line \fB420\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_MAX_PDS_TEMPLATE 102" .PP Maximum number of PDS templates\&. .PP Definition at line \fB294\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_MAX_PDS_TEMPLATE_MAPLEN 50" .PP Maximum template map length\&. .PP Definition at line \fB295\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_NOCLOBBER 0x0004" .PP Don't destroy existing file\&. Mode flag for g2c_create()\&. .PP Definition at line \fB278\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_NOERROR 0" .PP No error\&. .PP Definition at line \fB484\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_NOWRITE 0x0000" .PP Set read-only access for \fBg2c_open()\fP\&. .PP Definition at line \fB275\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_PNG_DRS_TEMPLATE_LEN 5" .PP Length of the idrstmpl array for PNG packing\&. .PP Definition at line \fB412\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_PNG_HEIGHT_MAX 100000" .PP Maximum height of PNG grid\&. .PP Definition at line \fB429\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_PNG_WIDTH_MAX 100000000" .PP Maximum width of PNG grid\&. .PP Definition at line \fB428\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_SECTION0_ARRAY_LEN 3" .PP Length of section 0 array\&. .PP Definition at line \fB408\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_SECTION0_BYTES 16" .PP Number of bytes in section 0\&. .PP Definition at line \fB282\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_SECTION0_LEN 3" .PP Length of section 0 array\&. .PP Definition at line \fB288\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_SECTION1_ARRAY_LEN 13" .PP Length of section 1 array\&. .PP Definition at line \fB409\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_SECTION1_BYTES 21" .PP Number of bytes in section 1 (not including reserved, optional data at the end of the section)\&. .PP Definition at line \fB286\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_SECTION1_LEN 13" .PP Length of section 1 array\&. .PP Definition at line \fB289\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_SHORT 3" .PP signed 2 byte integer .PP Definition at line \fB262\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_UBYTE 7" .PP unsigned 1 byte int .PP Definition at line \fB266\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_UINT 9" .PP unsigned 4-byte int .PP Definition at line \fB268\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_UINT64 11" .PP unsigned 8-byte int .PP Definition at line \fB270\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_USHORT 8" .PP unsigned 2-byte int .PP Definition at line \fB267\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_VERSION '2\&.1\&.0'" .PP Current version of NCEPLIBS-g2c library\&. .PP Definition at line \fB25\fP of file \fBgrib2\&.h\fP\&. .SS "#define G2C_WRITE 0x0001" .PP Set read-write access for \fBg2c_open()\fP\&. .PP Definition at line \fB276\fP of file \fBgrib2\&.h\fP\&. .SH "Typedef Documentation" .PP .SS "typedef float \fBg2float\fP" .PP Float type\&. This typedef is provided for backward compatibility and is not used by the library any more\&. Use float in new code\&. .PP Definition at line \fB40\fP of file \fBgrib2\&.h\fP\&. .SS "typedef int64_t \fBg2int\fP" .PP Long integer type\&. .PP Definition at line \fB32\fP of file \fBgrib2\&.h\fP\&. .SS "typedef uint64_t \fBg2intu\fP" .PP Unsigned long integer type\&. This typedef is provided for backward compatibility and is not used by the library any more\&. .PP Definition at line \fB36\fP of file \fBgrib2\&.h\fP\&. .SS "typedef struct \fBgribfield\fP \fBgribfield\fP" .PP Struct for GRIB field\&. .PP Definition at line \fB221\fP of file \fBgrib2\&.h\fP\&. .SH "Function Documentation" .PP .SS "\fBg2int\fP g2_addfield (unsigned char * cgrib, \fBg2int\fP ipdsnum, \fBg2int\fP * ipdstmpl, float * coordlist, \fBg2int\fP numcoord, \fBg2int\fP idrsnum, \fBg2int\fP * idrstmpl, float * fld, \fBg2int\fP ngrdpts, \fBg2int\fP ibmap, \fBg2int\fP * bmap)" .PP Pack sections 4 through 7 and adds them to a GRIB2 message\&. They are: .IP "4." 4 \fCProduct Definition Section\fP .IP "5." 4 \fCData Representation Section\fP .IP "6." 4 \fCBit-Map Section\fP .IP "7." 4 \fCData Section\fP .PP .PP This routine is used with routines \fBg2_create()\fP, \fBg2_addlocal()\fP, \fBg2_addgrid()\fP, and \fBg2_gribend()\fP to create a complete GRIB2 message\&. Function \fBg2_create()\fP must be called first to initialize a new GRIB2 message\&. Function \fBg2_addgrid()\fP must be called after \fBg2_create()\fP and before this routine to add the appropriate grid description to the GRIB2 message\&. A call to \fBg2_gribend()\fP is required to complete GRIB2 message after all fields have been added\&. .SS "Program History Log" Date Programmer Comments 2002-11-05 Gilbert Initial 2002-12-23 Gilbert Added complex spherical harmonic packing 2003-08-27 Gilbert Added support for new templates using PNG and JPEG2000 algorithms/templates\&. 2004-11-29 Gilbert JPEG2000 now can use WMO Template 5\&.40 PNG can use WMO Template 5\&.41\&. Added packing algorithm check\&. 2005-05-10 Gilbert Imposed minimum size on cpack\&. 2009-01-14 Vuong Changed structure name template to gtemplate 2023-09-08 Engle Added support for new template, 5\&.42, using CCSDS compression (libaec)\&. .PP \fBParameters\fP .RS 4 \fIcgrib\fP Char array that contains the GRIB2 message to which sections 4 through 7 should be added\&. Must be allocated large enough to store the entire GRIB2 message\&. .br \fIipdsnum\fP Product Definition Template Number (see \fCCode Table 4\&.0\fP)\&. .br \fIipdstmpl\fP Contains the data values for the Product Definition Template specified by ipdsnum\&. .br \fIcoordlist\fP Array containg floating point values intended to document the vertical discretisation associated to model data on hybrid coordinate vertical levels\&. .br \fInumcoord\fP number of values in array coordlist\&. .br \fIidrsnum\fP Data Representation Template Number (see \fCCode Table 5\&.0\fP)\&. .br \fIidrstmpl\fP The data values for the Data Representation Template specified by idrsnum\&. Note that some values in this template (eg\&. reference values, number of bits, etc\&.\&.\&.) may be changed by the data packing algorithms\&. Use this to specify scaling factors and order of spatial differencing, if desired\&. .br \fIfld\fP Array of data points to pack\&. .br \fIngrdpts\fP Number of data points in grid\&. i\&.e\&. size of fld and bmap\&. .br \fIibmap\fP Bitmap indicator (see \fCCode Table 6\&.0\fP) .IP "\(bu" 2 0 = bitmap applies and is included in Section 6\&. .IP "\(bu" 2 1-253 = Predefined bitmap applies\&. .IP "\(bu" 2 254 = Previously defined bitmap applies to this field\&. .IP "\(bu" 2 255 = Bit map does not apply to this product\&. .PP .br \fIbmap\fP Integer array containing bitmap to be added (if ibmap = 0)\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 > 0 Current size of updated GRIB2 message .IP "\(bu" 2 \fBG2_ADD_MSG_INIT\fP GRIB message was not initialized\&. Need to call routine \fBg2_create()\fP first\&. .IP "\(bu" 2 \fBG2_ADD_MSG_COMPLETE\fP GRIB message already complete\&. Cannot add new section\&. .IP "\(bu" 2 \fBG2_BAD_SEC_COUNTS\fP Sum of Section byte counts doesn't add to total byte count\&. .IP "\(bu" 2 \fBG2_BAD_SEC\fP Previous Section was not 3 or 7\&. .IP "\(bu" 2 \fBG2_ADDFIELD_BAD_PDT\fP Could not find requested Product Definition Template\&. .IP "\(bu" 2 \fBG2_ADDFIELD_BAD_GDS\fP Section 3 (GDS) not previously defined in message\&. .IP "\(bu" 2 \fBG2_ADDFIELD_BAD_DRT\fP Tried to use unsupported Data Representationi Template\&. .IP "\(bu" 2 \fBG2_ADDFIELD_BAD_BITMAP\fP Specified use of a previously defined bitmap, but one does not exist in the GRIB message\&. .IP "\(bu" 2 \fBG2_ADDFIELD_BAD_GDT\fP GDT of one of 5\&.50 through 5\&.53 required to pack field using DRT 5\&.51\&. .IP "\(bu" 2 \fBG2_ADDFIELD_ERR\fP Error packing data field\&. .PP .RE .PP \fBNote\fP .RS 4 Note that the Sections 4 through 7 can only follow Section 3 or Section 7 in a GRIB2 message\&. .RE .PP \fBAuthor\fP .RS 4 Stephen Gilbert .RE .PP \fBDate\fP .RS 4 2002-11-05 .RE .PP .PP Definition at line \fB100\fP of file \fBg2_addfield\&.c\fP\&. .PP References \fBaecpack()\fP, \fBcmplxpack()\fP, \fBgtemplate::ext\fP, \fBgtemplate::extlen\fP, \fBextpdstemplate()\fP, \fBG2_ADD_MSG_COMPLETE\fP, \fBG2_ADD_MSG_INIT\fP, \fBG2_ADDFIELD_BAD_BITMAP\fP, \fBG2_ADDFIELD_BAD_DRT\fP, \fBG2_ADDFIELD_BAD_GDS\fP, \fBG2_ADDFIELD_BAD_GDT\fP, \fBG2_ADDFIELD_BAD_PDT\fP, \fBG2_ADDFIELD_ERR\fP, \fBG2_BAD_SEC\fP, \fBG2_BAD_SEC_COUNTS\fP, \fBg2c_check_msg()\fP, \fBG2C_EMSGCOMPLETE\fP, \fBG2C_ENOTGRIB\fP, \fBgbit()\fP, \fBgetdim()\fP, \fBgetdrstemplate()\fP, \fBgetpdstemplate()\fP, \fBgetpoly()\fP, \fBjpcpack()\fP, \fBgtemplate::map\fP, \fBgtemplate::maplen\fP, \fBmkieee()\fP, \fBgtemplate::needext\fP, \fBpngpack()\fP, \fBsbit()\fP, \fBsbits()\fP, \fBsimpack()\fP, and \fBspecpack()\fP\&. .SS "\fBg2int\fP g2_addgrid (unsigned char * cgrib, \fBg2int\fP * igds, \fBg2int\fP * igdstmpl, \fBg2int\fP * ideflist, \fBg2int\fP idefnum)" .PP Packs a \fCGrid Definition Section (Section 3)\fP and adds it to a GRIB2 message\&. This function is used with routines \fBg2_create()\fP, \fBg2_addlocal()\fP, \fBg2_addfield()\fP, and \fBg2_gribend()\fP to create a complete GRIB2 message\&. \fBg2_create()\fP must be called first to initialize a new GRIB2 message\&. .PP \fBParameters\fP .RS 4 \fIcgrib\fP Char array that contains the GRIB2 message to which section should be added\&. Must be allocated large enough to store the entire GRIB2 message\&. .br \fIigds\fP Contains information needed for GRIB Grid Definition Section 3\&. Must be dimensioned >= 5\&. .IP "\(bu" 2 igds[0] Source of grid definition (see \fCCode Table 3\&.0\fP)\&. .IP "\(bu" 2 igds[1] Number of grid points in the defined grid\&. .IP "\(bu" 2 igds[2] 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\&. .IP "\(bu" 2 igds[3] Interpretation of list for optional points definition\&. (See \fCCode Table 3\&.11\fP)\&. .IP "\(bu" 2 igds[4] Grid Definition Template Number (See \fCCode Table 3\&.1\fP)\&. .PP .br \fIigdstmpl\fP Contains the data values for the specified Grid Definition Template (igds[4])\&. Each element of this integer array contains an entry (in the order specified) of Grid Defintion Template\&. .br \fIideflist\fP (Used if igds[2] != 0) This array contains the number of grid points contained in each row (or column)\&. .br \fIidefnum\fP (Used if igds[2] != 0) The number of entries in array ideflist\&. i\&.e\&. number of rows (or columns) for which optional grid points are defined\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 > 0 Current size of updated GRIB2 message .IP "\(bu" 2 \fBG2_ADD_MSG_INIT\fP GRIB message was not initialized\&. Need to call routine gribcreate first\&. .IP "\(bu" 2 \fBG2_ADD_MSG_COMPLETE\fP GRIB message already complete\&. Cannot add new section\&. .IP "\(bu" 2 \fBG2_BAD_SEC_COUNTS\fP Sum of Section byte counts doesn't add to total byte count .IP "\(bu" 2 \fBG2_BAD_SEC\fP Previous Section was not 1, 2 or 7\&. .IP "\(bu" 2 \fBG2_ADDGRID_BAD_GDT\fP Could not find requested Grid Definition Template\&. .PP .RE .PP \fBNote\fP .RS 4 The Grid Def Section (Section 3) can only follow Section 1, 2 or Section 7 in a GRIB2 message\&. .RE .PP \fBAuthor\fP .RS 4 Stephen Gilbeert .RE .PP \fBDate\fP .RS 4 2002-11-01 .RE .PP .PP Definition at line \fB66\fP of file \fBg2_addgrid\&.c\fP\&. .PP References \fBgtemplate::ext\fP, \fBextgridtemplate()\fP, \fBgtemplate::extlen\fP, \fBG2_ADD_MSG_COMPLETE\fP, \fBG2_ADD_MSG_INIT\fP, \fBG2_ADDGRID_BAD_GDT\fP, \fBG2_BAD_SEC\fP, \fBG2_BAD_SEC_COUNTS\fP, \fBg2c_check_msg()\fP, \fBG2C_EMSGCOMPLETE\fP, \fBG2C_ENOTGRIB\fP, \fBgbit()\fP, \fBgetgridtemplate()\fP, \fBgtemplate::map\fP, \fBgtemplate::maplen\fP, \fBgtemplate::needext\fP, \fBsbit()\fP, and \fBsbits()\fP\&. .SS "\fBg2int\fP g2_addlocal (unsigned char * cgrib, unsigned char * csec2, \fBg2int\fP lcsec2)" .PP Adds a \fCLocal Use Section (Section 2)\fP to a GRIB2 message\&. This function is used with routines \fBg2_create()\fP, \fBg2_addgrid()\fP, \fBg2_addfield()\fP, and \fBg2_gribend()\fP to create a complete GRIB2 message\&. .PP \fBParameters\fP .RS 4 \fIcgrib\fP Char array that contains the GRIB2 message to which section 2 should be added\&. Must be allocated large enough to store the entire GRIB2 message\&. .br \fIcsec2\fP Character array containing information to be added in Section 2\&. .br \fIlcsec2\fP Number of bytes of character array csec2 to be added to Section 2\&. .RE .PP \fBReturns\fP .RS 4 > 0 = Current size of updated GRIB2 message\&. .RE .PP .IP "\(bu" 2 \fBG2_ADD_MSG_INIT\fP GRIB message was not initialized\&. Need to call routine gribcreate first\&. .IP "\(bu" 2 \fBG2_ADD_MSG_COMPLETE\fP GRIB message already complete\&. Cannot add new section\&. .IP "\(bu" 2 \fBG2_BAD_SEC_COUNTS\fP Sum of Section byte counts doesn't add to total byte count\&. .IP "\(bu" 2 \fBG2_BAD_SEC\fP Previous Section was not 1 or 7\&. .PP .PP \fBNote\fP .RS 4 The Local Use Section (Section 2) can only follow Section 1 or Section 7 in a GRIB2 message\&. .RE .PP \fBAuthor\fP .RS 4 Stephen Gilbeert .RE .PP \fBDate\fP .RS 4 2002-11-01 .RE .PP .PP Definition at line \fB41\fP of file \fBg2_addlocal\&.c\fP\&. .PP References \fBG2_ADD_MSG_COMPLETE\fP, \fBG2_ADD_MSG_INIT\fP, \fBG2_BAD_SEC\fP, \fBG2_BAD_SEC_COUNTS\fP, \fBg2c_check_msg()\fP, \fBG2C_EMSGCOMPLETE\fP, \fBG2C_ENOTGRIB\fP, \fBgbit()\fP, and \fBsbit()\fP\&. .SS "\fBg2int\fP g2_create (unsigned char * cgrib, \fBg2int\fP * listsec0, \fBg2int\fP * listsec1)" .PP Initialize a new GRIB2 message and pack GRIB2 \fCSection 0 (Indicator Section)\fP and \fCSection 1 (Identification Section)\fP\&. This routine is used with routines \fBg2_addlocal()\fP, \fBg2_addgrid()\fP, \fBg2_addfield()\fP, and \fBg2_gribend()\fP to create a complete GRIB2 message\&. \fBg2_create()\fP must be called first to initialize a new GRIB2 message\&. A call to \fBg2_gribend()\fP is required to complete GRIB2 message after all fields have been added\&. .PP \fBParameters\fP .RS 4 \fIcgrib\fP Character array to contain the GRIB2 message\&. Must be allocated large enough to store the entire GRIB2 message\&. .br \fIlistsec0\fP Contains information needed for GRIB Indicator Section 0\&. Must be dimensioned >= 2\&. .IP "\(bu" 2 listsec0[0] Discipline-GRIB Master Table Number ([Code Table 0\&.0] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table0-0.shtml))\&. .IP "\(bu" 2 listsec0[1] GRIB Edition Number (currently 2)\&. .PP .br \fIlistsec1\fP Contains information needed for GRIB Identification Section 1\&. Must be dimensioned >= 13\&. .IP "\(bu" 2 listsec1[0] Id of orginating centre ([Table 0] (https://www.nco.ncep.noaa.gov/pmb/docs/on388/table0.html))\&. .IP "\(bu" 2 listsec1[1] Id of orginating sub-centre ([Table C] (https://www.nco.ncep.noaa.gov/pmb/docs/on388/tablec.html))\&. .IP "\(bu" 2 listsec1[2] GRIB Master Tables Version Number ([Table 1\&.0] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-0.shtml))\&. .IP "\(bu" 2 listsec1[3] GRIB Local Tables Version Number ([Table 1\&.1] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-1.shtml))\&. .IP "\(bu" 2 listsec1[4] Significance of Reference Time ([Table 1\&.2] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-2.shtml)) .IP "\(bu" 2 listsec1[5] Reference Time - Year (4 digits) .IP "\(bu" 2 listsec1[6] Reference Time - Month .IP "\(bu" 2 listsec1[7] Reference Time - Day .IP "\(bu" 2 listsec1[8] Reference Time - Hour .IP "\(bu" 2 listsec1[9] Reference Time - Minute .IP "\(bu" 2 listsec1[10] Reference Time - Second .IP "\(bu" 2 listsec1[11] Production status of data ([Table 1\&.3] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-3.shtml))\&. .IP "\(bu" 2 listsec1[12] Type of processed data ([Table 1\&.4] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-4.shtml))\&. .PP .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 > 0 Current size of new GRIB2 message .IP "\(bu" 2 \fBG2_CREATE_GRIB_VERSION\fP Tried to use for version other than GRIB Edition 2 .PP .RE .PP This routine is intended for use with routines \fBg2_addlocal()\fP, \fBg2_addgrid()\fP, \fBg2_addfield()\fP, and \fBg2_gribend()\fP to create a complete GRIB2 message\&. .PP \fBAuthor\fP .RS 4 Stephen Gilbeert .RE .PP \fBDate\fP .RS 4 2002-10-31 .RE .PP .PP Definition at line \fB68\fP of file \fBg2_create\&.c\fP\&. .PP References \fBG2_CREATE_GRIB_VERSION\fP, \fBLENSEC0\fP, \fBMAPSEC1LEN\fP, and \fBsbit()\fP\&. .SS "void g2_free (\fBgribfield\fP * gfld)" .PP Free memory that was allocated for struct \fBgribfield\fP\&. .PP \fBParameters\fP .RS 4 \fIgfld\fP pointer to \fBgribfield\fP structure (defined in include file \fBgrib2\&.h\fP) returned from routine \fBg2_getfld()\fP\&. .RE .PP \fBNote\fP .RS 4 This routine must be called to free up memory used by the decode routine, \fBg2_getfld()\fP, when user no longer needs to reference this data\&. .RE .PP \fBAuthor\fP .RS 4 Stephen Gilbeert .RE .PP \fBDate\fP .RS 4 2002-10-28 .RE .PP .PP Definition at line \fB23\fP of file \fBg2_free\&.c\fP\&. .PP References \fBgribfield::bmap\fP, \fBgribfield::coord_list\fP, \fBgribfield::fld\fP, \fBgribfield::idrtmpl\fP, \fBgribfield::idsect\fP, \fBgribfield::igdtmpl\fP, \fBgribfield::ipdtmpl\fP, \fBgribfield::list_opt\fP, and \fBgribfield::local\fP\&. .PP Referenced by \fBg2_getfld()\fP\&. .SS "\fBg2int\fP g2_getfld (unsigned char * cgrib, \fBg2int\fP ifldnum, \fBg2int\fP unpack, \fBg2int\fP expand, \fBgribfield\fP ** gfld)" .PP Return all the metadata, template values, bit-map (if applicable), and the unpacked data for a data field\&. All of the information returned is stored in a \fBgribfield\fP structure, which is defined in file \fBgrib2\&.h\fP\&. Users of this routine will need to include \fBgrib2\&.h\fP in their source code that calls this routine\&. .PP Since there can be multiple data fields packed into a GRIB2 message, the calling routine indicates which field is being requested with the ifldnum argument\&. .SS "Program History Log" Date Programmer Comments 2002-10-28 Gilbert Initial 2013-08-08 Vuong Free up memory in array igds - free(igds) .PP \fBParameters\fP .RS 4 \fIcgrib\fP Character pointer to the GRIB2 message\&. .br \fIifldnum\fP Specifies which field in the GRIB2 message to return\&. The first field is number 1, Fortran style\&. .br \fIunpack\fP Boolean value indicating whether to unpack bitmap/data field\&. .IP "\(bu" 2 1 unpack bitmap (if present) and data values\&. .IP "\(bu" 2 0 do not unpack bitmap and data values\&. .PP .br \fIexpand\fP Boolean value indicating whether the data points should be expanded to the correspond grid, if a bit-map is present\&. This argument is ignored if unpack == 0 OR if the returned field does not contain a bit-map\&. .IP "\(bu" 2 1 if possible, expand data field to grid, inserting zero values at gridpoints that are bitmapped out\&. (SEE REMARKS2) .IP "\(bu" 2 0 do not expand data field, leaving it an array of consecutive data points for each '1' in the bitmap\&. .PP .br \fIgfld\fP pointer to structure \fBgribfield\fP containing all decoded data for the data field\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2_NO_ERROR\fP no error .IP "\(bu" 2 \fBG2_GETFLD_NO_GRIB\fP Beginning characters 'GRIB' not found\&. .IP "\(bu" 2 \fBG2_GETFLD_GRIB_VERSION\fP GRIB message is not Edition 2\&. .IP "\(bu" 2 \fBG2_GETFLD_INVAL\fP The data field request number was not positive\&. .IP "\(bu" 2 \fBG2_GETFLD_WRONG_END\fP End string '7777' found, but not where expected\&. .IP "\(bu" 2 \fBG2_GETFLD_WRONG_NFLDS\fP GRIB message did not contain the requested number of data fields\&. .IP "\(bu" 2 \fBG2_GETFLD_BAD_END\fP End string '7777' not found at end of message\&. .IP "\(bu" 2 \fBG2_GETFLD_INVAL_SEC\fP Unrecognized Section encountered\&. .IP "\(bu" 2 \fBG2_GETFLD_NO_DRT\fP Data Representation Template 5\&.NN not yet implemented\&. .IP "\(bu" 2 \fBG2_GETFLD_BAD_SEC1\fP Error unpacking Section 1\&. .IP "\(bu" 2 \fBG2_GETFLD_BAD_SEC2\fP Error unpacking Section 2\&. .IP "\(bu" 2 \fBG2_GETFLD_BAD_SEC3\fP Error unpacking Section 3\&. .IP "\(bu" 2 \fBG2_GETFLD_BAD_SEC4\fP Error unpacking Section 4\&. .IP "\(bu" 2 \fBG2_GETFLD_BAD_SEC5\fP Error unpacking Section 5\&. .IP "\(bu" 2 \fBG2_GETFLD_BAD_SEC6\fP Error unpacking Section 6\&. .IP "\(bu" 2 \fBG2_GETFLD_BAD_SEC7\fP Error unpacking Section 7\&. .IP "\(bu" 2 \fBG2_GETFLD_NO_BITMAP\fP Previous bitmap specified, yet none exists\&. .PP .RE .PP \fBNote\fP .RS 4 Struct \fBgribfield\fP is allocated by this routine and it also contains pointers to many arrays of data that were allocated during decoding\&. Users are encouraged to free up this memory, when it is no longer needed, by an explicit call to routine \fBg2_free()\fP\&. .RE .PP .SS "Example:" .PP .nf #include "grib2\&.h" gribfield *gfld; ret=g2_getfld(cgrib,1,1,1,&gfld); \&.\&.\&. g2_free(gfld); .fi .PP .PP Routine \fBg2_info()\fP can be used to first determine how many data fields exist in a given GRIB message\&. .PP \fBNote\fP .RS 4 It may not always be possible to expand a bit-mapped data field\&. If a pre-defined bit-map is used and not included in the GRIB2 message itself, this routine would not have the necessary information to expand the data\&. In this case, gfld->expanded would would be set to 0 (false), regardless of the value of input argument expand\&. .RE .PP \fBAuthor\fP .RS 4 Stephen Gilbert .RE .PP \fBDate\fP .RS 4 2002-10-28 .RE .PP .PP Definition at line \fB93\fP of file \fBg2_getfld\&.c\fP\&. .PP References \fBgribfield::bmap\fP, \fBgribfield::coord_list\fP, \fBgribfield::discipline\fP, \fBgribfield::expanded\fP, \fBgribfield::fld\fP, \fBg2_free()\fP, \fBG2_GETFLD_BAD_END\fP, \fBG2_GETFLD_BAD_SEC1\fP, \fBG2_GETFLD_BAD_SEC2\fP, \fBG2_GETFLD_BAD_SEC3\fP, \fBG2_GETFLD_BAD_SEC4\fP, \fBG2_GETFLD_BAD_SEC5\fP, \fBG2_GETFLD_BAD_SEC6\fP, \fBG2_GETFLD_BAD_SEC7\fP, \fBG2_GETFLD_GRIB_VERSION\fP, \fBG2_GETFLD_INVAL\fP, \fBG2_GETFLD_INVAL_SEC\fP, \fBG2_GETFLD_NO_BITMAP\fP, \fBG2_GETFLD_NO_GRIB\fP, \fBG2_GETFLD_WRONG_END\fP, \fBG2_GETFLD_WRONG_NFLDS\fP, \fBG2_NO_ERROR\fP, \fBg2_unpack1()\fP, \fBg2_unpack2()\fP, \fBg2_unpack3()\fP, \fBg2_unpack4()\fP, \fBg2_unpack5()\fP, \fBg2_unpack6()\fP, \fBg2_unpack7()\fP, \fBgbit()\fP, \fBgribfield::griddef\fP, \fBgribfield::ibmap\fP, \fBgribfield::idrtlen\fP, \fBgribfield::idrtmpl\fP, \fBgribfield::idrtnum\fP, \fBgribfield::idsect\fP, \fBgribfield::idsectlen\fP, \fBgribfield::ifldnum\fP, \fBgribfield::igdtlen\fP, \fBgribfield::igdtmpl\fP, \fBgribfield::igdtnum\fP, \fBgribfield::interp_opt\fP, \fBgribfield::ipdtlen\fP, \fBgribfield::ipdtmpl\fP, \fBgribfield::ipdtnum\fP, \fBgribfield::list_opt\fP, \fBgribfield::local\fP, \fBgribfield::locallen\fP, \fBgribfield::ndpts\fP, \fBgribfield::ngrdpts\fP, \fBgribfield::num_coord\fP, \fBgribfield::num_opt\fP, \fBgribfield::numoct_opt\fP, \fBgribfield::unpacked\fP, and \fBgribfield::version\fP\&. .SS "\fBg2int\fP g2_gribend (unsigned char * cgrib)" .PP Finalize a GRIB2 message after all grids and fields have been added\&. This function adds the End Section ('7777') to the end of the GRIB message and calculates the length and stores it in the appropriate place in Section 0\&. This routine is used with routines \fBg2_create()\fP, \fBg2_addlocal()\fP, \fBg2_addgrid()\fP, and \fBg2_addfield()\fP to create a complete GRIB2 message\&. .PP \fBParameters\fP .RS 4 \fIcgrib\fP Char array containing all the data sections added be previous calls to \fBg2_create()\fP, \fBg2_addlocal()\fP, \fBg2_addgrid()\fP, and \fBg2_addfield()\fP\&. After function is called, contains the finalized GRIB2 message\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 > 0 Length of the final GRIB2 message in bytes\&. .IP "\(bu" 2 \fBG2_GRIBEND_MSG_INIT\fP GRIB message was not initialized - call \fBg2_create()\fP first\&. .IP "\(bu" 2 \fBG2_BAD_SEC_COUNTS\fP Sum of Section byte counts doesn't add to total byte count\&. .IP "\(bu" 2 \fBG2_BAD_SEC\fP Previous Section was not 7\&. .PP .RE .PP \fBNote\fP .RS 4 This routine is intended for use with routines \fBg2_create()\fP, \fBg2_addlocal()\fP, \fBg2_addgrid()\fP, and \fBg2_addfield()\fP to create a complete GRIB2 message\&. .RE .PP \fBAuthor\fP .RS 4 Stephen Gilbert .RE .PP \fBDate\fP .RS 4 2002-10-31 .RE .PP .PP Definition at line \fB40\fP of file \fBg2_gribend\&.c\fP\&. .PP References \fBG2_ADD_MSG_COMPLETE\fP, \fBG2_ADD_MSG_INIT\fP, \fBG2_BAD_SEC\fP, \fBG2_BAD_SEC_COUNTS\fP, \fBg2c_check_msg()\fP, \fBG2C_EMSGCOMPLETE\fP, \fBG2C_ENOTGRIB\fP, \fBgbit()\fP, and \fBsbit()\fP\&. .SS "\fBg2int\fP g2_info (unsigned char * cgrib, \fBg2int\fP * listsec0, \fBg2int\fP * listsec1, \fBg2int\fP * numfields, \fBg2int\fP * numlocal)" .PP Search through a GRIB2 message and return the number of gridded fields found in the message and the number (and maximum size) of Local Use Sections\&. Other checks are performed to see if the message is a valid GRIB2 message\&. .PP \fBParameters\fP .RS 4 \fIcgrib\fP Pointer to a buffer containing the GRIB2 message\&. .br \fIlistsec0\fP Pointer to an array that gets the information decoded from GRIB Indicator Section 0\&. Must be allocated with >= 3 elements (see \fBG2C_SECTION0_LEN\fP)\&. .IP "\(bu" 2 listsec0(0) Discipline-GRIB Master Table Number ([Code Table 0\&.0] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table0-0.shtml))\&. .IP "\(bu" 2 listsec0[1] GRIB Edition Number (currently 2)\&. .IP "\(bu" 2 listsec0[2] Length of GRIB message\&. .PP .br \fIlistsec1\fP Pointer to an array that gets the information read from GRIB Identification Section 1\&. Must be allocated with >= 13 elements (see \fBG2C_SECTION1_LEN\fP)\&. .IP "\(bu" 2 listsec1[0] Id of orginating centre ([Table 0] (https://www.nco.ncep.noaa.gov/pmb/docs/on388/table0.html))\&. .IP "\(bu" 2 listsec1[1] Id of orginating sub-centre ([Table C] (https://www.nco.ncep.noaa.gov/pmb/docs/on388/tablec.html))\&. .IP "\(bu" 2 listsec1[2] GRIB Master Tables Version Number ([Table 1\&.0] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-0.shtml))\&. .IP "\(bu" 2 listsec1[3] GRIB Local Tables Version Number ([Table 1\&.1] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-1.shtml))\&. .IP "\(bu" 2 listsec1[4] Significance of Reference Time ([Table 1\&.2] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-1.shtml)) .IP "\(bu" 2 listsec1[5] Reference Time - Year (4 digits) .IP "\(bu" 2 listsec1[6] Reference Time - Month .IP "\(bu" 2 listsec1[7] Reference Time - Day .IP "\(bu" 2 listsec1[8] Reference Time - Hour .IP "\(bu" 2 listsec1[9] Reference Time - Minute .IP "\(bu" 2 listsec1[10] Reference Time - Second .IP "\(bu" 2 listsec1[11] Production status of data ([Table 1\&.3] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-3.shtml))\&. .IP "\(bu" 2 listsec1[12] Type of processed data ([Table 1\&.4] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-4.shtml))\&. .PP .br \fInumfields\fP A pointer that gets the number of gridded fields found in the GRIB message\&. That is, the number of occurences of Sections 4 - 7\&. .br \fInumlocal\fP A pointer that gets the number of Local Use Sections (section 2) found in the GRIB message\&. .RE .PP \fBReturns\fP .RS 4 0 for success, otherwise: .IP "\(bu" 2 \fBG2_INFO_NO_GRIB\fP Beginning characters 'GRIB' not found\&. .IP "\(bu" 2 \fBG2_INFO_GRIB_VERSION\fP GRIB message is not Edition 2\&. .IP "\(bu" 2 \fBG2_INFO_NO_SEC1\fP Could not find Section 1, where expected\&. .IP "\(bu" 2 \fBG2_INFO_WRONG_END\fP End string '7777' found, but not where expected\&. .IP "\(bu" 2 \fBG2_INFO_BAD_END\fP End string '7777' not found at end of message\&. .IP "\(bu" 2 \fBG2_INFO_INVAL_SEC\fP Invalid section number found\&. .PP .RE .PP \fBAuthor\fP .RS 4 Stephen Gilbeert .RE .PP \fBDate\fP .RS 4 2002-10-28 .RE .PP .PP Definition at line \fB70\fP of file \fBg2_info\&.c\fP\&. .PP References \fBG2_INFO_BAD_END\fP, \fBG2_INFO_GRIB_VERSION\fP, \fBG2_INFO_INVAL_SEC\fP, \fBG2_INFO_NO_GRIB\fP, \fBG2_INFO_NO_SEC1\fP, \fBG2_INFO_WRONG_END\fP, \fBgbit()\fP, and \fBLOG\fP\&. .SS "\fBg2int\fP g2_unpack1 (unsigned char * cgrib, \fBg2int\fP * iofst, \fBg2int\fP ** ids, \fBg2int\fP * idslen)" .PP Unpacks \fCSection 1 - Identification Section\fP of a GRIB2 message\&. .PP \fBParameters\fP .RS 4 \fIcgrib\fP char array containing Section 1 of the GRIB2 message\&. .br \fIiofst\fP Bit offset for the beginning of Section 1 in cgrib\&. .br \fIids\fP Pointer that gets an array which contians the information read from Section 1, the Identification section\&. This array is allocated by this function, and must be freed by caller (using \fBg2_free()\fP)\&. .IP "\(bu" 2 ids[0] Identification of originating Centre (see \fCTable 0\fP)\&. .IP "\(bu" 2 ids[1] Identification of originating Sub-centre (see \fCTable C\fP)\&. .IP "\(bu" 2 ids[2] GRIB Master Tables Version Number (see \fCTable 1\&.0\fP)\&. .IP "\(bu" 2 ids[3] GRIB Local Tables Version Number (see \fCTable 1\&.1\fP)\&. .IP "\(bu" 2 ids[4] Significance of Reference Time (see \fCTable 1\&.2\fP)\&. .IP "\(bu" 2 ids[5] Year (4 digits) .IP "\(bu" 2 ids[6] Month .IP "\(bu" 2 ids[7] Day .IP "\(bu" 2 ids[8] Hour .IP "\(bu" 2 ids[9] Minute .IP "\(bu" 2 ids[10] Second .IP "\(bu" 2 ids[11] Production status of processed data (see \fCTable 1\&.3\fP)\&. .IP "\(bu" 2 ids[12] Type of processed data (see \fCTable 1\&.4\fP)\&. .PP .br \fIidslen\fP Number of elements in ids\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2_NO_ERROR\fP No error\&. .IP "\(bu" 2 \fBG2_UNPACK_BAD_SEC\fP Array passed is not section 1\&. .IP "\(bu" 2 \fBG2_UNPACK_NO_MEM\fP memory allocation error\&. .PP .RE .PP \fBAuthor\fP .RS 4 Stephen Gilbert .RE .PP \fBDate\fP .RS 4 2002-10-29 .RE .PP .PP Definition at line \fB55\fP of file \fBg2_unpack1\&.c\fP\&. .PP References \fBG2_NO_ERROR\fP, \fBG2_UNPACK_BAD_SEC\fP, \fBG2_UNPACK_NO_MEM\fP, and \fBgbit()\fP\&. .PP Referenced by \fBg2_getfld()\fP\&. .SS "\fBg2int\fP g2_unpack2 (unsigned char * cgrib, \fBg2int\fP * iofst, \fBg2int\fP * lencsec2, unsigned char ** csec2)" .PP Unpack \fCSection 2 (Local Use Section)\fP of a GRIB2 message\&. .SS "Program History Log" Date Programmer Comments 2002-10-31 Gilbert Initial 2008-12-23 Wesley Initialize lencsec2 Length of Local Use data 2010-08-05 Vuong If section 2 has zero length, ierr=0 .PP \fBParameters\fP .RS 4 \fIcgrib\fP char array containing Section 2 of the GRIB2 message\&. .br \fIiofst\fP Pointer that contains the bit offset for the beginning of Section 2 in cgrib\&. The modified version will be returned\&. .br \fIlencsec2\fP Length (in octets) of Local Use data\&. .br \fIcsec2\fP Pointer to a pointer that will get an allocated array containing local use data\&. This memory must be freed by the caller\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2_NO_ERROR\fP No error\&. .IP "\(bu" 2 \fBG2_UNPACK_BAD_SEC\fP Array passed had incorrect section number\&. .IP "\(bu" 2 \fBG2_UNPACK_NO_MEM\fP Memory allocation error\&. .PP .RE .PP \fBAuthor\fP .RS 4 Stephen Gilbert .RE .PP \fBDate\fP .RS 4 2002-10-31 .RE .PP .PP Definition at line \fB37\fP of file \fBg2_unpack2\&.c\fP\&. .PP References \fBG2_NO_ERROR\fP, \fBG2_UNPACK_BAD_SEC\fP, \fBG2_UNPACK_NO_MEM\fP, and \fBgbit()\fP\&. .PP Referenced by \fBg2_getfld()\fP\&. .SS "\fBg2int\fP g2_unpack3 (unsigned char * cgrib, \fBg2int\fP * iofst, \fBg2int\fP ** igds, \fBg2int\fP ** igdstmpl, \fBg2int\fP * mapgridlen, \fBg2int\fP ** ideflist, \fBg2int\fP * idefnum)" .PP Unpack \fCSection 3 (Grid Definition Section)\fP of a GRIB2 message\&. .SS "Program History Log" Date Programmer Comments 2002-10-31 Gilbert Initial 2009-01-14 Vuong Changed structure name template to gtemplate .PP \fBParameters\fP .RS 4 \fIcgrib\fP Char array ontaining Section 3 of the GRIB2 message\&. .br \fIiofst\fP Pointer to g2int which contains the bit offset for the beginning of Section 3 in cgrib\&. .br \fIigds\fP Pointer to a pointer which will get a pointer to memory allocated for the GDS array, of length 5\&. The array will contain information read from the appropriate GRIB Grid Definition Section 3 for the field being returned\&. .IP "\(bu" 2 igds[0] Source of grid definition (see \fCTable 3\&.0\fP)\&. .IP "\(bu" 2 igds[1] Number of grid points in the defined grid\&. .IP "\(bu" 2 igds[2] 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\&. .IP "\(bu" 2 igds[3] Interpretation of list for optional points definition\&. (See \fCTable 3\&.11\fP) .IP "\(bu" 2 igds[4] Grid Definition Template Number (see \fCTable 3\&.1\fP)\&. .PP .br \fIigdstmpl\fP Pointer a pointer to g2int, which will get a pointer to an allocated array that contians containing the data values from the Grid Definition Template specified by igds[4]\&. .br \fImapgridlen\fP A pointer tat gets the number of elements in igdstmpl\&. i\&.e\&. number of entries in Grid Defintion Template specified by igds[4]\&. .br \fIideflist\fP (Used if igds[2] \&.ne\&. 0) Pointer to integer array containing the number of grid points contained in each row (or column)\&. .br \fIidefnum\fP (Used if igds[2] != 0\&.) A pointer that gets the number of entries in array ideflist - i\&.e\&. number of rows (or columns) for which optional grid points are defined\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2_NO_ERROR\fP No error\&. .IP "\(bu" 2 \fBG2_UNPACK_BAD_SEC\fP Array passed had incorrect section number\&. .IP "\(bu" 2 \fBG2_UNPACK3_BAD_GDT\fP message contains an undefined Grid Definition Template\&. .IP "\(bu" 2 \fBG2_UNPACK_NO_MEM\fP Memory allocation error\&. .PP .RE .PP \fBAuthor\fP .RS 4 Stephen Gilbert .RE .PP \fBDate\fP .RS 4 2002-10-31 .RE .PP .PP Definition at line \fB62\fP of file \fBg2_unpack3\&.c\fP\&. .PP References \fBgtemplate::ext\fP, \fBextgridtemplate()\fP, \fBgtemplate::extlen\fP, \fBG2_NO_ERROR\fP, \fBG2_UNPACK3_BAD_GDT\fP, \fBG2_UNPACK_BAD_SEC\fP, \fBG2_UNPACK_NO_MEM\fP, \fBgbit()\fP, \fBgbits()\fP, \fBgetgridtemplate()\fP, \fBgtemplate::map\fP, \fBgtemplate::maplen\fP, and \fBgtemplate::needext\fP\&. .PP Referenced by \fBg2_getfld()\fP, \fBgetdim()\fP, and \fBgetpoly()\fP\&. .SS "\fBg2int\fP g2_unpack4 (unsigned char * cgrib, \fBg2int\fP * iofst, \fBg2int\fP * ipdsnum, \fBg2int\fP ** ipdstmpl, \fBg2int\fP * mappdslen, float ** coordlist, \fBg2int\fP * numcoord)" .PP Unpack \fCSection 4 (Product Definition Section)\fP of a GRIB2 message\&. .SS "Program History Log" Date Programmer Comments 2002-10-31 Gilbert Initial 2009-01-14 Vuong Changed structure name template to gtemplate .PP \fBParameters\fP .RS 4 \fIcgrib\fP Array containing Section 4 of the GRIB2 message\&. .br \fIiofst\fP Bit offset of the beginning of Section 4 in cgrib\&. Returned with updated bit offset\&. .br \fIipdsnum\fP Product Definition Template Number (see \fCTable 4\&.0\fP)\&. .br \fIipdstmpl\fP Pointer that gets an integer array containing the data values for the Product Definition Template specified by ipdsnum\&. .br \fImappdslen\fP Number of elements in ipdstmpl - i\&.e\&. number of entries in Product Defintion Template specified by ipdsnum\&. .br \fIcoordlist\fP Pointer that gets an array containing floating point values intended to document the vertical discretisation associated to model data on hybrid coordinate vertical levels\&. .br \fInumcoord\fP number of values in array coordlist\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2_NO_ERROR\fP No error\&. .IP "\(bu" 2 \fBG2_UNPACK_BAD_SEC\fP Array passed had incorrect section number\&. .IP "\(bu" 2 \fBG2_UNPACK4_BAD_PDT\fP message contains an undefined Product Definition Template\&. .IP "\(bu" 2 \fBG2_UNPACK_NO_MEM\fP Memory allocation error\&. .PP .RE .PP \fBAuthor\fP .RS 4 Stephen Gilbert .RE .PP \fBDate\fP .RS 4 2002-10-31 .RE .PP .PP Definition at line \fB45\fP of file \fBg2_unpack4\&.c\fP\&. .PP References \fBgtemplate::ext\fP, \fBgtemplate::extlen\fP, \fBextpdstemplate()\fP, \fBG2_NO_ERROR\fP, \fBG2_UNPACK4_BAD_PDT\fP, \fBG2_UNPACK_BAD_SEC\fP, \fBG2_UNPACK_NO_MEM\fP, \fBgbit()\fP, \fBgbits()\fP, \fBgetpdstemplate()\fP, \fBgtemplate::map\fP, \fBgtemplate::maplen\fP, \fBgtemplate::needext\fP, and \fBrdieee()\fP\&. .PP Referenced by \fBg2_getfld()\fP\&. .SS "\fBg2int\fP g2_unpack5 (unsigned char * cgrib, \fBg2int\fP * iofst, \fBg2int\fP * ndpts, \fBg2int\fP * idrsnum, \fBg2int\fP ** idrstmpl, \fBg2int\fP * mapdrslen)" .PP Unpack Section 5 (Data Representation Section) of a GRIB2 message\&. .SS "Program History Log" Date Programmer Comments 2002-10-31 Gilbert Initial 2009-01-14 Vuong Changed structure name template to gtemplate .PP \fBParameters\fP .RS 4 \fIcgrib\fP char array containing Section 5 of the GRIB2 message\&. .br \fIiofst\fP Bit offset for the beginning of Section 5 in cgrib\&. Returned with bit offset at the end of Section 5\&. .br \fIndpts\fP Number of data points unpacked and returned\&. .br \fIidrsnum\fP Data Representation Template Number (see Code Table 5\&.0)\&. .br \fIidrstmpl\fP 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\&. .br \fImapdrslen-\fP Number of elements in idrstmpl\&. i\&.e\&. number of entries in Data Representation Template 5\&.N (N=idrsnum)\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2_NO_ERROR\fP No error\&. .IP "\(bu" 2 \fBG2_UNPACK_BAD_SEC\fP Array passed had incorrect section number\&. .IP "\(bu" 2 \fBG2_UNPACK_NO_MEM\fP Memory allocation error\&. .IP "\(bu" 2 \fBG2_UNPACK5_BAD_DRT\fP 'GRIB' message contains an undefined Data Representation Template\&. .PP .RE .PP \fBAuthor\fP .RS 4 Stephen Gilbert .RE .PP \fBDate\fP .RS 4 2002-10-31 .RE .PP .PP Definition at line \fB40\fP of file \fBg2_unpack5\&.c\fP\&. .PP References \fBgtemplate::ext\fP, \fBextdrstemplate()\fP, \fBgtemplate::extlen\fP, \fBG2_NO_ERROR\fP, \fBG2_UNPACK5_BAD_DRT\fP, \fBG2_UNPACK_BAD_SEC\fP, \fBG2_UNPACK_NO_MEM\fP, \fBgbit()\fP, \fBgetdrstemplate()\fP, \fBgtemplate::map\fP, \fBgtemplate::maplen\fP, and \fBgtemplate::needext\fP\&. .PP Referenced by \fBg2_getfld()\fP\&. .SS "\fBg2int\fP g2_unpack6 (unsigned char * cgrib, \fBg2int\fP * iofst, \fBg2int\fP ngpts, \fBg2int\fP * ibmap, \fBg2int\fP ** bmap)" .PP Unpack Section 6 (Bit-Map Section) of a GRIB2 message\&. .PP \fBParameters\fP .RS 4 \fIcgrib\fP char array containing Section 6 of the GRIB2 message\&. .br \fIiofst\fP Bit offset of the beginning of Section 6 in cgrib\&. .br \fIngpts\fP Number of grid points specified in the bit-map .br \fIibmap\fP Bitmap indicator (see Code Table 6\&.0) .IP "\(bu" 2 0 bitmap applies and is included in Section 6\&. .IP "\(bu" 2 1-253 Predefined bitmap applies .IP "\(bu" 2 254 Previously defined bitmap applies to this field .IP "\(bu" 2 255 Bit map does not apply to this product\&. .PP .br \fIbmap\fP Pointer to an integer array containing decoded bitmap\&. (if ibmap=0) .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2_NO_ERROR\fP No error\&. .IP "\(bu" 2 \fBG2_UNPACK_BAD_SEC\fP Array passed had incorrect section number\&. .IP "\(bu" 2 \fBG2_UNPACK6_BAD_BITMAP\fP Unrecognized pre-defined bit-map\&. .IP "\(bu" 2 \fBG2_UNPACK_NO_MEM\fP Memory allocation error\&. .PP .RE .PP \fBAuthor\fP .RS 4 Stephen Gilbert .RE .PP \fBDate\fP .RS 4 2002-10-31 .RE .PP .PP Definition at line \fB32\fP of file \fBg2_unpack6\&.c\fP\&. .PP References \fBG2_NO_ERROR\fP, \fBG2_UNPACK_BAD_SEC\fP, \fBG2_UNPACK_NO_MEM\fP, \fBgbit()\fP, and \fBgbits()\fP\&. .PP Referenced by \fBg2_getfld()\fP\&. .SS "\fBg2int\fP g2_unpack7 (unsigned char * cgrib, \fBg2int\fP * iofst, \fBg2int\fP igdsnum, \fBg2int\fP * igdstmpl, \fBg2int\fP idrsnum, \fBg2int\fP * idrstmpl, \fBg2int\fP ndpts, float ** fld)" .PP 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 \fBg2c_unpack7()\fP function instead\&. .PP \fBParameters\fP .RS 4 \fIcgrib\fP char array containing Section 7 of the GRIB2 message .br \fIiofst\fP 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\&. .br \fIigdsnum\fP Grid Definition Template Number (see Code Table 3\&.0)\&. (Only used for DRS Template 5\&.51\&.) .br \fIigdstmpl\fP 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)\&. .br \fIidrsnum\fP Data Representation Template Number (see Code Table 5\&.0)\&. .br \fIidrstmpl\fP 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 .br \fIndpts\fP Number of data points to be unpacked and returned\&. .br \fIfld\fP 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\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2_NO_ERROR\fP No error\&. .IP "\(bu" 2 \fBG2_UNPACK_BAD_SEC\fP Array passed had incorrect section number\&. .IP "\(bu" 2 \fBG2_UNPACK7_BAD_DRT\fP Unrecognized Data Representation Template\&. .IP "\(bu" 2 \fBG2_UNPACK7_WRONG_GDT\fP need one of GDT 3\&.50 through 3\&.53 to decode DRT 5\&.51 .IP "\(bu" 2 \fBG2_UNPACK_NO_MEM\fP Memory allocation error\&. .IP "\(bu" 2 \fBG2_UNPACK7_CORRUPT_SEC\fP Corrupt section 7\&. .PP .RE .PP \fBAuthor\fP .RS 4 Stephen Gilbert .RE .PP \fBDate\fP .RS 4 2002-10-31 .RE .PP .PP Definition at line \fB214\fP of file \fBg2_unpack7\&.c\fP\&. .PP References \fBg2c_unpack7_int()\fP\&. .PP Referenced by \fBg2_getfld()\fP\&. .SS "int g2c_aecpackd (double * fld, size_t width, size_t height, int * idrstmpl, unsigned char * cpack, size_t * lcpack)" .PP This function packs up a double array into a AEC code stream\&. After the data are scaled, and the reference value is subtracted out, the data are passed to the AEC encoder\&. .PP This function also fills in GRIB2 Data Representation Template 5\&.42 with the appropriate values\&. .PP This function is the V2 API version of \fBaecpack()\fP for floats\&. .PP \fBParameters\fP .RS 4 \fIfld\fP Pointer to the float data values to pack\&. .br \fIwidth\fP The number of points in the x direction\&. .br \fIheight\fP The number of points in the y direction\&. .br \fIidrstmpl\fP Contains the array of values for Data Representation Template \fCTable 5\&.42\fP\&. .IP "\(bu" 2 0 Reference value - ignored on input, set by aecpack routine\&. .IP "\(bu" 2 1 Binary Scale Factor - used on input, unchanged by aecpack routine\&. .IP "\(bu" 2 2 Decimal Scale Factor - used on input, unchanged by aecpack routine\&. .IP "\(bu" 2 3 number of bits for each data value - ignored on input .IP "\(bu" 2 4 Original field type - currently ignored on input Data values assumed to be reals\&. Set to 0 on output\&. .IP "\(bu" 2 5 CCSDS compression options mask\&. .IP "\(bu" 2 6 Block size\&. .IP "\(bu" 2 7 Reference sample interval\&. May be modified in this function\&. .PP .br \fIcpack\fP A pointer that will get the packed data field\&. Must be allocated before this function is called\&. Pass the allocated size in the lcpack parameter\&. .br \fIlcpack\fP Pointer that gets the length of packed field in cpack\&. This must be set by the calling function to the size available in cpack\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EAEC\fP Error encoding/decoding AEC data\&. .PP .RE .PP \fBAuthor\fP .RS 4 Eric Engle (adapted from jpcpack) .RE .PP .PP Definition at line \fB410\fP of file \fBaecpack\&.c\fP\&. .PP References \fBaecpack_int()\fP, and \fBG2C_AEC_DRS_TEMPLATE_LEN\fP\&. .SS "int g2c_aecpackf (float * fld, size_t width, size_t height, int * idrstmpl, unsigned char * cpack, size_t * lcpack)" .PP This function packs up a float array into a AEC code stream\&. After the data are scaled, and the reference value is subtracted out, the data are passed to the AEC encoder\&. .PP This function also fills in GRIB2 Data Representation Template 5\&.42 with the appropriate values\&. .PP This function is the V2 API version of \fBaecpack()\fP for floats\&. .PP \fBParameters\fP .RS 4 \fIfld\fP Pointer to the float data values to pack\&. .br \fIwidth\fP The number of points in the x direction\&. .br \fIheight\fP The number of points in the y direction\&. .br \fIidrstmpl\fP Contains the array of values for Data Representation Template \fCTable 5\&.42\fP\&. .IP "\(bu" 2 0 Reference value - ignored on input, set by aecpack routine\&. .IP "\(bu" 2 1 Binary Scale Factor - used on input, unchanged by aecpack routine\&. .IP "\(bu" 2 2 Decimal Scale Factor - used on input, unchanged by aecpack routine\&. .IP "\(bu" 2 3 number of bits for each data value - ignored on input .IP "\(bu" 2 4 Original field type - currently ignored on input Data values assumed to be reals\&. Set to 0 on output\&. .IP "\(bu" 2 5 CCSDS compression options mask\&. .IP "\(bu" 2 6 Block size\&. .IP "\(bu" 2 7 Reference sample interval\&. May be modified in this function\&. .PP .br \fIcpack\fP A pointer that will get the packed data field\&. Must be allocated before this function is called\&. Pass the allocated size in the lcpack parameter\&. .br \fIlcpack\fP Pointer that gets the length of packed field in cpack\&. This must be set by the calling function to the size available in cpack\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EAEC\fP Error encoding/decoding AEC data\&. .PP .RE .PP \fBAuthor\fP .RS 4 Eric Engle (adapted from jpcpack) .RE .PP .PP Definition at line \fB346\fP of file \fBaecpack\&.c\fP\&. .PP References \fBaecpack_int()\fP, and \fBG2C_AEC_DRS_TEMPLATE_LEN\fP\&. .SS "int g2c_aecunpackd (unsigned char * cpack, size_t len, int * idrstmpl, size_t ndpts, double * fld)" .PP Unpack AEC compressed data into an array of doubles, using info from the GRIB2 Data Representation \fCTemplate 5\&.42\fP\&. This function is the V2 API version of \fBaecunpack()\fP for doubles\&. .PP \fBParameters\fP .RS 4 \fIcpack\fP The packed data\&. .br \fIlen\fP The length of the packed data\&. .br \fIidrstmpl\fP Pointer to array of values for Data Representation \fCTemplate 5\&.42\fP\&. .br \fIndpts\fP The number of data values to unpack\&. .br \fIfld\fP A pointer that gets the unpacked data values as an array of double\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_ENOMEM\fP Out of memory\&. .PP .RE .PP \fBAuthor\fP .RS 4 Eric Engle .RE .PP \fBDate\fP .RS 4 2023-10-16 .RE .PP .PP Definition at line \fB232\fP of file \fBaecunpack\&.c\fP\&. .PP References \fBaecunpack_int()\fP, \fBG2C_AEC_DRS_TEMPLATE_LEN\fP, and \fBLOG\fP\&. .SS "int g2c_aecunpackf (unsigned char * cpack, size_t len, int * idrstmpl, size_t ndpts, float * fld)" .PP Unpack AEC compressed data into an array of floats, using info from the GRIB2 Data Representation \fCTemplate 5\&.42\fP\&. .PP \fBParameters\fP .RS 4 \fIcpack\fP The packed data\&. .br \fIlen\fP The length of the packed data\&. .br \fIidrstmpl\fP Pointer to array of values for Data Representation \fCTemplate 5\&.42\fP\&. .br \fIndpts\fP The number of data values to unpack\&. .br \fIfld\fP A pointer that gets the unpacked data values as an array of float\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_ENOMEM\fP Out of memory\&. .PP .RE .PP \fBAuthor\fP .RS 4 Eric Engle .RE .PP \fBDate\fP .RS 4 2022-10-16 .RE .PP .PP Definition at line \fB194\fP of file \fBaecunpack\&.c\fP\&. .PP References \fBaecunpack_int()\fP, \fBG2C_AEC_DRS_TEMPLATE_LEN\fP, and \fBLOG\fP\&. .SS "int g2c_close (int g2cid)" .PP Close a GRIB2 file, freeing resources\&. .PP \fBParameters\fP .RS 4 \fIg2cid\fP Indentifier for the file\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP - No error\&. .IP "\(bu" 2 \fBG2C_EBADID\fP - Bad file ID\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 Aug 16, 2022 .RE .PP .PP Definition at line \fB1367\fP of file \fBg2cfile\&.c\fP\&. .PP References \fBg2c_file_info::f\fP, \fBfree_metadata()\fP, \fBG2C_EBADID\fP, \fBG2C_EFILE\fP, \fBg2c_file\fP, \fBG2C_MAX_FILES\fP, \fBG2C_NOERROR\fP, \fBg2c_file_info::g2cid\fP, \fBLOG\fP, \fBMUTEX_LOCK\fP, \fBMUTEX_UNLOCK\fP, \fBg2c_file_info::num_messages\fP, and \fBg2c_file_info::path\fP\&. .PP Referenced by \fBmain()\fP\&. .SS "int g2c_compare (int g2cid1, int g2cid2)" .PP Compare the metadata of two open GRIB2 files\&. .PP \fBParameters\fP .RS 4 \fIg2cid1\fP Indentifier for one file\&. .br \fIg2cid2\fP Indentifier for the other file\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EINVAL\fP Invalid parameters\&. .IP "\(bu" 2 \fBG2C_EFILE\fP File I/O error\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 Dec 28, 2022 .RE .PP .PP Definition at line \fB28\fP of file \fBg2ccompare\&.c\fP\&. .PP References \fBg2c_message_info::center\fP, \fBg2c_section5_info::data_def\fP, \fBg2c_message_info::day\fP, \fBg2c_message_info::discipline\fP, \fBG2C_EBADID\fP, \fBG2C_ENOSECTION\fP, \fBG2C_ERROR\fP, \fBg2c_file\fP, \fBG2C_MAX_FILES\fP, \fBG2C_NOERROR\fP, \fBg2c_section3_info::grid_def\fP, \fBg2c_message_info::hour\fP, \fBg2c_section3_info::interp_list\fP, \fBg2c_message_info::local_version\fP, \fBLOG\fP, \fBg2c_message_info::master_version\fP, \fBg2c_message_info::minute\fP, \fBg2c_message_info::month\fP, \fBg2c_file_info::msg\fP, \fBg2c_message_info::next\fP, \fBg2c_section_info::next\fP, \fBg2c_section4_info::num_coord\fP, \fBg2c_section3_info::num_data_points\fP, \fBg2c_section5_info::num_data_points\fP, \fBg2c_message_info::num_fields\fP, \fBg2c_message_info::num_local\fP, \fBg2c_file_info::num_messages\fP, \fBg2c_section3_info::num_opt\fP, \fBg2c_section_info::prev\fP, \fBg2c_section4_info::prod_def\fP, \fBg2c_message_info::sec\fP, \fBg2c_section_info::sec_info\fP, \fBg2c_section_info::sec_num\fP, \fBg2c_message_info::second\fP, \fBg2c_message_info::sig_ref_time\fP, \fBg2c_section3_info::source_grid_def\fP, \fBg2c_message_info::status\fP, \fBg2c_message_info::subcenter\fP, \fBg2c_section_info::template\fP, \fBg2c_section_info::template_len\fP, \fBg2c_message_info::type\fP, and \fBg2c_message_info::year\fP\&. .PP Referenced by \fBmain()\fP\&. .SS "int g2c_csv_init ()" .PP Initialize tables from 'CodeFlag\&.txt'\&. .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .PP .RE .PP \fBAuthor\fP .RS 4 Alyson Stahl .RE .PP \fBDate\fP .RS 4 8/2/24 .RE .PP .PP Definition at line \fB215\fP of file \fBg2ccsv\&.c\fP\&. .PP References \fBdoc\fP, \fBg2c_csv_strsep()\fP, \fBG2C_ECSV\fP, \fBG2C_ENAMETOOLONG\fP, \fBG2C_ENOMEM\fP, \fBg2c_find_table()\fP, \fBG2C_MAX_GRIB_CODE_LEN\fP, \fBG2C_MAX_GRIB_DESC_LEN\fP, \fBG2C_MAX_GRIB_LEVEL_DESC_LEN\fP, \fBG2C_MAX_GRIB_STATUS_LEN\fP, \fBG2C_MAX_GRIB_TITLE_LEN\fP, \fBG2C_NOERROR\fP, and \fBg2c_table\fP\&. .PP Referenced by \fBg2c_log_file()\fP, and \fBg2c_log_section1()\fP\&. .SS "int g2c_dec_jpeg2000 (char * injpc, size_t bufsize, int * outfld)" .PP Decode a JPEG2000 code stream specified in the JPEG2000 Part-1 standard (i\&.e\&., ISO/IEC 15444-1) using \fCJasPer Software\fP\&. .PP \fBParameters\fP .RS 4 \fIinjpc\fP Pointer to buffer that holds the input JPEG2000 code stream\&. .br \fIbufsize\fP Length (in bytes) of the buffer that holds the input JPEG2000 code stream\&. .br \fIoutfld\fP Pointer to int array, already allocated, that gets the unpacked data\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2_JASPER_DECODE\fP Error decode jpeg2000 code stream\&. .IP "\(bu" 2 \fBG2_JASPER_DECODE_COLOR\fP decoded image had multiple color components\&. Only grayscale is expected\&. .IP "\(bu" 2 \fBG2_JASPER_INIT\fP Error inializing Jasper library\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 9/7/22 .RE .PP .PP Definition at line \fB350\fP of file \fBdecenc_jpeg2000\&.c\fP\&. .PP References \fBint_dec_jpeg2000()\fP\&. .SS "int g2c_dec_png (unsigned char * pngbuf, int * width, int * height, unsigned char * cout)" .PP Decode PNG\&. .PP \fBParameters\fP .RS 4 \fIpngbuf\fP Pointer to PNG buffer\&. .br \fIwidth\fP Pointer to width\&. .br \fIheight\fP Pointer to height\&. .br \fIcout\fP Output buffer\&. .RE .PP \fBReturns\fP .RS 4 0 for success, error code otherwise\&. .RE .PP \fBAuthor\fP .RS 4 Alyson Stahl .RE .PP .PP Definition at line \fB100\fP of file \fBdecenc_png\&.c\fP\&. .PP References \fBdec_png()\fP\&. .SS "int g2c_degrib2 (int g2cid, const char * fileout)" .PP Write a summary file like the degrib2 utility\&. .PP \fBParameters\fP .RS 4 \fIg2cid\fP Indentifier for the file, returned by \fBg2c_open()\fP or g2c_create()\&. .br \fIfileout\fP Path of output file\&. Any existing file of this name will be overwritten\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EINVAL\fP Invalid parameters\&. .IP "\(bu" 2 \fBG2C_EFILE\fP File I/O error\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 Sep 17, 2022 .RE .PP .PP Definition at line \fB634\fP of file \fBg2cdegrib2\&.c\fP\&. .PP References \fBg2c_message_info::bytes_in_msg\fP, \fBg2c_message_info::bytes_to_msg\fP, \fBg2c_message_info::center\fP, \fBg2c_section5_info::data_def\fP, \fBg2c_message_info::day\fP, \fBg2c_message_info::discipline\fP, \fBG2C_EBADID\fP, \fBG2C_EFILE\fP, \fBG2C_EINVAL\fP, \fBG2C_ENOSECTION\fP, \fBG2C_ERROR\fP, \fBg2c_file\fP, \fBg2c_get_datetime()\fP, \fBg2c_get_level_desc()\fP, \fBg2c_get_prod()\fP, \fBG2C_MAX_FILES\fP, \fBG2C_MAX_NOAA_ABBREV_LEN\fP, \fBG2C_MAX_TYPE_OF_FIXED_SURFACE_LEN\fP, \fBG2C_NOERROR\fP, \fBg2c_param_abbrev()\fP, \fBg2c_section3_info::grid_def\fP, \fBg2c_message_info::hour\fP, \fBg2c_section6_info::indicator\fP, \fBg2c_section3_info::interp_list\fP, \fBg2c_message_info::local_version\fP, \fBLOG\fP, \fBg2c_message_info::master_version\fP, \fBg2c_message_info::minute\fP, \fBg2c_message_info::month\fP, \fBg2c_section_info::msg\fP, \fBg2c_message_info::msg_num\fP, \fBg2c_message_info::next\fP, \fBg2c_section_info::next\fP, \fBg2c_section4_info::num_coord\fP, \fBg2c_section3_info::num_data_points\fP, \fBg2c_section5_info::num_data_points\fP, \fBg2c_message_info::num_fields\fP, \fBg2c_message_info::num_local\fP, \fBg2c_section3_info::num_opt\fP, \fBg2c_section3_info::optional\fP, \fBg2c_section_info::prev\fP, \fBg2c_section4_info::prod_def\fP, \fBg2c_message_info::sec\fP, \fBg2c_section_info::sec_info\fP, \fBg2c_section_info::sec_len\fP, \fBg2c_section_info::sec_num\fP, \fBg2c_message_info::second\fP, \fBg2c_message_info::sig_ref_time\fP, \fBg2c_section3_info::source_grid_def\fP, \fBg2c_message_info::status\fP, \fBg2c_message_info::subcenter\fP, \fBg2c_section_info::template\fP, \fBg2c_section_info::template_len\fP, \fBg2c_message_info::type\fP, and \fBg2c_message_info::year\fP\&. .PP Referenced by \fBmain()\fP\&. .SS "int g2c_enc_jpeg2000 (unsigned char * cin, int width, int height, int nbits, int ltype, int ratio, int retry, char * outjpc, size_t jpclen)" .PP Encode a grayscale image into a JPEG2000 code stream specified in the JPEG2000 Part-1 standard (i\&.e\&., ISO/IEC 15444-1) using \fCJasPer Software\fP\&. .PP \fBParameters\fP .RS 4 \fIcin\fP Packed matrix of Grayscale image values to encode\&. .br \fIwidth\fP width of image\&. .br \fIheight\fP height of image\&. .br \fInbits\fP depth (in bits) of image\&. i\&.e number of bits used to hold each data value\&. .br \fIltype\fP indicator of lossless or lossy compression\&. .IP "\(bu" 2 1, for lossy compression .IP "\(bu" 2 != 1, for lossless compression .PP .br \fIratio\fP target compression ratio\&. (ratio:1) Used only when ltype == 1\&. .br \fIretry\fP If 1 try increasing number of guard bits\&. .br \fIoutjpc\fP Output encoded JPEG2000 code stream\&. .br \fIjpclen\fP Number of bytes allocated for the output JPEG2000 code stream in outjpc\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 > 0 = Length in bytes of encoded JPEG2000 code stream .IP "\(bu" 2 \fBG2_JASPER_INIT\fP Error initializing jasper library\&. .IP "\(bu" 2 \fBG2_JASPER_ENCODE\fP Error encode jpeg2000 code stream\&. .PP .RE .PP \fBNote\fP .RS 4 Requires JasPer Software version 1\&.500\&.4 or 1\&.700\&.2 or later\&. .RE .PP \fBAuthor\fP .RS 4 Stephen Gilbert .RE .PP \fBDate\fP .RS 4 2002-12-02 .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP .PP Definition at line \fB45\fP of file \fBdecenc_jpeg2000\&.c\fP\&. .PP References \fBenc_jpeg2000()\fP\&. .SS "int g2c_enc_png (unsigned char * data, int width, int height, int nbits, unsigned char * pngbuf)" .PP Encode PNG\&. .PP \fBParameters\fP .RS 4 \fIdata\fP data\&. .br \fIwidth\fP width\&. .br \fIheight\fP height\&. .br \fInbits\fP number of bits\&. .br \fIpngbuf\fP PNG buffer\&. .RE .PP \fBReturns\fP .RS 4 PNG length, or negative number for error\&. .RE .PP \fBAuthor\fP .RS 4 Alyson Stahl .RE .PP .PP Definition at line \fB237\fP of file \fBdecenc_png\&.c\fP\&. .PP References \fBenc_png()\fP\&. .SS "int g2c_find_desc (char * title, int code, char * desc)" .PP Given a table title and an integer code, find a description\&. .PP \fBParameters\fP .RS 4 \fItitle\fP Title of table\&. .br \fIcode\fP Code to search for as an int\&. .br \fIdesc\fP Pointer that gets a copy of the description\&. Must be allocated to \fBG2C_MAX_GRIB_DESC_LEN\fP + 1\&. .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 8/28/22 .RE .PP \fBReturns\fP .RS 4 0 for success, error code otherwise\&. .RE .PP .PP Definition at line \fB131\fP of file \fBg2ccsv\&.c\fP\&. .PP References \fBg2c_find_desc_str()\fP, and \fBG2C_MAX_GRIB_CODE_LEN\fP\&. .PP Referenced by \fBg2c_log_section1()\fP\&. .SS "int g2c_find_desc_str (char * title, char * code, char * desc)" .PP Given a table title and a code, find a description\&. .PP \fBParameters\fP .RS 4 \fItitle\fP Title of table\&. .br \fIcode\fP Code to search for\&. .br \fIdesc\fP Pointer that gets a copy of the description\&. Must be allocated to \fBG2C_MAX_GRIB_DESC_LEN\fP + 1\&. .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 8/28/22 .RE .PP \fBReturns\fP .RS 4 0 for success, error code otherwise\&. .RE .PP .PP Definition at line \fB84\fP of file \fBg2ccsv\&.c\fP\&. .PP References \fBG2C_EINVAL\fP, \fBG2C_ENOTFOUND\fP, \fBG2C_MAX_GRIB_CODE_LEN\fP, \fBG2C_MAX_GRIB_TITLE_LEN\fP, \fBG2C_NOERROR\fP, and \fBg2c_table\fP\&. .PP Referenced by \fBg2c_find_desc()\fP\&. .SS "int g2c_find_msg2 (int g2cid, size_t skip_bytes, size_t max_bytes, size_t * bytes_to_msg, size_t * bytes_in_msg)" .PP Search a file for the next GRIB1 or GRIB2 message\&. A grib message is identified by its indicator section, i\&.e\&. an 8-byte sequence with 'GRIB' in bytes 1-4 and a '1' or '2' in byte 8\&. If found, the length of the message is decoded from bytes 5-7\&. The search is done over a given section of the file\&. The search is terminated if an eof or i/o error is encountered\&. .PP \fBParameters\fP .RS 4 \fIg2cid\fP ID of the opened grib file, returned by \fBg2c_open()\fP\&. .br \fIskip_bytes\fP Number of bytes to skip before search\&. .br \fImax_bytes\fP Maximum number of bytes to search\&. .br \fIbytes_to_msg\fP Pointer that gets the number of bytes to skip before message\&. .br \fIbytes_in_msg\fP Pointer that gets the number of bytes in message (or 0 if no message found) .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EBADID\fP g2cid not found\&. .IP "\(bu" 2 \fBG2C_EFILE\fP File error\&. .IP "\(bu" 2 \fBG2C_EINVAL\fP Invalid input\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 2022-08-19 .RE .PP .PP Definition at line \fB164\fP of file \fBg2cfile\&.c\fP\&. .PP References \fBG2C_EBADID\fP, \fBG2C_EFILE\fP, \fBG2C_EINVAL\fP, \fBG2C_EMSG\fP, \fBG2C_ENOMEM\fP, \fBG2C_ERROR\fP, \fBg2c_file\fP, \fBG2C_MAGIC_HEADER_LEN\fP, \fBG2C_NOERROR\fP, \fBLOG\fP, \fBMIN\fP, and \fBREAD_BUF_SIZE\fP\&. .SS "void g2c_free_tables ()" .PP Free table memory\&. .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 8/28/22 .RE .PP .PP Definition at line \fB42\fP of file \fBg2ccsv\&.c\fP\&. .PP References \fBg2c_table\fP\&. .PP Referenced by \fBg2c_log_file()\fP\&. .SS "void g2c_gbit_int (unsigned char * in, int * iout, int iskip, int nbits)" .PP Extract arbitrary size values from a packed bit string, right justifying each value in the unpacked iout array\&. This is similar to \fBgbit()\fP, but with int types instead of g2int\&. .PP \fBParameters\fP .RS 4 \fIin\fP pointer to character array input\&. .br \fIiout\fP pointer that gets the unpacked array output\&. .br \fIiskip\fP initial number of bits to skip\&. .br \fInbits\fP number of bits to take\&. .RE .PP \fBAuthor\fP .RS 4 NOAA Programmer .RE .PP .PP Definition at line \fB113\fP of file \fBgbits\&.c\fP\&. .PP References \fBg2c_gbits_int()\fP\&. .SS "int g2c_gbits_int (unsigned char * in, int * iout, int iskip, int nbits, int nskip, int n)" .PP Extract arbitrary size values from a packed bit string, right justifying each value in the unpacked iout array\&. This is similar to \fBgbits()\fP, but with int types instead of g2int\&. .PP \fBParameters\fP .RS 4 \fIin\fP Pointer to character array input\&. .br \fIiout\fP Pointer that gets the unpacked array output\&. .br \fIiskip\fP Initial number of bits to skip\&. .br \fInbits\fP Number of bits to take\&. .br \fInskip\fP Additional number of bits to skip on each iteration\&. .br \fIn\fP Number of iterations\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_ENOMEM\fP Out of memory\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 8/31/22 .RE .PP .PP Definition at line \fB137\fP of file \fBgbits\&.c\fP\&. .PP References \fBG2C_EINVAL\fP, \fBG2C_ENOMEM\fP, \fBG2C_NOERROR\fP, and \fBgbits()\fP\&. .PP Referenced by \fBg2c_gbit_int()\fP\&. .SS "int g2c_get_drs_template (int drs_template_num, int * maplen, int * map, int * needext)" .PP Get DRS template information\&. The DRS template consists of a template map, and its length\&. There are no supported DRS templates with extensions\&. .PP \fBParameters\fP .RS 4 \fIdrs_template_num\fP The DRS template number\&. .br \fImaplen\fP Pointer that gets the length of the map\&. Ignored if NULL\&. .br \fImap\fP Pointer that gets the map as an array of int\&. Memory must be allocated by caller\&. Ignored if NULL\&. .br \fIneedext\fP Pointer that a non-zero value if an extension to this template is needed\&. Ignored if NULL\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_ENOTEMPLATE\fP Template not found\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 10/18/22 .RE .PP .PP Definition at line \fB266\fP of file \fBdrstemplates\&.c\fP\&. .PP References \fBG2C_ENOTEMPLATE\fP, \fBG2C_MAX_DRS_TEMPLATE\fP, \fBG2C_NOERROR\fP, and \fBtemplatesdrs\fP\&. .PP Referenced by \fBg2c_rw_section5_metadata()\fP\&. .SS "int g2c_get_grid_template (int grid_template_num, int * maplen, int * map, int * needext)" .PP Get grid template information\&. The grid template consists of a template map, its length, and, for some templates, an extra extension map, and its length\&. If an extension is needed, use \fBg2c_get_grid_template_extension()\fP to get it\&. .PP \fBParameters\fP .RS 4 \fIgrid_template_num\fP The grid template number\&. .br \fImaplen\fP Pointer that gets the length of the map\&. Ignored if NULL\&. .br \fImap\fP Pointer that gets the map as an array of int\&. Memory must be allocated by caller\&. Ignored if NULL\&. .br \fIneedext\fP Pointer that a non-zero value if an extension to this template is needed\&. Ignored if NULL\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_ENOTEMPLATE\fP Template not found\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 10/16/22 .RE .PP .PP Definition at line \fB391\fP of file \fBgridtemplates\&.c\fP\&. .PP References \fBG2C_ENOTEMPLATE\fP, \fBG2C_MAX_GDS_TEMPLATE\fP, \fBG2C_NOERROR\fP, and \fBtemplatesgrid\fP\&. .PP Referenced by \fBg2c_rw_section3_metadata()\fP\&. .SS "int g2c_get_grid_template_extension (int grid_template_num, int * template, int * extlen, int * ext)" .PP Get grid template extension information\&. .PP \fBParameters\fP .RS 4 \fIgrid_template_num\fP The grid template number\&. .br \fItemplate\fP Pointer to array that contains the template values\&. .br \fIextlen\fP Pointer that gets the length of the extension\&. Ignored if NULL\&. .br \fIext\fP Pointer that gets template extension array, if there is one\&. Memory must be allocated by the caller\&. Ignored if NULL\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EINVAL\fP Invalid input\&. .IP "\(bu" 2 \fBG2C_ENOTEMPLATE\fP Template not found\&. .IP "\(bu" 2 \fBG2C_ENOMEM\fP Out of memory\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 10/16/22 .RE .PP .PP Definition at line \fB316\fP of file \fBgridtemplates\&.c\fP\&. .PP References \fBgtemplate::ext\fP, \fBextgridtemplate()\fP, \fBgtemplate::extlen\fP, \fBG2C_EINVAL\fP, \fBG2C_ENOMEM\fP, \fBG2C_ENOTEMPLATE\fP, \fBG2C_MAX_GDS_TEMPLATE\fP, \fBG2C_NOERROR\fP, and \fBtemplatesgrid\fP\&. .SS "int g2c_get_msg (int g2cid, size_t skip_bytes, size_t max_bytes, size_t * bytes_to_msg, size_t * bytes_in_msg, unsigned char ** cbuf)" .PP Search a file for the next GRIB1 or GRIB2 message, and read it, allocating space in memory to hold the message\&. A grib message is identified by its indicator section, i\&.e\&. an 8-byte sequence with 'GRIB' in bytes 1-4 and a '1' or '2' in byte 8\&. If found, the length of the message is decoded from bytes 5-7\&. The search is done over a given section of the file\&. The search is terminated if an EOF or I/O error is encountered\&. .PP \fBParameters\fP .RS 4 \fIg2cid\fP ID of the opened grib file, returned by \fBg2c_open()\fP\&. .br \fIskip_bytes\fP The number of bytes to skip before search\&. .br \fImax_bytes\fP The maximum number of bytes to search\&. Must be at least 16\&. .br \fIbytes_to_msg\fP A pointer that gets the number of bytes to skip before message\&. .br \fIbytes_in_msg\fP A pointer that gets the number of bytes in message (or 0 if no message found) .br \fIcbuf\fP A pointer that gets allocation of memory, into which the message is copied\&. This memory must be freed by the caller\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EBADID\fP g2cid not found\&. .IP "\(bu" 2 \fBG2C_EFILE\fP File error\&. .IP "\(bu" 2 \fBG2C_EINVAL\fP Invalid input\&. .IP "\(bu" 2 \fBG2C_ENOMEM\fP Out of memory\&. .IP "\(bu" 2 \fBG2C_ENOMSG\fP No GRIB message found\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 2022-08-20 .RE .PP .PP Definition at line \fB291\fP of file \fBg2cfile\&.c\fP\&. .PP References \fBG2C_EBADID\fP, \fBG2C_EFILE\fP, \fBG2C_EINVAL\fP, \fBG2C_ENOMEM\fP, \fBG2C_ENOMSG\fP, \fBG2C_ERROR\fP, \fBg2c_file\fP, \fBG2C_MIN_MAX_BYTES\fP, \fBG2C_NOERROR\fP, \fBLOG\fP, and \fBseekgb()\fP\&. .SS "int g2c_get_pds_template (int pds_template_num, int * maplen, int * map, int * needext)" .PP Get PDS template information\&. The PDS template consists of a template map, its length, and, for some templates, an extra extension map, and its length\&. If an extension is needed, use \fBg2c_get_pds_template_extension()\fP to get it\&. .PP \fBParameters\fP .RS 4 \fIpds_template_num\fP The PDS template number\&. .br \fImaplen\fP Pointer that gets the length of the map\&. Ignored if NULL\&. .br \fImap\fP Pointer that gets the map as an array of int\&. Memory must be allocated by caller\&. Ignored if NULL\&. .br \fIneedext\fP Pointer that a non-zero value if an extension to this template is needed\&. Ignored if NULL\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_ENOTEMPLATE\fP Template not found\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 10/18/22 .RE .PP .PP Definition at line \fB1806\fP of file \fBpdstemplates\&.c\fP\&. .PP References \fBG2C_ENOTEMPLATE\fP, \fBG2C_MAX_PDS_TEMPLATE\fP, \fBG2C_NOERROR\fP, and \fBtemplatespds\fP\&. .PP Referenced by \fBg2c_rw_section4_metadata()\fP\&. .SS "int g2c_get_pds_template_extension (int pds_template_num, int * template, int * extlen, int * ext)" .PP Get pds template extension information\&. .PP \fBParameters\fP .RS 4 \fIpds_template_num\fP The pds template number\&. .br \fItemplate\fP Pointer to array that contains the template values\&. .br \fIextlen\fP Pointer that gets the length of the extension\&. Ignored if NULL\&. .br \fIext\fP Pointer that gets template extension array, if there is one\&. Memory must be allocated by the caller\&. Ignored if NULL\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EINVAL\fP Invalid input\&. .IP "\(bu" 2 \fBG2C_ENOTEMPLATE\fP Template not found\&. .IP "\(bu" 2 \fBG2C_ENOMEM\fP Out of memory\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 10/16/22 .RE .PP .PP Definition at line \fB1731\fP of file \fBpdstemplates\&.c\fP\&. .PP References \fBgtemplate::ext\fP, \fBgtemplate::extlen\fP, \fBextpdstemplate()\fP, \fBG2C_EINVAL\fP, \fBG2C_ENOMEM\fP, \fBG2C_ENOTEMPLATE\fP, \fBG2C_MAX_PDS_TEMPLATE\fP, \fBG2C_NOERROR\fP, and \fBtemplatespds\fP\&. .SS "int g2c_get_prod (int g2cid, int msg_num, int prod_num, int * num_data_points, float * data)" .PP Read the data for a product\&. .PP \fBParameters\fP .RS 4 \fIg2cid\fP File ID\&. .br \fImsg_num\fP Message number in file (first message in file is message 0)\&. .br \fIprod_num\fP Product number in message (first product in message is product 0)\&. .br \fInum_data_points\fP Pointer that gets the number of data points in the product\&. Ignored if NULL\&. .br \fIdata\fP Pointer that gets the data\&. Ignored if NULL\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 Sep 28, 2022 .RE .PP .PP Definition at line \fB32\fP of file \fBg2cprod\&.c\fP\&. .PP References \fBg2c_message_info::bytes_to_msg\fP, \fBg2c_section_info::bytes_to_sec\fP, \fBg2c_section5_info::data_def\fP, \fBg2c_file_info::f\fP, \fBG2C_EBADID\fP, \fBG2C_EFILE\fP, \fBG2C_EINVAL\fP, \fBG2C_ENOMEM\fP, \fBG2C_ENOMSG\fP, \fBG2C_ENOPRODUCT\fP, \fBG2C_ENOSECTION\fP, \fBG2C_ERROR\fP, \fBg2c_file\fP, \fBG2C_MAX_FILES\fP, \fBG2C_NOERROR\fP, \fBg2c_unpack7()\fP, \fBg2c_section3_info::grid_def\fP, \fBg2c_section_info::msg\fP, \fBg2c_message_info::msg_num\fP, \fBMUTEX_LOCK\fP, \fBMUTEX_UNLOCK\fP, \fBg2c_message_info::next\fP, \fBg2c_section_info::next\fP, \fBg2c_section5_info::num_data_points\fP, \fBg2c_section_info::prev\fP, \fBg2c_message_info::sec\fP, \fBg2c_section_info::sec_info\fP, \fBg2c_section_info::sec_len\fP, \fBg2c_section_info::sec_num\fP, \fBg2c_section_info::template\fP, and \fBg2c_section_info::template_len\fP\&. .PP Referenced by \fBg2c_degrib2()\fP\&. .SS "int g2c_inq (int g2cid, int * num_msg)" .PP Learn about a GRIB2 file\&. .PP \fBParameters\fP .RS 4 \fIg2cid\fP ID of the opened file, as from \fBg2c_open()\fP\&. .br \fInum_msg\fP Pointer that gets the number of messages in the file\&. Ignored if NULL\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EBADID\fP File ID not found\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 10/21/22 .RE .PP .PP Definition at line \fB31\fP of file \fBg2cinq\&.c\fP\&. .PP References \fBG2C_EBADID\fP, \fBg2c_file\fP, \fBG2C_MAX_FILES\fP, \fBG2C_NOERROR\fP, \fBMUTEX_LOCK\fP, \fBMUTEX_UNLOCK\fP, and \fBg2c_file_info::num_messages\fP\&. .SS "int g2c_inq_dim (int g2cid, int msg_num, int prod_num, int dim_num, size_t * len, char * name, float * val)" .PP Learn about the one of the dimensions of a GRIB2 product\&. This function will return the size, name, and values along the dimension\&. .PP \fBParameters\fP .RS 4 \fIg2cid\fP ID of the opened file, as from \fBg2c_open()\fP\&. .br \fImsg_num\fP Number of the message in the file, starting with the first message as 0\&. .br \fIprod_num\fP Product number\&. .br \fIdim_num\fP Dimension number, with the first dimension as 0\&. .br \fIlen\fP Pointer that gets the length of this dimension\&. Ignored if NULL\&. .br \fIname\fP Pointer that gets the name of this dimension\&. Must have memory of size G2C_MAX_NAME\&. Ignored if NULL\&. .br \fIval\fP Pointer that gets array of dimension values, of length len\&. Ignored if NULL\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EBADID\fP File ID not found\&. .IP "\(bu" 2 \fBG2C_ENOMSG\fP Message not found\&. .IP "\(bu" 2 \fBG2C_ENOPRODUCT\fP Product not found\&. .IP "\(bu" 2 \fBG2C_ENOSECTION\fP GDS not found\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 10/21/22 .RE .PP .PP Definition at line \fB372\fP of file \fBg2cinq\&.c\fP\&. .PP References \fBG2C_EBADID\fP, \fBG2C_EINVAL\fP, \fBG2C_ENOMSG\fP, \fBG2C_ENOPRODUCT\fP, \fBG2C_ENOSECTION\fP, \fBg2c_file\fP, \fBG2C_MAX_FILES\fP, \fBG2C_MAX_NAME\fP, \fBG2C_NOERROR\fP, \fBg2c_dim_info::len\fP, \fBg2c_message_info::msg_num\fP, \fBMUTEX_LOCK\fP, \fBMUTEX_UNLOCK\fP, \fBg2c_dim_info::name\fP, \fBg2c_message_info::next\fP, \fBg2c_section_info::next\fP, \fBg2c_section_info::prev\fP, \fBg2c_message_info::sec\fP, \fBg2c_section_info::sec_info\fP, \fBg2c_section_info::sec_num\fP, and \fBg2c_dim_info::value\fP\&. .PP Referenced by \fBg2c_inq_dim_info()\fP\&. .SS "int g2c_inq_dim_info (int g2cid, int msg_num, int prod_num, int dim_num, size_t * len, char * name)" .PP Learn about the one of the dimensions of a GRIB2 product\&. This function will return the size and name of the dimension\&. .PP \fBParameters\fP .RS 4 \fIg2cid\fP ID of the opened file, as from \fBg2c_open()\fP\&. .br \fImsg_num\fP Number of the message in the file, starting with the first message as 0\&. .br \fIprod_num\fP Product number\&. .br \fIdim_num\fP Dimension number, with the first dimension as 0\&. .br \fIlen\fP Pointer that gets the length of this dimension\&. Ignored if NULL\&. .br \fIname\fP Pointer that gets the name of this dimension\&. Must have memory of size G2C_MAX_NAME\&. Ignored if NULL\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EBADID\fP File ID not found\&. .IP "\(bu" 2 \fBG2C_ENOMSG\fP Message not found\&. .IP "\(bu" 2 \fBG2C_ENOPRODUCT\fP Product not found\&. .IP "\(bu" 2 \fBG2C_ENOSECTION\fP GDS not found\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 10/21/22 .RE .PP .PP Definition at line \fB468\fP of file \fBg2cinq\&.c\fP\&. .PP References \fBg2c_inq_dim()\fP\&. .SS "int g2c_inq_msg (int g2cid, int msg_num, unsigned char * discipline, int * num_fields, int * num_local, short * center, short * subcenter, unsigned char * master_version, unsigned char * local_version)" .PP Learn about a GRIB2 message\&. .PP \fBParameters\fP .RS 4 \fIg2cid\fP ID of the opened file, as from \fBg2c_open()\fP\&. .br \fImsg_num\fP Number of the message in the file, starting with the first message as 0\&. .br \fIdiscipline\fP Pointer that gets the discipline from the message\&. Ignored if NULL\&. .br \fInum_fields\fP Pointer that gets the number of fields in the message\&. Ignored if NULL\&. .br \fInum_local\fP Pointer that gets the number of local sections in the message\&. Ignored if NULL\&. .br \fIcenter\fP Pointer that gets the code for the producing center from the message\&. Ignored if NULL\&. .br \fIsubcenter\fP Pointer that gets the code for the producing subcenter from the message\&. Ignored if NULL\&. .br \fImaster_version\fP Pointer that gets the master version from the message\&. Ignored if NULL\&. .br \fIlocal_version\fP Pointer that gets the local version from the message\&. Ignored if NULL\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EBADID\fP File ID not found\&. .IP "\(bu" 2 \fBG2C_ENOMSG\fP Message not found\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 10/21/22 .RE .PP .PP Definition at line \fB87\fP of file \fBg2cinq\&.c\fP\&. .PP References \fBg2c_message_info::center\fP, \fBg2c_message_info::discipline\fP, \fBG2C_EBADID\fP, \fBG2C_EINVAL\fP, \fBG2C_ENOMSG\fP, \fBg2c_file\fP, \fBG2C_MAX_FILES\fP, \fBG2C_NOERROR\fP, \fBg2c_message_info::local_version\fP, \fBg2c_message_info::master_version\fP, \fBg2c_message_info::msg_num\fP, \fBMUTEX_LOCK\fP, \fBMUTEX_UNLOCK\fP, \fBg2c_message_info::next\fP, \fBg2c_message_info::num_fields\fP, \fBg2c_message_info::num_local\fP, and \fBg2c_message_info::subcenter\fP\&. .SS "int g2c_inq_msg_time (int g2cid, int msg_num, unsigned char * sig_ref_time, short * year, unsigned char * month, unsigned char * day, unsigned char * hour, unsigned char * minute, unsigned char * second)" .PP Learn about the date/time information in a GRIB2 message\&. .PP \fBParameters\fP .RS 4 \fIg2cid\fP ID of the opened file, as from \fBg2c_open()\fP\&. .br \fImsg_num\fP Number of the message in the file, starting with the first message as 0\&. .br \fIsig_ref_time\fP Pointer that gets Significane of reference time value from the message\&. Ignored if NULL\&. .br \fIyear\fP Pointer that gets the year from the message\&. Ignored if NULL\&. .br \fImonth\fP Pointer that gets the month from the message\&. Ignored if NULL\&. .br \fIday\fP Pointer that gets the day from the message\&. Ignored if NULL\&. .br \fIhour\fP Pointer that gets the hour from the message\&. Ignored if NULL\&. .br \fIminute\fP Pointer that gets the minute from the message\&. Ignored if NULL\&. .br \fIsecond\fP Pointer that gets the seconds from the message\&. Ignored if NULL\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EBADID\fP File ID not found\&. .IP "\(bu" 2 \fBG2C_ENOMSG\fP Message not found\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 10/22/22 .RE .PP .PP Definition at line \fB170\fP of file \fBg2cinq\&.c\fP\&. .PP References \fBg2c_message_info::day\fP, \fBG2C_EBADID\fP, \fBG2C_EINVAL\fP, \fBG2C_ENOMSG\fP, \fBg2c_file\fP, \fBG2C_MAX_FILES\fP, \fBG2C_NOERROR\fP, \fBg2c_message_info::hour\fP, \fBg2c_message_info::minute\fP, \fBg2c_message_info::month\fP, \fBg2c_message_info::msg_num\fP, \fBMUTEX_LOCK\fP, \fBMUTEX_UNLOCK\fP, \fBg2c_message_info::next\fP, \fBg2c_message_info::second\fP, \fBg2c_message_info::sig_ref_time\fP, and \fBg2c_message_info::year\fP\&. .SS "int g2c_inq_prod (int g2cid, int msg_num, int prod_num, int * pds_template_len, long long int * pds_template, int * gds_template_len, long long int * gds_template, int * drs_template_len, long long int * drs_template)" .PP Inquire about a product\&. .PP \fBParameters\fP .RS 4 \fIg2cid\fP File ID\&. .br \fImsg_num\fP Message number\&. .br \fIprod_num\fP Product number\&. .br \fIpds_template_len\fP PDS template length\&. Ignored if NULL\&. .br \fIpds_template\fP Pointer that gets the PDS template\&. Ignored if NULL\&. .br \fIgds_template_len\fP GDS template length\&. Ignored if NULL\&. .br \fIgds_template\fP Pointer that gets the GDS template\&. Ignored if NULL\&. .br \fIdrs_template_len\fP The DRS template length\&. Ignored if NULL\&. .br \fIdrs_template\fP Pointer that gets the DRS template\&. Ignored if NULL\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EBADID\fP File ID not found\&. .IP "\(bu" 2 \fBG2C_ENOMSG\fP Message not found\&. .IP "\(bu" 2 \fBG2C_ENOPRODUCT\fP Product not found\&. .IP "\(bu" 2 \fBG2C_ENOSECTION\fP Section not found\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 10/21/22 .RE .PP .PP Definition at line \fB247\fP of file \fBg2cinq\&.c\fP\&. .PP References \fBG2C_EBADID\fP, \fBG2C_EINVAL\fP, \fBG2C_ENOMSG\fP, \fBG2C_ENOPRODUCT\fP, \fBG2C_ENOSECTION\fP, \fBg2c_file\fP, \fBG2C_MAX_FILES\fP, \fBG2C_NOERROR\fP, \fBg2c_message_info::msg_num\fP, \fBMUTEX_LOCK\fP, \fBMUTEX_UNLOCK\fP, \fBg2c_message_info::next\fP, \fBg2c_section_info::next\fP, \fBg2c_section_info::prev\fP, \fBg2c_message_info::sec\fP, \fBg2c_section_info::sec_info\fP, \fBg2c_section_info::sec_num\fP, \fBg2c_section_info::template\fP, and \fBg2c_section_info::template_len\fP\&. .SS "int g2c_jpcpackd (double * fld, size_t width, size_t height, int * idrstmpl, unsigned char * cpack, size_t * lcpack)" .PP This function packs up a double array into a JPEG2000 code stream\&. After the data are scaled, and the reference value is subtracted out, the data are treated as a grayscale image and passed to a JPEG2000 encoder\&. .PP This function also fills in GRIB2 Data Representation Template 5\&.40 or 5\&.40000 with the appropriate values\&. .PP This function is the V2 API version of \fBjpcpack()\fP for doubles\&. .PP \fBParameters\fP .RS 4 \fIfld\fP Pointer to the double data values to pack\&. .br \fIwidth\fP The number of points in the x direction\&. .br \fIheight\fP The number of points in the y direction\&. .br \fIidrstmpl\fP Contains the array of values for Data Representation Template \fCTable 5\&.40\fP or 5\&.40000\&. .IP "\(bu" 2 0 Reference value - ignored on input, set by jpcpack routine\&. .IP "\(bu" 2 1 Binary Scale Factor - used on input, unchanged by jpcpack routine\&. .IP "\(bu" 2 2 Decimal Scale Factor - used on input, unchanged by jpcpack routine\&. .IP "\(bu" 2 3 number of bits for each data value - ignored on input .IP "\(bu" 2 4 Original field type - currently ignored on input Data values assumed to be reals\&. Set to 0 on output\&. .IP "\(bu" 2 5 if 0 use lossless compression, if 1 use lossy compression\&. .IP "\(bu" 2 6 Desired compression ratio, if idrstmpl[5]=1\&. Set to 255, if idrstmpl[5]=0\&. May be modified in this function\&. .PP .br \fIcpack\fP A pointer that will get the packed data field\&. Must be allocated before this function is called\&. Pass the allocated size in the lcpack parameter\&. .br \fIlcpack\fP Pointer that gets the length of packed field in cpack\&. This must be set by the calling function to the size available in cpack\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EJPEG\fP Error encoding/decoding JPEG data\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP .PP Definition at line \fB386\fP of file \fBjpcpack\&.c\fP\&. .PP References \fBG2C_JPEG_DRS_TEMPLATE_LEN\fP, and \fBjpcpack_int()\fP\&. .SS "int g2c_jpcpackf (float * fld, size_t width, size_t height, int * idrstmpl, unsigned char * cpack, size_t * lcpack)" .PP This function packs up a float array into a JPEG2000 code stream\&. After the data are scaled, and the reference value is subtracted out, the data are treated as a grayscale image and passed to a JPEG2000 encoder\&. .PP This function also fills in GRIB2 Data Representation Template 5\&.40 or 5\&.40000 with the appropriate values\&. .PP This function is the V2 API version of \fBjpcpack()\fP for floats\&. .PP \fBParameters\fP .RS 4 \fIfld\fP Pointer to the float data values to pack\&. .br \fIwidth\fP The number of points in the x direction\&. .br \fIheight\fP The number of points in the y direction\&. .br \fIidrstmpl\fP Contains the array of values for Data Representation Template \fCTable 5\&.40\fP or 5\&.40000\&. .IP "\(bu" 2 0 Reference value - ignored on input, set by jpcpack routine\&. .IP "\(bu" 2 1 Binary Scale Factor - used on input, unchanged by jpcpack routine\&. .IP "\(bu" 2 2 Decimal Scale Factor - used on input, unchanged by jpcpack routine\&. .IP "\(bu" 2 3 number of bits for each data value - ignored on input .IP "\(bu" 2 4 Original field type - currently ignored on input Data values assumed to be reals\&. Set to 0 on output\&. .IP "\(bu" 2 5 if 0 use lossless compression, if 1 use lossy compression\&. .IP "\(bu" 2 6 Desired compression ratio, if idrstmpl[5]=1\&. Set to 255, if idrstmpl[5]=0\&. May be modified in this function\&. .PP .br \fIcpack\fP A pointer that will get the packed data field\&. Must be allocated before this function is called\&. Pass the allocated size in the lcpack parameter\&. .br \fIlcpack\fP Pointer that gets the length of packed field in cpack\&. This must be set by the calling function to the size available in cpack\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EJPEG\fP Error encoding/decoding JPEG data\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP .PP Definition at line \fB320\fP of file \fBjpcpack\&.c\fP\&. .PP References \fBG2C_JPEG_DRS_TEMPLATE_LEN\fP, and \fBjpcpack_int()\fP\&. .SS "int g2c_jpcunpackd (unsigned char * cpack, size_t len, int * idrstmpl, size_t ndpts, double * fld)" .PP Unpack JPEG2000 compressed data into an array of doubles, using info from the GRIB2 Data Representation \fCTemplate 5\&.40\fP or 5\&.40000\&. This function is the V2 API version of \fBjpcunpack()\fP for doubles\&. .PP \fBParameters\fP .RS 4 \fIcpack\fP The packed data\&. .br \fIlen\fP The length of the packed data\&. .br \fIidrstmpl\fP Pointer to array of values for Data Representation \fCTemplate 5\&.40\fP or 5\&.40000\&. .br \fIndpts\fP The number of data values to unpack\&. .br \fIfld\fP A pointer that gets the unpacked data values as an array of double\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_ENOMEM\fP Out of memory\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 2022-08-12 .RE .PP .PP Definition at line \fB199\fP of file \fBjpcunpack\&.c\fP\&. .PP References \fBG2C_JPEG_DRS_TEMPLATE_LEN\fP, \fBjpcunpack_int()\fP, and \fBLOG\fP\&. .SS "int g2c_jpcunpackf (unsigned char * cpack, size_t len, int * idrstmpl, size_t ndpts, float * fld)" .PP Unpack JPEG2000 compressed data into an array of floats, using info from the GRIB2 Data Representation \fCTemplate 5\&.40\fP or 5\&.40000\&. .PP \fBParameters\fP .RS 4 \fIcpack\fP The packed data\&. .br \fIlen\fP The length of the packed data\&. .br \fIidrstmpl\fP Pointer to array of values for Data Representation \fCTemplate 5\&.40\fP or 5\&.40000\&. .br \fIndpts\fP The number of data values to unpack\&. .br \fIfld\fP A pointer that gets the unpacked data values as an array of float\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_ENOMEM\fP Out of memory\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 2022-09-08 .RE .PP .PP Definition at line \fB159\fP of file \fBjpcunpack\&.c\fP\&. .PP References \fBG2C_JPEG_DRS_TEMPLATE_LEN\fP, \fBjpcunpack_int()\fP, and \fBLOG\fP\&. .SS "int g2c_log_file (int g2cid)" .PP Print a summary of the contents of an open GRIB2 file\&. If the NCEPLIBS-g2c library is built without the LOGGING option, this function will do nothing\&. .PP \fBParameters\fP .RS 4 \fIg2cid\fP The file ID, returned by \fBg2c_open()\fP or g2c_create()\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EBADID\fP g2cid not found\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett 8/22/22 .RE .PP .PP Definition at line \fB189\fP of file \fBg2cutil\&.c\fP\&. .PP References \fBg2c_message_info::bytes_in_msg\fP, \fBg2c_message_info::bytes_to_msg\fP, \fBg2c_message_info::center\fP, \fBg2c_message_info::day\fP, \fBg2c_csv_init()\fP, \fBG2C_EBADID\fP, \fBg2c_file\fP, \fBg2c_free_tables()\fP, \fBg2c_log_section()\fP, \fBg2c_log_section1()\fP, \fBG2C_NOERROR\fP, \fBg2c_table\fP, \fBg2c_message_info::hour\fP, \fBg2c_message_info::local_version\fP, \fBLOG\fP, \fBg2c_message_info::master_version\fP, \fBg2c_message_info::minute\fP, \fBg2c_message_info::month\fP, \fBg2c_message_info::msg_num\fP, \fBg2c_message_info::next\fP, \fBg2c_section_info::next\fP, \fBg2c_message_info::num_fields\fP, \fBg2c_message_info::num_local\fP, \fBg2c_message_info::sec\fP, \fBg2c_message_info::sec1_len\fP, \fBg2c_message_info::second\fP, \fBg2c_message_info::sig_ref_time\fP, \fBg2c_message_info::status\fP, \fBg2c_message_info::subcenter\fP, \fBg2c_message_info::type\fP, and \fBg2c_message_info::year\fP\&. .PP Referenced by \fBread_metadata()\fP\&. .SS "int g2c_open (const char * path, int mode, int * g2cid)" .PP Open an existing GRIB2 file\&. This function opens the GRIB2 file and reads its metadata\&. .PP GRIB2 messages in the file are assigned a message ID, starting with 0 for the first message in the file\&. .PP Each product within a message is assigned a product ID, starting with 0 for the first product in the message\&. .PP Files opened with this function should be closed with a call \fBg2c_close()\fP to release resources\&. .PP \fBParameters\fP .RS 4 \fIpath\fP Path of the file\&. .br \fImode\fP Open mode flags\&. .br \fIg2cid\fP Pointer that gets an indentifier for the file\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP - No error\&. .IP "\(bu" 2 \fBG2C_EINVAL\fP - Invalid input\&. .IP "\(bu" 2 \fBG2C_ETOOMANYFILES\fP - Trying to open too many files at the same time\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 Aug 16, 2022 .RE .PP .PP Definition at line \fB1201\fP of file \fBg2cfile\&.c\fP\&. .PP References \fBg2c_add_file()\fP, \fBLOG\fP, \fBMUTEX_LOCK\fP, \fBMUTEX_UNLOCK\fP, and \fBread_metadata()\fP\&. .PP Referenced by \fBmain()\fP\&. .SS "int g2c_open_index (const char * data_file, const char * index_file, int mode, int * g2cid)" .PP Open a GRIB2 file with the help of an index file\&. The index file, generated by the grb2index utility, of the \fBg2c_write_index()\fP function, contains the byte offsets for the sections of each message in the GRIB2 file\&. When a GRIB2 file is opened with an index file, the library does not have to scan the file to locate all metadata\&. .PP \fBParameters\fP .RS 4 \fIdata_file\fP The name of the data file to which the index applies\&. .br \fIindex_file\fP The name that will be given to the index file\&. An existing file will be overwritten\&. .br \fImode\fP Open mode flags\&. .br \fIg2cid\fP Pointer that gets the g2cid for this file\&. Ignored if NULL\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 10/12/22 .RE .PP .PP Definition at line \fB914\fP of file \fBg2cindex\&.c\fP\&. .PP References \fBadd_msg()\fP, \fBadd_section()\fP, \fBg2c_message_info::bytes_to_bms\fP, \fBg2c_message_info::bytes_to_data\fP, \fBg2c_message_info::bytes_to_local\fP, \fBg2c_message_info::bytes_to_msg\fP, \fBg2c_message_info::discipline\fP, \fBg2c_add_file()\fP, \fBG2C_EBADSECTION\fP, \fBG2C_EFILE\fP, \fBG2C_EINVAL\fP, \fBG2C_ENAMETOOLONG\fP, \fBg2c_file\fP, \fBg2c_file_io_ubyte()\fP, \fBg2c_file_io_uint()\fP, \fBG2C_FILE_READ\fP, \fBG2C_INDEX_BASENAME_LEN\fP, \fBG2C_INDEX_DATE_STR_LEN\fP, \fBG2C_INDEX_HEADER_LEN\fP, \fBG2C_INDEX_STR1_LEN\fP, \fBG2C_INDEX_TIME_STR_LEN\fP, \fBg2c_log_section1()\fP, \fBG2C_MAX_NAME\fP, \fBG2C_NOERROR\fP, \fBg2c_rw_section1_metadata()\fP, \fBg2c_start_index_record()\fP, \fBg2c_start_index_record_lf()\fP, \fBLOG\fP, \fBg2c_message_info::master_version\fP, \fBMUTEX_LOCK\fP, and \fBMUTEX_UNLOCK\fP\&. .PP Referenced by \fBmain()\fP\&. .SS "int g2c_open_index1 (const char * index_file)" .PP Open a GRIB1 index file and read the contents\&. This function opens the GRIB2 index file and reads its metadata, and opens the accompanying GRIB2 file\&. .PP GRIB2 messages in the file are assigned a message ID, starting with 0 for the first message in the file\&. .PP Each product within a message is assigned a product ID, starting with 0 for the first product in the message\&. .PP Files opened with this function should be closed with a call \fBg2c_close()\fP to release resources\&. .PP \fBParameters\fP .RS 4 \fIindex_file\fP The name that will be given to the index file\&. An existing file will be overwritten\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 10/12/22 .RE .PP .PP Definition at line \fB812\fP of file \fBg2cindex\&.c\fP\&. .PP References \fBG2C_EFILE\fP, \fBG2C_EINVAL\fP, \fBG2C_FILE_READ\fP, \fBG2C_INDEX1_BDS_VAL_LEN\fP, \fBG2C_INDEX1_BMS_VAL_LEN\fP, \fBG2C_INDEX1_GDS_VAL_LEN\fP, \fBG2C_INDEX1_PDS_VAL_LEN\fP, \fBG2C_INDEX_BASENAME_LEN\fP, \fBG2C_INDEX_DATE_STR_LEN\fP, \fBG2C_INDEX_HEADER_LEN\fP, \fBG2C_INDEX_TIME_STR_LEN\fP, \fBG2C_NOERROR\fP, \fBg2c_start_index1_record()\fP, \fBLOG\fP, \fBMUTEX_LOCK\fP, \fBMUTEX_UNLOCK\fP, \fBread_hdr_rec1()\fP, and \fBread_hdr_rec2()\fP\&. .SS "int g2c_param_abbrev (int g2disc, int g2cat, int g2num, char * abbrev)" .PP Get NOAA abbreviation for a GRIB2 parameter\&. .PP \fBParameters\fP .RS 4 \fIg2disc\fP The GRIB2 discipline number\&. .br \fIg2cat\fP The GRIB2 category number\&. .br \fIg2num\fP The GRIB2 parameter number\&. .br \fIabbrev\fP Pointer that gets the abbreviation\&. Ignored if NULL\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EFILE\fP Error reading CSV file\&. .IP "\(bu" 2 \fBG2C_ENOPARAM\fP Parameter not found\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 9/19/22 .RE .PP .PP Definition at line \fB1091\fP of file \fBg2cparams\&.c\fP\&. .PP References \fBG2C_MAX_NOAA_ABBREV_LEN\fP, \fBG2C_MAX_NOAA_PARAMS\fP, \fBG2C_NOERROR\fP, \fBLOG\fP, and \fBparam\fP\&. .PP Referenced by \fBg2c_degrib2()\fP, and \fBg2c_log_section()\fP\&. .SS "int g2c_param_all (int param_idx, int * g1num, int * g1ver, int * g2disc, int * g2cat, int * g2num, char * abbrev)" .PP Return all the information about a parameter\&. .PP \fBParameters\fP .RS 4 \fIparam_idx\fP Parameter index between 0 and \fBG2C_MAX_NOAA_PARAMS\fP\&. .br \fIg1num\fP Pointer that gets the GRIB1 parameter\&. Ignored if NULL\&. .br \fIg1ver\fP Pointer that gets the GRIB1 parameter table version number\&. Ignored if NULL\&. .br \fIg2disc\fP Pointer that gets the GRIB2 discipline number\&. Ignored if NULL\&. .br \fIg2cat\fP Pointer that gets the GRIB2 category number\&. Ignored if NULL\&. .br \fIg2num\fP Pointer that gets the GRIB2 parameter number\&. Ignored if NULL\&. .br \fIabbrev\fP Pointer that gets the abbreviation\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EINVAL\fP Invalid input\&. .IP "\(bu" 2 \fBG2C_EFILE\fP Error reading CSV file\&. .IP "\(bu" 2 \fBG2C_ENOPARAM\fP Parameter not found\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 9/19/22 .RE .PP .PP Definition at line \fB1185\fP of file \fBg2cparams\&.c\fP\&. .PP References \fBg2c_param::g1num\fP, \fBg2c_param::g1ver\fP, \fBG2C_EINVAL\fP, \fBG2C_MAX_NOAA_ABBREV_LEN\fP, \fBG2C_MAX_NOAA_PARAMS\fP, \fBG2C_NOERROR\fP, \fBg2c_param::g2cat\fP, \fBg2c_param::g2disc\fP, \fBg2c_param::g2num\fP, and \fBparam\fP\&. .SS "int g2c_param_g1tog2 (int g1num, int g1ver, int * g2disc, int * g2cat, int * g2num)" .PP Translate GRIB1 parameter to GRIB2 parameter\&. .PP \fBParameters\fP .RS 4 \fIg1num\fP The GRIB1 parameter\&. .br \fIg1ver\fP The GRIB1 parameter table version number\&. .br \fIg2disc\fP Pointer that gets the GRIB2 discipline number\&. Ignored if NULL\&. .br \fIg2cat\fP Pointer that gets the GRIB2 category number\&. Ignored if NULL\&. .br \fIg2num\fP Pointer that gets the GRIB2 parameter number\&. Ignored if NULL\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EFILE\fP Error reading CSV file\&. .IP "\(bu" 2 \fBG2C_ENOPARAM\fP Parameter not found\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 9/19/22 .RE .PP .PP Definition at line \fB1051\fP of file \fBg2cparams\&.c\fP\&. .PP References \fBG2C_ENOPARAM\fP, \fBG2C_MAX_NOAA_PARAMS\fP, \fBG2C_NOERROR\fP, \fBg2c_param::g2cat\fP, \fBg2c_param::g2disc\fP, \fBg2c_param::g2num\fP, and \fBparam\fP\&. .SS "int g2c_param_g2tog1 (int g2disc, int g2cat, int g2num, int * g1num, int * g1ver)" .PP Translate GRIB2 parameter to GRIB1 parameter\&. .PP \fBParameters\fP .RS 4 \fIg2disc\fP The GRIB2 discipline number\&. .br \fIg2cat\fP The GRIB2 category number\&. .br \fIg2num\fP The GRIB2 parameter number\&. .br \fIg1num\fP Pointer that gets the GRIB1 parameter\&. Ignored if NULL\&. .br \fIg1ver\fP Pointer that gets the GRIB1 parameter table version number\&. Ignored if NULL\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EFILE\fP Error reading CSV file\&. .IP "\(bu" 2 \fBG2C_ENOPARAM\fP Parameter not found\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 9/19/22 .RE .PP .PP Definition at line \fB1136\fP of file \fBg2cparams\&.c\fP\&. .PP References \fBg2c_param::g1num\fP, \fBg2c_param::g1ver\fP, \fBG2C_ENOPARAM\fP, \fBG2C_MAX_NOAA_PARAMS\fP, \fBG2C_NOERROR\fP, \fBLOG\fP, and \fBparam\fP\&. .SS "int g2c_pngpackd (double * fld, size_t width, size_t height, int * idrstmpl, unsigned char * cpack, int * lcpack)" .PP This subroutine packs up a double data field into PNG image format\&. After the data field is scaled, and the reference value is subtracted out, it is treated as a grayscale image and passed to a PNG encoder\&. It also fills in GRIB2 Data Representation Template 5\&.41 or 5\&.40010 with the appropriate values\&. .PP \fBParameters\fP .RS 4 \fIfld\fP Pointer to array of double that contains the data values to pack\&. .br \fIwidth\fP Number of points in the x direction\&. .br \fIheight\fP Number of points in the y direction\&. .br \fIidrstmpl\fP Contains the array of values for Data Representation \fCTemplate 5\&.41\fP or 5\&.40010\&. .IP "\(bu" 2 0 Reference value - ignored on input, set by pngpack routine\&. .IP "\(bu" 2 1 Binary Scale Factor - used on input\&. .IP "\(bu" 2 2 Decimal Scale Factor - used on input\&. .IP "\(bu" 2 3 number of bits for each grayscale pixel value - ignored on input\&. .IP "\(bu" 2 4 Original field type - currently ignored on input, set = 0 on output\&. Data values assumed to be reals\&. .PP .br \fIcpack\fP The packed data field\&. .br \fIlcpack\fP length of packed field cpack\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EPNG\fP Error encoding/decoding PNG data\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 Aug 8, 2022 .RE .PP .PP Definition at line \fB348\fP of file \fBpngpack\&.c\fP\&. .PP References \fBG2C_PNG_DRS_TEMPLATE_LEN\fP, and \fBpngpack_int()\fP\&. .SS "int g2c_pngpackf (float * fld, size_t width, size_t height, int * idrstmpl, unsigned char * cpack, int * lcpack)" .PP This subroutine packs up a float data field into PNG image format\&. After the data field is scaled, and the reference value is subtracted out, it is treated as a grayscale image and passed to a PNG encoder\&. It also fills in GRIB2 Data Representation Template 5\&.41 or 5\&.40010 with the appropriate values\&. .PP \fBParameters\fP .RS 4 \fIfld\fP Pointer to array of float that contains the data values to pack\&. .br \fIwidth\fP Number of points in the x direction\&. .br \fIheight\fP Number of points in the y direction\&. .br \fIidrstmpl\fP Contains the array of values for Data Representation \fCTemplate 5\&.41\fP or 5\&.40010\&. .IP "\(bu" 2 0 Reference value - ignored on input, set by pngpack routine\&. .IP "\(bu" 2 1 Binary Scale Factor - used on input\&. .IP "\(bu" 2 2 Decimal Scale Factor - used on input\&. .IP "\(bu" 2 3 number of bits for each grayscale pixel value - ignored on input\&. .IP "\(bu" 2 4 Original field type - currently ignored on input, set = 0 on output\&. Data values assumed to be reals\&. .PP .br \fIcpack\fP The packed data field\&. .br \fIlcpack\fP length of packed field cpack\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EPNG\fP Error encoding/decoding PNG data\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP .PP Definition at line \fB294\fP of file \fBpngpack\&.c\fP\&. .PP References \fBG2C_PNG_DRS_TEMPLATE_LEN\fP, and \fBpngpack_int()\fP\&. .SS "int g2c_pngunpackd (unsigned char * cpack, size_t len, int * idrstmpl, size_t ndpts, double * fld)" .PP This subroutine unpacks a data field that was packed into a PNG image format using info from the GRIB2 Data Representation Template 5\&.41 or 5\&.40010\&. .PP \fBParameters\fP .RS 4 \fIcpack\fP The packed data field (character*1 array)\&. .br \fIlen\fP length of packed field cpack()\&. .br \fIidrstmpl\fP Pointer to array of values for Data Representation \fCTemplate 5\&.41\fP or 5\&.40010\&. .br \fIndpts\fP The number of data values to unpack\&. .br \fIfld\fP Contains the unpacked data values\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No Error\&. .IP "\(bu" 2 \fBG2C_ENOMEM\fP Out of memory\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 Aug 8, 2022 .RE .PP .PP Definition at line \fB188\fP of file \fBpngunpack\&.c\fP\&. .PP References \fBG2C_PNG_DRS_TEMPLATE_LEN\fP, and \fBpngunpack_int()\fP\&. .SS "int g2c_pngunpackf (unsigned char * cpack, size_t len, int * idrstmpl, size_t ndpts, float * fld)" .PP This subroutine unpacks a data field that was packed into a PNG image format using info from the GRIB2 Data Representation Template 5\&.41 or 5\&.40010\&. .PP \fBParameters\fP .RS 4 \fIcpack\fP The packed data field (character*1 array)\&. .br \fIlen\fP length of packed field cpack()\&. .br \fIidrstmpl\fP Pointer to array of values for Data Representation \fCTemplate 5\&.41\fP or 5\&.40010\&. .br \fIndpts\fP The number of data values to unpack\&. .br \fIfld\fP Contains the unpacked data values\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No Error\&. .IP "\(bu" 2 \fBG2C_ENOMEM\fP Out of memory\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 Sep 8, 2022 .RE .PP .PP Definition at line \fB156\fP of file \fBpngunpack\&.c\fP\&. .PP References \fBG2C_PNG_DRS_TEMPLATE_LEN\fP, and \fBpngunpack_int()\fP\&. .SS "int g2c_seekmsg (int g2cid, size_t skip, size_t * offset, size_t * msglen)" .PP Search a file for the next GRIB2 Message\&. The search is terminated when a GRIB2 message is found, or the end of the file is reached\&. .PP \fBParameters\fP .RS 4 \fIg2cid\fP ID of an open GRIB2 file, returned from \fBg2c_open()\fP/g2c_create()\&. .br \fIskip\fP The number of bytes in the file to skip before starting the search\&. .br \fIoffset\fP Pointer that gets the number of bytes to skip from the beggining of the file to where the GRIB message starts\&. Ignored if NULL\&. .br \fImsglen\fP Pointer that gets the number of bytes in message (set to 0, if no message found)\&. Ignored if NULL\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .IP "\(bu" 2 \fBG2C_EBADID\fP Bad g2cid\&. .IP "\(bu" 2 \fBG2C_ENOMEM\fP Out of memory\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 2022-09-11 .RE .PP .PP Definition at line \fB56\fP of file \fBg2cfile\&.c\fP\&. .PP References \fBG2C_EBADID\fP, \fBG2C_EFILE\fP, \fBG2C_ENOMEM\fP, \fBg2c_file\fP, \fBG2C_MAGIC_HEADER\fP, \fBG2C_NOERROR\fP, \fBG2C_SEEKMSG_BUFSIZE\fP, \fBhton64\fP, and \fBLOG\fP\&. .PP Referenced by \fBread_metadata()\fP\&. .SS "int g2c_set_log_level (int new_level)" .PP Use this to set the global log level\&. Settings: .IP "\(bu" 2 -1 turn off all logging\&. .IP "\(bu" 2 0 show only errors\&. .IP "\(bu" 2 1 output useful as verbose to utilities\&. .IP "\(bu" 2 2 or 3 shows some/all calls to top-level functions\&. .IP "\(bu" 2 4+ ever greater levels of detail\&. .PP .PP If logging is not enabled when building NCEPLIBS-g2c, this function will do nothing\&. .PP \fBParameters\fP .RS 4 \fInew_level\fP The new logging level\&. .RE .PP \fBReturns\fP .RS 4 \fBG2C_NOERROR\fP No error\&. .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP .PP Definition at line \fB129\fP of file \fButil\&.c\fP\&. .PP References \fBG2C_NOERROR\fP, and \fBLOG\fP\&. .PP Referenced by \fBmain()\fP\&. .SS "const char * g2c_strerror (int g2cerr)" .PP Given an error code, return an error message\&. .PP \fBParameters\fP .RS 4 \fIg2cerr\fP An error number returned by one of the g2c_* functions\&. .RE .PP \fBReturns\fP .RS 4 The error message\&. .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP .PP Definition at line \fB29\fP of file \fBg2cutil\&.c\fP\&. .PP References \fBG2C_EBADEND\fP, \fBG2C_EBADID\fP, \fBG2C_EBADSECTION\fP, \fBG2C_EBADTEMPLATE\fP, \fBG2C_EBADTYPE\fP, \fBG2C_EFILE\fP, \fBG2C_EINVAL\fP, \fBG2C_EJPEG\fP, \fBG2C_EMSG\fP, \fBG2C_EMSGCOMPLETE\fP, \fBG2C_ENAMETOOLONG\fP, \fBG2C_ENOEND\fP, \fBG2C_ENOMEM\fP, \fBG2C_ENOMSG\fP, \fBG2C_ENOPARAM\fP, \fBG2C_ENOPRODUCT\fP, \fBG2C_ENOSECTION\fP, \fBG2C_ENOTEMPLATE\fP, \fBG2C_ENOTFOUND\fP, \fBG2C_ENOTGRIB\fP, \fBG2C_ENOTGRIB2\fP, \fBG2C_EPNG\fP, \fBG2C_ETOOMANYFILES\fP, \fBG2C_EXML\fP, and \fBG2C_NOERROR\fP\&. .SS "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)" .PP This subroutine unpacks Section 7 (Data Section) of a GRIB2 message\&. This function is the newer version of \fBg2_unpack7()\fP\&. .PP \fBParameters\fP .RS 4 \fIcgrib\fP char array containing Section 7 of the GRIB2 message .br \fIigdsnum\fP Grid Definition Template Number (see Code Table 3\&.0)\&. (Only used for DRS Template 5\&.51\&.) May be zero for other templates\&. .br \fIgds_tmpl_len\fP Number of elements in the GDS template\&. .br \fIgdstmpl\fP 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\&. .br \fIidrsnum\fP Data Representation Template Number (see Code Table 5\&.0)\&. .br \fIdrs_tmpl_len\fP Number of elements in the DRS template\&. .br \fIdrstmpl\fP 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 .br \fIndpts\fP Number of data points to be unpacked and returned\&. .br \fIfld\fP Pointer which the data\&. Memory must be allocated in advance by caller\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2_NO_ERROR\fP No error\&. .IP "\(bu" 2 \fBG2_UNPACK_BAD_SEC\fP Array passed had incorrect section number\&. .IP "\(bu" 2 \fBG2_UNPACK7_BAD_DRT\fP Unrecognized Data Representation Template\&. .IP "\(bu" 2 \fBG2_UNPACK7_WRONG_GDT\fP need one of GDT 3\&.50 through 3\&.53 to decode DRT 5\&.51 .IP "\(bu" 2 \fBG2_UNPACK_NO_MEM\fP Memory allocation error\&. .IP "\(bu" 2 \fBG2_UNPACK7_CORRUPT_SEC\fP Corrupt section 7\&. .PP .RE .PP \fBAuthor\fP .RS 4 Stephen Gilbert .RE .PP \fBDate\fP .RS 4 2002-10-31 .RE .PP .PP Definition at line \fB259\fP of file \fBg2_unpack7\&.c\fP\&. .PP References \fBG2C_EINVAL\fP, \fBG2C_ENOMEM\fP, \fBg2c_unpack7_int()\fP, and \fBLOG\fP\&. .PP Referenced by \fBg2c_get_prod()\fP\&. .SS "int g2c_write_index (int g2cid, int mode, const char * index_file)" .PP Create an index file from a GRIB2 file, just like those created by the grb2index utility\&. The index file starts with two header records: .IP "1." 4 81-byte header with 'gb2ix1' in columns 42-47\&. .IP "2." 4 81-byte header with number of bytes to skip before index records, total length in bytes of the index records, number of index records, and grib file basename written in format ('ix1form:',3i10,2x,a40)\&. .PP .PP Each following index record corresponds to a grib message and has the internal format: .IP "\(bu" 2 byte 001 - 004 length of index record .IP "\(bu" 2 byte 005 - 008 bytes to skip in data file before grib message .IP "\(bu" 2 byte 009 - 012 bytes to skip in message before lus (local use) (0, if none)\&. .IP "\(bu" 2 byte 013 - 016 bytes to skip in message before gds .IP "\(bu" 2 byte 017 - 020 bytes to skip in message before pds .IP "\(bu" 2 byte 021 - 024 bytes to skip in message before drs .IP "\(bu" 2 byte 025 - 028 bytes to skip in message before bms .IP "\(bu" 2 byte 029 - 032 bytes to skip in message before data section .IP "\(bu" 2 byte 033 - 040 bytes total in the message .IP "\(bu" 2 byte 041 - 041 grib version number (currently 2) .IP "\(bu" 2 byte 042 - 042 message discipline .IP "\(bu" 2 byte 043 - 044 field number within grib2 message (1-based) .IP "\(bu" 2 byte 045 - ii identification section (ids) .IP "\(bu" 2 byte ii+1- jj grid definition section (gds) .IP "\(bu" 2 byte jj+1- kk product definition section (pds) .IP "\(bu" 2 byte kk+1- ll the data representation section (drs) .IP "\(bu" 2 byte ll+1-ll+6 first 6 bytes of the bit map section (bms) .PP .PP \fBParameters\fP .RS 4 \fIg2cid\fP File it for an open GRIB2 file, as returned by \fBg2c_open()\fP\&. .br \fImode\fP Mode flags\&. Set \fBG2C_NOCLOBBER\fP to avoid overwriting and existing file\&. .br \fIindex_file\fP The name that will be given to the index file\&. An existing file will be overwritten\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 \fBG2C_NOERROR\fP No error\&. .PP .RE .PP \fBAuthor\fP .RS 4 Ed Hartnett .RE .PP \fBDate\fP .RS 4 10/12/22 .RE .PP .PP Definition at line \fB431\fP of file \fBg2cindex\&.c\fP\&. .PP References \fBg2c_message_info::bytes_in_msg\fP, \fBg2c_message_info::bytes_to_local\fP, \fBg2c_message_info::bytes_to_msg\fP, \fBg2c_section_info::bytes_to_sec\fP, \fBg2c_message_info::discipline\fP, \fBg2c_file_info::f\fP, \fBg2c_message_info::file\fP, \fBG2C_EBADID\fP, \fBG2C_EFILE\fP, \fBG2C_EINVAL\fP, \fBg2c_file\fP, \fBg2c_file_io_ubyte()\fP, \fBg2c_file_io_uint()\fP, \fBG2C_FILE_WRITE\fP, \fBg2c_get_prod_sections()\fP, \fBG2C_INDEX_BASENAME_LEN\fP, \fBG2C_INDEX_BITMAP_BYTES\fP, \fBG2C_INDEX_FIXED_LEN\fP, \fBG2C_INDEX_FIXED_LEN_2\fP, \fBG2C_INDEX_HEADER_LEN\fP, \fBG2C_LARGE_FILE_INDEX\fP, \fBG2C_MAX_FILES\fP, \fBG2C_NOCLOBBER\fP, \fBG2C_NOERROR\fP, \fBg2c_rw_section1_metadata()\fP, \fBg2c_rw_section3_metadata()\fP, \fBg2c_rw_section4_metadata()\fP, \fBg2c_rw_section5_metadata()\fP, \fBg2c_start_index_record()\fP, \fBg2c_start_index_record_lf()\fP, \fBLOG\fP, \fBg2c_message_info::master_version\fP, \fBMUTEX_LOCK\fP, \fBMUTEX_UNLOCK\fP, \fBg2c_message_info::next\fP, \fBg2c_message_info::num_fields\fP, \fBONE_BYTE\fP, \fBg2c_message_info::sec1_len\fP, and \fBg2c_section_info::sec_len\fP\&. .PP Referenced by \fBmain()\fP\&. .SS "void seekgb (FILE * lugb, \fBg2int\fP iseek, \fBg2int\fP mseek, \fBg2int\fP * lskip, \fBg2int\fP * lgrib)" .PP Search a file for the next GRIB Message\&. The search is done starting at byte offset iseek of the file referenced by lugb for mseek bytes at a time\&. If found, the starting position and length of the message are returned in lskip and lgrib, respectively\&. The search is terminated when an EOF or I/O error is encountered\&. .SS "Program History Log" Date Programmer Comments 2002-10-28 GILBERT Modified from Iredell's skgb subroutine 2009-01-16 VUONG Changed lskip to 4 instead of sizof(g2int) .PP \fBParameters\fP .RS 4 \fIlugb\fP FILE pointer for the file to search\&. File must be opened before this routine is called\&. .br \fIiseek\fP The number of bytes in the file to skip before search\&. .br \fImseek\fP The maximum number of bytes to search at a time (must be at least 16, but larger numbers like 4092 will result in better perfomance)\&. .br \fIlskip\fP Pointer that gets the number of bytes to skip from the beggining of the file to where the GRIB message starts\&. .br \fIlgrib\fP Pointer that gets the number of bytes in message (set to 0, if no message found)\&. .RE .PP \fBAuthor\fP .RS 4 Stephen Gilbert .RE .PP \fBDate\fP .RS 4 2002-10-28 .RE .PP .PP Definition at line \fB46\fP of file \fBseekgb\&.c\fP\&. .PP References \fBBYTE\fP, \fBgbit()\fP, and \fBLOG\fP\&. .PP Referenced by \fBg2c_get_msg()\fP\&. .SH "Author" .PP Generated automatically by Doxygen for NCEPLIBS-g2c from the source code\&.