1 tplarson 1.6 char *cvsinfo_jretile_fewtomany = "cvsinfo: $Header: /home/cvsuser/cvsroot/JSOC/proj/globalhs/apps/jretile_fewtomany.c,v 1.5 2013/04/28 08:05:21 tplarson Exp $";
|
2 tplarson 1.5
|
3 tplarson 1.1 int jretile_fewtomany(void)
4 {
5 int newstat = 0;
6 int status = DRMS_SUCCESS;
7
8 char *inrecquery = NULL;
9 char *outseries = NULL;
10 char *segnamein = NULL;
11 char *segnameout = NULL;
12 DRMS_RecordSet_t *inrecset = NULL;
13 DRMS_RecordSet_t *outrecset = NULL;
14 int irecin, irecout, nrecsin=0, nrecsout=0, nlchunks;
15 DRMS_Record_t *inrec = NULL;
16 DRMS_Record_t *outrec = NULL;
17 DRMS_Segment_t *segin = NULL;
18 DRMS_Segment_t *segout = NULL;
19 DRMS_Array_t *inarr = NULL;
20 DRMS_Array_t *outarr = NULL;
21 DRMS_RecLifetime_t lifetime;
22 DRMS_Type_t usetype = DRMS_TYPE_FLOAT;
23 int length[2], startind[2], endind[2];
24 tplarson 1.1 float *inptr, *outptr;
25 long long histrecnum=-1;
26 int quality;
27 int mapmmax=-1;
28 int sinbdivs=-1;
29 double cadence=0;
|
30 tplarson 1.4 int i;
|
31 tplarson 1.1
32 TIME tnow, UNIX_epoch = -220924792.000; /* 1970.01.01_00:00:00_UTC */
33 char tstartstr[100];
34
35 double tstart, tepoch, tstep, tround, tstop, tstartin, tstopin, tstepin, tstartuse, tstopuse, nseconds, chunksecs;
36 char *ttotal, *tchunk;
37 int ndt;
38 int lmin, lmax, lminin, lmaxin, lminuse, lmaxuse, lchunk, lchunksize, lchunkfirst, lchunklast;
39 int ntimechunks, nmodes, npts, imode, itime;
40 int out_time_offset, out_modes_offset, out_offset, in_time_offset, in_modes_offset, in_offset, out_index, in_index;
41 int iset, lminout, lmaxout;
42 double tstartout, tstopout;
43 float *arrptr;
44 int nrecords, nsegments, nskip;
45
46 int errbufstat=setvbuf(stderr, NULL, _IONBF, BUFSIZ);
47 int outbufstat=setvbuf(stdout, NULL, _IONBF, BUFSIZ);
48
49 double wt0, wt1, wt2, wt3, wt;
50 double ut0, ut1, ut2, ut3, ut;
51 double st0, st1, st2, st3, st;
52 tplarson 1.1 double ct0, ct1, ct2, ct3, ct;
53
54 wt0=getwalltime();
55 ct0=getcputime(&ut0, &st0);
56
57 inrecquery = (char *)cmdparams_save_str(&cmdparams, "in", &newstat);
58 outseries = (char *)cmdparams_save_str(&cmdparams, "out", &newstat);
59 segnamein = (char *)cmdparams_save_str(&cmdparams, "segin", &newstat);
60 segnameout = (char *)cmdparams_save_str(&cmdparams, "segout", &newstat);
61 int seginflag = strcmp(kNOTSPECIFIED, segnamein);
62 int segoutflag = strcmp(kNOTSPECIFIED, segnameout);
63 int verbflag = cmdparams_save_int(&cmdparams, "VERB", &newstat);
64 int permflag = cmdparams_save_int(&cmdparams, "PERM", &newstat);
65 if (permflag)
66 lifetime = DRMS_PERMANENT;
67 else
68 lifetime = DRMS_TRANSIENT;
|
69 tplarson 1.4 unsigned short calverkey = (unsigned short)cmdparams_save_int(&cmdparams, "CALVERKEY", &newstat);
|
70 tplarson 1.1
71 char *histlinkname = (char *)cmdparams_save_str(&cmdparams, "histlink", &newstat);
72
73 tstart=cmdparams_save_time(&cmdparams, "TSTART", &newstat);
74 ttotal=(char *)cmdparams_save_str(&cmdparams, "TTOTAL", &newstat);
75 status=drms_names_parseduration(&ttotal, &nseconds, 1);
|
76 tplarson 1.2 if (status != DRMS_SUCCESS)
|
77 tplarson 1.1 {
78 // newstat = newstat | CPSAVE_UNKNOWN_ERROR;
79 fprintf(stderr, "ERROR: problem parsing TTOTAL, = %s\n", ttotal);
80 return 1;
81 }
82 tchunk=(char *)cmdparams_save_str(&cmdparams, "TCHUNK", &newstat);
83 if (strcmp(kNOTSPECIFIED, tchunk))
84 {
85 status=drms_names_parseduration(&tchunk, &chunksecs, 1);
|
86 tplarson 1.2 if (status != DRMS_SUCCESS)
|
87 tplarson 1.1 newstat = newstat | CPSAVE_UNKNOWN_ERROR;
88 }
89 else
90 chunksecs=0;
91
92 lmin=cmdparams_save_int(&cmdparams, "LMIN", &newstat);
93 lmax=cmdparams_save_int(&cmdparams, "LMAX", &newstat);
94 lchunksize=cmdparams_save_int(&cmdparams, "LCHUNK", &newstat);
95 if (lchunksize == 0)
96 lchunksize=lmax+1;
97
98 if (newstat)
99 {
100 fprintf(stderr, "ERROR: problem with input arguments, status = %d, diagnosis follows\n", newstat);
101 cpsave_decode_error(newstat);
102 return 1;
103 }
104 else if (savestrlen != strlen(savestr))
105 {
106 fprintf(stderr, "ERROR: problem with savestr, savestrlen = %d, strlen(savestr) = %d\n", savestrlen, (int)strlen(savestr));
107 return 1;
108 tplarson 1.1 }
109
110 DRMS_Record_t *tempoutrec = drms_create_record(drms_env,
111 outseries,
112 DRMS_TRANSIENT,
113 &status);
114
115 if (status != DRMS_SUCCESS)
116 {
117 fprintf(stderr,"ERROR: couldn't open a record in output dataseries %s, status = %d\n", outseries, status);
118 return 1;
119 }
120
121 // set up ancillary dataseries for processing metadata
|
122 tplarson 1.6 // char *cvsinfo = strdup("$Header: /home/cvsuser/cvsroot/JSOC/proj/globalhs/apps/jretile_fewtomany.c,v 1.5 2013/04/28 08:05:21 tplarson Exp $");
|
123 tplarson 1.1 DRMS_Link_t *histlink = hcon_lookup_lower(&tempoutrec->links, histlinkname);
124 if (histlink != NULL)
125 {
|
126 tplarson 1.5 histrecnum=set_history(histlink);
|
127 tplarson 1.1 if (histrecnum < 0)
128 {
129 drms_close_record(tempoutrec, DRMS_FREE_RECORD);
130 return 1;
131 }
132 }
133 else
134 {
135 fprintf(stderr,"WARNING: could not find history link in output dataseries\n");
136 }
137
138 // these must be present in the output dataseries and variable, not links or constants
139 // now done in DoIt() that calls this function
140 /*
141 char *outchecklist[] = {"T_START", "QUALITY", "LMIN", "LMAX", "NDT"};
142 int itest;
143 for (itest=0; itest < ARRLENGTH(outchecklist); itest++)
144 {
145 DRMS_Keyword_t *outkeytest = hcon_lookup_lower(&tempoutrec->keywords, outchecklist[itest]);
146 if (outkeytest == NULL || outkeytest->info->islink || outkeytest->info->recscope == 1)
147 {
148 tplarson 1.1 fprintf(stderr, "ERROR: output keyword %s is either missing, constant, or a link\n", outchecklist[itest]);
149 drms_close_record(tempoutrec, DRMS_FREE_RECORD);
150 return 1;
151 }
152 }
153 */
154
155 tepoch=drms_getkey_time(tempoutrec, "T_START_epoch", &status);
156 tstep=drms_getkey_float(tempoutrec, "T_START_step", &status);
157 tround=drms_getkey_float(tempoutrec, "T_START_round", &status);
158 cadence=drms_getkey_float(tempoutrec, "T_STEP", &status);
159 if (fmod(tstart-tepoch,tstep) > tround/2)
160 {
161 fprintf(stderr, "ERROR: output dataseries seems incompatible with input parameters (tstep must divide tstart-tepoch): tstart = %f, tepoch = %f, tstep = %f\n", tstart, tepoch, tstep);
162 drms_close_record(tempoutrec, DRMS_FREE_RECORD);
163 return 1;
164 }
165 if (chunksecs == 0.0)
166 chunksecs = tstep;
167 else if (fmod(chunksecs,tstep))
168 {
169 tplarson 1.1 fprintf(stderr, "ERROR: output dataseries seems incompatible with input parameters (tstep must divide chunksecs): chunksecs = %f, tstep = %f\n", chunksecs, tstep);
170 drms_close_record(tempoutrec, DRMS_FREE_RECORD);
171 return 1;
172 }
173 if (fmod(nseconds,chunksecs) != 0.0)
174 {
175 fprintf(stderr, "ERROR: input parameters seem incompatible (chunksecs must divide nseconds): nseconds = %f, chunksecs = %f\n", nseconds, chunksecs);
176 drms_close_record(tempoutrec, DRMS_FREE_RECORD);
177 return 1;
178 }
179 ntimechunks=nseconds/chunksecs;
180 ndt=chunksecs/cadence;
181 if (verbflag)
182 {
183 printf("%d timechunks, %.1f seconds per chunk\n", ntimechunks, chunksecs);
184 }
185
186 int mapmmaxout=-1;
187 int sinbdivsout=-1;
188 DRMS_Keyword_t *outkeytest = hcon_lookup_lower(&tempoutrec->keywords, "MAPMMAX");
189 if (outkeytest != NULL && outkeytest->info->recscope == 1)
190 tplarson 1.1 mapmmaxout=drms_getkey_int(tempoutrec, "MAPMMAX", &status);
191 outkeytest = hcon_lookup_lower(&tempoutrec->keywords, "SINBDIVS");
192 if (outkeytest != NULL && outkeytest->info->recscope == 1)
193 sinbdivsout=drms_getkey_int(tempoutrec, "SINBDIVS", &status);
194
195 drms_close_record(tempoutrec, DRMS_FREE_RECORD);
196
197
198 char *inchecklist[] = {"T_START", "QUALITY", "LMIN", "LMAX", "T_STEP"};
199 DRMS_Keyword_t *inkeytest;
200 int itest;
201 inrecset = drms_open_records(drms_env, inrecquery, &status);
202 // inrecset = drms_open_recordset(drms_env, inrecquery, &status);
203
204 if (status != DRMS_SUCCESS || inrecset == NULL)
205 {
206 fprintf(stderr, "ERROR: problem opening input recordset: status = %d\n", status);
207 return 1;
208 }
209 nrecsin = inrecset->n;
210
211 tplarson 1.1 if (verbflag)
212 printf("input recordset opened, nrecs = %d\n", nrecsin);
213
214 int noinput=0;
215 if (nrecsin == 0)
216 {
217 printf("WARNING: input recordset contains no records\n");
218 noinput=1;
219 goto skip1;
220 // return 1;
221 }
222
223 inrec = inrecset->records[0];
224 // inrec = drms_recordset_fetchnext(drms_env, inrecset, &fetchstat);
225
226 for (itest=0; itest < ARRLENGTH(inchecklist); itest++)
227 {
228 inkeytest = hcon_lookup_lower(&inrec->keywords, inchecklist[itest]);
229 if (inkeytest == NULL)
230 {
231 fprintf(stderr, "ERROR: required input keyword %s is missing\n", inchecklist[itest]);
232 tplarson 1.1 drms_close_records(inrecset, DRMS_FREE_RECORD);
233 return 1;
234 }
235 }
236
237 if (cadence != drms_getkey_float(inrec, "T_STEP", &status))
238 {
239 fprintf(stderr, "ERROR: input T_STEP does not equal output T_STEP\n");
240 drms_close_records(inrecset, DRMS_FREE_RECORD);
241 return 1;
242 }
243
244 inkeytest = hcon_lookup_lower(&inrec->keywords, "MAPMMAX");
245 if (inkeytest != NULL)
246 mapmmax=drms_getkey_int(inrec, "MAPMMAX", &status);
247 if (mapmmaxout != -1 && mapmmaxout != mapmmax)
248 {
249 fprintf(stderr, "ERROR: input MAPMMAX does not equal output MAPMMAX, in=%d, out=%d\n", mapmmax, mapmmaxout);
250 drms_close_records(inrecset, DRMS_FREE_RECORD);
251 return 1;
252 }
253 tplarson 1.1
254 inkeytest = hcon_lookup_lower(&inrec->keywords, "SINBDIVS");
255 if (outkeytest != NULL)
256 sinbdivs=drms_getkey_int(inrec, "SINBDIVS", &status);
257 if (sinbdivsout != -1 && sinbdivsout != sinbdivs)
258 {
259 fprintf(stderr, "ERROR: input SINBDIVS does not equal output SINBDIVS, in=%d, out=%d\n", sinbdivs, sinbdivsout);
260 drms_close_records(inrecset, DRMS_FREE_RECORD);
261 return 1;
262 }
263
264
265 status=drms_stage_records(inrecset, 1, 0);
266 if (status != DRMS_SUCCESS)
267 {
268 fprintf(stderr, "ERROR: drms_stage_records returned status = %d\n", status);
269 return 1;
270 }
271
272 skip1:
273
274 tplarson 1.1 nrecords=0;
275 nsegments=0;
276 nskip=0;
277
278 lchunkfirst = lmin/lchunksize;
279 lchunklast = lmax/lchunksize;
280
281 nlchunks = (lchunklast - lchunkfirst) + 1;
282 nrecsout = nlchunks*ntimechunks;
283 outrecset = drms_create_records(drms_env, nrecsout, outseries, lifetime, &status);
284 if (status != DRMS_SUCCESS || outrecset == NULL)
285 {
286 fprintf(stderr,"ERROR: unable to create records record in output dataseries %s, status = %d\n", outseries, status);
287 drms_close_records(inrecset, DRMS_FREE_RECORD);
288 return 1;
289 }
290
|
291 tplarson 1.4 unsigned long long calversout, calvers;
|
292 tplarson 1.2 int calversunset=1;
|
293 tplarson 1.4 int mixflag=0;
294 unsigned int nybblearrout[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
295 int fixflagarr[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
296 for (i=0;i<16;i++)
297 {
298 if (getbits(calverkey,i,1))
299 fixflagarr[i]=1;
300 }
|
301 tplarson 1.2
|
302 tplarson 1.4 // int firsttimethrough=1;
|
303 tplarson 1.1 irecout=0;
304 for (iset=0; iset < ntimechunks; iset++)
305 {
306 tstartout=tstart + iset * chunksecs;
307 tstopout=tstartout+chunksecs;
308 sprint_time(tstartstr, tstartout, "TAI", 0);
309
310 if (verbflag)
311 {
312 wt1=getwalltime();
313 ct1=getcputime(&ut1, &st1);
314 printf("processing timechunk %d, tstart = %s\n", iset, tstartstr);
315 }
316
317 for (lchunk = lchunkfirst; lchunk <= lchunklast; lchunk++)
318 {
319 lminout = lchunk * lchunksize;
320 lmaxout = lminout + lchunksize - 1;
321 lminout = MAXIMUM(lminout,lmin);
322 lmaxout = MINIMUM(lmaxout,lmax);
323
324 tplarson 1.1 /*
325 outrec = drms_create_record(drms_env, outseries, lifetime, &status);
326 if (status != DRMS_SUCCESS || outrec == NULL)
327 {
328 fprintf(stderr,"ERROR: unable to open record in output dataseries, status = %d, histrecnum = %lld\n", status, histrecnum);
329 drms_close_records(inrecset, DRMS_FREE_RECORD);
330 return 0;
331 }
332 */
|
333 tplarson 1.4
|
334 tplarson 1.1 outrec = outrecset->records[irecout++];
|
335 tplarson 1.2 if (histlink != NULL)
|
336 tplarson 1.1 drms_setlink_static(outrec, histlinkname, histrecnum);
337
338 if (verbflag > 1)
339 {
340 wt2=getwalltime();
341 ct2=getcputime(&ut2, &st2);
|
342 tplarson 1.4 printf(" processing lchunk %d, min = %d, max = %d\n", lchunk-lchunkfirst, lminout, lmaxout);
|
343 tplarson 1.1 }
344
345 if (noinput)
346 {
347 goto skip2;
348 }
349
350 if (segoutflag)
351 segout = drms_segment_lookup(outrec, segnameout);
352 else
353 segout = drms_segment_lookupnum(outrec, 0);
354
355 length[0]=2*ndt;
356 length[1]=lmaxout*(lmaxout+1)/2+lmaxout - lminout*(lminout+1)/2 + 1;
357 arrptr=(float *)(calloc(length[0]*length[1],sizeof(float)));
358 outarr = drms_array_create(usetype, 2, length, arrptr, &status);
359 if (status != DRMS_SUCCESS || outarr == NULL || segout == NULL)
360 {
361 fprintf(stderr,"ERROR: problem creating output array or segment: length = [%d, %d], status = %d, histrecnum = %lld", length[0], length[1], status, histrecnum);
362 drms_close_records(inrecset, DRMS_FREE_RECORD);
363 drms_close_records(outrecset, DRMS_FREE_RECORD);
364 tplarson 1.1 return 0;
365 }
366 outptr = (float *)(outarr->data);
367
368 nskip=0;
|
369 tplarson 1.4 mixflag=0;
370 calversunset=1;
|
371 tplarson 1.1 for (irecin=0; irecin < nrecsin; irecin++)
372 {
373 inrec = inrecset->records[irecin]; //drms_recordset_fetchnext(drms_env, inrecset, &fetchstat);
374 quality=drms_getkey_int(inrec, "QUALITY", &status);
375 if (status != DRMS_SUCCESS || (quality & QUAL_NODATA)) //may want stricter test on quality here
376 {
|
377 tplarson 1.6 if (verbflag>2) printf("SKIP: input data not used due to quality, irecin = %d, status = %d, quality = %08x\n", irecin, status, quality);
|
378 tplarson 1.1 nskip++;
379 continue;
380 }
381
382 tstartin=drms_getkey_time(inrec, "T_START", &status);
383 tstopin=drms_getkey_time(inrec, "T_STOP", &status);
384 lminin=drms_getkey_int(inrec, "LMIN", &status);
385 lmaxin=drms_getkey_int(inrec, "LMAX", &status);
386 tstepin=tstopin-tstartin;
387
388 if (tstartin >= tstopout || tstopin <= tstartout || lminin > lmaxout || lmaxin < lminout)
389 {
390 nskip++;
391 continue;
392 }
393
|
394 tplarson 1.4 if (calversunset)
395 {
396 calversout=drms_getkey_longlong(inrec, "CALVER64", &status);
397 if (status != DRMS_SUCCESS)
398 calversout = 0;
399 calversunset=0;
400 for (i=0;i<16;i++)
401 nybblearrout[i]=getbits(calversout,4*i+3,4);
402 }
403
404 calvers=drms_getkey_longlong(inrec, "CALVER64", &status);
405 if (status != DRMS_SUCCESS)
406 calvers = 0;
407
408 for (i=0;i<16;i++)
409 {
410 int nybble=getbits(calvers,4*i+3,4);
411 if (fixflagarr[i])
412 {
413 if (nybble != nybblearrout[i])
414 {
415 tplarson 1.4 fprintf(stderr, "ERROR: input data has mixed values for field %d of CALVER64: %d and %d, recnum = %lld, histrecnum = %lld\n", i, nybblearrout[i], nybble, inrec->recnum, histrecnum);
416 return 0;
417 }
418 }
419 else
420 {
421 if (nybble < nybblearrout[i])
422 nybblearrout[i]=nybble;
423 }
424 }
425
426 if (!mixflag && (quality & QUAL_MIXEDCALVER || calvers != calversout))
427 mixflag=1;
428
|
429 tplarson 1.1 tstartuse=MAXIMUM(tstartout, tstartin);
430 tstopuse= MINIMUM(tstopout, tstopin);
431 lminuse=MAXIMUM(lminout, lminin);
432 lmaxuse=MINIMUM(lmaxout, lmaxin);
433 nmodes=MODES(lmaxuse+1)-MODES(lminuse);
434 npts=(tstopuse - tstartuse)/cadence;
435
436 out_time_offset = (tstartuse - tstartout)/cadence;
437 out_modes_offset = MODES(lminuse) - MODES(lminout);
438 out_offset = 2 * (out_modes_offset * ndt + out_time_offset);
439 in_time_offset = (tstartuse - tstartin)/cadence;
440 in_modes_offset = MODES(lminuse) - MODES(lminin);
441 in_offset = 0; // 2 * (in_modes_offset * tstepin / cadence + in_time_offset);
442 startind[0]=2*in_time_offset;
443 startind[1]=in_modes_offset;
444 endind[0]=2*(in_time_offset + npts) - 1;
445 endind[1]=in_modes_offset + nmodes - 1;
446
447 if (seginflag)
448 segin = drms_segment_lookup(inrec, segnamein);
449 else
450 tplarson 1.1 segin = drms_segment_lookupnum(inrec, 0);
|
451 tplarson 1.2 if (segin != NULL)
|
452 tplarson 1.1 // inarr = drms_segment_read(segin, usetype, &status);
453 inarr = drms_segment_readslice(segin, usetype, startind, endind, &status);
454 if (status != DRMS_SUCCESS || inarr == NULL || segin == NULL)
455 {
456 fprintf(stderr, "ERROR: problem reading input segment: tstart = %f, lmin = %d, lmax = %d, irecin = %d, status = %d, histrecnum = %lld\n", tstartin, lminin, lmaxin, irecin, status, histrecnum);
457 drms_close_records(inrecset, DRMS_FREE_RECORD);
458 drms_close_records(outrecset, DRMS_FREE_RECORD);
459 return 0;
460 }
461 else
462 {
463 inptr=(float *)(inarr->data);
464 }
465
466 for (imode=0; imode<nmodes; imode++)
467 {
468 for (itime=0; itime<npts; itime++)
469 {
470 in_index=in_offset + 2*itime;
471 out_index=out_offset + 2*itime;
472 outptr[out_index] = inptr[in_index];
473 tplarson 1.1 outptr[out_index+1] = inptr[in_index+1];
474 }
475 out_offset+=2*ndt;
476 in_offset+=2*npts; // 2*tstepin/cadence;
477 }
478
479 drms_free_array(inarr);
480 }
|
481 tplarson 1.4 // firsttimethrough=0;
|
482 tplarson 1.1
483 if (nskip == nrecsin)
484 {
485 fprintf(stderr, "WARNING: no inputs for this output, no segment written\n");
486 }
487 else
488 {
489 outarr->bzero=segout->bzero;
490 outarr->bscale=segout->bscale;
491 status=drms_segment_write(segout, outarr, 0);
492 nsegments++;
493 if (status != DRMS_SUCCESS)
494 {
495 fprintf(stderr, "ERROR: problem writing output segment: status = %d, T_START = %s, LMIN = %d, LMAX = %d, histrecnum = %lld\n", status, tstartstr, lminout, lmaxout, histrecnum);
496 drms_close_records(inrecset, DRMS_FREE_RECORD);
497 drms_close_records(outrecset, DRMS_FREE_RECORD);
|
498 tplarson 1.2 return 0;
|
499 tplarson 1.1 }
500 }
501 drms_free_array(outarr);
502
|
503 tplarson 1.2 drms_copykeys(outrec, inrec, 0, kDRMS_KeyClass_Explicit);
|
504 tplarson 1.4 // copykeys takes care of MAPMMAX, SINBDIVS, etc. that should be constant across the input
|
505 tplarson 1.1 skip2:
506
507 drms_setkey_int(outrec, "LMIN", lminout);
508 drms_setkey_int(outrec, "LMAX", lmaxout);
509 drms_setkey_time(outrec, "T_START", tstartout);
510 drms_setkey_time(outrec, "T_STOP", tstopout);
511 drms_setkey_time(outrec, "T_OBS", tstartout+chunksecs/2);
512 drms_setkey_int(outrec, "NDT", ndt);
513
|
514 tplarson 1.4 for (i=0;i<16;i++)
515 calversout=setbits(calversout,4*i+3,4,nybblearrout[i]);
516 drms_setkey_longlong(outrec, "CALVER64", calversout);
517
|
518 tplarson 1.1 if (noinput || nskip == nrecsin)
519 drms_setkey_int(outrec, "QUALITY", QUAL_NODATA);
|
520 tplarson 1.4 else if (mixflag)
521 drms_setkey_int(outrec, "QUALITY", QUAL_MIXEDCALVER);
|
522 tplarson 1.1 else
523 drms_setkey_int(outrec, "QUALITY", 0);
524
525 tnow = (double)time(NULL);
526 tnow += UNIX_epoch;
527 drms_setkey_time(outrec, "DATE", tnow);
528
529 // drms_close_record(outrec, DRMS_INSERT_RECORD);
530 nrecords++;
531
532 if (verbflag > 1)
533 {
534 wt=getwalltime();
535 ct=getcputime(&ut, &st);
|
536 tplarson 1.4 fprintf(stdout, " lchunk %d done: %.2f ms wall time, %.2f ms cpu time\n", lchunk-lchunkfirst,
|
537 tplarson 1.1 wt-wt2,
538 ct-ct2);
539 }
540
541 }
542
543 if (verbflag)
544 {
545 wt=getwalltime();
546 ct=getcputime(&ut, &st);
547 fprintf(stdout, "timechunk %d done: %.2f ms wall time, %.2f ms cpu time\n", iset,
548 wt-wt1,
549 ct-ct1);
550
551 }
552
553 }
554
555 drms_close_records(inrecset, DRMS_FREE_RECORD);
556 drms_close_records(outrecset, DRMS_INSERT_RECORD);
557
558 tplarson 1.1 wt=getwalltime();
559 ct=getcputime(&ut, &st);
560 if (verbflag)
561 {
562 printf("number of records created = %d\n", nrecords);
563 printf("number of segments created = %d\n", nsegments);
564 fprintf(stdout, "total time spent: %.2f ms wall time, %.2f ms cpu time\n",
565 wt-wt0, ct-ct0);
566 }
567
568 printf("module %s successful completion\n", cmdparams.argv[0]);
569
570 return 0;
571
572 }
|