104 unsigned char *cpack;
105 static g2int zero = 0, one = 1, four = 4, five = 5, six = 6, seven = 7;
106 const g2int minsize = 50000;
107 g2int iofst, ibeg, lencurr, len, nsize;
108 g2int ilen, isecnum, i, nbits, temp, left;
109 g2int ibmprev, j, lcpack, ioctet, newlen, ndpts;
110 g2int lensec4, lensec5, lensec6, lensec7;
111 g2int issec3 = 0, isprevbmap = 0, lpos3 = 0, JJ, KK, MM;
115#if defined USE_PNG || defined USE_JPEG2000 || defined USE_OPENJPEG || defined USE_AEC
116 unsigned int allones = 4294967295u;
117 g2int width, height, iscan, itemp;
138 gbit(cgrib, &ilen, iofst, 32);
140 gbit(cgrib, &isecnum, iofst, 8);
152 gbit(cgrib, &ibmprev, iofst, 8);
154 if (ibmprev >= 0 && ibmprev <= 253)
167 printf(
"g2_addfield: Section byte counts don''t add to total.\n");
168 printf(
"g2_addfield: Sum of section byte counts = %ld\n", len);
169 printf(
"g2_addfield: Total byte count in Section 0 = %ld\n", lencurr);
175 if (isecnum != 3 && isecnum != 7)
177 printf(
"g2_addfield: Sections 4-7 can only be added after Section 3 or 7.\n");
178 printf(
"g2_addfield: Section %ld was the last found in given GRIB message.\n",
185 printf(
"g2_addfield: Sections 4-7 can only be added if Section 3 was previously included.\n");
186 printf(
"g2_addfield: Section 3 was not found in given GRIB message.\n");
187 printf(
"g2_addfield: Call to routine addgrid required to specify Grid definition.\n");
194 sbit(cgrib, &four, iofst, 8);
196 sbit(cgrib, &numcoord, iofst, 16);
198 sbit(cgrib, &ipdsnum, iofst, 16);
217 for (i = 0; i < mappds->
maplen; i++)
219 nbits = abs(mappds->
map[i]) * 8;
220 if ((mappds->
map[i] >= 0) || (ipdstmpl[i] >= 0))
221 sbit(cgrib, ipdstmpl + i, iofst, nbits);
224 sbit(cgrib, &one, iofst, 1);
225 temp = abs(ipdstmpl[i]);
226 sbit(cgrib, &temp, iofst + 1, nbits - 1);
228 iofst = iofst + nbits;
235 for (i = 0; i < mappds->
extlen; i++)
237 nbits = abs(mappds->
ext[i]) * 8;
238 if (mappds->
ext[i] >= 0 || ipdstmpl[j] >= 0)
239 sbit(cgrib, ipdstmpl + j, iofst, nbits);
242 sbit(cgrib, &one, iofst, 1);
243 temp = abs(ipdstmpl[j]);
244 sbit(cgrib, &temp, iofst + 1, nbits - 1);
246 iofst = iofst + nbits;