45 g2int needext, i, j, nbits, isecnum;
46 g2int lensec, isign, newlen;
52 gbit(cgrib, &lensec, *iofst, 32);
54 gbit(cgrib, &isecnum, *iofst, 8);
64 gbit(cgrib, ndpts, *iofst, 32);
66 gbit(cgrib, idrsnum, *iofst, 16);
75 *mapdrslen = mapdrs->
maplen;
82 lidrstmpl = calloc(*mapdrslen,
sizeof(
g2int));
93 *idrstmpl = lidrstmpl;
95 for (i = 0; i < mapdrs->
maplen; i++)
97 nbits = abs(mapdrs->
map[i]) * 8;
98 if (mapdrs->
map[i] >= 0)
100 gbit(cgrib, lidrstmpl + i, *iofst, nbits);
104 gbit(cgrib, &isign, *iofst, 1);
105 gbit(cgrib, lidrstmpl + i, *iofst + 1, nbits - 1);
107 lidrstmpl[i] = -1 * lidrstmpl[i];
109 *iofst = *iofst + nbits;
121 lidrstmpl = realloc(lidrstmpl, newlen *
sizeof(
g2int));
122 *idrstmpl = lidrstmpl;
126 for (i = *mapdrslen; i < newlen; i++)
128 nbits = abs(mapdrs->
ext[j]) * 8;
129 if (mapdrs->
ext[j] >= 0)
131 gbit(cgrib, lidrstmpl + i, *iofst, nbits);
135 gbit(cgrib, &isign, *iofst, 1);
136 gbit(cgrib, lidrstmpl + i, *iofst + 1, nbits - 1);
138 lidrstmpl[i] = -1 * lidrstmpl[i];
140 *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 nbits)
Get bits - unpack bits: Extract arbitrary size values from a packed bit string, right justifying each...
#define G2_UNPACK5_BAD_DRT
In g2_unpack5(), undefined Data Representation Template.
#define G2_UNPACK_BAD_SEC
Bad section number in unpacking function.
#define G2_UNPACK_NO_MEM
Error allocating memory in unpack function.
#define G2_NO_ERROR
Function succeeded.
int64_t g2int
Long integer type.
Header file with internal function prototypes 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.
Struct for GRIB template, returned by getgridtemplate().