70 g2int ierr, mapsec1len = 13;
71 g2int mapsec1[13] = {2, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1};
72 g2int i, j, istart, iofst, lengrib, lensec0, lensec1;
73 g2int ipos, isecnum, nbits, lensec;
81 for (j = 0; j < 100; j++)
83 if (cgrib[j] ==
'G' && cgrib[j + 1] ==
'R' && cgrib[j + 2] ==
'I' &&
92 printf(
"g2_info: Beginning characters GRIB not found.");
98 iofst = 8 * (istart + 6);
99 gbit(cgrib, listsec0, iofst, 8);
101 gbit(cgrib, listsec0 + 1, iofst, 8);
104 gbit(cgrib, &lengrib, iofst, 32);
106 listsec0[2] = lengrib;
108 ipos = istart + lensec0;
111 if (listsec0[1] != 2)
113 printf(
"g2_info: can only decode GRIB edition 2.");
119 gbit(cgrib, &lensec1, iofst, 32);
121 gbit(cgrib, &isecnum, iofst, 8);
125 printf(
"g2_info: Could not find section 1.");
133 for (i = 0;i<mapsec1len;i++)
135 nbits = mapsec1[i]*8;
136 gbit(cgrib, listsec1 + i, iofst, nbits);
137 iofst = iofst + nbits;
139 ipos = ipos + lensec1;
146 if (cgrib[ipos]==
'7' && cgrib[ipos + 1]==
'7' && cgrib[ipos + 2]==
'7' &&
147 cgrib[ipos + 3]==
'7')
150 if (ipos != (istart + lengrib))
152 printf(
"g2_info: '7777' found, but not where expected.\n");
160 gbit(cgrib, &lensec, iofst, 32);
162 gbit(cgrib, &isecnum, iofst, 8);
164 ipos = ipos + lensec;
165 if (ipos > (istart + lengrib))
167 printf(
"g2_info: '7777' not found at end of GRIB message.\n");
171 if ( isecnum>=2 && isecnum<=7 )
177 else if (isecnum == 4)
183 printf(
"g2_info: Invalid section number found in GRIB message: %ld\n", isecnum);
g2int g2_info(unsigned char *cgrib, g2int *listsec0, g2int *listsec1, g2int *numfields, g2int *numlocal)
This subroutine searches through a GRIB2 message and returns the number of gridded fields found in th...
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...
Header file for NCEPLIBS-g2c library.
int64_t g2int
Long integer type.