70 g2int 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;
80 for (j = 0; j < 100; j++)
82 if (cgrib[j] ==
'G' && cgrib[j + 1] ==
'R' && cgrib[j + 2] ==
'I' &&
91 printf(
"g2_info: Beginning characters GRIB not found.");
96 iofst = 8 * (istart + 6);
97 gbit(cgrib, listsec0, iofst, 8);
99 gbit(cgrib, listsec0 + 1, iofst, 8);
102 gbit(cgrib, &lengrib, iofst, 32);
104 listsec0[2] = lengrib;
106 ipos = istart + lensec0;
109 if (listsec0[1] != 2)
111 printf(
"g2_info: can only decode GRIB edition 2.");
116 gbit(cgrib, &lensec1, iofst, 32);
118 gbit(cgrib, &isecnum, iofst, 8);
122 printf(
"g2_info: Could not find section 1.");
129 for (i = 0; i < mapsec1len; i++)
131 nbits = mapsec1[i] * 8;
132 gbit(cgrib, listsec1 + i, iofst, nbits);
133 iofst = iofst + nbits;
135 ipos = ipos + lensec1;
142 if (cgrib[ipos] ==
'7' && cgrib[ipos + 1] ==
'7' && cgrib[ipos + 2] ==
'7' &&
143 cgrib[ipos + 3] ==
'7')
146 if (ipos != (istart + lengrib))
148 printf(
"g2_info: '7777' found, but not where expected.\n");
155 gbit(cgrib, &lensec, iofst, 32);
157 gbit(cgrib, &isecnum, iofst, 8);
159 ipos = ipos + lensec;
160 if (ipos > (istart + lengrib))
162 printf(
"g2_info: '7777' not found at end of GRIB message.\n");
165 if (isecnum >= 2 && isecnum <= 7)
171 else if (isecnum == 4)
176 printf(
"g2_info: Invalid section number found in GRIB message: %ld\n", isecnum);