24 #define MAX_PRODS 2048
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;
185 status = nc_inq_typeid(grpid,
"binDataType", &binDataType);
188 status = nc_def_compound(grpid, 8,
"binDataType", &binDataType);
191 status = nc_insert_compound(grpid, binDataType,
"sum", 0, NC_FLOAT);
194 status = nc_insert_compound(grpid, binDataType,
"sum_squared", 4, NC_FLOAT);
197 status = nc_def_dim(grpid,
"binDataDim", NC_UNLIMITED, &binDataDim);
202 for (prod = 0; prod < nprods; prod++) {
203 if (nc_inq_varid(grpid, prodnames[prod], &varid) == NC_NOERR) {
204 fprintf(
stderr,
"line %d of %s: BinData for %s is already defined\n",
205 __LINE__, __FILE__, prodnames[prod]);
209 status = nc_def_var(grpid, prodnames[prod], binDataType, 1, &binDataDim, &varid);
212 fprintf(
stderr,
"trying to create binData for product %s\n", prodnames[prod]);
215 binDataVarid[numberOfProducts++] = varid;
217 fprintf(
stderr,
"line %d of %s: Max number of output products exceeded\n",
223 size_t chunksize = 256;
237 if (iprod >= numberOfProducts) {
238 fprintf(
stderr,
"line %d of %s: product index %d out of range\n",
239 __LINE__, __FILE__, iprod);
243 countp = nbins_to_write;
244 status = nc_put_vara(grpid, binDataVarid[iprod], &startp[iprod], &countp,
data);
246 startp[iprod] += countp;
255 nc_type binIndexType;
260 (void) fprintf(
stderr,
"line %d of %s: defining 32bit BinIndex when already in 64bit mode\n", __LINE__, __FILE__);
265 if (nc_inq_varid(grpid,
"BinIndex", &varid) == NC_NOERR) {
266 fprintf(
stderr,
"line %d of %s: BinIndex is already defined\n",
274 status = nc_insert_compound(grpid, binIndexType,
"start_num",
278 status = nc_insert_compound(grpid, binIndexType,
"begin",
282 status = nc_insert_compound(grpid, binIndexType,
"extent",
286 status = nc_insert_compound(grpid, binIndexType,
"max",
290 status = nc_def_dim(grpid,
"binIndexDim", NC_UNLIMITED, &binIndexDim);
293 status = nc_def_var(grpid,
"BinIndex", binIndexType, 1, &binIndexDim,
298 size_t chunksize = 256;
299 nc_init_compress(grpid, binIndexVarid, &binIndexDim, 1, &chunksize, deflate);
308 nc_type binIndexType;
313 (void) fprintf(
stderr,
"line %d of %s: defining 64bit BinIndex when already in 32bit mode\n", __LINE__, __FILE__);
318 if (nc_inq_varid(grpid,
"BinIndex", &varid) == NC_NOERR) {
319 fprintf(
stderr,
"line %d of %s: BinIndex is already defined\n",
327 status = nc_insert_compound(grpid, binIndexType,
"start_num",
331 status = nc_insert_compound(grpid, binIndexType,
"begin",
335 status = nc_insert_compound(grpid, binIndexType,
"extent",
339 status = nc_insert_compound(grpid, binIndexType,
"max",
343 status = nc_def_dim(grpid,
"binIndexDim", NC_UNLIMITED, &binIndexDim);
346 status = nc_def_var(grpid,
"BinIndex", binIndexType, 1, &binIndexDim,
351 size_t chunksize = 256;
352 nc_init_compress(grpid, binIndexVarid, &binIndexDim, 1, &chunksize, deflate);
362 static size_t start = 0;
363 size_t count = n_write;
377 if (nc_inq_varid(grpid,
"qual_l3", &varid) == NC_NOERR) {
378 fprintf(
stderr,
"line %d of %s: BinIndex is already defined\n",
383 status = nc_def_dim(grpid,
"qualityDim", NC_UNLIMITED, &qualityDim);
386 status = nc_def_var(grpid,
"qual_l3", NC_BYTE, 1, &qualityDim, &qualityVarid);
390 size_t chunksize = 256;
399 static size_t startp;
402 countp = nbins_to_write;
403 status = nc_put_vara(grpid, qualityVarid, &startp, &countp,
data);