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