45 g2int ierr, needext, i, j, nbits, isecnum;
46 g2int lensec, isign, newlen;
53 gbit(cgrib, &lensec, *iofst, 32);
55 gbit(cgrib, &isecnum, *iofst, 8);
67 gbit(cgrib, ndpts, *iofst, 32);
69 gbit(cgrib, idrsnum, *iofst, 16);
80 *mapdrslen = mapdrs->
maplen;
87 lidrstmpl = calloc(*mapdrslen,
sizeof(
g2int));
99 *idrstmpl = lidrstmpl;
101 for (i = 0; i < mapdrs->
maplen; i++)
103 nbits = abs(mapdrs->
map[i]) * 8;
104 if (mapdrs->
map[i] >= 0)
106 gbit(cgrib, lidrstmpl + i, *iofst, nbits);
110 gbit(cgrib, &isign, *iofst, 1);
111 gbit(cgrib, lidrstmpl + i, *iofst + 1, nbits - 1);
113 lidrstmpl[i] = -1 * lidrstmpl[i];
115 *iofst = *iofst + nbits;
127 lidrstmpl = realloc(lidrstmpl, newlen *
sizeof(
g2int));
128 *idrstmpl = lidrstmpl;
131 for (i = *mapdrslen; i < newlen; i++)
133 nbits = abs(mapdrs->
ext[j])*8;
134 if (mapdrs->
ext[j] >= 0)
136 gbit(cgrib, lidrstmpl + i, *iofst, nbits);
140 gbit(cgrib, &isign, *iofst, 1);
141 gbit(cgrib, lidrstmpl + i, *iofst + 1, nbits-1);
143 lidrstmpl[i] = -1*lidrstmpl[i];
145 *iofst = *iofst + nbits;
gtemplate * extdrstemplate(g2int number, g2int *list)
This subroutine generates the remaining octet map for a given Data Representation Template,...
gtemplate * getdrstemplate(g2int number)
This subroutine returns DRS template information for a specified Data Representation Template.
g2int g2_unpack5(unsigned char *cgrib, g2int *iofst, g2int *ndpts, g2int *idrsnum, g2int **idrstmpl, g2int *mapdrslen)
This subroutine unpacks Section 5 (Data Representation Section) as defined in GRIB Edition 2.
void gbit(unsigned char *in, g2int *iout, g2int iskip, g2int nbyte)
Get bits - unpack bits: Extract arbitrary size values from a packed bit string, right justifying each...
Header file for NCEPLIBS-g2c library.
g2int * ext
Number of octets of each entry in the extension part of the template.
g2int extlen
Number of entries in the template extension.
g2int * map
Number of octets of each entry in the static part of the template.
g2int needext
Indicates whether or not the template needs to be extended.
g2int maplen
Number of entries in the static part of the template.
int64_t g2int
Long integer type.
Struct for GRIB template.