30 static nc_type binListType = NC_NAT;
31 static int binListDim = -1;
32 static int binListVarid = -1;
33 static int binDataDim = -1;
34 static int numberOfProducts = 0;
36 static int binIndexDim = -1;
37 static int binIndexVarid = -1;
38 static int qualityDim = -1;
39 static int qualityVarid = -1;
40 static int sizeOfFile = -1;
48 (void) fprintf(
stderr,
"line %d of %s: defining 32bit BinList when already in 64bit mode\n", __LINE__, __FILE__);
53 if (nc_inq_varid(grpid,
"BinList", &binListVarid) == NC_NOERR) {
54 (void) fprintf(
stderr,
"line %d of %s: BinList is already defined\n", __LINE__, __FILE__);
61 status = nc_insert_compound(grpid, binListType,
"bin_num",
66 status = nc_insert_compound(grpid, binListType,
"nobs",
71 status = nc_insert_compound(grpid, binListType,
"nscenes",
76 status = nc_insert_compound(grpid, binListType,
"weights",
81 status = nc_insert_compound(grpid, binListType,
"time_rec",
86 status = nc_def_dim(grpid,
"binListDim", NC_UNLIMITED, &binListDim);
89 status = nc_def_var(grpid,
"BinList", binListType, 1, &binListDim, &binListVarid);
93 size_t chunksize = 256;
105 (void) fprintf(
stderr,
"line %d of %s: defining 64bit BinList when already in 32bit mode\n", __LINE__, __FILE__);
110 if (nc_inq_varid(grpid,
"BinList", &binListVarid) == NC_NOERR) {
111 (void) fprintf(
stderr,
"line %d of %s: BinList is already defined\n", __LINE__, __FILE__);
120 status = nc_insert_compound(grpid, binListType,
"bin_num",
125 status = nc_insert_compound(grpid, binListType,
"nobs",
130 status = nc_insert_compound(grpid, binListType,
"nscenes",
135 status = nc_insert_compound(grpid, binListType,
"weights",
140 status = nc_insert_compound(grpid, binListType,
"time_rec",
145 status = nc_def_dim(grpid,
"binListDim", NC_UNLIMITED, &binListDim);
148 status = nc_def_var(grpid,
"BinList", binListType, 1, &binListDim, &binListVarid);
152 size_t chunksize = 256;
162 static size_t startp = 0;
165 if (binListVarid == -1) {
166 (void) fprintf(
stderr,
"line %d of %s: BinList variable needs to be defined first\n",
171 countp = nbins_to_write;
172 status = nc_put_vara(grpid, binListVarid, &startp, &countp,
data);
183 nc_type binDataType = -1;
186 fprintf(
stderr,
"line %d of %s: Max number of output products exceeded\n",
191 status = nc_inq_typeid(grpid,
"binDataType", &binDataType);
194 status = nc_def_compound(grpid, 8,
"binDataType", &binDataType);
197 status = nc_insert_compound(grpid, binDataType,
"sum", 0, NC_FLOAT);
200 status = nc_insert_compound(grpid, binDataType,
"sum_squared", 4, NC_FLOAT);
203 status = nc_def_dim(grpid,
"binDataDim", NC_UNLIMITED, &binDataDim);
208 for (prod = 0; prod < nprods; prod++) {
209 if (nc_inq_varid(grpid, prodnames[prod], &varid) == NC_NOERR) {
210 fprintf(
stderr,
"line %d of %s: BinData for %s is already defined\n",
211 __LINE__, __FILE__, prodnames[prod]);
215 status = nc_def_var(grpid, prodnames[prod], binDataType, 1, &binDataDim, &varid);
218 fprintf(
stderr,
"trying to create binData for product %s\n", prodnames[prod]);
221 binDataVarid[numberOfProducts++] = varid;
224 size_t chunksize = 256;
238 if (iprod >= numberOfProducts) {
239 fprintf(
stderr,
"line %d of %s: product index %d out of range\n",
240 __LINE__, __FILE__, iprod);
244 countp = nbins_to_write;
245 status = nc_put_vara(grpid, binDataVarid[iprod], &startp[iprod], &countp,
data);
247 startp[iprod] += countp;
256 nc_type binIndexType;
261 (void) fprintf(
stderr,
"line %d of %s: defining 32bit BinIndex when already in 64bit mode\n", __LINE__, __FILE__);
266 if (nc_inq_varid(grpid,
"BinIndex", &varid) == NC_NOERR) {
267 fprintf(
stderr,
"line %d of %s: BinIndex is already defined\n",
275 status = nc_insert_compound(grpid, binIndexType,
"start_num",
279 status = nc_insert_compound(grpid, binIndexType,
"begin",
283 status = nc_insert_compound(grpid, binIndexType,
"extent",
287 status = nc_insert_compound(grpid, binIndexType,
"max",
291 status = nc_def_dim(grpid,
"binIndexDim", NC_UNLIMITED, &binIndexDim);
294 status = nc_def_var(grpid,
"BinIndex", binIndexType, 1, &binIndexDim,
299 size_t chunksize = 256;
300 nc_init_compress(grpid, binIndexVarid, &binIndexDim, 1, &chunksize, deflate);
309 nc_type binIndexType;
314 (void) fprintf(
stderr,
"line %d of %s: defining 64bit BinIndex when already in 32bit mode\n", __LINE__, __FILE__);
319 if (nc_inq_varid(grpid,
"BinIndex", &varid) == NC_NOERR) {
320 fprintf(
stderr,
"line %d of %s: BinIndex is already defined\n",
328 status = nc_insert_compound(grpid, binIndexType,
"start_num",
332 status = nc_insert_compound(grpid, binIndexType,
"begin",
336 status = nc_insert_compound(grpid, binIndexType,
"extent",
340 status = nc_insert_compound(grpid, binIndexType,
"max",
344 status = nc_def_dim(grpid,
"binIndexDim", NC_UNLIMITED, &binIndexDim);
347 status = nc_def_var(grpid,
"BinIndex", binIndexType, 1, &binIndexDim,
352 size_t chunksize = 256;
353 nc_init_compress(grpid, binIndexVarid, &binIndexDim, 1, &chunksize, deflate);
363 static size_t start = 0;
364 size_t count = n_write;
378 if (nc_inq_varid(grpid,
"qual_l3", &varid) == NC_NOERR) {
379 fprintf(
stderr,
"line %d of %s: BinIndex is already defined\n",
384 status = nc_def_dim(grpid,
"qualityDim", NC_UNLIMITED, &qualityDim);
387 status = nc_def_var(grpid,
"qual_l3", NC_BYTE, 1, &qualityDim, &qualityVarid);
391 size_t chunksize = 256;
400 static size_t startp;
403 countp = nbins_to_write;
404 status = nc_put_vara(grpid, qualityVarid, &startp, &countp,
data);