73 static g2int one = 1, three = 3, miss = 65535;
74 g2int lensec3, iofst, ibeg, lencurr, len;
75 g2int i, j, temp, ilen, isecnum, nbits;
96 gbit(cgrib, &ilen, iofst, 32);
98 gbit(cgrib, &isecnum, iofst, 8);
109 printf(
"g2_addgrid: Section byte counts don''t add to total.\n");
110 printf(
"g2_addgrid: Sum of section byte counts = %ld\n", len);
111 printf(
"g2_addgrid: Total byte count in Section 0 = %ld\n", lencurr);
117 if (isecnum != 1 && isecnum != 2 && isecnum != 7)
119 printf(
"g2_addgrid: Section 3 can only be added after Section 1, 2 or 7.\n");
120 printf(
"g2_addgrid: Section ',isecnum,' was the last found in given GRIB message.\n");
127 sbit(cgrib, &three, iofst, 8);
129 sbit(cgrib, igds+0, iofst, 8);
131 sbit(cgrib, igds+1, iofst, 32);
133 sbit(cgrib, igds+2, iofst, 8);
135 sbit(cgrib, igds+3, iofst, 8);
141 sbit(cgrib, igds+4, iofst, 16);
143 sbit(cgrib, &miss, iofst, 16);
165 for (i = 0; i < mapgrid->
maplen; i++)
167 nbits = abs(mapgrid->
map[i]) * 8;
168 if ((mapgrid->
map[i] >= 0) || (igdstmpl[i] >= 0))
169 sbit(cgrib, igdstmpl+i, iofst, nbits);
172 sbit(cgrib, &one, iofst, 1);
173 temp = abs(igdstmpl[i]);
174 sbit(cgrib, &temp, iofst+1, nbits-1);
176 iofst = iofst + nbits;
183 for (i = 0; i < mapgrid->
extlen; i++)
185 nbits = abs(mapgrid->
ext[i]) * 8;
186 if (mapgrid->
ext[i] >= 0 || igdstmpl[j] >= 0)
187 sbit(cgrib, igdstmpl + j, iofst, nbits);
190 sbit(cgrib, &one, iofst, 1);
191 temp = abs(igdstmpl[j]);
192 sbit(cgrib, &temp, iofst + 1, nbits - 1);
194 iofst = iofst + nbits;
208 sbits(cgrib, ideflist, iofst, nbits, 0, idefnum);
209 iofst = iofst + (nbits * idefnum);
213 lensec3 = (iofst - ibeg) / 8;
214 sbit(cgrib, &lensec3, ibeg, 32);
218 sbit(cgrib, &lencurr, 96, 32);