44 g2int j, k, lensec2, iofst, ibeg, lencurr, ilen, len, istart;
65 gbit(cgrib, &ilen, iofst, 32);
67 gbit(cgrib, &isecnum, iofst, 8);
78 printf(
"g2_addlocal: Section byte counts don't add to total.\n");
79 printf(
"g2_addlocal: Sum of section byte counts = %ld\n", len);
80 printf(
"g2_addlocal: Total byte count in Section 0 = %ld\n", lencurr);
86 if (isecnum != 1 && isecnum != 7)
88 printf(
"g2_addlocal: Section 2 can only be added after Section 1 or Section 7.\n");
89 printf(
"g2_addlocal: Section %ld was the last found in given GRIB message.\n", isecnum);
96 sbit(cgrib, &two, iofst, 8);
99 for (j = istart; j < istart + lcsec2; j++)
100 cgrib[j] = csec2[k++];
104 lensec2 = lcsec2 + 5;
105 sbit(cgrib, &lensec2, ibeg, 32);
109 sbit(cgrib, &lencurr, 96, 32);
g2int g2_addlocal(unsigned char *cgrib, unsigned char *csec2, g2int lcsec2)
Adds a Local Use Section (Section 2) to a GRIB2 message.
void gbit(unsigned char *in, g2int *iout, g2int iskip, g2int nbits)
Get arbitrary size values from a packed bit string, right justifying each value in the unpacked iout ...
void sbit(unsigned char *out, g2int *in, g2int iskip, g2int nbits)
Store arbitrary size values into a packed bit string, taking the low order bits from each value in th...
#define G2_BAD_SEC_COUNTS
Sum of Section byte counts doesn't add to total byte count.
#define G2_BAD_SEC
Previous Section was unexpected.
#define G2_ADD_MSG_COMPLETE
GRIB message already complete.
#define G2_ADD_MSG_INIT
GRIB message was not initialized - call g2_create() first.
#define G2C_ENOTGRIB
GRIB header not found.
#define G2C_EMSGCOMPLETE
GRIB message already complete.
int64_t g2int
Long integer type.
Header file with internal function prototypes NCEPLIBS-g2c library.
int g2c_check_msg(unsigned char *cgrib, g2int *lencurr, int verbose)
Check for 'GRIB' at the beginning of a GRIB message, and check to see if the message is already termi...