60 g2int i, j, nbits, isecnum;
61 g2int lensec, ibyttem = 0, isign, newlen;
62 g2int *ligds, *ligdstmpl = NULL, *lideflist = NULL;
69 gbit(cgrib, &lensec, *iofst, 32);
71 gbit(cgrib, &isecnum, *iofst, 8);
81 ligds = calloc(5,
sizeof(
g2int));
84 gbit(cgrib, &ligds[0], *iofst, 8);
86 gbit(cgrib, &ligds[1], *iofst, 32);
88 gbit(cgrib, &ligds[2], *iofst, 8);
90 gbit(cgrib, &ligds[3], *iofst, 8);
92 gbit(cgrib, &ligds[4], *iofst, 16);
95 if (ligds[4] != 65535)
103 *mapgridlen = mapgrid->
maplen;
110 if (!(ligdstmpl = calloc(*mapgridlen,
sizeof(
g2int))))
118 *igdstmpl = ligdstmpl;
121 for (i = 0; i < *mapgridlen; i++)
123 nbits = abs(mapgrid->
map[i]) * 8;
124 if (mapgrid->
map[i] >= 0)
126 gbit(cgrib, ligdstmpl + i, *iofst, nbits);
130 gbit(cgrib, &isign, *iofst, 1);
131 gbit(cgrib, ligdstmpl + i, *iofst + 1, nbits - 1);
133 ligdstmpl[i] = -1 * ligdstmpl[i];
135 *iofst = *iofst + nbits;
136 ibyttem = ibyttem + abs(mapgrid->
map[i]);
149 ligdstmpl = realloc(ligdstmpl, newlen *
sizeof(
g2int));
150 *igdstmpl = ligdstmpl;
152 for (i = *mapgridlen; i < newlen; i++)
154 nbits = abs(mapgrid->
ext[j]) * 8;
155 if (mapgrid->
ext[j] >= 0)
157 gbit(cgrib, ligdstmpl + i, *iofst, nbits);
161 gbit(cgrib, &isign, *iofst, 1);
162 gbit(cgrib, ligdstmpl + i, *iofst + 1, nbits - 1);
164 ligdstmpl[i] = -1 * ligdstmpl[i];
166 *iofst = *iofst + nbits;
167 ibyttem = ibyttem + abs(mapgrid->
ext[j]);
170 *mapgridlen = newlen;
188 nbits = ligds[2] * 8;
189 *idefnum = (lensec - 14 - ibyttem) / ligds[2];
191 lideflist = calloc(*idefnum,
sizeof(
g2int));
198 *ideflist = lideflist;
199 gbits(cgrib, lideflist, *iofst, nbits, 0, *idefnum);
200 *iofst = *iofst + (nbits * *idefnum);