45 g2int nbitsd=0, isign;
46 g2int j, iofst, ival1, ival2, minsd, itemp, l, k, n, non=0;
47 g2int *ifld, *ifldmiss=0;
48 g2int *gref, *gwidth, *glen;
49 g2int itype, ngroups, nbitsgref, nbitsgwidth, nbitsglen;
51 float ref, bscale, dscale, rmiss1, rmiss2;
55 bscale = (float)
int_power(2.0, idrstmpl[1]);
56 dscale = (float)
int_power(10.0, -idrstmpl[2]);
57 nbitsgref = idrstmpl[3];
59 ngroups = idrstmpl[9];
60 nbitsgwidth = idrstmpl[11];
61 nbitsglen = idrstmpl[15];
63 nbitsd=idrstmpl[17] * 8;
68 for (j = 0; j < ndpts; j++)
75 gref = (
g2int *)calloc(ngroups,
sizeof(
g2int));
76 gwidth = (
g2int *)calloc(ngroups,
sizeof(
g2int));
82 rdieee(idrstmpl+7,&rmiss1,1);
84 rmiss1 = (float)idrstmpl[7];
90 rdieee(idrstmpl+7,&rmiss1,1);
91 rdieee(idrstmpl+8,&rmiss2,1);
94 rmiss1 = (float)idrstmpl[7];
95 rmiss2 = (float)idrstmpl[8];
105 gbit(cpack, &ival1, iofst, nbitsd);
106 iofst = iofst + nbitsd;
107 if (idrstmpl[16] == 2)
110 gbit(cpack, &ival2, iofst, nbitsd);
111 iofst = iofst + nbitsd;
113 gbit(cpack, &isign, iofst, 1);
115 gbit(cpack, &minsd, iofst, nbitsd - 1);
116 iofst = iofst + nbitsd - 1;
130 gbits(cpack, gref, iofst, nbitsgref, 0, ngroups);
131 itemp = nbitsgref * ngroups;
132 iofst = iofst + itemp;
134 iofst = iofst + (8 - (itemp % 8));
138 for (j = 0; j < ngroups; j++)
143 if (nbitsgwidth != 0) {
144 gbits(cpack, gwidth, iofst, nbitsgwidth, 0, ngroups);
145 itemp = nbitsgwidth * ngroups;
146 iofst = iofst + itemp;
148 iofst = iofst + (8 - (itemp % 8));
151 for (j = 0; j < ngroups; j++)
155 for (j = 0; j < ngroups; j++)
156 gwidth[j] = gwidth[j] + idrstmpl[10];
159 glen = calloc(ngroups,
sizeof(
g2int));
162 gbits(cpack, glen, iofst, nbitsglen, 0, ngroups);
163 itemp = nbitsglen * ngroups;
164 iofst = iofst + itemp;
166 iofst = iofst + (8 - (itemp % 8));
170 for (j = 0; j < ngroups; j++)
173 for (j = 0;j<ngroups;j++)
174 glen[j] = (glen[j]*idrstmpl[13])+idrstmpl[12];
175 glen[ngroups-1] = idrstmpl[14];
181 for (j = 0; j < ngroups; j++)
183 totBit += (gwidth[j] * glen[j]);
188 if (totBit / 8. > lensec)
192 if (idrstmpl[6] == 0)
195 for (j = 0; j < ngroups; j++)
199 gbits(cpack, ifld + n, iofst, gwidth[j], 0, glen[j]);
200 for (k = 0; k < glen[j]; k++)
202 ifld[n] = ifld[n] + gref[j];
208 for (l = n; l < n + glen[j]; l++)
212 iofst = iofst + (gwidth[j] * glen[j]);
215 else if (idrstmpl[6] == 1 || idrstmpl[6] == 2)
218 ifldmiss = malloc(ndpts *
sizeof(
g2int));
219 for (j = 0; j < ndpts; j++)
223 for (j = 0; j < ngroups; j++)
229 gbits(cpack, ifld + n, iofst, gwidth[j], 0, glen[j]);
230 iofst = iofst + (gwidth[j] * glen[j]);
231 for (k = 0; k < glen[j]; k++)
233 if (ifld[n] == msng1)
235 else if (idrstmpl[6] == 2 && ifld[n] == msng2)
239 ifld[non++] = ifld[n] + gref[j];
248 if (gref[j] == msng1)
250 for (l = n; l < n + glen[j]; l++)
253 else if (idrstmpl[6] == 2 && gref[j] == msng2)
255 for (l = n; l < n + glen[j]; l++)
260 for (l = n; l < n + glen[j]; l++)
262 for (l = non; l < non + glen[j]; l++)
281 if (idrstmpl[16] == 1)
284 if (idrstmpl[6] == 0)
288 for (n = 1; n < itemp; n++)
290 ifld[n] = ifld[n] + minsd;
291 ifld[n] = ifld[n] + ifld[n - 1];
294 else if (idrstmpl[16] == 2)
298 if (idrstmpl[6] == 0)
302 for (n = 2; n < itemp; n++)
304 ifld[n] = ifld[n] + minsd;
305 ifld[n] = ifld[n] + (2 * ifld[n - 1]) - ifld[n - 2];
311 if (idrstmpl[6] == 0)
313 for (n = 0; n <ndpts; n++)
315 fld[n] = (((float)ifld[n] * bscale) + ref) * dscale;
318 else if (idrstmpl[6] == 1 || idrstmpl[6] == 2)
322 for (n = 0; n < ndpts; n++)
324 if (ifldmiss[n] == 0)
326 fld[n] = (((float)ifld[non++] * bscale) + ref) * dscale;
328 else if (ifldmiss[n] == 1)
330 else if (ifldmiss[n] == 2)