38 g2int iofst, lencurr, len, ilen, isecnum;
39 g2int ierr = 0, lengrib;
40 static unsigned char G = 0x47;
41 static unsigned char R = 0x52;
42 static unsigned char I = 0x49;
43 static unsigned char B = 0x42;
44 static unsigned char seven = 0x37;
47 if (cgrib[0] != G || cgrib[1] != R || cgrib[2] != I || cgrib[3] != B) {
48 printf(
"g2_gribend: GRIB not found in given message.\n");
54 gbit(cgrib, &lencurr, 96, 32);
62 gbit(cgrib, &ilen, iofst, 32);
64 gbit(cgrib, &isecnum, iofst, 8);
72 printf(
"g2_gribend: Section byte counts don''t add to total.\n");
73 printf(
"g2_gribend: Sum of section byte counts = %d\n", (
int)len);
74 printf(
"g2_gribend: Total byte count in Section 0 = %d\n", (
int)lencurr);
82 printf(
"g2_gribend: Section 8 can only be added after Section 7.\n");
83 printf(
"g2_gribend: Section %ld was the last found in given GRIB message.\n", isecnum);
89 cgrib[lencurr] = seven;
90 cgrib[lencurr + 1] = seven;
91 cgrib[lencurr + 2] = seven;
92 cgrib[lencurr + 3] = seven;
95 lengrib = lencurr + 4;
96 sbit(cgrib, &lengrib, 96, 32);
g2int g2_gribend(unsigned char *cgrib)
This routine finalizes a GRIB2 message after all grids and fields have been added.
void gbit(unsigned char *in, g2int *iout, g2int iskip, g2int nbyte)
Get bits - unpack bits: Extract arbitrary size values from a packed bit string, right justifying each...
void sbit(unsigned char *out, g2int *in, g2int iskip, g2int nbyte)
Store bits - put arbitrary size values into a packed bit string, taking the low order bits from each ...
Header file for NCEPLIBS-g2c library.
int64_t g2int
Long integer type.