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 |
< |
if (status) |
76 |
> |
if (status != DRMS_SUCCESS) |
77 |
|
{ |
78 |
|
// newstat = newstat | CPSAVE_UNKNOWN_ERROR; |
79 |
|
fprintf(stderr, "ERROR: problem parsing TTOTAL, = %s\n", ttotal); |
83 |
|
if (strcmp(kNOTSPECIFIED, tchunk)) |
84 |
|
{ |
85 |
|
status=drms_names_parseduration(&tchunk, &chunksecs, 1); |
86 |
< |
if (status) |
86 |
> |
if (status != DRMS_SUCCESS) |
87 |
|
newstat = newstat | CPSAVE_UNKNOWN_ERROR; |
88 |
|
} |
89 |
|
else |
288 |
|
return 1; |
289 |
|
} |
290 |
|
|
291 |
+ |
long long calversout, calvers; |
292 |
+ |
int calversunset=1; |
293 |
+ |
|
294 |
+ |
int firsttimethrough=1; |
295 |
|
irecout=0; |
296 |
|
for (iset=0; iset < ntimechunks; iset++) |
297 |
|
{ |
323 |
|
} |
324 |
|
*/ |
325 |
|
outrec = outrecset->records[irecout++]; |
326 |
< |
if (histlink) |
326 |
> |
if (histlink != NULL) |
327 |
|
drms_setlink_static(outrec, histlinkname, histrecnum); |
328 |
|
|
329 |
|
if (verbflag > 1) |
368 |
|
continue; |
369 |
|
} |
370 |
|
|
371 |
+ |
if (firsttimethrough) |
372 |
+ |
{ |
373 |
+ |
if (calversunset) |
374 |
+ |
{ |
375 |
+ |
calversout=drms_getkey_longlong(inrec, "CALVER64", &status); |
376 |
+ |
if (status != DRMS_SUCCESS) |
377 |
+ |
calversout = 0; |
378 |
+ |
calversunset=0; |
379 |
+ |
} |
380 |
+ |
|
381 |
+ |
calvers=drms_getkey_longlong(inrec, "CALVER64", &status); |
382 |
+ |
if (status != DRMS_SUCCESS) |
383 |
+ |
calvers = 0; |
384 |
+ |
|
385 |
+ |
if (calvers != calversout) |
386 |
+ |
{ |
387 |
+ |
fprintf(stderr, "ERROR: input data has mixed CALVER64: %lld and %lld, recnum = %lld, histrecnum = %lld\n", calversout, calvers, inrec->recnum, histrecnum); |
388 |
+ |
return 0; |
389 |
+ |
} |
390 |
+ |
} |
391 |
+ |
|
392 |
|
tstartin=drms_getkey_time(inrec, "T_START", &status); |
393 |
|
tstopin=drms_getkey_time(inrec, "T_STOP", &status); |
394 |
|
lminin=drms_getkey_int(inrec, "LMIN", &status); |
423 |
|
segin = drms_segment_lookup(inrec, segnamein); |
424 |
|
else |
425 |
|
segin = drms_segment_lookupnum(inrec, 0); |
426 |
< |
if (segin) |
426 |
> |
if (segin != NULL) |
427 |
|
// inarr = drms_segment_read(segin, usetype, &status); |
428 |
|
inarr = drms_segment_readslice(segin, usetype, startind, endind, &status); |
429 |
|
if (status != DRMS_SUCCESS || inarr == NULL || segin == NULL) |
453 |
|
|
454 |
|
drms_free_array(inarr); |
455 |
|
} |
456 |
+ |
firsttimethrough=0; |
457 |
|
|
458 |
|
if (nskip == nrecsin) |
459 |
|
{ |
472 |
|
fprintf(stderr, "ERROR: problem writing output segment: status = %d, T_START = %s, LMIN = %d, LMAX = %d, histrecnum = %lld\n", status, tstartstr, lminout, lmaxout, histrecnum); |
473 |
|
drms_close_records(inrecset, DRMS_FREE_RECORD); |
474 |
|
drms_close_records(outrecset, DRMS_FREE_RECORD); |
475 |
< |
return 0; |
475 |
> |
return 0; |
476 |
|
} |
477 |
|
} |
478 |
|
drms_free_array(outarr); |
479 |
|
|
480 |
+ |
drms_copykeys(outrec, inrec, 0, kDRMS_KeyClass_Explicit); |
481 |
+ |
// copykeys takes care of MAPMMAX, SINBDIVS, CALVER64, etc. that should be constant across the input |
482 |
|
skip2: |
483 |
|
|
456 |
– |
drms_copykeys(outrec, inrec, 0, kDRMS_KeyClass_Explicit); |
484 |
|
drms_setkey_int(outrec, "LMIN", lminout); |
485 |
|
drms_setkey_int(outrec, "LMAX", lmaxout); |
486 |
|
drms_setkey_time(outrec, "T_START", tstartout); |
497 |
|
drms_setkey_int(outrec, "QUALITY", 0); |
498 |
|
} |
499 |
|
|
473 |
– |
// these could be constant, but set them just in case |
474 |
– |
drms_setkey_int(outrec, "MAPMMAX", mapmmax); |
475 |
– |
drms_setkey_int(outrec, "SINBDIVS", sinbdivs); |
476 |
– |
|
500 |
|
tnow = (double)time(NULL); |
501 |
|
tnow += UNIX_epoch; |
502 |
|
drms_setkey_time(outrec, "DATE", tnow); |