46 g2int *mappdslen,
float **coordlist,
g2int *numcoord)
49 g2int needext, i, j, nbits, isecnum;
50 g2int lensec, isign, newlen;
59 gbit(cgrib, &lensec, *iofst, 32);
61 gbit(cgrib, &isecnum, *iofst, 8);
71 gbit(cgrib, numcoord, *iofst, 16);
73 gbit(cgrib, ipdsnum, *iofst, 16);
82 *mappdslen = mappds->
maplen;
89 lipdstmpl = calloc(*mappdslen,
sizeof(
g2int));
98 *ipdstmpl = lipdstmpl;
100 for (i = 0; i < mappds->
maplen; i++)
102 nbits = abs(mappds->
map[i]) * 8;
103 if (mappds->
map[i] >= 0)
105 gbit(cgrib, lipdstmpl + i, *iofst, nbits);
109 gbit(cgrib, &isign, *iofst, 1);
110 gbit(cgrib, lipdstmpl + i, *iofst + 1, nbits - 1);
112 lipdstmpl[i] = -1 * lipdstmpl[i];
114 *iofst = *iofst + nbits;
126 lipdstmpl = realloc(lipdstmpl, newlen *
sizeof(
g2int));
127 *ipdstmpl = lipdstmpl;
130 for (i = *mappdslen; i < newlen; i++)
132 nbits = abs(mappds->
ext[j]) * 8;
133 if (mappds->
ext[j] >= 0)
135 gbit(cgrib, lipdstmpl + i, *iofst, nbits);
139 gbit(cgrib, &isign, *iofst, 1);
140 gbit(cgrib, lipdstmpl + i, *iofst + 1, nbits - 1);
142 lipdstmpl[i] = -1 * lipdstmpl[i];
144 *iofst = *iofst + nbits;
159 coordieee = calloc(*numcoord,
sizeof(
g2int));
160 lcoordlist = calloc(*numcoord,
sizeof(
float));
161 if (coordieee == 0 || lcoordlist == 0)
173 *coordlist = lcoordlist;
175 gbits(cgrib, coordieee, *iofst, 32, 0, *numcoord);
176 rdieee(coordieee, *coordlist, *numcoord);
178 *iofst = *iofst + (32 * (*numcoord));
g2int g2_unpack4(unsigned char *cgrib, g2int *iofst, g2int *ipdsnum, g2int **ipdstmpl, g2int *mappdslen, float **coordlist, g2int *numcoord)
Unpack Section 4 (Product Definition Section) of a GRIB2 message.
void gbit(unsigned char *in, g2int *iout, g2int iskip, g2int nbits)
Get arbitrary size values from a packed bit string, right justifying each value in the unpacked iout ...
void gbits(unsigned char *in, g2int *iout, g2int iskip, g2int nbits, g2int nskip, g2int n)
Unpack arbitrary size values from a packed bit string, right justifying each value in the unpacked io...
gtemplate * extpdstemplate(g2int number, g2int *list)
This subroutine generates the remaining octet map for a given Product Definition Template,...
void rdieee(g2int *rieee, float *a, g2int num)
Read a list of real values in 32-bit IEEE floating point format.