.TH "grib2_int.h" 3 "Version 2.1.0" "NCEPLIBS-g2c" \" -*- nroff -*-
.ad l
.nh
.SH NAME
grib2_int.h \- Header file with internal function prototypes NCEPLIBS-g2c library\&.  

.SH SYNOPSIS
.br
.PP
\fC#include <assert\&.h>\fP
.br
\fC#include <ctype\&.h>\fP
.br
\fC#include <stdint\&.h>\fP
.br
\fC#include <stdio\&.h>\fP
.br
\fC#include <stdlib\&.h>\fP
.br
\fC#include <errno\&.h>\fP
.br
\fC#include <arpa/inet\&.h>\fP
.br
\fC#include 'grib2\&.h'\fP
.br

.SS "Data Structures"

.in +1c
.ti -1c
.RI "struct \fBg2c_code_table\fP"
.br
.RI "A GRIB2 code table\&. "
.ti -1c
.RI "struct \fBg2c_dim_info\fP"
.br
.RI "Keep information about dimensions defined in section 3\&. "
.ti -1c
.RI "struct \fBg2c_entry\fP"
.br
.RI "An entry in a GRIB2 code table\&. "
.ti -1c
.RI "struct \fBg2c_file_info\fP"
.br
.RI "This is the information about each open file\&. "
.ti -1c
.RI "struct \fBg2c_message_info\fP"
.br
.RI "This is the information about each message\&. "
.ti -1c
.RI "struct \fBg2c_param\fP"
.br
.RI "An entry in the table of NOAA abbreviations for GRIB parameters\&. "
.ti -1c
.RI "struct \fBg2c_section3_info\fP"
.br
.RI "Information about \fCSection 3 GRID DEFINITION SECTION\fP\&. "
.ti -1c
.RI "struct \fBg2c_section4_info\fP"
.br
.RI "Information about \fCSection 4 PRODUCT DEFINITION SECTION\fP\&. "
.ti -1c
.RI "struct \fBg2c_section5_info\fP"
.br
.RI "Information about \fCSection 5 DATA REPRESENTATION SECTION\fP\&. "
.ti -1c
.RI "struct \fBg2c_section6_info\fP"
.br
.RI "Information about \fCSection 6 BIT-MAP SECTION\fP\&. "
.ti -1c
.RI "struct \fBg2c_section_info\fP"
.br
.RI "Information about a section 3 through 7 in a GRIB2 message\&. "
.ti -1c
.RI "struct \fBgtemplate\fP"
.br
.RI "Struct for GRIB template, returned by \fBgetgridtemplate()\fP\&. "
.in -1c
.SS "Macros"

.in +1c
.ti -1c
.RI "#define \fBALOG2\fP   (0\&.69314718)"
.br
.RI "ln(2\&.0) "
.ti -1c
.RI "#define \fBBYTE\fP   8"
.br
.RI "Number of bits in a byte\&. "
.ti -1c
.RI "#define \fBEIGHT_BYTES\fP   8"
.br
.RI "Eight bytes\&. "
.ti -1c
.RI "#define \fBEXTERN_MUTEX\fP(m)"
.br
.RI "Pthreads not enabled, so do nothing\&. "
.ti -1c
.RI "#define \fBFOUR_BYTES\fP   4"
.br
.RI "Four bytes\&. "
.ti -1c
.RI "#define \fBG2C_FILE_READ\fP   0"
.br
.RI "Read\&. "
.ti -1c
.RI "#define \fBG2C_FILE_WRITE\fP   1"
.br
.RI "Write\&. "
.ti -1c
.RI "#define \fBG2C_INDEX1_BDS_VAL_LEN\fP   10"
.br
.RI "Length of the binary data section (bds) in index file\&. "
.ti -1c
.RI "#define \fBG2C_INDEX1_BMS_VAL_LEN\fP   5"
.br
.RI "Length of the bitmap section (bms) in index file\&. "
.ti -1c
.RI "#define \fBG2C_INDEX1_GDS_VAL2_LEN\fP   27"
.br
.RI "Length of the gds in index file\&. "
.ti -1c
.RI "#define \fBG2C_INDEX1_GDS_VAL_LEN\fP   41"
.br
.RI "Length of the grid definition section (gds) in index file\&. "
.ti -1c
.RI "#define \fBG2C_INDEX1_PDS_VAL2_LEN\fP   27"
.br
.RI "Length of the pds 2 section in the index file\&. "
.ti -1c
.RI "#define \fBG2C_INDEX1_PDS_VAL3_LEN\fP   27"
.br
.RI "Length of the pds 3 section in the index file\&. "
.ti -1c
.RI "#define \fBG2C_INDEX1_PDS_VAL_LEN\fP   27"
.br
.RI "Length of the product definition section (pds) in index file\&. "
.ti -1c
.RI "#define \fBG2C_JASPER_JPEG_FORMAT_NAME\fP   'jpc'"
.br
.RI "Name of JPEG codec in Jasper\&. "
.ti -1c
.RI "#define \fBG2C_MAGIC_HEADER\fP   'GRIB'"
.br
.RI "GRIB magic header string\&. "
.ti -1c
.RI "#define \fBG2C_MAGIC_HEADER_LEN\fP   8"
.br
.RI "Full length of magic header string (includes GRIB version byte)\&. "
.ti -1c
.RI "#define \fBG2C_MAX_MESSAGES\fP   1024"
.br
.RI "Maximum number of messages in a file\&. "
.ti -1c
.RI "#define \fBG2C_MIN_MAX_BYTES\fP   16"
.br
.RI "Minimum acceptable value for max_bytes parameter of \fBg2c_get_msg()\fP\&. "
.ti -1c
.RI "#define \fBhton64\fP(y)   (((uint64_t)htonl(y)) << \fBWORD\fP | htonl(y >> \fBWORD\fP))"
.br
.RI "Byte swap 64-bit ints\&. "
.ti -1c
.RI "#define \fBLATITUDE\fP   'Latitude'"
.br
.RI "Latitude\&. "
.ti -1c
.RI "#define \fBLOG\fP(e)"
.br
.RI "Ignore logging to stdout\&. "
.ti -1c
.RI "#define \fBLONGITUDE\fP   'Longitude'"
.br
.RI "Longitude\&. "
.ti -1c
.RI "#define \fBMUTEX\fP(m)"
.br
.RI "Pthreads not enabled, so do nothing\&. "
.ti -1c
.RI "#define \fBMUTEX_LOCK\fP(m)"
.br
.RI "Pthreads not enabled, so do nothing\&. "
.ti -1c
.RI "#define \fBMUTEX_UNLOCK\fP(m)"
.br
.RI "Pthreads not enabled, so do nothing\&. "
.ti -1c
.RI "#define \fBntoh64\fP(y)   (((uint64_t)ntohl(y)) << \fBWORD\fP | ntohl(y >> \fBWORD\fP))"
.br
.RI "Byte swap 64-bit ints\&. "
.ti -1c
.RI "#define \fBONE_BYTE\fP   1"
.br
.RI "One byte\&. "
.ti -1c
.RI "#define \fBTWO_BYTES\fP   2"
.br
.RI "Two bytes\&. "
.ti -1c
.RI "#define \fBWORD\fP   32"
.br
.RI "Number of bits in four bytes\&. "
.in -1c
.SS "Typedefs"

.in +1c
.ti -1c
.RI "typedef struct \fBg2c_entry\fP \fBG2C_CODE_ENTRY_T\fP"
.br
.RI "An entry in a GRIB2 code table\&. "
.ti -1c
.RI "typedef struct \fBg2c_code_table\fP \fBG2C_CODE_TABLE_T\fP"
.br
.RI "A GRIB2 code table\&. "
.ti -1c
.RI "typedef struct \fBg2c_dim_info\fP \fBG2C_DIM_INFO_T\fP"
.br
.RI "Keep information about dimensions defined in section 3\&. "
.ti -1c
.RI "typedef struct \fBg2c_file_info\fP \fBG2C_FILE_INFO_T\fP"
.br
.RI "This is the information about each open file\&. "
.ti -1c
.RI "typedef struct \fBg2c_message_info\fP \fBG2C_MESSAGE_INFO_T\fP"
.br
.RI "This is the information about each message\&. "
.ti -1c
.RI "typedef struct \fBg2c_param\fP \fBG2C_PARAM_T\fP"
.br
.RI "An entry in the table of NOAA abbreviations for GRIB parameters\&. "
.ti -1c
.RI "typedef struct \fBg2c_section3_info\fP \fBG2C_SECTION3_INFO_T\fP"
.br
.RI "Information about \fCSection 3 GRID DEFINITION SECTION\fP\&. "
.ti -1c
.RI "typedef struct \fBg2c_section4_info\fP \fBG2C_SECTION4_INFO_T\fP"
.br
.RI "Information about \fCSection 4 PRODUCT DEFINITION SECTION\fP\&. "
.ti -1c
.RI "typedef struct \fBg2c_section5_info\fP \fBG2C_SECTION5_INFO_T\fP"
.br
.RI "Information about \fCSection 5 DATA REPRESENTATION SECTION\fP\&. "
.ti -1c
.RI "typedef struct \fBg2c_section6_info\fP \fBG2C_SECTION6_INFO_T\fP"
.br
.RI "Information about \fCSection 6 BIT-MAP SECTION\fP\&. "
.ti -1c
.RI "typedef struct \fBg2c_section_info\fP \fBG2C_SECTION_INFO_T\fP"
.br
.RI "Information about a section 3 through 7 in a GRIB2 message\&. "
.ti -1c
.RI "typedef struct \fBgtemplate\fP \fBgtemplate\fP"
.br
.RI "Struct for GRIB template\&. "
.in -1c
.SS "Functions"

.in +1c
.ti -1c
.RI "int \fBadd_msg\fP (\fBG2C_FILE_INFO_T\fP *file, int msg_num, size_t bytes_to_msg, size_t bytes_in_msg, int read_file, \fBG2C_MESSAGE_INFO_T\fP **msg)"
.br
.RI "Add new message to linked list\&. "
.ti -1c
.RI "int \fBadd_section\fP (FILE *f, \fBG2C_MESSAGE_INFO_T\fP *msg, int sec_id, unsigned int sec_len, size_t bytes_to_sec, unsigned char sec_num)"
.br
.RI "Add metadata about a new section 3, 4, 5, 6, or 7\&. "
.ti -1c
.RI "void \fBaecpack\fP (float *fld, \fBg2int\fP width, \fBg2int\fP height, \fBg2int\fP *idrstmpl, unsigned char *cpack, \fBg2int\fP *lcpack)"
.br
.RI "This function packs up a float array into a AEC code stream\&. "
.ti -1c
.RI "\fBg2int\fP \fBaecunpack\fP (unsigned char *cpack, \fBg2int\fP len, \fBg2int\fP *idrstmpl, \fBg2int\fP 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 "void \fBcmplxpack\fP (float *fld, \fBg2int\fP ndpts, \fBg2int\fP idrsnum, \fBg2int\fP *idrstmpl, unsigned char *cpack, \fBg2int\fP *lcpack)"
.br
.RI "Pack up a data field using a complex packing algorithm\&. "
.ti -1c
.RI "void \fBcompack\fP (float *fld, \fBg2int\fP ndpts, \fBg2int\fP idrsnum, \fBg2int\fP *idrstmpl, unsigned char *cpack, \fBg2int\fP *lcpack)"
.br
.RI "Pack a data field using a complex packing algorithm\&. "
.ti -1c
.RI "int \fBcomunpack\fP (unsigned char *cpack, \fBg2int\fP lensec, \fBg2int\fP idrsnum, \fBg2int\fP *idrstmpl, \fBg2int\fP ndpts, float *fld)"
.br
.RI "Unpack a data field that was packed using a complex packing algorithm, using info from the GRIB2 Data Representation \fCTemplate 5\&.2\fP or \fCTemplate 5\&.3\fP\&. "
.ti -1c
.RI "int \fBdec_aec\fP (unsigned char *cpack, \fBg2int\fP len, \fBg2int\fP nbits, \fBg2int\fP flags, \fBg2int\fP block_size, \fBg2int\fP rsi, unsigned char *cfld, \fBg2int\fP cfldlen)"
.br
.RI "Decode an AEC code stream specified in the \fCCCSDS 121\&.0-B-3 Blue Book\fP\&. "
.ti -1c
.RI "int \fBdec_jpeg2000\fP (char *injpc, \fBg2int\fP bufsize, \fBg2int\fP *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 \fBdec_png\fP (unsigned char *pngbuf, \fBg2int\fP *width, \fBg2int\fP *height, unsigned char *cout)"
.br
.RI "Decode PNG\&. "
.ti -1c
.RI "int \fBenc_aec\fP (unsigned char *data, \fBg2int\fP ctemplen, \fBg2int\fP nbits, \fBg2int\fP flags, \fBg2int\fP block_size, \fBg2int\fP rsi, unsigned char *aecbuf, \fBg2int\fP *aecbuflen)"
.br
.RI "Encode data into an AEC code stream specified in the \fCCCSDS 121\&.0-B-3 Blue Book\fP\&. "
.ti -1c
.RI "int \fBenc_jpeg2000\fP (unsigned char *cin, \fBg2int\fP width, \fBg2int\fP height, \fBg2int\fP nbits, \fBg2int\fP ltype, \fBg2int\fP ratio, \fBg2int\fP retry, char *outjpc, \fBg2int\fP 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 \fBenc_png\fP (unsigned char *data, \fBg2int\fP width, \fBg2int\fP height, \fBg2int\fP nbits, unsigned char *pngbuf)"
.br
.RI "Encode PNG\&. "
.ti -1c
.RI "\fBgtemplate\fP * \fBextdrstemplate\fP (\fBg2int\fP number, \fBg2int\fP *list)"
.br
.RI "This subroutine generates the remaining octet map for a given Data Representation Template, if required\&. "
.ti -1c
.RI "\fBgtemplate\fP * \fBextgridtemplate\fP (\fBg2int\fP number, \fBg2int\fP *list)"
.br
.RI "This subroutine generates the remaining octet map for a given Grid Definition Template, if required\&. "
.ti -1c
.RI "\fBgtemplate\fP * \fBextpdstemplate\fP (\fBg2int\fP number, \fBg2int\fP *list)"
.br
.RI "This subroutine generates the remaining octet map for a given Product Definition Template, if required\&. "
.ti -1c
.RI "int \fBg2c_add_file\fP (const char *path, int mode, int *g2cid)"
.br
.RI "Open a GRIB2 file and add it to the list of open files\&. "
.ti -1c
.RI "int \fBg2c_check_msg\fP (unsigned char *cgrib, \fBg2int\fP *lencurr, int verbose)"
.br
.RI "Check for 'GRIB' at the beginning of a GRIB message, and check to see if the message is already terminated with '7777'\&. "
.ti -1c
.RI "int \fBg2c_file_io\fP (FILE *f, int write, int g2ctype, void *var)"
.br
.RI "Read or write a big-endian integer type to an open file, with conversion between native and big-endian format\&. "
.ti -1c
.RI "int \fBg2c_file_io_byte\fP (FILE *f, int write, char *var)"
.br
.RI "Read or write a big-endian signed byte to an open GRIB2 file, with conversion between native and big-endian format, and special GRIB2 handling of negative numbers\&. "
.ti -1c
.RI "int \fBg2c_file_io_int\fP (FILE *f, int write, int *var)"
.br
.RI "Read or write a big-endian 4-byte signed int to an open GRIB2 file, with conversion between native and big-endian format, and special GRIB2 handling of negative numbers\&. "
.ti -1c
.RI "int \fBg2c_file_io_longlong\fP (FILE *f, int write, long long *var)"
.br
.RI "Read or write a big-endian signed long long to an open GRIB2 file, with conversion between native and big-endian format, and special GRIB2 handling of negative numbers\&. "
.ti -1c
.RI "int \fBg2c_file_io_short\fP (FILE *f, int write, short *var)"
.br
.RI "Read or write a big-endian signed short to an open GRIB2 file, with conversion between native and big-endian format, and special GRIB2 handling of negative numbers\&. "
.ti -1c
.RI "int \fBg2c_file_io_template\fP (FILE *f, int rw_flag, int map, long long int *template_value)"
.br
.RI "Read or write a big-endian 4-byte int or unsigned int from or to an open file, with conversion between native and big-endian format, and handling of GRIB negative numbers\&. "
.ti -1c
.RI "int \fBg2c_file_io_ubyte\fP (FILE *f, int write, unsigned char *var)"
.br
.RI "Read or write a big-endian unsigned byte to an open GRIB2 file, with conversion between native and big-endian format\&. "
.ti -1c
.RI "int \fBg2c_file_io_uint\fP (FILE *f, int write, unsigned int *var)"
.br
.RI "Read or write a big-endian 4-byte unsigned int to an open GRIB2 file, with conversion between native and big-endian format\&. "
.ti -1c
.RI "int \fBg2c_file_io_ulonglong\fP (FILE *f, int write, unsigned long long *var)"
.br
.RI "Read or write a big-endian unsigned long long to an open GRIB2 file, with conversion between native and big-endian format\&. "
.ti -1c
.RI "int \fBg2c_file_io_ushort\fP (FILE *f, int write, unsigned short *var)"
.br
.RI "Read or write a big-endian unsigned short to an open GRIB2 file, with conversion between native and big-endian format\&. "
.ti -1c
.RI "int \fBg2c_get_datetime\fP (int ipdtn, long long int *ipdtmpl, short year, unsigned char month, unsigned char day, unsigned char hour, unsigned char minute, unsigned char second, char *tabbrev)"
.br
.RI "Convert date and time from GRIB2 info to string output\&. "
.ti -1c
.RI "int \fBg2c_get_level_desc\fP (int ipdtn, long long int *ipdtmpl, char *level_desc)"
.br
.RI "Determine the string that describes the level information, given the GRIB2 Product Definition Template information\&. "
.ti -1c
.RI "int \fBg2c_log_section1\fP (\fBG2C_MESSAGE_INFO_T\fP *msg)"
.br
.RI "Log section 0 information\&. "
.ti -1c
.RI "int \fBg2c_rw_section1_metadata\fP (FILE *f, int rw_flag, \fBG2C_MESSAGE_INFO_T\fP *msg)"
.br
.RI "Read Section 1\&. "
.ti -1c
.RI "int \fBg2c_rw_section3_metadata\fP (FILE *f, int rw_flag, \fBG2C_SECTION_INFO_T\fP *sec)"
.br
.RI "Read the metadata from section 3 (Grid Definition Section) of a GRIB2 message\&. "
.ti -1c
.RI "int \fBg2c_rw_section4_metadata\fP (FILE *f, int rw_flag, \fBG2C_SECTION_INFO_T\fP *sec)"
.br
.RI "Read or write the metadata from section 4 (Product Definition Section) of a GRIB2 message\&. "
.ti -1c
.RI "int \fBg2c_rw_section5_metadata\fP (FILE *f, int rw_flag, \fBG2C_SECTION_INFO_T\fP *sec)"
.br
.RI "Read or write the metadata from section 5 (Data Representation Section) of a GRIB2 message\&. "
.ti -1c
.RI "int \fBg2c_rw_section6_metadata\fP (FILE *f, int rw_flag, \fBG2C_SECTION_INFO_T\fP *sec)"
.br
.RI "Read or write the metadata from section 6 (Data Representation Section) of a GRIB2 message\&. "
.ti -1c
.RI "void \fBgbit\fP (unsigned char *in, \fBg2int\fP *iout, \fBg2int\fP iskip, \fBg2int\fP nbits)"
.br
.RI "Get arbitrary size values from a packed bit string, right justifying each value in the unpacked iout array\&. "
.ti -1c
.RI "void \fBgbits\fP (unsigned char *in, \fBg2int\fP *iout, \fBg2int\fP iskip, \fBg2int\fP nbits, \fBg2int\fP nskip, \fBg2int\fP n)"
.br
.RI "Unpack arbitrary size values from a packed bit string, right justifying each value in the unpacked iout array\&. "
.ti -1c
.RI "\fBg2int\fP \fBgetdim\fP (unsigned char *csec3, \fBg2int\fP *width, \fBg2int\fP *height, \fBg2int\fP *iscan)"
.br
.RI "Return the dimensions and scanning mode of a grid definition\&. "
.ti -1c
.RI "\fBgtemplate\fP * \fBgetdrstemplate\fP (\fBg2int\fP number)"
.br
.RI "This subroutine returns DRS template information for a specified Data Representation Template\&. "
.ti -1c
.RI "\fBgtemplate\fP * \fBgetgridtemplate\fP (\fBg2int\fP number)"
.br
.RI "This subroutine returns grid template information for a specified Grid Definition Template for [Section 3 - the Grid Definition Section (GDS)](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect3.shtml)\&. "
.ti -1c
.RI "\fBgtemplate\fP * \fBgetpdstemplate\fP (\fBg2int\fP number)"
.br
.RI "This subroutine returns PDS template information for a specified Product Definition Template\&. "
.ti -1c
.RI "\fBg2int\fP \fBgetpoly\fP (unsigned char *csec3, \fBg2int\fP *jj, \fBg2int\fP *kk, \fBg2int\fP *mm)"
.br
.RI "This subroutine returns the J, K, and M pentagonal resolution parameters specified in a GRIB Grid Definition Section (GDS) used spherical harmonic coefficients using GDT 5\&.50 through 5\&.53\&. "
.ti -1c
.RI "double \fBint_power\fP (double x, \fBg2int\fP y)"
.br
.RI "Function similar to C pow() power function\&. "
.ti -1c
.RI "void \fBjpcpack\fP (float *fld, \fBg2int\fP width, \fBg2int\fP height, \fBg2int\fP *idrstmpl, unsigned char *cpack, \fBg2int\fP *lcpack)"
.br
.RI "This function packs up a float array into a JPEG2000 code stream\&. "
.ti -1c
.RI "\fBg2int\fP \fBjpcunpack\fP (unsigned char *cpack, \fBg2int\fP len, \fBg2int\fP *idrstmpl, \fBg2int\fP 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 "void \fBmisspack\fP (float *fld, \fBg2int\fP ndpts, \fBg2int\fP idrsnum, \fBg2int\fP *idrstmpl, unsigned char *cpack, \fBg2int\fP *lcpack)"
.br
.RI "Pack a data field using a complex packing algorithm\&. "
.ti -1c
.RI "void \fBmkieee\fP (float *a, \fBg2int\fP *rieee, \fBg2int\fP num)"
.br
.RI "Store a list of real values in 32-bit IEEE floating point format\&. "
.ti -1c
.RI "int \fBpack_gp\fP (\fBg2int\fP *kfildo, \fBg2int\fP *ic, \fBg2int\fP *nxy, \fBg2int\fP *is523, \fBg2int\fP *minpk, \fBg2int\fP *inc, \fBg2int\fP *missp, \fBg2int\fP *misss, \fBg2int\fP *jmin, \fBg2int\fP *jmax, \fBg2int\fP *lbit, \fBg2int\fP *nov, \fBg2int\fP *ndg, \fBg2int\fP *lx, \fBg2int\fP *ibit, \fBg2int\fP *jbit, \fBg2int\fP *kbit, \fBg2int\fP *novref, \fBg2int\fP *lbitref, \fBg2int\fP *ier)"
.br
.RI "Determines groups of variable size, but at least of size minpk, the associated max (jmax( )) and min (jmin( )), the number of bits necessary to hold the values in each group (lbit( )), the number of values in each group (nov( )), the number of bits necessary to pack the jmin( ) values (ibit), the number of bits necessary to pack the lbit( ) values (jbit), and the number of bits necessary to pack the nov( ) values (kbit)\&. "
.ti -1c
.RI "void \fBpngpack\fP (float *fld, \fBg2int\fP width, \fBg2int\fP height, \fBg2int\fP *idrstmpl, unsigned char *cpack, \fBg2int\fP *lcpack)"
.br
.RI "This subroutine packs up a float data field into PNG image format\&. "
.ti -1c
.RI "\fBg2int\fP \fBpngunpack\fP (unsigned char *cpack, \fBg2int\fP len, \fBg2int\fP *idrstmpl, \fBg2int\fP 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 "void \fBrdieee\fP (\fBg2int\fP *rieee, float *a, \fBg2int\fP num)"
.br
.RI "Read a list of real values in 32-bit IEEE floating point format\&. "
.ti -1c
.RI "void \fBsbit\fP (unsigned char *out, \fBg2int\fP *in, \fBg2int\fP iskip, \fBg2int\fP nbits)"
.br
.RI "Store arbitrary size values into a packed bit string, taking the low order bits from each value in the unpacked array\&. "
.ti -1c
.RI "void \fBsbits\fP (unsigned char *out, \fBg2int\fP *in, \fBg2int\fP iskip, \fBg2int\fP nbits, \fBg2int\fP nskip, \fBg2int\fP n)"
.br
.RI "Store arbitrary size values into a packed bit string, taking the low order bits from each value in the unpacked array\&. "
.ti -1c
.RI "void \fBsimpack\fP (float *fld, \fBg2int\fP ndpts, \fBg2int\fP *idrstmpl, unsigned char *cpack, \fBg2int\fP *lcpack)"
.br
.RI "Packs a data field using the simple packing algorithm\&. "
.ti -1c
.RI "\fBg2int\fP \fBsimunpack\fP (unsigned char *cpack, \fBg2int\fP *idrstmpl, \fBg2int\fP ndpts, float *fld)"
.br
.RI "Unpack a data field that was packed using a simple packing algorithm, using info from the GRIB2 Data Representation Template 5\&.0\&. "
.ti -1c
.RI "void \fBspecpack\fP (float *fld, \fBg2int\fP ndpts, \fBg2int\fP JJ, \fBg2int\fP KK, \fBg2int\fP MM, \fBg2int\fP *idrstmpl, unsigned char *cpack, \fBg2int\fP *lcpack)"
.br
.RI "Pack a spectral data field using the complex packing algorithm for spherical harmonic data as defined in the GRIB2 Data Representation \fCTemplate 5\&.51\fP\&. "
.ti -1c
.RI "\fBg2int\fP \fBspecunpack\fP (unsigned char *cpack, \fBg2int\fP *idrstmpl, \fBg2int\fP ndpts, \fBg2int\fP JJ, \fBg2int\fP KK, \fBg2int\fP MM, float *fld)"
.br
.RI "Unpack a spectral data field that was packed using the complex packing algorithm for spherical harmonic data as defined in the GRIB2 documention, using info from the GRIB2 Data Representation \fCTemplate 5\&.51\fP\&. "
.in -1c
.SH "Detailed Description"
.PP 
Header file with internal function prototypes NCEPLIBS-g2c library\&. 


.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 
.RE
.PP
\fBDate\fP
.RS 4
2021-11-08 
.RE
.PP

.PP
Definition in file \fBgrib2_int\&.h\fP\&.
.SH "Data Type Documentation"
.PP 
.SH "struct g2c_code_table"
.PP 
A GRIB2 code table\&. 
.PP
Definition at line \fB256\fP of file \fBgrib2_int\&.h\fP\&.
.PP
\fBData Fields:\fP
.RS 4
\fBG2C_CODE_ENTRY_T\fP * \fIentry\fP 
.br
.PP
struct \fBg2c_code_table\fP * \fInext\fP 
.br
.PP
char \fItitle[\fBG2C_MAX_GRIB_TITLE_LEN\fP+1]\fP 
.br
.PP
.RE
.PP
.SH "struct g2c_dim_info"
.PP 
Keep information about dimensions defined in section 3\&. 
.PP
Definition at line \fB185\fP of file \fBgrib2_int\&.h\fP\&.
.PP
\fBData Fields:\fP
.RS 4
int \fIdimid\fP Dimension ID\&. 
.br
.PP
size_t \fIlen\fP Length of dimension\&. 
.br
.PP
char \fIname[\fBG2C_MAX_NAME\fP+1]\fP Name of dimension\&. 
.br
.PP
float * \fIvalue\fP Array of dimension values\&. 
.br
.PP
.RE
.PP
.SH "struct g2c_entry"
.PP 
An entry in a GRIB2 code table\&. 
.PP
Definition at line \fB247\fP of file \fBgrib2_int\&.h\fP\&.
.PP
\fBData Fields:\fP
.RS 4
char \fIcode[\fBG2C_MAX_GRIB_CODE_LEN\fP+1]\fP 
.br
.PP
char \fIdesc[\fBG2C_MAX_GRIB_DESC_LEN\fP+1]\fP 
.br
.PP
struct \fBg2c_entry\fP * \fInext\fP 
.br
.PP
char \fIstatus[\fBG2C_MAX_GRIB_STATUS_LEN\fP+1]\fP 
.br
.PP
.RE
.PP
.SH "struct g2c_file_info"
.PP 
This is the information about each open file\&. 
.PP
Definition at line \fB237\fP of file \fBgrib2_int\&.h\fP\&.
.PP
\fBData Fields:\fP
.RS 4
\fBFILE\fP * \fIf\fP FILE pointer to open file\&. 
.br
.PP
int \fIg2cid\fP ID of the file\&. 
.br
.PP
\fBG2C_MESSAGE_INFO_T\fP * \fImsg\fP Information about each message in the file\&. 
.br
.PP
\fBsize_t\fP \fInum_messages\fP Number of messages in the file\&. 
.br
.PP
\fBchar\fP \fIpath[\fBG2C_MAX_NAME\fP+1]\fP Path of the file\&. 
.br
.PP
.RE
.PP
.SH "struct g2c_message_info"
.PP 
This is the information about each message\&. 
.PP
Definition at line \fB135\fP of file \fBgrib2_int\&.h\fP\&.
.PP
\fBData Fields:\fP
.RS 4
size_t \fIbytes_in_msg\fP Number of bytes in this message\&. 
.br
.PP
size_t \fIbytes_to_bms\fP Number of bytes in the message to the bitmap section\&. 
.br
.PP
size_t \fIbytes_to_data\fP Number of bytes in the message to the (first) data section\&. 
.br
.PP
size_t \fIbytes_to_local\fP Number of bytes in the message before the (first) local section\&. 
.br
.PP
size_t \fIbytes_to_msg\fP Number of bytes to skip in the file, to get to this message\&. 
.br
.PP
short \fIcenter\fP Originating center\&. 
.br
.PP
unsigned char \fIday\fP Day\&. 
.br
.PP
unsigned char \fIdiscipline\fP Discipline from section 0\&. 
.br
.PP
struct \fBg2c_file_info\fP * \fIfile\fP Pointer to containing file\&. 
.br
.PP
unsigned char \fIhour\fP Hour\&. 
.br
.PP
unsigned char \fIlocal_version\fP Version number of GRIB local tables used to augment Master Tables\&. 
.br
.PP
unsigned char \fImaster_version\fP GRIB master tables version number\&. 
.br
.PP
unsigned char \fIminute\fP Minute\&. 
.br
.PP
unsigned char \fImonth\fP Month\&. 
.br
.PP
size_t \fImsg_num\fP Number of message in file (0-based)\&. 
.br
.PP
struct \fBg2c_message_info\fP * \fInext\fP Pointer to next in list\&. 
.br
.PP
int \fInum_fields\fP Number of fields in the message\&. 
.br
.PP
int \fInum_local\fP Number of local sections in the message\&. 
.br
.PP
int \fInum_sections\fP Number of sections in the file\&. 
.br
.PP
struct \fBg2c_section_info\fP * \fIsec\fP List of section metadata\&. 
.br
.PP
int \fIsec1_len\fP Length of section 1\&. 
.br
.PP
unsigned char \fIsecond\fP Second\&. 
.br
.PP
int \fIsection1[\fBG2C_SECTION1_ARRAY_LEN\fP]\fP Section 1 array\&. 
.br
.PP
int * \fIsection_number\fP Array (length num_sections) of section numbers\&. 
.br
.PP
size_t * \fIsection_offset\fP Array (length num_sections) of byte offsets from start of message to section\&. 
.br
.PP
unsigned char \fIsig_ref_time\fP Significance of reference time\&. 
.br
.PP
unsigned char \fIstatus\fP Production Status of Processed data in the GRIB message\&. 
.br
.PP
short \fIsubcenter\fP Originating subcenter\&. 
.br
.PP
unsigned char \fItype\fP Type of processed data in this GRIB message\&. 
.br
.PP
short \fIyear\fP Year\&. 
.br
.PP
.RE
.PP
.SH "struct g2c_param"
.PP 
An entry in the table of NOAA abbreviations for GRIB parameters\&. 
.PP
Definition at line \fB264\fP of file \fBgrib2_int\&.h\fP\&.
.PP
\fBData Fields:\fP
.RS 4
char \fIabbrev[\fBG2C_MAX_NOAA_ABBREV_LEN\fP+1]\fP NOAA abbreviation for this parameter\&. 
.br
.PP
int \fIg1num\fP GRIB1 parameter number\&. 
.br
.PP
int \fIg1ver\fP GRIB1 table version\&. 
.br
.PP
int \fIg2cat\fP GRIB2 category number\&. 
.br
.PP
int \fIg2disc\fP GRIB2 discipline\&. 
.br
.PP
int \fIg2num\fP GRIB2 parameter number\&. 
.br
.PP
.RE
.PP
.SH "struct g2c_section3_info"
.PP 
Information about \fCSection 3 GRID DEFINITION SECTION\fP\&. 
.PP
Definition at line \fB195\fP of file \fBgrib2_int\&.h\fP\&.
.PP
\fBData Fields:\fP
.RS 4
\fBG2C_DIM_INFO_T\fP \fIdim[2]\fP Dimension information\&. 
.br
.PP
unsigned short \fIgrid_def\fP Grid definition template number (= N) (See Table 3\&.1)\&. 
.br
.PP
unsigned char \fIinterp_list\fP Interpetation of list of numbers defining number of points (See Table 3\&.11)\&. 
.br
.PP
unsigned int \fInum_data_points\fP Number of data points\&. 
.br
.PP
unsigned char \fInum_opt\fP Number of octets for optional list of numbers defining number of points\&. 
.br
.PP
int * \fIoptional\fP Optional list of numbers defining number of points\&. 
.br
.PP
unsigned char \fIsource_grid_def\fP Source of grid definition (See Table 3\&.0)\&. 
.br
.PP
.RE
.PP
.SH "struct g2c_section4_info"
.PP 
Information about \fCSection 4 PRODUCT DEFINITION SECTION\fP\&. 
.PP
Definition at line \fB208\fP of file \fBgrib2_int\&.h\fP\&.
.PP
\fBData Fields:\fP
.RS 4
int \fIfield_num\fP 
.br
.PP
unsigned short \fInum_coord\fP Number of coordinate values after template\&. 
.br
.PP
int * \fIoptional\fP Optional list of numbers defining number of points\&. 
.br
.PP
unsigned short \fIprod_def\fP Product definition template number (See Table 4\&.0)\&. 
.br
.PP
.RE
.PP
.SH "struct g2c_section5_info"
.PP 
Information about \fCSection 5 DATA REPRESENTATION SECTION\fP\&. 
.PP
Definition at line \fB218\fP of file \fBgrib2_int\&.h\fP\&.
.PP
\fBData Fields:\fP
.RS 4
unsigned short \fIdata_def\fP Data representation template number (See Table 5\&.0)\&. 
.br
.PP
unsigned int \fInum_data_points\fP Number of data points where one or more values are specified in Section 7 when a bit map is present, total number of data points when a bit map is absent\&. 
.br
.PP
.RE
.PP
.SH "struct g2c_section6_info"
.PP 
Information about \fCSection 6 BIT-MAP SECTION\fP\&. 
.PP
Definition at line \fB229\fP of file \fBgrib2_int\&.h\fP\&.
.PP
\fBData Fields:\fP
.RS 4
unsigned char \fIindicator\fP Bit map indicator\&. 
.br
See \fCTable 6\&.0\fP\&. 
.br
.PP
.RE
.PP
.SH "struct g2c_section_info"
.PP 
Information about a section 3 through 7 in a GRIB2 message\&. 
.PP
Definition at line \fB170\fP of file \fBgrib2_int\&.h\fP\&.
.PP
\fBData Fields:\fP
.RS 4
size_t \fIbytes_to_sec\fP Number of bytes from start of message to this section\&. 
.br
.PP
\fBG2C_MESSAGE_INFO_T\fP * \fImsg\fP Pointer to contianing message\&. 
.br
.PP
struct \fBg2c_section_info\fP * \fInext\fP Pointer to next in list\&. 
.br
.PP
struct \fBg2c_section_info\fP * \fIprev\fP Pointer to previous in list\&. 
.br
.PP
int \fIsec_id\fP ID of the section (0-based)\&. 
.br
.PP
void * \fIsec_info\fP Pointer to struct specific for section 3, 4, 5, 6, or 7\&. 
.br
.PP
unsigned int \fIsec_len\fP Length of the section (in bytes)\&. 
.br
.PP
unsigned char \fIsec_num\fP Section number\&. 
.br
.PP
long long int * \fItemplate\fP Grid, product, or data template\&. 
.br
.PP
int \fItemplate_len\fP Number of entries in template\&. 
.br
.PP
.RE
.PP
.SH "struct gtemplate"
.PP 
Struct for GRIB template, returned by \fBgetgridtemplate()\fP\&. 
.PP
Definition at line \fB277\fP of file \fBgrib2_int\&.h\fP\&.
.PP
\fBData Fields:\fP
.RS 4
\fBg2int\fP * \fIext\fP Number of octets of each entry in the extension part of the template\&. 
.br
.PP
\fBg2int\fP \fIextlen\fP Number of entries in the template extension\&. 
.br
.PP
\fBg2int\fP * \fImap\fP Number of octets of each entry in the static part of the template\&. 
.br
.PP
\fBg2int\fP \fImaplen\fP Number of entries in the static part of the template\&. 
.br
.PP
\fBg2int\fP \fIneedext\fP Indicates whether or not the template needs to be extended\&. 
.br
.PP
\fBg2int\fP \fInum\fP The template number\&. 
.br
.PP
\fBg2int\fP \fItype\fP The template type: 3 Grid Defintion Template\&. 
.br
4 Product Defintion Template\&. 5 Data Representation Template\&. 
.br
.PP
.RE
.PP
.SH "Macro Definition Documentation"
.PP 
.SS "#define ALOG2   (0\&.69314718)"

.PP
ln(2\&.0) 
.PP
Definition at line \fB30\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define BYTE   8"

.PP
Number of bits in a byte\&. 
.PP
Definition at line \fB47\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define EIGHT_BYTES   8"

.PP
Eight bytes\&. 
.PP
Definition at line \fB53\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define EXTERN_MUTEX(m)"

.PP
Pthreads not enabled, so do nothing\&. 
.PP
Definition at line \fB113\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define FOUR_BYTES   4"

.PP
Four bytes\&. 
.PP
Definition at line \fB52\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define G2C_FILE_READ   0"

.PP
Read\&. 
.PP
Definition at line \fB131\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define G2C_FILE_WRITE   1"

.PP
Write\&. 
.PP
Definition at line \fB132\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define G2C_INDEX1_BDS_VAL_LEN   10"

.PP
Length of the binary data section (bds) in index file\&. 
.PP
Definition at line \fB73\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define G2C_INDEX1_BMS_VAL_LEN   5"

.PP
Length of the bitmap section (bms) in index file\&. 
.PP
Definition at line \fB70\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define G2C_INDEX1_GDS_VAL2_LEN   27"

.PP
Length of the gds in index file\&. 
.PP
Definition at line \fB82\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define G2C_INDEX1_GDS_VAL_LEN   41"

.PP
Length of the grid definition section (gds) in index file\&. 
.PP
Definition at line \fB67\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define G2C_INDEX1_PDS_VAL2_LEN   27"

.PP
Length of the pds 2 section in the index file\&. 
.PP
Definition at line \fB76\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define G2C_INDEX1_PDS_VAL3_LEN   27"

.PP
Length of the pds 3 section in the index file\&. 
.PP
Definition at line \fB79\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define G2C_INDEX1_PDS_VAL_LEN   27"

.PP
Length of the product definition section (pds) in index file\&. 
.PP
Definition at line \fB64\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define G2C_JASPER_JPEG_FORMAT_NAME   'jpc'"

.PP
Name of JPEG codec in Jasper\&. 
.PP
Definition at line \fB33\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define G2C_MAGIC_HEADER   'GRIB'"

.PP
GRIB magic header string\&. 
.PP
Definition at line \fB39\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define G2C_MAGIC_HEADER_LEN   8"

.PP
Full length of magic header string (includes GRIB version byte)\&. 
.PP
Definition at line \fB42\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define G2C_MAX_MESSAGES   1024"

.PP
Maximum number of messages in a file\&. 
.PP
Definition at line \fB45\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define G2C_MIN_MAX_BYTES   16"

.PP
Minimum acceptable value for max_bytes parameter of \fBg2c_get_msg()\fP\&. 
.PP
Definition at line \fB36\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define hton64(y)   (((uint64_t)htonl(y)) << \fBWORD\fP | htonl(y >> \fBWORD\fP))"

.PP
Byte swap 64-bit ints\&. This converts native-endian 8-byte ints into big-endian 8-byte ints\&. 
.PP
Definition at line \fB129\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define LATITUDE   'Latitude'"

.PP
Latitude\&. 
.PP
Definition at line \fB56\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define LOG(e)"

.PP
Ignore logging to stdout\&. Library was not built with LOGGING=ON\&. 
.PP
Definition at line \fB428\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define LONGITUDE   'Longitude'"

.PP
Longitude\&. 
.PP
Definition at line \fB59\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define MUTEX(m)"

.PP
Pthreads not enabled, so do nothing\&. 
.PP
Definition at line \fB110\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define MUTEX_LOCK(m)"

.PP
Pthreads not enabled, so do nothing\&. 
.PP
Definition at line \fB116\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define MUTEX_UNLOCK(m)"

.PP
Pthreads not enabled, so do nothing\&. 
.PP
Definition at line \fB119\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define ntoh64(y)   (((uint64_t)ntohl(y)) << \fBWORD\fP | ntohl(y >> \fBWORD\fP))"

.PP
Byte swap 64-bit ints\&. This converts big-endian 8-byte ints into native endian 8-byte ints\&. 
.PP
Definition at line \fB125\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define ONE_BYTE   1"

.PP
One byte\&. 
.PP
Definition at line \fB50\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define TWO_BYTES   2"

.PP
Two bytes\&. 
.PP
Definition at line \fB51\fP of file \fBgrib2_int\&.h\fP\&.
.SS "#define WORD   32"

.PP
Number of bits in four bytes\&. 
.PP
Definition at line \fB48\fP of file \fBgrib2_int\&.h\fP\&.
.SH "Typedef Documentation"
.PP 
.SS "typedef struct \fBg2c_entry\fP \fBG2C_CODE_ENTRY_T\fP"

.PP
An entry in a GRIB2 code table\&. 
.SS "typedef struct \fBg2c_code_table\fP \fBG2C_CODE_TABLE_T\fP"

.PP
A GRIB2 code table\&. 
.SS "typedef struct \fBg2c_dim_info\fP \fBG2C_DIM_INFO_T\fP"

.PP
Keep information about dimensions defined in section 3\&. 
.SS "typedef struct \fBg2c_file_info\fP \fBG2C_FILE_INFO_T\fP"

.PP
This is the information about each open file\&. 
.SS "typedef struct \fBg2c_message_info\fP \fBG2C_MESSAGE_INFO_T\fP"

.PP
This is the information about each message\&. 
.SS "typedef struct \fBg2c_param\fP \fBG2C_PARAM_T\fP"

.PP
An entry in the table of NOAA abbreviations for GRIB parameters\&. 
.SS "typedef struct \fBg2c_section3_info\fP \fBG2C_SECTION3_INFO_T\fP"

.PP
Information about \fCSection 3 GRID DEFINITION SECTION\fP\&. 
.SS "typedef struct \fBg2c_section4_info\fP \fBG2C_SECTION4_INFO_T\fP"

.PP
Information about \fCSection 4 PRODUCT DEFINITION SECTION\fP\&. 
.SS "typedef struct \fBg2c_section5_info\fP \fBG2C_SECTION5_INFO_T\fP"

.PP
Information about \fCSection 5 DATA REPRESENTATION SECTION\fP\&. 
.SS "typedef struct \fBg2c_section6_info\fP \fBG2C_SECTION6_INFO_T\fP"

.PP
Information about \fCSection 6 BIT-MAP SECTION\fP\&. 
.SS "typedef struct \fBg2c_section_info\fP \fBG2C_SECTION_INFO_T\fP"

.PP
Information about a section 3 through 7 in a GRIB2 message\&. 
.SS "typedef struct \fBgtemplate\fP \fBgtemplate\fP"

.PP
Struct for GRIB template\&. 
.PP
Definition at line \fB305\fP of file \fBgrib2_int\&.h\fP\&.
.SH "Function Documentation"
.PP 
.SS "int add_msg (\fBG2C_FILE_INFO_T\fP * file, int msg_num, size_t bytes_to_msg, size_t bytes_in_msg, int read_file, \fBG2C_MESSAGE_INFO_T\fP ** msg)"

.PP
Add new message to linked list\&. 
.PP
\fBParameters\fP
.RS 4
\fIfile\fP Pointer to the G2C_FILE_INFO_T for this file\&. 
.br
\fImsg_num\fP Number of the message in file (0-based)\&. 
.br
\fIbytes_to_msg\fP Number of bytes to the start of the message in the file\&. 
.br
\fIbytes_in_msg\fP Length of message in bytes\&. 
.br
\fIread_file\fP Set to true to cause metadata to be read from a GRIB2 data file\&. 
.br
\fImsg\fP Pointer to a pointer that will get the location of the newly created \fBG2C_MESSAGE_INFO_T\fP object\&. 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 12, 2022 
.RE
.PP

.PP
Definition at line \fB1017\fP of file \fBg2cfile\&.c\fP\&.
.PP
References \fBg2c_message_info::bytes_in_msg\fP, \fBg2c_message_info::bytes_to_msg\fP, \fBg2c_message_info::file\fP, \fBG2C_ENOMEM\fP, \fBG2C_NOERROR\fP, \fBLOG\fP, \fBg2c_file_info::msg\fP, \fBg2c_message_info::msg_num\fP, \fBg2c_message_info::next\fP, \fBg2c_file_info::num_messages\fP, and \fBread_msg_metadata()\fP\&.
.PP
Referenced by \fBg2c_open_index()\fP, and \fBread_metadata()\fP\&.
.SS "int add_section (FILE * f, \fBG2C_MESSAGE_INFO_T\fP * msg, int sec_id, unsigned int sec_len, size_t bytes_to_sec, unsigned char sec_num)"

.PP
Add metadata about a new section 3, 4, 5, 6, or 7\&. 
.PP
\fBParameters\fP
.RS 4
\fIf\fP FILE pointer to open GRIB2 file\&. 
.br
\fImsg\fP Pointer to the G2C_MESSAGE_INFO_T struct\&. 
.br
\fIsec_id\fP 0-based section ID\&. 
.br
\fIsec_len\fP Length of section\&. 
.br
\fIbytes_to_sec\fP Number of bytes from start of message to this section\&. 
.br
\fIsec_num\fP Section number\&.
.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 12, 2022 
.RE
.PP

.PP
Definition at line \fB794\fP of file \fBg2cfile\&.c\fP\&.
.PP
References \fBg2c_section_info::bytes_to_sec\fP, \fBG2C_EBADSECTION\fP, \fBG2C_ENOMEM\fP, \fBG2C_FILE_READ\fP, \fBG2C_NOERROR\fP, \fBg2c_rw_section3_metadata()\fP, \fBg2c_rw_section4_metadata()\fP, \fBg2c_rw_section5_metadata()\fP, \fBg2c_rw_section6_metadata()\fP, \fBLOG\fP, \fBg2c_section_info::msg\fP, \fBg2c_section_info::next\fP, \fBg2c_message_info::num_local\fP, \fBg2c_section_info::prev\fP, \fBg2c_message_info::sec\fP, \fBg2c_section_info::sec_id\fP, \fBg2c_section_info::sec_len\fP, and \fBg2c_section_info::sec_num\fP\&.
.PP
Referenced by \fBg2c_open_index()\fP, and \fBread_msg_metadata()\fP\&.
.SS "void aecpack (float * fld, \fBg2int\fP width, \fBg2int\fP height, \fBg2int\fP * idrstmpl, unsigned char * cpack, \fBg2int\fP * 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
\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
\fBAuthor\fP
.RS 4
Eric Engle (adapted from jpcpack) 
.RE
.PP

.PP
Definition at line \fB297\fP of file \fBaecpack\&.c\fP\&.
.PP
References \fBaecpack_int()\fP\&.
.PP
Referenced by \fBg2_addfield()\fP\&.
.SS "\fBg2int\fP aecunpack (unsigned char * cpack, \fBg2int\fP len, \fBg2int\fP * idrstmpl, \fBg2int\fP 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\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Eric Engle 
.RE
.PP
\fBDate\fP
.RS 4
2023-10-16 
.RE
.PP

.PP
Definition at line \fB161\fP of file \fBaecunpack\&.c\fP\&.
.PP
References \fBaecunpack_int()\fP, and \fBLOG\fP\&.
.PP
Referenced by \fBg2c_unpack7_int()\fP\&.
.SS "void cmplxpack (float * fld, \fBg2int\fP ndpts, \fBg2int\fP idrsnum, \fBg2int\fP * idrstmpl, unsigned char * cpack, \fBg2int\fP * lcpack)"

.PP
Pack up a data field using a complex packing algorithm\&. This function supports GRIB2 complex packing templates with or without spatial differences (i\&.e\&. DRTs 5\&.2 and 5\&.3)\&. It also fills in GRIB2 Data Representation Template 5\&.2 or 5\&.3 with the appropriate values\&.
.PP
\fBParameters\fP
.RS 4
\fIfld\fP Contains the data values to pack\&. 
.br
\fIndpts\fP The number of data values in array fld 
.br
\fIidrsnum\fP Data Representation Template number\&. Must equal 2 or 3\&. 
.br
\fIidrstmpl\fP Contains the array of values for Data Representation Template 5\&.2 or 5\&.3
.IP "\(bu" 2
0 Reference value - ignored on input, set by compack routine\&.
.IP "\(bu" 2
1 Binary Scale Factor
.IP "\(bu" 2
2 Decimal Scale Factor
.IP "\(bu" 2
6 Missing value management
.IP "\(bu" 2
7 Primary missing value
.IP "\(bu" 2
8 Secondary missing value
.IP "\(bu" 2
16 Order of Spatial Differencing ( 1 or 2 ) 
.PP
.br
\fIcpack\fP The packed data field\&. 
.br
\fIlcpack\fP length of packed field cpack\&. Will be set to -1 if missing value management field is not 1 or 2\&.
.RE
.PP
\fBAuthor\fP
.RS 4
Stephen Gilbert 
.RE
.PP
\fBDate\fP
.RS 4
2004-08-27 
.RE
.PP

.PP
Definition at line \fB37\fP of file \fBcmplxpack\&.c\fP\&.
.PP
References \fBcompack()\fP, and \fBmisspack()\fP\&.
.PP
Referenced by \fBg2_addfield()\fP\&.
.SS "void compack (float * fld, \fBg2int\fP ndpts, \fBg2int\fP idrsnum, \fBg2int\fP * idrstmpl, unsigned char * cpack, \fBg2int\fP * lcpack)"

.PP
Pack a data field using a complex packing algorithm\&. This function supports GRIB2 complex packing templates with or without spatial differences (i\&.e\&. DRTs 5\&.2 and 5\&.3)\&. It also fills in GRIB2 Data Representation \fCTemplate 5\&.2\fP or \fCTemplate 5\&.3\fP with the appropriate values\&.
.PP
\fBParameters\fP
.RS 4
\fIfld\fP Contains the data values to pack\&. 
.br
\fIndpts\fP The number of data values in array fld\&. 
.br
\fIidrsnum\fP Data Representation Template number\&. Must equal 2 or 3\&. 
.br
\fIidrstmpl\fP Contains the array of values for Data Representation Template 5\&.2 or 5\&.3\&.
.IP "\(bu" 2
0 Reference value - ignored on input, set my \fBcompack()\fP\&.
.IP "\(bu" 2
1 Binary Scale Factor
.IP "\(bu" 2
2 Decimal Scale Factor
.IP "\(bu" 2
6 Missing value management
.IP "\(bu" 2
7 Primary missing value
.IP "\(bu" 2
8 Secondary missing value
.IP "\(bu" 2
16 Order of Spatial Differencing (1 or 2) 
.PP
.br
\fIcpack\fP The packed data field\&. 
.br
\fIlcpack\fP length of packed field cpack\&.
.RE
.PP
\fBAuthor\fP
.RS 4
Stephen Gilbert 
.RE
.PP
\fBDate\fP
.RS 4
2002-11-07 
.RE
.PP

.PP
Definition at line \fB42\fP of file \fBcompack\&.c\fP\&.
.PP
References \fBALOG2\fP, \fBint_power()\fP, \fBmkieee()\fP, \fBpack_gp()\fP, \fBsbit()\fP, and \fBsbits()\fP\&.
.PP
Referenced by \fBcmplxpack()\fP\&.
.SS "int comunpack (unsigned char * cpack, \fBg2int\fP lensec, \fBg2int\fP idrsnum, \fBg2int\fP * idrstmpl, \fBg2int\fP ndpts, float * fld)"

.PP
Unpack a data field that was packed using a complex packing algorithm, using info from the GRIB2 Data Representation \fCTemplate 5\&.2\fP or \fCTemplate 5\&.3\fP\&. Supports GRIB2 complex packing templates with or without spatial differences (i\&.e\&. DRTs 5\&.2 and 5\&.3)\&.
.SS "Program History Log"
Date   Programmer   Comments    2002-10-29   Gilbert   Initial    2004-12-16   Gilbert   Added test (from Arthur Taylor/MDL) verifying group widths/lengths   
.PP
\fBParameters\fP
.RS 4
\fIcpack\fP pointer to the packed data field\&. 
.br
\fIlensec\fP length of section 7 (used for error checking)\&. 
.br
\fIidrsnum\fP Data Representation Template number\&. Must equal 2 or 3\&. 
.br
\fIidrstmpl\fP pointer to the array of values for Data Representation Template 5\&.2 or 5\&.3 
.br
\fIndpts\fP The number of data values to unpack 
.br
\fIfld\fP Contains the unpacked data values\&. Must be allocated with at least ndpts * sizeof(float) bytes before calling this routine\&.
.RE
.PP
\fBReturns\fP
.RS 4
0 for success, error code otherwise\&.
.RE
.PP
\fBAuthor\fP
.RS 4
Stephen Gilbert 
.RE
.PP
\fBDate\fP
.RS 4
2002-10-29 
.RE
.PP

.PP
Definition at line \fB41\fP of file \fBcomunpack\&.c\fP\&.
.PP
References \fBgbit()\fP, \fBgbits()\fP, \fBint_power()\fP, \fBLOG\fP, and \fBrdieee()\fP\&.
.PP
Referenced by \fBg2c_unpack7_int()\fP\&.
.SS "int dec_aec (unsigned char * cpack, \fBg2int\fP len, \fBg2int\fP nbits, \fBg2int\fP flags, \fBg2int\fP block_size, \fBg2int\fP rsi, unsigned char * cfld, \fBg2int\fP cfldlen)"

.PP
Decode an AEC code stream specified in the \fCCCSDS 121\&.0-B-3 Blue Book\fP\&. 
.PP
\fBParameters\fP
.RS 4
\fIcpack\fP Pointer to buffer that holds the input AEC code stream\&. 
.br
\fIlen\fP Length (in bytes) of the buffer that holds the input AEC code stream\&. 
.br
\fInbits\fP CCSDS bits per sample\&. 
.br
\fIflags\fP CCSDS compression options mask\&. 
.br
\fIblock_size\fP CCSDS block size\&. 
.br
\fIrsi\fP CCSDS reference sample interval\&. 
.br
\fIcfld\fP Pointer to output buffer from the AEC decoder\&. 
.br
\fIcfldlen\fP length of output buffer\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
>0 Length of data from AEC decoder
.IP "\(bu" 2
0 Successful decode (AEC_OK)
.IP "\(bu" 2
-1 AEC_CONF_ERROR
.IP "\(bu" 2
-2 AEC_STREAM_ERROR
.IP "\(bu" 2
-3 AEC_DATA_ERROR
.IP "\(bu" 2
-4 AEC_MEM_ERROR
.IP "\(bu" 2
-5 AEC_RSI_OFFSETS_ERROR
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Eric Engle 
.RE
.PP
\fBDate\fP
.RS 4
2023-10-16 
.RE
.PP

.PP
Definition at line \fB38\fP of file \fBdecenc_aec\&.c\fP\&.
.PP
References \fBLOG\fP\&.
.PP
Referenced by \fBaecunpack_int()\fP\&.
.SS "int dec_jpeg2000 (char * injpc, \fBg2int\fP bufsize, \fBg2int\fP * 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 g2int array, already allocated, that gets the unpacked data\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
0 Successful decode
.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
Stephen Gilbert, Ed Hartnett 
.RE
.PP

.PP
Definition at line \fB377\fP of file \fBdecenc_jpeg2000\&.c\fP\&.
.PP
References \fBint_dec_jpeg2000()\fP\&.
.PP
Referenced by \fBjpcunpack_int()\fP\&.
.SS "int dec_png (unsigned char * pngbuf, \fBg2int\fP * width, \fBg2int\fP * 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
Stephen Gilbert 
.RE
.PP

.PP
Definition at line \fB127\fP of file \fBdecenc_png\&.c\fP\&.
.PP
References \fBG2C_PNG_HEIGHT_MAX\fP, \fBG2C_PNG_WIDTH_MAX\fP, and \fBuser_read_data()\fP\&.
.PP
Referenced by \fBg2c_dec_png()\fP, and \fBpngunpack_int()\fP\&.
.SS "int enc_aec (unsigned char * data, \fBg2int\fP ctemplen, \fBg2int\fP nbits, \fBg2int\fP flags, \fBg2int\fP block_size, \fBg2int\fP rsi, unsigned char * aecbuf, \fBg2int\fP * aecbuflen)"

.PP
Encode data into an AEC code stream specified in the \fCCCSDS 121\&.0-B-3 Blue Book\fP\&. 
.PP
\fBParameters\fP
.RS 4
\fIdata\fP Pointer to buffer that holds the input data\&. 
.br
\fIctemplen\fP Length (in bytes) of the buffer that holds the input data\&.\&. 
.br
\fInbits\fP CCSDS bits per sample\&. 
.br
\fIflags\fP CCSDS compression options mask\&. 
.br
\fIblock_size\fP CCSDS block size\&. 
.br
\fIrsi\fP CCSDS reference sample interval\&. 
.br
\fIaecbuf\fP Pointer to buffer holding the AEC encoded stream\&. 
.br
\fIaecbuflen\fP Length of AEC code stream\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
>0 Exact length of AEC encoded data\&.
.IP "\(bu" 2
0 Successful decode (AEC_OK)
.IP "\(bu" 2
-1 AEC_CONF_ERROR
.IP "\(bu" 2
-2 AEC_STREAM_ERROR
.IP "\(bu" 2
-3 AEC_DATA_ERROR
.IP "\(bu" 2
-4 AEC_MEM_ERROR
.IP "\(bu" 2
-5 AEC_RSI_OFFSETS_ERROR
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Eric Engle 
.RE
.PP
\fBDate\fP
.RS 4
2023-10-16 
.RE
.PP

.PP
Definition at line \fB108\fP of file \fBdecenc_aec\&.c\fP\&.
.PP
References \fBLOG\fP\&.
.PP
Referenced by \fBaecpack_int()\fP\&.
.SS "int enc_jpeg2000 (unsigned char * cin, \fBg2int\fP width, \fBg2int\fP height, \fBg2int\fP nbits, \fBg2int\fP ltype, \fBg2int\fP ratio, \fBg2int\fP retry, char * outjpc, \fBg2int\fP 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\&. 
.IP "\(bu" 2
### Program History Log Date   Programmer   Comments    2002-12-02   Gilbert   Initial    2004-12-16   Gilbert   Added retry argument allowing increased guard bits\&.    2022-04-15   Hartnett   Converted to use jas_ instead of jpc_ functions\&.   
.PP
.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 \fB94\fP of file \fBdecenc_jpeg2000\&.c\fP\&.
.PP
References \fBG2_JASPER_ENCODE\fP, \fBG2_JASPER_INIT\fP, \fBG2C_JASPER_JPEG_FORMAT_NAME\fP, \fBLOG\fP, and \fBMAXOPTSSIZE\fP\&.
.PP
Referenced by \fBg2c_enc_jpeg2000()\fP, and \fBjpcpack_int()\fP\&.
.SS "int enc_png (unsigned char * data, \fBg2int\fP width, \fBg2int\fP height, \fBg2int\fP 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
Stephen Gilbert 
.RE
.PP

.PP
Definition at line \fB259\fP of file \fBdecenc_png\&.c\fP\&.
.PP
References \fBuser_flush_data()\fP, and \fBuser_write_data()\fP\&.
.PP
Referenced by \fBg2c_enc_png()\fP, and \fBpngpack_int()\fP\&.
.SS "\fBgtemplate\fP * extdrstemplate (\fBg2int\fP number, \fBg2int\fP * list)"

.PP
This subroutine generates the remaining octet map for a given Data Representation Template, if required\&. Some Templates can vary depending on data values given in an earlier part of the Template, and it is necessary to know some of the earlier entry values to generate the full octet map of the Template\&.
.PP
\fBParameters\fP
.RS 4
\fInumber\fP The number of the Data Representation Template that is being requested\&. 
.br
\fIlist\fP The list of values for each entry in the the Data Representation Template\&.
.RE
.PP
\fBReturns\fP
.RS 4
Pointer to the returned template struct\&. Returns NULL pointer, if template not found\&.
.RE
.PP
\fBAuthor\fP
.RS 4
Stephen Gilbert 
.RE
.PP
\fBDate\fP
.RS 4
2000-05-11 
.RE
.PP

.PP
Definition at line \fB218\fP of file \fBdrstemplates\&.c\fP\&.
.PP
References \fBgetdrsindex()\fP, and \fBgetdrstemplate()\fP\&.
.PP
Referenced by \fBg2_unpack5()\fP\&.
.SS "\fBgtemplate\fP * extgridtemplate (\fBg2int\fP number, \fBg2int\fP * template)"

.PP
This subroutine generates the remaining octet map for a given Grid Definition Template, if required\&. Some Templates can vary depending on data values given in an earlier part of the Template, and it is necessary to know some of the earlier entry values to generate the full octet map of the Template\&.
.PP
This function allocates memory for the extension\&. The pointer ext in the gtemplate struct must be freed to prevent memory leaks\&.
.PP
\fBParameters\fP
.RS 4
\fInumber\fP The number of the Grid Definition Template that is being requested\&. 
.br
\fItemplate\fP The grid definition template array\&.
.RE
.PP
\fBReturns\fP
.RS 4
Pointer to the returned template struct\&. Returns NULL pointer, if template not found\&.
.RE
.PP
\fBAuthor\fP
.RS 4
Stephen Gilbert 
.RE
.PP
\fBDate\fP
.RS 4
2000-05-09 
.RE
.PP

.PP
Definition at line \fB241\fP of file \fBgridtemplates\&.c\fP\&.
.PP
References \fBgetgridindex()\fP, and \fBgetgridtemplate()\fP\&.
.PP
Referenced by \fBg2_addgrid()\fP, \fBg2_unpack3()\fP, and \fBg2c_get_grid_template_extension()\fP\&.
.SS "\fBgtemplate\fP * extpdstemplate (\fBg2int\fP number, \fBg2int\fP * list)"

.PP
This subroutine generates the remaining octet map for a given Product Definition Template, if required\&. Some Templates can vary depending on data values given in an earlier part of the Template, and it is necessary to know some of the earlier entry values to generate the full octet map of the Template\&.
.PP
This function allocates memory in the ext field of the gtemplate struct\&. This memory must be freed by the caller\&.
.PP
\fBParameters\fP
.RS 4
\fInumber\fP number of the Product Definition Template 4\&.NN that is being requested\&. 
.br
\fIlist\fP The list of values for each entry in the the Product Definition Template\&.
.RE
.PP
\fBReturns\fP
.RS 4
Pointer to the returned template struct\&. Returns NULL pointer if template not found\&.
.RE
.PP
\fBAuthor\fP
.RS 4
Stephen Gilbert 
.RE
.PP
\fBDate\fP
.RS 4
2000-05-11 
.RE
.PP

.PP
Definition at line \fB553\fP of file \fBpdstemplates\&.c\fP\&.
.PP
References \fBgetpdsindex()\fP, and \fBgetpdstemplate()\fP\&.
.PP
Referenced by \fBg2_addfield()\fP, \fBg2_unpack4()\fP, and \fBg2c_get_pds_template_extension()\fP\&.
.SS "int g2c_add_file (const char * path, int mode, int * g2cid)"

.PP
Open a GRIB2 file and add it to the list of open files\&. 
.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 \fB1143\fP of file \fBg2cfile\&.c\fP\&.
.PP
References \fBfind_available_g2cid()\fP, \fBG2C_EFILE\fP, \fBG2C_EINVAL\fP, \fBG2C_ENAMETOOLONG\fP, \fBg2c_file\fP, \fBG2C_MAX_NAME\fP, \fBG2C_NOERROR\fP, \fBG2C_WRITE\fP, \fBg2c_file_info::g2cid\fP, \fBLOG\fP, \fBg2c_file_info::msg\fP, and \fBg2c_file_info::num_messages\fP\&.
.PP
Referenced by \fBg2c_open()\fP, and \fBg2c_open_index()\fP\&.
.SS "int g2c_check_msg (unsigned char * cgrib, \fBg2int\fP * lencurr, int verbose)"

.PP
Check for 'GRIB' at the beginning of a GRIB message, and check to see if the message is already terminated with '7777'\&. 
.PP
\fBParameters\fP
.RS 4
\fIcgrib\fP Buffer that contains the GRIB message\&. 
.br
\fIlencurr\fP Pointer that gets the length of the GRIB message\&. 
.br
\fIverbose\fP If non-zero, print any error messages to stdout\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
\fBG2C_NOERROR\fP No error\&.
.IP "\(bu" 2
\fBG2C_ENOTGRIB\fP GRIB header not found\&.
.IP "\(bu" 2
\fBG2C_EMSGCOMPLETE\fP GRIB message already complete\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 
.RE
.PP
\fBDate\fP
.RS 4
Nov 11, 2021 
.RE
.PP

.PP
Definition at line \fB26\fP of file \fButil\&.c\fP\&.
.PP
References \fBG2C_EMSGCOMPLETE\fP, \fBG2C_ENOTGRIB\fP, \fBG2C_NOERROR\fP, and \fBgbit()\fP\&.
.PP
Referenced by \fBg2_addfield()\fP, \fBg2_addgrid()\fP, \fBg2_addlocal()\fP, and \fBg2_gribend()\fP\&.
.SS "int g2c_file_io (FILE * f, int write, int g2ctype, void * var)"

.PP
Read or write a big-endian integer type to an open file, with conversion between native and big-endian format\&. GRIB2 handles negative numbers in a special way\&. Instead of storing two-compliments, like every other programmer and computing organization in the world, GRIB2 flips the first bit, then stores the rest of the int as an unsigned number in the remaining 31 bits\&. How exciting!
.PP
This function takes the excitement out of GRIB2 negative numbers\&.
.PP
\fBParameters\fP
.RS 4
\fIf\fP Pointer to the open FILE\&. 
.br
\fIwrite\fP Non-zero if function should write, otherwise function will read\&. 
.br
\fIg2ctype\fP The type to be read or written\&. 
.br
\fIvar\fP Pointer to the int to be written, or pointer to the storage that gets the int read\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
:: G2C_NOERROR No error\&.
.IP "\(bu" 2
:: G2C_EINVAL Invalid input\&.
.IP "\(bu" 2
:: G2C_EFILE Error reading/writing file\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 
.RE
.PP
\fBDate\fP
.RS 4
11/7/22 
.RE
.PP

.PP
Definition at line \fB41\fP of file \fBg2cio\&.c\fP\&.
.PP
References \fBBITSHIFT_15\fP, \fBBITSHIFT_31\fP, \fBBITSHIFT_63\fP, \fBBITSHIFT_7\fP, \fBEIGHT_BYTES\fP, \fBFOUR_BYTES\fP, \fBG2C_BYTE\fP, \fBG2C_EBADTYPE\fP, \fBG2C_EFILE\fP, \fBG2C_EINVAL\fP, \fBG2C_INT\fP, \fBG2C_INT64\fP, \fBG2C_NOERROR\fP, \fBG2C_SHORT\fP, \fBG2C_UBYTE\fP, \fBG2C_UINT\fP, \fBG2C_UINT64\fP, \fBG2C_USHORT\fP, \fBhton64\fP, \fBntoh64\fP, \fBONE_BYTE\fP, and \fBTWO_BYTES\fP\&.
.PP
Referenced by \fBg2c_file_io_byte()\fP, \fBg2c_file_io_int()\fP, \fBg2c_file_io_longlong()\fP, \fBg2c_file_io_short()\fP, \fBg2c_file_io_ubyte()\fP, \fBg2c_file_io_uint()\fP, \fBg2c_file_io_ulonglong()\fP, and \fBg2c_file_io_ushort()\fP\&.
.SS "int g2c_file_io_byte (FILE * f, int write, char * var)"

.PP
Read or write a big-endian signed byte to an open GRIB2 file, with conversion between native and big-endian format, and special GRIB2 handling of negative numbers\&. 
.PP
\fBParameters\fP
.RS 4
\fIf\fP Pointer to the open GRIB2 FILE\&. 
.br
\fIwrite\fP Non-zero to write, zero to read\&. 
.br
\fIvar\fP Pointer to the byte\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
:: G2C_NOERROR No error\&.
.IP "\(bu" 2
:: G2C_EINVAL Invalid input\&.
.IP "\(bu" 2
:: G2C_EFILE Error reading/writing file\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 11/13/22 
.RE
.PP

.PP
Definition at line \fB316\fP of file \fBg2cio\&.c\fP\&.
.PP
References \fBG2C_BYTE\fP, and \fBg2c_file_io()\fP\&.
.PP
Referenced by \fBg2c_file_io_template()\fP\&.
.SS "int g2c_file_io_int (FILE * f, int write, int * var)"

.PP
Read or write a big-endian 4-byte signed int to an open GRIB2 file, with conversion between native and big-endian format, and special GRIB2 handling of negative numbers\&. 
.PP
\fBParameters\fP
.RS 4
\fIf\fP Pointer to the open GRIB2 FILE\&. 
.br
\fIwrite\fP Non-zero to write, zero to read\&. 
.br
\fIvar\fP Pointer to the int\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
:: G2C_NOERROR No error\&.
.IP "\(bu" 2
:: G2C_EINVAL Invalid input\&.
.IP "\(bu" 2
:: G2C_EFILE Error reading/writing file\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 11/7/22 
.RE
.PP

.PP
Definition at line \fB230\fP of file \fBg2cio\&.c\fP\&.
.PP
References \fBg2c_file_io()\fP, and \fBG2C_INT\fP\&.
.PP
Referenced by \fBg2c_file_io_template()\fP\&.
.SS "int g2c_file_io_longlong (FILE * f, int write, long long * var)"

.PP
Read or write a big-endian signed long long to an open GRIB2 file, with conversion between native and big-endian format, and special GRIB2 handling of negative numbers\&. 
.PP
\fBParameters\fP
.RS 4
\fIf\fP Pointer to the open GRIB2 FILE\&. 
.br
\fIwrite\fP Non-zero to write, zero to read\&. 
.br
\fIvar\fP Pointer to the long long\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
:: G2C_NOERROR No error\&.
.IP "\(bu" 2
:: G2C_EINVAL Invalid input\&.
.IP "\(bu" 2
:: G2C_EFILE Error reading/writing file\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 11/13/22 
.RE
.PP

.PP
Definition at line \fB359\fP of file \fBg2cio\&.c\fP\&.
.PP
References \fBg2c_file_io()\fP, and \fBG2C_INT64\fP\&.
.SS "int g2c_file_io_short (FILE * f, int write, short * var)"

.PP
Read or write a big-endian signed short to an open GRIB2 file, with conversion between native and big-endian format, and special GRIB2 handling of negative numbers\&. 
.PP
\fBParameters\fP
.RS 4
\fIf\fP Pointer to the open GRIB2 FILE\&. 
.br
\fIwrite\fP Non-zero to write, zero to read\&. 
.br
\fIvar\fP Pointer to the short\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
:: G2C_NOERROR No error\&.
.IP "\(bu" 2
:: G2C_EINVAL Invalid input\&.
.IP "\(bu" 2
:: G2C_EFILE Error reading/writing file\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 11/13/22 
.RE
.PP

.PP
Definition at line \fB273\fP of file \fBg2cio\&.c\fP\&.
.PP
References \fBg2c_file_io()\fP, and \fBG2C_SHORT\fP\&.
.PP
Referenced by \fBg2c_file_io_template()\fP, \fBg2c_rw_section1_metadata()\fP, \fBg2c_start_index_record()\fP, and \fBg2c_start_index_record_lf()\fP\&.
.SS "int g2c_file_io_template (FILE * f, int rw_flag, int map, long long int * template_value)"

.PP
Read or write a big-endian 4-byte int or unsigned int from or to an open file, with conversion between native and big-endian format, and handling of GRIB negative numbers\&. This is for template values\&.
.PP
With template values, if the map value is negative, then the template value may be negative\&.
.PP
\fBParameters\fP
.RS 4
\fIf\fP Pointer to the open FILE\&. 
.br
\fIrw_flag\fP Non-zero if function should write, otherwise function will read\&. 
.br
\fImap\fP The map value for this template item\&. 
.br
\fItemplate_value\fP Pointer to the template value to be written, or pointer to the storage that gets the templage value read\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
:: G2C_NOERROR No error\&.
.IP "\(bu" 2
:: G2C_EINVAL Invalid input\&.
.IP "\(bu" 2
:: G2C_EFILE Error reading/writing file\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 11/7/22 
.RE
.PP

.PP
Definition at line \fB408\fP of file \fBg2cio\&.c\fP\&.
.PP
References \fBFOUR_BYTES\fP, \fBG2C_EBADTEMPLATE\fP, \fBg2c_file_io_byte()\fP, \fBg2c_file_io_int()\fP, \fBg2c_file_io_short()\fP, \fBg2c_file_io_ubyte()\fP, \fBg2c_file_io_uint()\fP, \fBg2c_file_io_ushort()\fP, \fBG2C_NOERROR\fP, \fBONE_BYTE\fP, and \fBTWO_BYTES\fP\&.
.PP
Referenced by \fBg2c_rw_section3_metadata()\fP, \fBg2c_rw_section4_metadata()\fP, and \fBg2c_rw_section5_metadata()\fP\&.
.SS "int g2c_file_io_ubyte (FILE * f, int write, unsigned char * var)"

.PP
Read or write a big-endian unsigned byte to an open GRIB2 file, with conversion between native and big-endian format\&. 
.PP
\fBParameters\fP
.RS 4
\fIf\fP Pointer to the open GRIB2 FILE\&. 
.br
\fIwrite\fP Non-zero to write, zero to read\&. 
.br
\fIvar\fP Pointer to the unsigned byte\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
:: G2C_NOERROR No error\&.
.IP "\(bu" 2
:: G2C_EINVAL Invalid input\&.
.IP "\(bu" 2
:: G2C_EFILE Error reading/writing file\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 11/13/22 
.RE
.PP

.PP
Definition at line \fB337\fP of file \fBg2cio\&.c\fP\&.
.PP
References \fBg2c_file_io()\fP, and \fBG2C_UBYTE\fP\&.
.PP
Referenced by \fBg2c_file_io_template()\fP, \fBg2c_open_index()\fP, \fBg2c_rw_section1_metadata()\fP, \fBg2c_rw_section3_metadata()\fP, \fBg2c_rw_section6_metadata()\fP, \fBg2c_start_index1_record()\fP, \fBg2c_start_index_record()\fP, \fBg2c_start_index_record_lf()\fP, \fBg2c_write_index()\fP, and \fBread_msg_metadata()\fP\&.
.SS "int g2c_file_io_uint (FILE * f, int write, unsigned int * var)"

.PP
Read or write a big-endian 4-byte unsigned int to an open GRIB2 file, with conversion between native and big-endian format\&. 
.PP
\fBParameters\fP
.RS 4
\fIf\fP Pointer to the open GRIB2 FILE\&. 
.br
\fIwrite\fP Non-zero to write, zero to read\&. 
.br
\fIvar\fP Pointer to the unsigned int\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
:: G2C_NOERROR No error\&.
.IP "\(bu" 2
:: G2C_EINVAL Invalid input\&.
.IP "\(bu" 2
:: G2C_EFILE Error reading/writing file\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 11/7/22 
.RE
.PP

.PP
Definition at line \fB251\fP of file \fBg2cio\&.c\fP\&.
.PP
References \fBg2c_file_io()\fP, and \fBG2C_UINT\fP\&.
.PP
Referenced by \fBg2c_file_io_template()\fP, \fBg2c_open_index()\fP, \fBg2c_rw_section1_metadata()\fP, \fBg2c_rw_section3_metadata()\fP, \fBg2c_rw_section5_metadata()\fP, \fBg2c_start_index1_record()\fP, \fBg2c_start_index_record()\fP, \fBg2c_start_index_record_lf()\fP, \fBg2c_write_index()\fP, and \fBread_msg_metadata()\fP\&.
.SS "int g2c_file_io_ulonglong (FILE * f, int write, unsigned long long * var)"

.PP
Read or write a big-endian unsigned long long to an open GRIB2 file, with conversion between native and big-endian format\&. 
.PP
\fBParameters\fP
.RS 4
\fIf\fP Pointer to the open GRIB2 FILE\&. 
.br
\fIwrite\fP Non-zero to write, zero to read\&. 
.br
\fIvar\fP Pointer to the unsigned long long\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
:: G2C_NOERROR No error\&.
.IP "\(bu" 2
:: G2C_EINVAL Invalid input\&.
.IP "\(bu" 2
:: G2C_EFILE Error reading/writing file\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 11/13/22 
.RE
.PP

.PP
Definition at line \fB380\fP of file \fBg2cio\&.c\fP\&.
.PP
References \fBg2c_file_io()\fP, and \fBG2C_UINT64\fP\&.
.PP
Referenced by \fBg2c_start_index_record()\fP, and \fBg2c_start_index_record_lf()\fP\&.
.SS "int g2c_file_io_ushort (FILE * f, int write, unsigned short * var)"

.PP
Read or write a big-endian unsigned short to an open GRIB2 file, with conversion between native and big-endian format\&. 
.PP
\fBParameters\fP
.RS 4
\fIf\fP Pointer to the open GRIB2 FILE\&. 
.br
\fIwrite\fP Non-zero to write, zero to read\&. 
.br
\fIvar\fP Pointer to the unsigned short\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
:: G2C_NOERROR No error\&.
.IP "\(bu" 2
:: G2C_EINVAL Invalid input\&.
.IP "\(bu" 2
:: G2C_EFILE Error reading/writing file\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 11/13/22 
.RE
.PP

.PP
Definition at line \fB294\fP of file \fBg2cio\&.c\fP\&.
.PP
References \fBg2c_file_io()\fP, and \fBG2C_USHORT\fP\&.
.PP
Referenced by \fBg2c_file_io_template()\fP, \fBg2c_rw_section3_metadata()\fP, \fBg2c_rw_section4_metadata()\fP, and \fBg2c_rw_section5_metadata()\fP\&.
.SS "int g2c_get_datetime (int ipdtn, long long int * ipdtmpl, short year, unsigned char month, unsigned char day, unsigned char hour, unsigned char minute, unsigned char second, char * tabbrev)"

.PP
Convert date and time from GRIB2 info to string output\&. 
.PP
\fBNote\fP
.RS 4
This function is based on the prvtime() function in NCEPLIBS-grib_utils\&.
.RE
.PP
\fBParameters\fP
.RS 4
\fIipdtn\fP Product Definition Template Number ([Code Table 4\&.0] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-0.shtml))\&. 
.br
\fIipdtmpl\fP Array of data values for the Product Definition Template specified by ipdtn\&. 
.br
\fIyear\fP year 
.br
\fImonth\fP month 
.br
\fIday\fP day 
.br
\fIhour\fP hour 
.br
\fIminute\fP minute 
.br
\fIsecond\fP second 
.br
\fItabbrev\fP Character array that will get the date and time string\&. Must be of length 100\&.
.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 \fB49\fP of file \fBg2cdegrib2\&.c\fP\&.
.PP
References \fBG2C_DATE_TIME_LEN\fP, and \fBG2C_NOERROR\fP\&.
.PP
Referenced by \fBg2c_degrib2()\fP\&.
.SS "int g2c_get_level_desc (int ipdtn, long long int * ipdtmpl, char * level_desc)"

.PP
Determine the string that describes the level information, given the GRIB2 Product Definition Template information\&. This subroutine finds the 'Type of first fixed surface' (see [Code table 4\&.5](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-0.shtml)) using the product definition template value and product template array\&. The location in the template array varies depending on the template number\&.
.PP
\fBParameters\fP
.RS 4
\fIipdtn\fP Product Definition Template Number ([Code Table 4\&.0] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-0.shtml))\&. 
.br
\fIipdtmpl\fP Array of data values for the Product Definition Template specified by ipdtn\&. 
.br
\fIlevel_desc\fP Character array which gets the string describing the level\&. Must be of length 40\&.
.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 \fB309\fP of file \fBg2cdegrib2\&.c\fP\&.
.PP
References \fBformat_level()\fP, and \fBG2C_NOERROR\fP\&.
.PP
Referenced by \fBg2c_degrib2()\fP\&.
.SS "int g2c_log_section1 (\fBG2C_MESSAGE_INFO_T\fP * msg)"

.PP
Log section 0 information\&. 
.PP
\fBParameters\fP
.RS 4
\fImsg\fP Pointer to \fBG2C_MESSAGE_INFO_T\fP which contains section 0 information\&.
.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/16/22 
.RE
.PP

.PP
Definition at line \fB101\fP of file \fBg2cutil\&.c\fP\&.
.PP
References \fBg2c_message_info::center\fP, \fBg2c_message_info::day\fP, \fBg2c_message_info::discipline\fP, \fBg2c_csv_init()\fP, \fBg2c_find_desc()\fP, \fBG2C_MAX_GRIB_DESC_LEN\fP, \fBG2C_NOERROR\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::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 \fBg2c_log_file()\fP, and \fBg2c_open_index()\fP\&.
.SS "int g2c_rw_section1_metadata (FILE * f, int rw_flag, \fBG2C_MESSAGE_INFO_T\fP * msg)"

.PP
Read Section 1\&. 
.PP
\fBParameters\fP
.RS 4
\fIf\fP Pointer to open file\&. 
.br
\fIrw_flag\fP \fBG2C_FILE_WRITE\fP if function should write, \fBG2C_FILE_READ\fP if it should read\&. 
.br
\fImsg\fP Pointer to G2C_MESSAGE_INFO_T which will be populated with the values of section 0\&.
.RE
.PP
\fBReturns\fP
.RS 4
-G2C_NOERROR No error\&.
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 
.RE
.PP
\fBDate\fP
.RS 4
10/16/22 
.RE
.PP

.PP
Definition at line \fB874\fP of file \fBg2cfile\&.c\fP\&.
.PP
References \fBg2c_message_info::center\fP, \fBg2c_message_info::day\fP, \fBG2C_ENOSECTION\fP, \fBg2c_file_io_short()\fP, \fBg2c_file_io_ubyte()\fP, \fBg2c_file_io_uint()\fP, \fBG2C_NOERROR\fP, \fBG2C_SECTION1_BYTES\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::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 \fBg2c_open_index()\fP, \fBg2c_write_index()\fP, and \fBread_msg_metadata()\fP\&.
.SS "int g2c_rw_section3_metadata (FILE * f, int rw_flag, \fBG2C_SECTION_INFO_T\fP * sec)"

.PP
Read the metadata from section 3 (Grid Definition Section) of a GRIB2 message\&. When this function is called, the file cursor is positioned just after the section number field in the section\&. The size of the section, and the section number, have already been read when this function is called\&.
.PP
\fBParameters\fP
.RS 4
\fIf\fP FILE pointer to open GRIB2 file\&. 
.br
\fIrw_flag\fP \fBG2C_FILE_WRITE\fP if function should write, \fBG2C_FILE_READ\fP (0) if it should read\&. 
.br
\fIsec\fP Pointer to the G2C_SECTION_INFO_T struct\&.
.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_ENOMEM\fP Out of memory\&.
.IP "\(bu" 2
\fBG2C_ENOTEMPLATE\fP Can't find template\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 
.RE
.PP
\fBDate\fP
.RS 4
Sep 15, 2022 
.RE
.PP

.PP
Definition at line \fB478\fP of file \fBg2cfile\&.c\fP\&.
.PP
References \fBdetermine_dims()\fP, \fBG2C_EINVAL\fP, \fBG2C_ENOMEM\fP, \fBg2c_file_io_template()\fP, \fBg2c_file_io_ubyte()\fP, \fBg2c_file_io_uint()\fP, \fBg2c_file_io_ushort()\fP, \fBg2c_get_grid_template()\fP, \fBG2C_MAX_GDS_TEMPLATE_MAPLEN\fP, \fBG2C_NOERROR\fP, \fBg2c_section3_info::grid_def\fP, \fBg2c_section3_info::interp_list\fP, \fBLOG\fP, \fBg2c_section3_info::num_data_points\fP, \fBg2c_section3_info::num_opt\fP, \fBg2c_section_info::sec_info\fP, \fBg2c_section_info::sec_num\fP, \fBg2c_section3_info::source_grid_def\fP, \fBg2c_section_info::template\fP, and \fBg2c_section_info::template_len\fP\&.
.PP
Referenced by \fBadd_section()\fP, and \fBg2c_write_index()\fP\&.
.SS "int g2c_rw_section4_metadata (FILE * f, int rw_flag, \fBG2C_SECTION_INFO_T\fP * sec)"

.PP
Read or write the metadata from section 4 (Product Definition Section) of a GRIB2 message\&. When this function is called, the file cursor is positioned just after the section number field in the section\&. The size of the section, and the section number, have already been read/written when this function is called\&.
.PP
\fBParameters\fP
.RS 4
\fIf\fP FILE pointer to open GRIB2 file\&. 
.br
\fIrw_flag\fP \fBG2C_FILE_WRITE\fP if function should write, \fBG2C_FILE_READ\fP if it should read\&. 
.br
\fIsec\fP Pointer to the G2C_SECTION_INFO_T struct\&.
.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_ENOMEM\fP Out of memory\&.
.IP "\(bu" 2
\fBG2C_ENOTEMPLATE\fP Can't find template\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 
.RE
.PP
\fBDate\fP
.RS 4
Sep 16, 2022 
.RE
.PP

.PP
Definition at line \fB574\fP of file \fBg2cfile\&.c\fP\&.
.PP
References \fBG2C_EINVAL\fP, \fBG2C_ENOMEM\fP, \fBg2c_file_io_template()\fP, \fBg2c_file_io_ushort()\fP, \fBg2c_get_pds_template()\fP, \fBG2C_MAX_PDS_TEMPLATE_MAPLEN\fP, \fBG2C_NOERROR\fP, \fBLOG\fP, \fBg2c_section_info::msg\fP, \fBg2c_section4_info::num_coord\fP, \fBg2c_message_info::num_fields\fP, \fBg2c_section4_info::prod_def\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\&.
.PP
Referenced by \fBadd_section()\fP, and \fBg2c_write_index()\fP\&.
.SS "int g2c_rw_section5_metadata (FILE * f, int rw_flag, \fBG2C_SECTION_INFO_T\fP * sec)"

.PP
Read or write the metadata from section 5 (Data Representation Section) of a GRIB2 message\&. When this function is called, the file cursor is positioned just after the section number field in the section\&. The size of the section, and the section number, have already been read when this function is called\&.
.PP
\fBParameters\fP
.RS 4
\fIf\fP FILE pointer to open GRIB2 file\&. 
.br
\fIrw_flag\fP \fBG2C_FILE_WRITE\fP if function should write, \fBG2C_FILE_READ\fP if it should read\&. 
.br
\fIsec\fP Pointer to the G2C_SECTION_INFO_T struct\&.
.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_ENOMEM\fP Out of memory\&.
.IP "\(bu" 2
\fBG2C_ENOTEMPLATE\fP Can't find template\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 
.RE
.PP
\fBDate\fP
.RS 4
Sep 16, 2022 
.RE
.PP

.PP
Definition at line \fB663\fP of file \fBg2cfile\&.c\fP\&.
.PP
References \fBg2c_section5_info::data_def\fP, \fBG2C_EINVAL\fP, \fBG2C_ENOMEM\fP, \fBg2c_file_io_template()\fP, \fBg2c_file_io_uint()\fP, \fBg2c_file_io_ushort()\fP, \fBg2c_get_drs_template()\fP, \fBG2C_MAX_PDS_TEMPLATE_MAPLEN\fP, \fBG2C_NOERROR\fP, \fBLOG\fP, \fBg2c_section5_info::num_data_points\fP, \fBg2c_section_info::sec_info\fP, \fBg2c_section_info::template\fP, and \fBg2c_section_info::template_len\fP\&.
.PP
Referenced by \fBadd_section()\fP, and \fBg2c_write_index()\fP\&.
.SS "int g2c_rw_section6_metadata (FILE * f, int rw_flag, \fBG2C_SECTION_INFO_T\fP * sec)"

.PP
Read or write the metadata from section 6 (Data Representation Section) of a GRIB2 message\&. When this function is called, the file cursor is positioned just after the section number field in the section\&. The size of the section, and the section number, have already been read when this function is called\&.
.PP
\fBParameters\fP
.RS 4
\fIf\fP FILE pointer to open GRIB2 file\&. 
.br
\fIrw_flag\fP \fBG2C_FILE_WRITE\fP if function should write, \fBG2C_FILE_READ\fP if it should read\&. 
.br
\fIsec\fP Pointer to the G2C_SECTION_INFO_T struct\&.
.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_ENOMEM\fP Out of memory\&.
.IP "\(bu" 2
\fBG2C_ENOTEMPLATE\fP Can't find template\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 
.RE
.PP
\fBDate\fP
.RS 4
Sep 16, 2022 
.RE
.PP

.PP
Definition at line \fB745\fP of file \fBg2cfile\&.c\fP\&.
.PP
References \fBG2C_EINVAL\fP, \fBG2C_ENOMEM\fP, \fBg2c_file_io_ubyte()\fP, \fBG2C_NOERROR\fP, \fBg2c_section6_info::indicator\fP, \fBLOG\fP, and \fBg2c_section_info::sec_info\fP\&.
.PP
Referenced by \fBadd_section()\fP\&.
.SS "void gbit (unsigned char * in, \fBg2int\fP * iout, \fBg2int\fP iskip, \fBg2int\fP nbits)"

.PP
Get arbitrary size values from a packed bit string, right justifying each value in the unpacked iout array\&. 
.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 \fB20\fP of file \fBgbits\&.c\fP\&.
.PP
References \fBgbits()\fP\&.
.PP
Referenced by \fBcomunpack()\fP, \fBg2_addfield()\fP, \fBg2_addgrid()\fP, \fBg2_addlocal()\fP, \fBg2_getfld()\fP, \fBg2_gribend()\fP, \fBg2_info()\fP, \fBg2_unpack1()\fP, \fBg2_unpack2()\fP, \fBg2_unpack3()\fP, \fBg2_unpack4()\fP, \fBg2_unpack5()\fP, \fBg2_unpack6()\fP, \fBg2c_check_msg()\fP, \fBg2c_unpack7_int()\fP, and \fBseekgb()\fP\&.
.SS "void gbits (unsigned char * in, \fBg2int\fP * iout, \fBg2int\fP iskip, \fBg2int\fP nbits, \fBg2int\fP nskip, \fBg2int\fP n)"

.PP
Unpack arbitrary size values from a packed bit string, right justifying each value in the unpacked iout array\&. 
.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
\fBAuthor\fP
.RS 4
NOAA Programmer 
.RE
.PP

.PP
Definition at line \fB57\fP of file \fBgbits\&.c\fP\&.
.PP
Referenced by \fBaecunpack_int()\fP, \fBcomunpack()\fP, \fBg2_unpack3()\fP, \fBg2_unpack4()\fP, \fBg2_unpack6()\fP, \fBg2c_gbits_int()\fP, \fBgbit()\fP, \fBpngunpack_int()\fP, \fBsimunpack()\fP, and \fBspecunpack()\fP\&.
.SS "\fBg2int\fP getdim (unsigned char * csec3, \fBg2int\fP * width, \fBg2int\fP * height, \fBg2int\fP * iscan)"

.PP
Return the dimensions and scanning mode of a grid definition\&. 
.PP
\fBParameters\fP
.RS 4
\fIcsec3\fP Character array that contains the packed GRIB2 GDS\&. 
.br
\fIwidth\fP x (or i) dimension of the grid\&. 0 if grid is not recognized\&. 
.br
\fIheight\fP y (or j) dimension of the grid\&. 0 if grid is not recognized\&. 
.br
\fIiscan\fP Scanning mode (see \fCTable 3\&.4\fP)\&. 0 of grid not recognized\&.
.RE
.PP
\fBReturns\fP
.RS 4
Always returns 0\&.
.RE
.PP
\fBAuthor\fP
.RS 4
Stephen Gilbert 
.RE
.PP
\fBDate\fP
.RS 4
2002-12-11 
.RE
.PP

.PP
Definition at line \fB27\fP of file \fBgetdim\&.c\fP\&.
.PP
References \fBg2_unpack3()\fP\&.
.PP
Referenced by \fBg2_addfield()\fP\&.
.SS "\fBgtemplate\fP * getdrstemplate (\fBg2int\fP number)"

.PP
This subroutine returns DRS template information for a specified Data Representation Template\&. The number of entries in the template is returned along with a map of the number of octets occupied by each entry\&. Also, a flag is returned to indicate whether the template would need to be extended\&.
.PP
\fBParameters\fP
.RS 4
\fInumber\fP The number of the Data Representation Template that is being requested\&.
.RE
.PP
\fBReturns\fP
.RS 4
Pointer to the returned template struct\&. Returns NULL if template not found\&.
.RE
.PP
\fBAuthor\fP
.RS 4
Stephen Gilbert 
.RE
.PP
\fBDate\fP
.RS 4
2000-05-11 
.RE
.PP

.PP
Definition at line \fB172\fP of file \fBdrstemplates\&.c\fP\&.
.PP
References \fBgetdrsindex()\fP, and \fBtemplatesdrs\fP\&.
.PP
Referenced by \fBextdrstemplate()\fP, \fBg2_addfield()\fP, and \fBg2_unpack5()\fP\&.
.SS "\fBgtemplate\fP * getgridtemplate (\fBg2int\fP number)"

.PP
This subroutine returns grid template information for a specified Grid Definition Template for [Section 3 - the Grid Definition Section (GDS)](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect3.shtml)\&. The number of entries in the template is returned along with a map of the number of octets occupied by each entry\&. Also, a flag is returned to indicate whether the template would need to be extended\&.
.PP
This function allocates storage for the template\&. The returned pointer must be freed by the caller\&.
.PP
\fBParameters\fP
.RS 4
\fInumber\fP The number of the Grid Definition Template that is being requested\&.
.RE
.PP
\fBReturns\fP
.RS 4
Pointer to the returned template struct (must be freed by caller)\&. Returns NULL pointer, if template not found\&.
.RE
.PP
\fBAuthor\fP
.RS 4
Stephen Gilbert 
.RE
.PP
\fBDate\fP
.RS 4
2000-05-09 
.RE
.PP

.PP
Definition at line \fB193\fP of file \fBgridtemplates\&.c\fP\&.
.PP
References \fBgetgridindex()\fP, and \fBtemplatesgrid\fP\&.
.PP
Referenced by \fBextgridtemplate()\fP, \fBg2_addgrid()\fP, and \fBg2_unpack3()\fP\&.
.SS "\fBgtemplate\fP * getpdstemplate (\fBg2int\fP number)"

.PP
This subroutine returns PDS template information for a specified Product Definition Template\&. The number of entries in the template is returned along with a map of the number of octets occupied by each entry\&. Also, a flag is returned to indicate whether the template would need to be extended\&.
.PP
This function allocates memory for the gtemplate struct, which must be freed by the caller\&.
.PP
\fBParameters\fP
.RS 4
\fInumber\fP the number of the Product Definition Template that is being requested\&.
.RE
.PP
\fBReturns\fP
.RS 4
Pointer to the returned template struct\&. Returns NULL pointer if template not found\&.
.RE
.PP
\fBAuthor\fP
.RS 4
Stephen Gilbert 
.RE
.PP
\fBDate\fP
.RS 4
2000-05-11 
.RE
.PP

.PP
Definition at line \fB504\fP of file \fBpdstemplates\&.c\fP\&.
.PP
References \fBgetpdsindex()\fP, and \fBtemplatespds\fP\&.
.PP
Referenced by \fBextpdstemplate()\fP, \fBg2_addfield()\fP, and \fBg2_unpack4()\fP\&.
.SS "\fBg2int\fP getpoly (unsigned char * csec3, \fBg2int\fP * jj, \fBg2int\fP * kk, \fBg2int\fP * mm)"

.PP
This subroutine returns the J, K, and M pentagonal resolution parameters specified in a GRIB Grid Definition Section (GDS) used spherical harmonic coefficients using GDT 5\&.50 through 5\&.53\&. If 51 - complex data spectral packing is used as the data representation template number (see \fCTable 5\&.0\fP), then the Grid Definition Template Number in section 3 should be one of:
.IP "\(bu" 2
50: Spherical Harmonic Coefficients (See Template 3\&.50)
.IP "\(bu" 2
51: Rotated Spherical Harmonic Coefficients (See Template 3\&.51)
.IP "\(bu" 2
52: Stretched Spherical Harmonic Coefficients (See Template 3\&.52)
.IP "\(bu" 2
53: Rotated and Stretched Spherical Harmonic Coefficients (See Template 3\&.53)
.PP
.PP
\fBParameters\fP
.RS 4
\fIcsec3\fP Character array that contains the packed GRIB2 GDS\&. 
.br
\fIjj\fP J pentagonal resolution parameter\&. 
.br
\fIkk\fP K pentagonal resolution parameter\&. 
.br
\fImm\fP M pentagonal resolution parameter\&.
.RE
.PP
\fBReturns\fP
.RS 4
always returns 0\&.
.RE
.PP
\fBNote\fP
.RS 4
Returns jj, kk, and mm set to zero, if grid template not recognized\&.
.RE
.PP
\fBAuthor\fP
.RS 4
Stephen Gilbert 
.RE
.PP
\fBDate\fP
.RS 4
2002-12-11 
.RE
.PP

.PP
Definition at line \fB40\fP of file \fBgetpoly\&.c\fP\&.
.PP
References \fBg2_unpack3()\fP\&.
.PP
Referenced by \fBg2_addfield()\fP\&.
.SS "double int_power (double x, \fBg2int\fP y)"

.PP
Function similar to C pow() power function\&. 
.PP
\fBParameters\fP
.RS 4
\fIx\fP The base value whose power is to be calculated\&. 
.br
\fIy\fP The power value\&.
.RE
.PP
\fBReturns\fP
.RS 4
x**y
.RE
.PP
\fBAuthor\fP
.RS 4
Wesley Ebisuzaki 
.RE
.PP

.PP
Definition at line \fB18\fP of file \fBint_power\&.c\fP\&.
.PP
Referenced by \fBaecpack_int()\fP, \fBaecunpack_int()\fP, \fBcompack()\fP, \fBcomunpack()\fP, \fBjpcpack_int()\fP, \fBjpcunpack_int()\fP, \fBmisspack()\fP, \fBmkieee()\fP, \fBpngpack_int()\fP, \fBpngunpack_int()\fP, \fBrdieee()\fP, \fBsimpack()\fP, \fBsimunpack()\fP, and \fBspecunpack()\fP\&.
.SS "void jpcpack (float * fld, \fBg2int\fP width, \fBg2int\fP height, \fBg2int\fP * idrstmpl, unsigned char * cpack, \fBg2int\fP * 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
\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
\fBAuthor\fP
.RS 4
Stephen Gilbert, Ed Hartnett 
.RE
.PP

.PP
Definition at line \fB269\fP of file \fBjpcpack\&.c\fP\&.
.PP
References \fBjpcpack_int()\fP\&.
.PP
Referenced by \fBg2_addfield()\fP\&.
.SS "\fBg2int\fP jpcunpack (unsigned char * cpack, \fBg2int\fP len, \fBg2int\fP * idrstmpl, \fBg2int\fP 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
\fBG2_JPCUNPACK_MEM\fP Out of memory\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Stephem Gilbert 
.RE
.PP
\fBDate\fP
.RS 4
2003-08-27 
.RE
.PP

.PP
Definition at line \fB123\fP of file \fBjpcunpack\&.c\fP\&.
.PP
References \fBG2_JPCUNPACK_MEM\fP, \fBjpcunpack_int()\fP, and \fBLOG\fP\&.
.PP
Referenced by \fBg2c_unpack7_int()\fP\&.
.SS "void misspack (float * fld, \fBg2int\fP ndpts, \fBg2int\fP idrsnum, \fBg2int\fP * idrstmpl, unsigned char * cpack, \fBg2int\fP * lcpack)"

.PP
Pack a data field using a complex packing algorithm\&. This funciton supports GRIB2 complex packing templates with or without spatial differences (See \fCTemplate 5\&.2\fP and \fCTemplate 5\&.3\fP)\&.
.PP
This function fills in GRIB2 Data Representation template arrays with the appropriate values\&.
.PP
\fBParameters\fP
.RS 4
\fIfld\fP Contains the data values to pack 
.br
\fIndpts\fP The number of data values in array fld 
.br
\fIidrsnum\fP Data Representation Template number\&. Must equal 2 or 3\&. 
.br
\fIidrstmpl\fP Contains the array of values for Data Representation Template 5\&.2 or 5\&.3\&.
.IP "\(bu" 2
0 Reference value - ignored on input, set by misspack routine\&.
.IP "\(bu" 2
1 Binary Scale Factor - used on input\&.
.IP "\(bu" 2
2 Decimal Scale Factor- used on input\&.
.IP "\(bu" 2
6 Missing value management\&.
.IP "\(bu" 2
7 Primary missing value\&.
.IP "\(bu" 2
8 Secondary missing value\&.
.IP "\(bu" 2
16 Order of Spatial Differencing (1 or 2)\&. 
.PP
.br
\fIcpack\fP The packed data field (character*1 array)\&. 
.br
\fIlcpack\fP length of packed field cpack\&.
.RE
.PP
\fBAuthor\fP
.RS 4
Stephen Gilbert 
.RE
.PP
\fBDate\fP
.RS 4
2000-06-21 
.RE
.PP

.PP
Definition at line \fB43\fP of file \fBmisspack\&.c\fP\&.
.PP
References \fBALOG2\fP, \fBint_power()\fP, \fBmkieee()\fP, \fBpack_gp()\fP, \fBrdieee()\fP, \fBsbit()\fP, and \fBsbits()\fP\&.
.PP
Referenced by \fBcmplxpack()\fP\&.
.SS "void mkieee (float * a, \fBg2int\fP * rieee, \fBg2int\fP num)"

.PP
Store a list of real values in 32-bit IEEE floating point format\&. 
.PP
\fBParameters\fP
.RS 4
\fIa\fP Input array of floating point values\&. 
.br
\fInum\fP Number of floating point values to convert\&. 
.br
\fIrieee\fP Output array of data values in 32-bit IEEE format stored in g2int integer array\&. rieee must be allocated with at least 4*num bytes of memory before calling this function\&.
.RE
.PP
\fBAuthor\fP
.RS 4
Stephen Gilbert 
.RE
.PP
\fBDate\fP
.RS 4
2002-10-29 
.RE
.PP

.PP
Definition at line \fB22\fP of file \fBmkieee\&.c\fP\&.
.PP
References \fBint_power()\fP\&.
.PP
Referenced by \fBaecpack_int()\fP, \fBcompack()\fP, \fBg2_addfield()\fP, \fBjpcpack_int()\fP, \fBmisspack()\fP, \fBpngpack_int()\fP, \fBsimpack()\fP, and \fBspecpack()\fP\&.
.SS "int pack_gp (\fBg2int\fP * kfildo, \fBg2int\fP * ic, \fBg2int\fP * nxy, \fBg2int\fP * is523, \fBg2int\fP * minpk, \fBg2int\fP * inc, \fBg2int\fP * missp, \fBg2int\fP * misss, \fBg2int\fP * jmin, \fBg2int\fP * jmax, \fBg2int\fP * lbit, \fBg2int\fP * nov, \fBg2int\fP * ndg, \fBg2int\fP * lx, \fBg2int\fP * ibit, \fBg2int\fP * jbit, \fBg2int\fP * kbit, \fBg2int\fP * novref, \fBg2int\fP * lbitref, \fBg2int\fP * ier)"

.PP
Determines groups of variable size, but at least of size minpk, the associated max (jmax( )) and min (jmin( )), the number of bits necessary to hold the values in each group (lbit( )), the number of values in each group (nov( )), the number of bits necessary to pack the jmin( ) values (ibit), the number of bits necessary to pack the lbit( ) values (jbit), and the number of bits necessary to pack the nov( ) values (kbit)\&. The routine is designed to determine the groups such that a small number of bits is necessary to pack the data without excessive computations\&. If all values in the group are zero, the number of bits to use in packing is defined as zero when there can be no missing values; when there can be missing values, the number of bits must be at least 1 to have the capability to recognize the missing value\&. However, if all values in a group are missing, the number of bits needed is 0, and the unpacker recognizes this\&. All variables are g2int\&. Even though the groups are initially of size minpk or larger, an adjustment between two groups (the lookback procedure) may make a group smaller than minpk\&. The control on group size is that the sum of the sizes of the two consecutive groups, each of size minpk or larger, is not decreased\&. When determining the number of bits necessary for packing, the largest value that can be accommodated in, say, mbits, is 2**mbits-1; this largest value (and the next smallest value) is reserved for the missing value indicator (only) when is523 ne 0\&. If the dimension ndg is not large enough to hold all the groups, the local value of minpk is increased by 50 percent\&. This is repeated until ndg will suffice\&. A diagnostic is printed whenever this happens, which should be very rarely\&. If it happens often, ndg in subroutine pack should be increased and a corresponding increase in subroutine unpack made\&. Considerable code is provided so that no more checking for missing values within loops is done than necessary; the added efficiency of this is relatively minor, but does no harm\&. For grib2, the reference value for the length of groups in nov( ) and for the number of bits necessary to pack group values are determined, and subtracted before jbit and kbit are determined\&.
.PP
When 1 or more groups are large compared to the others, the width of all groups must be as large as the largest\&. A subroutine reduce breaks up large groups into 2 or more to reduce total bits required\&. If reduce should abort, pack_gp will be executed again without the call to reduce\&.
.PP
PROGRAM HISTORY LOG:
.IP "\(bu" 2
February 1994 Glahn tdl mos-2000
.IP "\(bu" 2
June 1995 Glahn modified for lmiss error\&.
.IP "\(bu" 2
July 1996 Glahn added misss
.IP "\(bu" 2
February 1997 Glahn removed 4 redundant tests for missp\&.eq\&.0; inserted a test to better handle a string of 9999's
.IP "\(bu" 2
February 1997 Glahn added loops to eliminate test for misss when misss = 0
.IP "\(bu" 2
March 1997 Glahn corrected for secondary missing value
.IP "\(bu" 2
March 1997 Glahn corrected for use of local value of minpk
.IP "\(bu" 2
March 1997 Glahn corrected for secondary missing value
.IP "\(bu" 2
March 1997 Glahn changed calculating number of bits through exponents to an array (improved overall packing performance by about 35 percent!)\&. allowed 0 bits for packing jmin( ), lbit( ), and nov( )\&.
.IP "\(bu" 2
May 1997 Glahn a number of changes for efficiency\&. mod functions eliminated and one ifthen added\&. jount removed\&. recomputation of bits not made unless necessary after moving points from one group to another\&. nendb adjusted to eliminate possibility of very small group at the end\&. about 8 percent improvement in overall packing\&. iskipa removed; there is always a group b that can become group a\&. control on size of group b (statement below 150) added\&. added adda, and use of ge and le instead of gt and lt in loops between 150 and 160\&. ibitbs added to shorten trips through loop\&.
.IP "\(bu" 2
March 2000 Glahn modified for grib2; changed name from packgp
.IP "\(bu" 2
january 2001 Glahn comments; ier = 706 substituted for stops; added return1; removed statement number 110; added ier and * return
.IP "\(bu" 2
November 2001 Glahn changed some diagnostic formats to allow printing larger numbers
.IP "\(bu" 2
November 2001 Glahn added misslx( ) to put maximum value into jmin( ) when all values missing to agree with grib standard\&.
.IP "\(bu" 2
November 2001 Glahn changed two tests on missp and misss eq 0 to tests on is523\&. however, missp and misss cannot in general be = 0\&.
.IP "\(bu" 2
November 2001 Glahn added call to reduce; defined itest before loops to reduce computation; started large group when all same value
.IP "\(bu" 2
December 2001 Glahn modified and added a few comments
.IP "\(bu" 2
January 2002 Glahn removed loop before 150 to determine a group of all same value
.IP "\(bu" 2
January 2002 Glahn changed mallow from 9999999 to 2**30+1, and made it a parameter
.IP "\(bu" 2
March 2002 Glahn added non fatal ier = 716, 717; removed nendb=nxy above 150; added iersav=0; comments
.PP
.PP
DATA SET USE
.IP "\(bu" 2
kfildo - unit number for output (print) file\&. (output)
.PP
.PP
\fBParameters\fP
.RS 4
\fIkfildo\fP unit number for output (print) file\&. (input) 
.br
\fIic\fP array to hold data for packing\&. the values do not have to be positive at this point, but must be in the range -2**30 to +2**30 (the the value of mallow)\&. these g2int values will be retained exactly through packing and unpacking\&. (input) 
.br
\fInxy\fP number of values in ic( )\&. also treated as its dimension\&. (input) 
.br
\fIis523\fP missing value management 0=data contains no missing values 1=data contains primary missing values 2=data contains primary and secondary missing values (input) 
.br
\fIminpk\fP the minimum size of each group, except possibly the last one\&. (input) 
.br
\fIinc\fP the number of values to add to an already existing group in determining whether or not to start a new group\&. ideally, this would be 1, but each time inc values are attempted, the max and min of the next minpk values must be found\&. this is 'a loop within a
loop,' and a slightly larger value may give about as good results with slightly less computational time\&. if inc is le 0, 1 is used, and a diagnostic is output\&. note: it is expected that inc will equal 1\&. the code uses inc primarily in the loops starting at statement 180\&. if inc were 1, there would not need to be loops as such\&. however, kinc (the local value of inc) is set ge 1 when near the end of the data to forestall a very small group at the end\&. (input) 
.br
\fImissp\fP when missing points can be present in the data, they will have the value missp or misss\&. missp is the primary missing value and misss is the secondary missing value \&. these must not be values that would occur with subtracting the minimum (reference) value or scaling\&. for example, missp = 0 would not be advisable\&. (input) 
.br
\fImisss\fP secondary missing value indicator (see missp)\&. (input) 
.br
\fIjmin\fP the minimum of each group (j=1,lx)\&. (output) 
.br
\fIjmax\fP the maximum of each group (j=1,lx)\&. this is not really needed, but since the max of each group must be found, saving it here is cheap in case the user wants it\&. (output) 
.br
\fIlbit\fP the number of bits necessary to pack each group (j=1,lx)\&. it is assumed the minimum of each group will be removed before packing, and the values to pack will, therefore, all be positive\&. however, ic( ) does not necessarily contain all positive values\&. if the overall minimum has been removed (the usual case), then ic( ) will contain only positive values\&. (output) 
.br
\fInov\fP the number of values in each group (j=1,lx)\&. (output) 
.br
\fIndg\fP the dimension of jmin, jmax, lbit, and nov\&. (input) 
.br
\fIlx\fP the number of groups determined\&. (output) 
.br
\fIibit\fP the number of bits necessary to pack the jmin(j) values, j=1,lx\&. (output) 
.br
\fIjbit\fP the number of bits necessary to pack the lbit(j) values, j=1,lx\&. (output) 
.br
\fIkbit\fP the number of bits necessary to pack the nov(j) values, j=1,lx\&. (output) 
.br
\fInovref\fP reference value for nov( )\&. (output) 
.br
\fIlbitref\fP reference value for lbit( )\&. (output) 
.br
\fIier\fP Error code
.IP "\(bu" 2
0 No error\&.
.IP "\(bu" 2
706 value will not pack in 30 bits--fatal
.IP "\(bu" 2
714 error in reduce--non-fatal
.IP "\(bu" 2
715 ngp not large enough in reduce--non-fatal
.IP "\(bu" 2
716 minpk inceased--non-fatal
.IP "\(bu" 2
717 inc set
.IP "\(bu" 2
1--non-fatal
.IP "\(bu" 2
alternate return when ier ne 0 and fatal error\&.
.PP
.RE
.PP
\fBReturns\fP
.RS 4
0 - check ier for error code\&. 
.PP
.nf
   INTERNAL VARIABLES

.fi
.PP
 
.PP
.nf

              cfeed = contains the character representation
                      of a printer form feed\&.
              ifeed = contains the g2int value of a printer
                      form feed\&.
               kinc = working copy of inc\&. may be modified\&.
               mina = minimum value in group a\&.
               maxa = maximum value in group a\&.
              nenda = the place in ic( ) where group a ends\&.
             kstart = the place in ic( ) where group a starts\&.
              ibita = number of bits needed to hold values in group a\&.
               minb = minimum value in group b\&.
               maxb = maximum value in group b\&.
              nendb = the place in ic( ) where group b ends\&.
              ibitb = number of bits needed to hold values in group b\&.
               minc = minimum value in group c\&.
               maxc = maximum value in group c\&.
             ktotal = count of number of values in ic( ) processed\&.
              nount = number of values added to group a\&.
              lmiss = 0 when is523 = 0\&. when packing into a
                      specific number of bits, say mbits,
                      the maximum value that can be handled is
                      2**mbits-1\&. when is523 = 1, indicating
                      primary missing values, this maximum value
                      is reserved to hold the primary missing value
                      indicator and lmiss = 1\&. when is523 = 2,
                      the value just below the maximum i\&.e\&.,
                      2**mbits-2 is reserved to hold the secondary
                      missing value indicator and lmiss = 2\&.
             lminpk = local value of minpk\&. this will be adjusted
                      upward whenever ndg is not large enough to hold
                      all the groups\&.
             mallow = the largest allowable value for packing\&.
             mislla = set to 1 when all values in group a are missing\&.
                      this is used to distinguish between a real
                      minimum when all values are not missing
                      and a minimum that has been set to zero when
                      all values are missing\&. 0 otherwise\&.
                      note that this does not distinguish between
                      primary and secondary missings when secondary
                      missings are present\&. this means that
                      lbit( ) will not be zero with the resulting
                      compression efficiency when secondary missings
                      are present\&. also note that a check has been
                      made earlier to determine that secondary
                      missings are really there\&.
             misllb = set to 1 when all values in group b are missing\&.
                      this is used to distinguish between a real
                      minimum when all values are not missing
                      and a minimum that has been set to zero when
                      all values are missing\&. 0 otherwise\&.
             misllc = performs the same function for group c that
                      mislla and misllb do for groups b and c,
                      respectively\&.
           ibxx2(j) = an array that when this routine is first entered
                      is set to 2**j, j=0,30\&. ibxx2(30) = 2**30, which
                      is the largest value packable, because 2**31
                      is larger than the g2int word size\&.
             ifirst = set by data statement to 0\&. changed to 1 on
                      first
                      entry when ibxx2( ) is filled\&.
              minak = keeps track of the location in ic( ) where the
                      minimum value in group a is located\&.
              maxak = does the same as minak, except for the maximum\&.
              minbk = the same as minak for group b\&.
              maxbk = the same as maxak for group b\&.
              minck = the same as minak for group c\&.
              maxck = the same as maxak for group c\&.
               adda = keeps track whether or not an attempt to add
                      points to group a was made\&. if so, then adda
                      keeps from trying to put one back into b\&.
                      (g2int)
             ibitbs = keeps current value if ibitb so that loop
                      ending at 166 doesn't have to start at
                      ibitb = 0 every time\&.
          misslx(j) = mallow except when a group is all one value (and
                      lbit(j) = 0) and that value is missing\&. in
                      that case, misslx(j) is missp or misss\&. this
                      gets inserted into jmin(j) later as the
                      missing indicator; it can't be put in until
                      the end, because jmin( ) is used to calculate
                      the maximum number of bits (ibits) needed to
                      pack jmin( )\&.
.fi
.PP
 
.RE
.PP

.PP
Definition at line \fB255\fP of file \fBpack_gp\&.c\fP\&.
.PP
References \fBFALSE_\fP, \fBreduce()\fP, and \fBTRUE_\fP\&.
.PP
Referenced by \fBcompack()\fP, and \fBmisspack()\fP\&.
.SS "void pngpack (float * fld, \fBg2int\fP width, \fBg2int\fP height, \fBg2int\fP * idrstmpl, unsigned char * cpack, \fBg2int\fP * 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
\fBAuthor\fP
.RS 4
Stephen Gilbert 
.RE
.PP
\fBDate\fP
.RS 4
2003-08-27 
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 
.RE
.PP

.PP
Definition at line \fB254\fP of file \fBpngpack\&.c\fP\&.
.PP
References \fBpngpack_int()\fP\&.
.PP
Referenced by \fBg2_addfield()\fP\&.
.SS "\fBg2int\fP pngunpack (unsigned char * cpack, \fBg2int\fP len, \fBg2int\fP * idrstmpl, \fBg2int\fP 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
\fBG2_JPCUNPACK_MEM\fP Out of memory\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Stephen Gilbert 
.RE
.PP
\fBDate\fP
.RS 4
2003-08-27 
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 
.RE
.PP

.PP
Definition at line \fB126\fP of file \fBpngunpack\&.c\fP\&.
.PP
References \fBG2_JPCUNPACK_MEM\fP, \fBG2C_ENOMEM\fP, and \fBpngunpack_int()\fP\&.
.PP
Referenced by \fBg2c_unpack7_int()\fP\&.
.SS "void rdieee (\fBg2int\fP * rieee, float * a, \fBg2int\fP num)"

.PP
Read a list of real values in 32-bit IEEE floating point format\&. 
.PP
\fBParameters\fP
.RS 4
\fIrieee\fP g2int array of floating point values in 32-bit IEEE format\&. 
.br
\fInum\fP Number of floating point values to convert\&. 
.br
\fIa\fP float array of real values\&. a must be allocated with at least 4*num bytes of memory before calling this function\&.
.RE
.PP
\fBAuthor\fP
.RS 4
Stephen Gilbert 
.RE
.PP
\fBDate\fP
.RS 4
2002-10-25 
.RE
.PP

.PP
Definition at line \fB20\fP of file \fBrdieee\&.c\fP\&.
.PP
References \fBint_power()\fP\&.
.PP
Referenced by \fBaecunpack_int()\fP, \fBcomunpack()\fP, \fBg2_miss()\fP, \fBg2_unpack4()\fP, \fBg2c_unpack7_int()\fP, \fBjpcunpack_int()\fP, \fBmisspack()\fP, \fBpngunpack_int()\fP, \fBsimunpack()\fP, and \fBspecunpack()\fP\&.
.SS "void sbit (unsigned char * out, \fBg2int\fP * in, \fBg2int\fP iskip, \fBg2int\fP nbits)"

.PP
Store arbitrary size values into a packed bit string, taking the low order bits from each value in the unpacked array\&. 
.PP
\fBParameters\fP
.RS 4
\fIout\fP Pointer to packed array output\&. Must be allocated large enough to hold output\&. 
.br
\fIin\fP Pointer that gets the unpacked array input\&. 
.br
\fIiskip\fP Initial number of bits to skip\&. 
.br
\fInbits\fP Number of bits to pack\&.
.RE
.PP
\fBAuthor\fP
.RS 4
NOAA Programmer 
.RE
.PP

.PP
Definition at line \fB38\fP of file \fBgbits\&.c\fP\&.
.PP
References \fBsbits()\fP\&.
.PP
Referenced by \fBcompack()\fP, \fBg2_addfield()\fP, \fBg2_addgrid()\fP, \fBg2_addlocal()\fP, \fBg2_create()\fP, \fBg2_gribend()\fP, \fBmisspack()\fP, and \fBsimpack()\fP\&.
.SS "void sbits (unsigned char * out, \fBg2int\fP * in, \fBg2int\fP iskip, \fBg2int\fP nbits, \fBg2int\fP nskip, \fBg2int\fP n)"

.PP
Store arbitrary size values into a packed bit string, taking the low order bits from each value in the unpacked array\&. 
.PP
\fBParameters\fP
.RS 4
\fIout\fP Pointer to packed array output\&. Must be allocated large enough to hold output\&. 
.br
\fIin\fP Pointer that gets the unpacked array input\&. 
.br
\fIiskip\fP Initial number of bits to skip\&. 
.br
\fInbits\fP Number of bits to pack\&. 
.br
\fInskip\fP Additional number of bits to skip on each iteration\&. 
.br
\fIn\fP Number of iterations\&.
.RE
.PP
\fBAuthor\fP
.RS 4
NOAA Programmer 
.RE
.PP

.PP
Definition at line \fB178\fP of file \fBgbits\&.c\fP\&.
.PP
Referenced by \fBaecpack_int()\fP, \fBcompack()\fP, \fBg2_addfield()\fP, \fBg2_addgrid()\fP, \fBjpcpack_int()\fP, \fBmisspack()\fP, \fBpngpack_int()\fP, \fBsbit()\fP, and \fBsimpack()\fP\&.
.SS "void simpack (float * fld, \fBg2int\fP ndpts, \fBg2int\fP * idrstmpl, unsigned char * cpack, \fBg2int\fP * lcpack)"

.PP
Packs a data field using the simple packing algorithm\&. This function also fills in GRIB2 Data Representation Template 5\&.0 with the appropriate values\&.
.PP
\fBParameters\fP
.RS 4
\fIfld\fP Contains the data values to pack\&. 
.br
\fIndpts\fP The number of data values in array fld\&. 
.br
\fIidrstmpl\fP Contains the array of values for [Data Representation Template 5\&.0](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-0.shtml)\&.
.IP "\(bu" 2
0 Reference value - ignored on input - set by simpack routine\&.
.IP "\(bu" 2
1 Binary Scale Factor - unchanged from input\&.
.IP "\(bu" 2
2 Decimal Scale Factor - unchanged from input\&.
.IP "\(bu" 2
3 Number of bits used to pack data, if value is > 0 and <= 31\&. If this input value is 0 or outside above range then the num of bits is calculated based on given data and scale factors\&.
.IP "\(bu" 2
4 Original field type - currently ignored on input\&. Data values assumed to be reals\&. Set to 0 by simpack routine\&. 
.PP
.br
\fIcpack\fP The packed data field 
.br
\fIlcpack\fP length of packed field starting at cpack\&.
.RE
.PP
\fBAuthor\fP
.RS 4
Stephen Gilbert 
.RE
.PP
\fBDate\fP
.RS 4
2002-11-06 
.RE
.PP

.PP
Definition at line \fB36\fP of file \fBsimpack\&.c\fP\&.
.PP
References \fBALOG2\fP, \fBint_power()\fP, \fBLOG\fP, \fBmkieee()\fP, \fBsbit()\fP, and \fBsbits()\fP\&.
.PP
Referenced by \fBg2_addfield()\fP, and \fBspecpack()\fP\&.
.SS "\fBg2int\fP simunpack (unsigned char * cpack, \fBg2int\fP * idrstmpl, \fBg2int\fP ndpts, float * fld)"

.PP
Unpack a data field that was packed using a simple packing algorithm, using info from the GRIB2 Data Representation Template 5\&.0\&. 
.PP
\fBParameters\fP
.RS 4
\fIcpack\fP pointer to the packed data field\&. 
.br
\fIidrstmpl\fP pointer to the array of values for Data Representation Template 5\&.0\&. 
.br
\fIndpts\fP The number of data values to unpack\&. 
.br
\fIfld\fP A pointer that gets the unpacked data values\&. fld must be `* allocated with at least ndpts * sizeof(float) bytes before calling this routine\&.
.RE
.PP
\fBReturns\fP
.RS 4
0 for success, error code otherwise\&.
.RE
.PP
\fBAuthor\fP
.RS 4
Stephen Gilbert 
.RE
.PP
\fBDate\fP
.RS 4
2002-10-29 
.RE
.PP

.PP
Definition at line \fB28\fP of file \fBsimunpack\&.c\fP\&.
.PP
References \fBG2_JPCUNPACK_MEM\fP, \fBG2_NO_ERROR\fP, \fBgbits()\fP, \fBint_power()\fP, \fBLOG\fP, and \fBrdieee()\fP\&.
.PP
Referenced by \fBg2c_unpack7_int()\fP\&.
.SS "void specpack (float * fld, \fBg2int\fP ndpts, \fBg2int\fP JJ, \fBg2int\fP KK, \fBg2int\fP MM, \fBg2int\fP * idrstmpl, unsigned char * cpack, \fBg2int\fP * lcpack)"

.PP
Pack a spectral data field using the complex packing algorithm for spherical harmonic data as defined in the GRIB2 Data Representation \fCTemplate 5\&.51\fP\&. 
.PP
\fBParameters\fP
.RS 4
\fIfld\fP Contains the data values to be packed\&. 
.br
\fIndpts\fP The number of data values to pack\&. 
.br
\fIJJ\fP J - pentagonal resolution parameter\&. 
.br
\fIKK\fP K - pentagonal resolution parameter\&. 
.br
\fIMM\fP M - pentagonal resolution parameter\&. 
.br
\fIidrstmpl\fP Contains the array of 10 values for [Data Representation Template 5\&.51](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-51.shtml)\&. 
.br
\fIcpack\fP Pointer that gets the packed data field\&. Must be allocated by caller\&. 
.br
\fIlcpack\fP length of packed field cpack\&.
.RE
.PP
\fBAuthor\fP
.RS 4
Stephen Gilbert 
.RE
.PP
\fBDate\fP
.RS 4
2002-12-19 
.RE
.PP

.PP
Definition at line \fB33\fP of file \fBspecpack\&.c\fP\&.
.PP
References \fBmkieee()\fP, and \fBsimpack()\fP\&.
.PP
Referenced by \fBg2_addfield()\fP\&.
.SS "\fBg2int\fP specunpack (unsigned char * cpack, \fBg2int\fP * idrstmpl, \fBg2int\fP ndpts, \fBg2int\fP JJ, \fBg2int\fP KK, \fBg2int\fP MM, float * fld)"

.PP
Unpack a spectral data field that was packed using the complex packing algorithm for spherical harmonic data as defined in the GRIB2 documention, using info from the GRIB2 Data Representation \fCTemplate 5\&.51\fP\&. 
.PP
\fBParameters\fP
.RS 4
\fIcpack\fP pointer to the packed data field\&. 
.br
\fIidrstmpl\fP pointer to the array of values for Data Representation Template 5\&.51\&. 
.br
\fIndpts\fP The number of data values to unpack (real and imaginary parts)\&. 
.br
\fIJJ\fP pentagonal resolution parameter\&. 
.br
\fIKK\fP pentagonal resolution parameter\&. 
.br
\fIMM\fP pentagonal resolution parameter\&. 
.br
\fIfld\fP Contains the unpacked data values\&. fld must be allocated with at least ndpts * sizeof(float) bytes before calling this routine\&.
.RE
.PP
\fBReturns\fP
.RS 4
0 for success, -3 for wrong type\&.
.RE
.PP
\fBAuthor\fP
.RS 4
Stephen Gilbert 
.RE
.PP
\fBDate\fP
.RS 4
2000-06-21 
.RE
.PP

.PP
Definition at line \fB35\fP of file \fBspecunpack\&.c\fP\&.
.PP
References \fBG2_NO_ERROR\fP, \fBG2_SPECUNPACK_TYPE\fP, \fBgbits()\fP, \fBint_power()\fP, and \fBrdieee()\fP\&.
.PP
Referenced by \fBg2c_unpack7_int()\fP\&.
.SH "Author"
.PP 
Generated automatically by Doxygen for NCEPLIBS-g2c from the source code\&.