00001 char *cvsinfo_jretile_maxmem = "cvsinfo: $Header: /home/cvsuser/cvsroot/JSOC/proj/globalhs/apps/jretile_maxmem.c,v 1.6 2017/03/31 20:02:28 tplarson Exp $";
00002
00003 int jretile_maxmem(void)
00004 {
00005 int newstat = 0;
00006 int status = DRMS_SUCCESS;
00007
00008 char *inrecquery = NULL;
00009 char *outseries = NULL;
00010 char *segnamein = NULL;
00011 char *segnameout = NULL;
00012 DRMS_RecordSet_t *inrecset = NULL;
00013 DRMS_RecordSet_t *outrecset = NULL;
00014 int irecin, irecout, nrecsin=0, nrecsout=0, nlchunks;
00015 DRMS_Record_t *inrec = NULL;
00016 DRMS_Record_t *outrec = NULL;
00017 DRMS_Segment_t *segin = NULL;
00018 DRMS_Segment_t *segout = NULL;
00019 DRMS_Array_t *inarr = NULL;
00020 DRMS_Array_t *outarr = NULL;
00021 DRMS_RecLifetime_t lifetime;
00022 DRMS_Type_t usetype = DRMS_TYPE_FLOAT;
00023 int length[2], startind[2], endind[2];
00024 float *inptr, *outptr;
00025 long long histrecnum=-1;
00026 int quality;
00027 int mapmmax=-1;
00028 int sinbdivs=-1;
00029 double cadence=0;
00030 int i;
00031
00032 TIME tnow, UNIX_epoch = -220924792.000;
00033 char tstartstr[100];
00034
00035 double tstart, tepoch, tstep, tround, tstop, tstartin, tstopin, tstepin, tstartuse, tstopuse, nseconds, chunksecs;
00036 char *ttotal, *tchunk;
00037 int ndt, ndtin;
00038 int lmin, lmax, lminin, lmaxin, lminuse, lmaxuse, lchunk, lchunksize, lchunkfirst, lchunklast;
00039 int ntimechunks, nmodes, npts, imode, itime;
00040 int out_time_offset, out_modes_offset, out_offset, in_time_offset, in_modes_offset, in_offset, out_index, in_index;
00041 int iset, lminout, lmaxout;
00042 double tstartout, tstopout;
00043 float *arrptr;
00044 int nrecords, nsegments, nskip;
00045
00046 int errbufstat=setvbuf(stderr, NULL, _IONBF, BUFSIZ);
00047 int outbufstat=setvbuf(stdout, NULL, _IONBF, BUFSIZ);
00048
00049 double wt0, wt1, wt2, wt3, wt;
00050 double ut0, ut1, ut2, ut3, ut;
00051 double st0, st1, st2, st3, st;
00052 double ct0, ct1, ct2, ct3, ct;
00053
00054 wt0=getwalltime();
00055 ct0=getcputime(&ut0, &st0);
00056
00057 inrecquery = (char *)cmdparams_save_str(&cmdparams, "in", &newstat);
00058 outseries = (char *)cmdparams_save_str(&cmdparams, "out", &newstat);
00059 segnamein = (char *)cmdparams_save_str(&cmdparams, "segin", &newstat);
00060 segnameout = (char *)cmdparams_save_str(&cmdparams, "segout", &newstat);
00061 int seginflag = strcmp(kNOTSPECIFIED, segnamein);
00062 int segoutflag = strcmp(kNOTSPECIFIED, segnameout);
00063 int verbflag = cmdparams_save_int(&cmdparams, "VERB", &newstat);
00064 int permflag = cmdparams_save_int(&cmdparams, "PERM", &newstat);
00065 if (permflag)
00066 lifetime = DRMS_PERMANENT;
00067 else
00068 lifetime = DRMS_TRANSIENT;
00069 unsigned short calverkey = (unsigned short)cmdparams_save_int(&cmdparams, "CALVERKEY", &newstat);
00070
00071 char *histlinkname = (char *)cmdparams_save_str(&cmdparams, "histlink", &newstat);
00072
00073 tstart=cmdparams_save_time(&cmdparams, "TSTART", &newstat);
00074 ttotal=(char *)cmdparams_save_str(&cmdparams, "TTOTAL", &newstat);
00075 status=drms_names_parseduration(&ttotal, &nseconds, 1);
00076 if (status != DRMS_SUCCESS)
00077 {
00078
00079 fprintf(stderr, "ERROR: problem parsing TTOTAL, = %s\n", ttotal);
00080 return 1;
00081 }
00082 tchunk=(char *)cmdparams_save_str(&cmdparams, "TCHUNK", &newstat);
00083 if (strcmp(kNOTSPECIFIED, tchunk))
00084 {
00085 status=drms_names_parseduration(&tchunk, &chunksecs, 1);
00086 if (status != DRMS_SUCCESS)
00087 newstat = newstat | CPSAVE_UNKNOWN_ERROR;
00088 }
00089 else
00090 chunksecs=0;
00091
00092 lmin=cmdparams_save_int(&cmdparams, "LMIN", &newstat);
00093 lmax=cmdparams_save_int(&cmdparams, "LMAX", &newstat);
00094 lchunksize=cmdparams_save_int(&cmdparams, "LCHUNK", &newstat);
00095 if (lchunksize == 0)
00096 lchunksize=lmax+1;
00097
00098 if (newstat)
00099 {
00100 fprintf(stderr, "ERROR: problem with input arguments, status = %d, diagnosis follows\n", newstat);
00101 cpsave_decode_error(newstat);
00102 return 1;
00103 }
00104 else if (savestrlen != strlen(savestr))
00105 {
00106 fprintf(stderr, "ERROR: problem with savestr, savestrlen = %d, strlen(savestr) = %d\n", savestrlen, (int)strlen(savestr));
00107 return 1;
00108 }
00109
00110 DRMS_Record_t *tempoutrec = drms_create_record(drms_env,
00111 outseries,
00112 DRMS_TRANSIENT,
00113 &status);
00114
00115 if (status != DRMS_SUCCESS)
00116 {
00117 fprintf(stderr,"ERROR: couldn't open a record in output dataseries %s, status = %d\n", outseries, status);
00118 return 1;
00119 }
00120
00121
00122 DRMS_Link_t *histlink = hcon_lookup_lower(&tempoutrec->links, histlinkname);
00123 if (histlink != NULL)
00124 {
00125 histrecnum=set_history(histlink);
00126 if (histrecnum < 0)
00127 {
00128 drms_close_record(tempoutrec, DRMS_FREE_RECORD);
00129 return 1;
00130 }
00131 }
00132 else
00133 {
00134 fprintf(stderr,"WARNING: could not find history link in output dataseries\n");
00135 }
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154 tepoch=drms_getkey_time(tempoutrec, "T_START_epoch", &status);
00155 tstep=drms_getkey_float(tempoutrec, "T_START_step", &status);
00156 tround=drms_getkey_float(tempoutrec, "T_START_round", &status);
00157 cadence=drms_getkey_float(tempoutrec, "T_STEP", &status);
00158 if (fmod(tstart-tepoch,tstep) > tround/2)
00159 {
00160 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);
00161 drms_close_record(tempoutrec, DRMS_FREE_RECORD);
00162 return 1;
00163 }
00164 if (chunksecs == 0.0)
00165 chunksecs = tstep;
00166 else if (fmod(chunksecs,tstep))
00167 {
00168 fprintf(stderr, "ERROR: output dataseries seems incompatible with input parameters (tstep must divide chunksecs): chunksecs = %f, tstep = %f\n", chunksecs, tstep);
00169 drms_close_record(tempoutrec, DRMS_FREE_RECORD);
00170 return 1;
00171 }
00172 if (fmod(nseconds,chunksecs) != 0.0)
00173 {
00174 fprintf(stderr, "ERROR: input parameters seem incompatible (chunksecs must divide nseconds): nseconds = %f, chunksecs = %f\n", nseconds, chunksecs);
00175 drms_close_record(tempoutrec, DRMS_FREE_RECORD);
00176 return 1;
00177 }
00178 ntimechunks=nseconds/chunksecs;
00179 ndt=chunksecs/cadence;
00180 if (verbflag)
00181 {
00182 printf("%d timechunks, %.1f seconds per chunk\n", ntimechunks, chunksecs);
00183 }
00184
00185 int mapmmaxout=-1;
00186 int sinbdivsout=-1;
00187 DRMS_Keyword_t *outkeytest = hcon_lookup_lower(&tempoutrec->keywords, "MAPMMAX");
00188 if (outkeytest != NULL && outkeytest->info->recscope == 1)
00189 mapmmaxout=drms_getkey_int(tempoutrec, "MAPMMAX", &status);
00190 outkeytest = hcon_lookup_lower(&tempoutrec->keywords, "SINBDIVS");
00191 if (outkeytest != NULL && outkeytest->info->recscope == 1)
00192 sinbdivsout=drms_getkey_int(tempoutrec, "SINBDIVS", &status);
00193
00194 float apinnerout=0.0;
00195 float apwidthout=0.0;
00196 float apinner=0.0;
00197 float apwidth=0.0;
00198 outkeytest = hcon_lookup_lower(&tempoutrec->keywords, "APINNER");
00199 if (outkeytest != NULL && outkeytest->info->recscope == 1)
00200 apinnerout=drms_getkey_float(tempoutrec, "APINNER", &status);
00201 outkeytest = hcon_lookup_lower(&tempoutrec->keywords, "APWIDTH");
00202 if (outkeytest != NULL && outkeytest->info->recscope == 1)
00203 apwidthout=drms_getkey_float(tempoutrec, "APWIDTH", &status);
00204
00205 drms_close_record(tempoutrec, DRMS_FREE_RECORD);
00206
00207
00208 char *inchecklist[] = {"T_START", "QUALITY", "LMIN", "LMAX", "T_STEP"};
00209 DRMS_Keyword_t *inkeytest;
00210 int itest;
00211 inrecset = drms_open_records(drms_env, inrecquery, &status);
00212
00213
00214 if (status != DRMS_SUCCESS || inrecset == NULL)
00215 {
00216 fprintf(stderr, "ERROR: problem opening input recordset: status = %d\n", status);
00217 return 1;
00218 }
00219 nrecsin = inrecset->n;
00220
00221 if (verbflag)
00222 printf("input recordset opened, nrecs = %d\n", nrecsin);
00223
00224 int noinput=0;
00225 if (nrecsin == 0)
00226 {
00227 printf("WARNING: input recordset contains no records\n");
00228 noinput=1;
00229 goto skip1;
00230
00231 }
00232
00233 inrec = inrecset->records[0];
00234
00235 for (itest=0; itest < ARRLENGTH(inchecklist); itest++)
00236 {
00237 inkeytest = hcon_lookup_lower(&inrec->keywords, inchecklist[itest]);
00238 if (inkeytest == NULL)
00239 {
00240 fprintf(stderr, "ERROR: required input keyword %s is missing\n", inchecklist[itest]);
00241 drms_close_records(inrecset, DRMS_FREE_RECORD);
00242 return 1;
00243 }
00244 }
00245
00246 if (cadence != drms_getkey_float(inrec, "T_STEP", &status))
00247 {
00248 fprintf(stderr, "ERROR: input T_STEP does not equal output T_STEP\n");
00249 drms_close_records(inrecset, DRMS_FREE_RECORD);
00250 return 1;
00251 }
00252
00253 inkeytest = hcon_lookup_lower(&inrec->keywords, "MAPMMAX");
00254 if (inkeytest != NULL)
00255 mapmmax=drms_getkey_int(inrec, "MAPMMAX", &status);
00256 if (mapmmaxout != -1 && mapmmaxout != mapmmax)
00257 {
00258 fprintf(stderr, "ERROR: input MAPMMAX does not equal output MAPMMAX, in=%d, out=%d\n", mapmmax, mapmmaxout);
00259 drms_close_records(inrecset, DRMS_FREE_RECORD);
00260 return 1;
00261 }
00262
00263 inkeytest = hcon_lookup_lower(&inrec->keywords, "SINBDIVS");
00264 if (inkeytest != NULL)
00265 sinbdivs=drms_getkey_int(inrec, "SINBDIVS", &status);
00266 if (sinbdivsout != -1 && sinbdivsout != sinbdivs)
00267 {
00268 fprintf(stderr, "ERROR: input SINBDIVS does not equal output SINBDIVS, in=%d, out=%d\n", sinbdivs, sinbdivsout);
00269 drms_close_records(inrecset, DRMS_FREE_RECORD);
00270 return 1;
00271 }
00272
00273 inkeytest = hcon_lookup_lower(&inrec->keywords, "APINNER");
00274 if (inkeytest != NULL)
00275 apinner=drms_getkey_float(inrec, "APINNER", &status);
00276 if (apinnerout != 0.0 && (int)(10000*apinnerout) != (int)(10000*apinner))
00277 {
00278 fprintf(stderr, "ERROR: input APINNER does not equal output APINNER, in=%f, out=%f\n",apinner, apinnerout);
00279 drms_close_records(inrecset, DRMS_FREE_RECORD);
00280 return 1;
00281 }
00282
00283 inkeytest = hcon_lookup_lower(&inrec->keywords, "APWIDTH");
00284 if (inkeytest != NULL)
00285 apwidth=drms_getkey_float(inrec, "APWIDTH", &status);
00286 if (apinnerout != 0.0 && (int)(10000*apwidthout) != (int)(10000*apwidth))
00287 {
00288 fprintf(stderr, "ERROR: input APWIDTH does not equal output APWIDTH, in=%f, out=%f\n", apwidth, apwidth);
00289 drms_close_records(inrecset, DRMS_FREE_RECORD);
00290 return 1;
00291 }
00292
00293
00294 status=drms_stage_records(inrecset, 1, 0);
00295 if (status != DRMS_SUCCESS)
00296 {
00297 fprintf(stderr, "ERROR: drms_stage_records returned status = %d\n", status);
00298 return 1;
00299 }
00300
00301 skip1:
00302
00303 nrecords=0;
00304 nsegments=0;
00305 nskip=0;
00306
00307 lchunkfirst = lmin/lchunksize;
00308 lchunklast = lmax/lchunksize;
00309
00310 nlchunks = (lchunklast - lchunkfirst) + 1;
00311 nrecsout = nlchunks*ntimechunks;
00312 outrecset = drms_create_records(drms_env, nrecsout, outseries, lifetime, &status);
00313 if (status != DRMS_SUCCESS || outrecset == NULL)
00314 {
00315 fprintf(stderr,"ERROR: unable to create records record in output dataseries %s, status = %d\n", outseries, status);
00316 drms_close_records(inrecset, DRMS_FREE_RECORD);
00317 return 1;
00318 }
00319
00320 unsigned long long calversout, calvers;
00321 int calversunset=1;
00322 int mixflag=0;
00323 unsigned int nybblearrout[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
00324 int fixflagarr[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
00325 for (i=0;i<16;i++)
00326 {
00327 if (getbits(calverkey,i,1))
00328 fixflagarr[i]=1;
00329 }
00330
00331 int *firstflagarr=(int *)malloc(nrecsin*sizeof(int));
00332 DRMS_Array_t **inarrarr=(DRMS_Array_t **)malloc(nrecsin*sizeof(DRMS_Array_t *));
00333 for (irecin=0; irecin < nrecsin; irecin++)
00334 {
00335 firstflagarr[irecin]=1;
00336 inarrarr[irecin]=NULL;
00337 }
00338
00339 irecout=0;
00340 for (iset=0; iset < ntimechunks; iset++)
00341 {
00342 tstartout=tstart + iset * chunksecs;
00343 tstopout=tstartout+chunksecs;
00344 sprint_time(tstartstr, tstartout, "TAI", 0);
00345
00346 if (verbflag)
00347 {
00348 wt1=getwalltime();
00349 ct1=getcputime(&ut1, &st1);
00350 printf("processing timechunk %d, tstart = %s\n", iset, tstartstr);
00351 }
00352
00353 for (lchunk = lchunkfirst; lchunk <= lchunklast; lchunk++)
00354 {
00355 lminout = lchunk * lchunksize;
00356 lmaxout = lminout + lchunksize - 1;
00357 lminout = MAXIMUM(lminout,lmin);
00358 lmaxout = MINIMUM(lmaxout,lmax);
00359
00360 outrec = outrecset->records[irecout++];
00361 if (histlink != NULL)
00362 drms_setlink_static(outrec, histlinkname, histrecnum);
00363
00364 if (verbflag > 1)
00365 {
00366 wt2=getwalltime();
00367 ct2=getcputime(&ut2, &st2);
00368 printf(" processing lchunk %d, min = %d, max = %d\n", lchunk-lchunkfirst, lminout, lmaxout);
00369 }
00370
00371 if (noinput)
00372 {
00373 goto skip2;
00374 }
00375
00376 if (segoutflag)
00377 segout = drms_segment_lookup(outrec, segnameout);
00378 else
00379 segout = drms_segment_lookupnum(outrec, 0);
00380
00381 length[0]=2*ndt;
00382 length[1]=lmaxout*(lmaxout+1)/2+lmaxout - lminout*(lminout+1)/2 + 1;
00383 arrptr=(float *)(calloc(length[0]*length[1],sizeof(float)));
00384 outarr = drms_array_create(usetype, 2, length, arrptr, &status);
00385 if (status != DRMS_SUCCESS || outarr == NULL || segout == NULL)
00386 {
00387 fprintf(stderr,"ERROR: problem creating output array or segment: length = [%d, %d], status = %d, histrecnum = %lld", length[0], length[1], status, histrecnum);
00388 drms_close_records(inrecset, DRMS_FREE_RECORD);
00389 drms_close_records(outrecset, DRMS_FREE_RECORD);
00390 return 0;
00391 }
00392 outptr = (float *)(outarr->data);
00393
00394 nskip=0;
00395 mixflag=0;
00396 calversunset=1;
00397 for (irecin=0; irecin < nrecsin; irecin++)
00398 {
00399 inrec = inrecset->records[irecin];
00400 quality=drms_getkey_int(inrec, "QUALITY", &status);
00401 if (status != DRMS_SUCCESS || (quality & QUAL_NODATA))
00402 {
00403 if (verbflag>2) printf("SKIP: input data not used due to quality, irecin = %d, status = %d, quality = %08x\n", irecin, status, quality);
00404 nskip++;
00405 continue;
00406 }
00407
00408 tstartin=drms_getkey_time(inrec, "T_START", &status);
00409 tstopin=drms_getkey_time(inrec, "T_STOP", &status);
00410 lminin=drms_getkey_int(inrec, "LMIN", &status);
00411 lmaxin=drms_getkey_int(inrec, "LMAX", &status);
00412 ndtin=(tstopin-tstartin)/cadence;
00413
00414 if (tstartin >= tstopout || tstopin <= tstartout || lminin > lmaxout || lmaxin < lminout)
00415 {
00416 nskip++;
00417 continue;
00418 }
00419
00420 if (calversunset)
00421 {
00422 calversout=drms_getkey_longlong(inrec, "CALVER64", &status);
00423 if (status != DRMS_SUCCESS)
00424 calversout = 0;
00425 calversunset=0;
00426 for (i=0;i<16;i++)
00427 nybblearrout[i]=getbits(calversout,4*i+3,4);
00428 }
00429
00430 calvers=drms_getkey_longlong(inrec, "CALVER64", &status);
00431 if (status != DRMS_SUCCESS)
00432 calvers = 0;
00433
00434 for (i=0;i<16;i++)
00435 {
00436 int nybble=getbits(calvers,4*i+3,4);
00437 if (fixflagarr[i])
00438 {
00439 if (nybble != nybblearrout[i])
00440 {
00441 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);
00442 return 0;
00443 }
00444 }
00445 else
00446 {
00447 if (nybble < nybblearrout[i])
00448 nybblearrout[i]=nybble;
00449 }
00450 }
00451
00452 if (!mixflag && (quality & QUAL_MIXEDCALVER || calvers != calversout))
00453 mixflag=1;
00454
00455 if (firstflagarr[irecin])
00456 {
00457 if (seginflag)
00458 segin = drms_segment_lookup(inrec, segnamein);
00459 else
00460 segin = drms_segment_lookupnum(inrec, 0);
00461 if (segin != NULL)
00462 inarr = drms_segment_read(segin, usetype, &status);
00463 if (status != DRMS_SUCCESS || inarr == NULL || segin == NULL)
00464 {
00465 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);
00466 drms_close_records(inrecset, DRMS_FREE_RECORD);
00467 drms_close_records(outrecset, DRMS_FREE_RECORD);
00468 return 0;
00469 }
00470 else
00471 {
00472 inarrarr[irecin]=inarr;
00473 }
00474 firstflagarr[irecin]=0;
00475 }
00476
00477 inptr = (float *)(inarrarr[irecin])->data;
00478
00479 tstartuse=MAXIMUM(tstartout, tstartin);
00480 tstopuse= MINIMUM(tstopout, tstopin);
00481 lminuse=MAXIMUM(lminout, lminin);
00482 lmaxuse=MINIMUM(lmaxout, lmaxin);
00483 nmodes=MODES(lmaxuse+1)-MODES(lminuse);
00484 npts=(tstopuse - tstartuse)/cadence;
00485
00486 out_time_offset = (tstartuse - tstartout)/cadence;
00487 out_modes_offset = MODES(lminuse) - MODES(lminout);
00488 out_offset = 2 * (out_modes_offset * ndt + out_time_offset);
00489 in_time_offset = (tstartuse - tstartin)/cadence;
00490 in_modes_offset = MODES(lminuse) - MODES(lminin);
00491 in_offset = 2 * (in_modes_offset * ndtin + in_time_offset);
00492
00493 for (imode=0; imode<nmodes; imode++)
00494 {
00495 for (itime=0; itime<npts; itime++)
00496 {
00497 in_index=in_offset + 2*itime;
00498 out_index=out_offset + 2*itime;
00499 outptr[out_index] = inptr[in_index];
00500 outptr[out_index+1] = inptr[in_index+1];
00501 }
00502 out_offset+=2*ndt;
00503 in_offset+=2*ndtin;
00504 }
00505
00506 }
00507
00508 if (nskip == nrecsin)
00509 {
00510 fprintf(stderr, "WARNING: no inputs for this output, no segment written\n");
00511 }
00512 else
00513 {
00514 outarr->bzero=segout->bzero;
00515 outarr->bscale=segout->bscale;
00516 status=drms_segment_write(segout, outarr, 0);
00517 nsegments++;
00518 if (status != DRMS_SUCCESS)
00519 {
00520 fprintf(stderr, "ERROR: problem writing output segment: status = %d, T_START = %s, LMIN = %d, LMAX = %d, histrecnum = %lld\n", status, tstartstr, lminout, lmaxout, histrecnum);
00521 drms_close_records(inrecset, DRMS_FREE_RECORD);
00522 drms_close_records(outrecset, DRMS_FREE_RECORD);
00523 return 0;
00524 }
00525 }
00526 drms_free_array(outarr);
00527
00528 drms_copykeys(outrec, inrec, 0, kDRMS_KeyClass_Explicit);
00529
00530 skip2:
00531
00532 drms_setkey_int(outrec, "LMIN", lminout);
00533 drms_setkey_int(outrec, "LMAX", lmaxout);
00534 drms_setkey_time(outrec, "T_START", tstartout);
00535 drms_setkey_time(outrec, "T_STOP", tstopout);
00536 drms_setkey_time(outrec, "T_OBS", tstartout+chunksecs/2);
00537 drms_setkey_int(outrec, "NDT", ndt);
00538
00539 for (i=0;i<16;i++)
00540 calversout=setbits(calversout,4*i+3,4,nybblearrout[i]);
00541 drms_setkey_longlong(outrec, "CALVER64", calversout);
00542
00543 if (noinput || nskip == nrecsin)
00544 drms_setkey_int(outrec, "QUALITY", QUAL_NODATA);
00545 else if (mixflag)
00546 drms_setkey_int(outrec, "QUALITY", QUAL_MIXEDCALVER);
00547 else
00548 drms_setkey_int(outrec, "QUALITY", 0);
00549
00550 tnow = (double)time(NULL);
00551 tnow += UNIX_epoch;
00552 drms_setkey_time(outrec, "DATE", tnow);
00553
00554 nrecords++;
00555
00556 if (verbflag > 1)
00557 {
00558 wt=getwalltime();
00559 ct=getcputime(&ut, &st);
00560 fprintf(stdout, " lchunk %d done: %.2f ms wall time, %.2f ms cpu time\n", lchunk-lchunkfirst,
00561 wt-wt2,
00562 ct-ct2);
00563 }
00564
00565 }
00566
00567 if (verbflag)
00568 {
00569 wt=getwalltime();
00570 ct=getcputime(&ut, &st);
00571 fprintf(stdout, "timechunk %d done: %.2f ms wall time, %.2f ms cpu time\n", iset,
00572 wt-wt1,
00573 ct-ct1);
00574
00575 }
00576
00577 }
00578
00579 for (irecin=0; irecin < nrecsin; irecin++)
00580 if (inarrarr[irecin] != NULL) drms_free_array(inarrarr[irecin]);
00581 free(inarrarr);
00582 free(firstflagarr);
00583
00584 drms_close_records(inrecset, DRMS_FREE_RECORD);
00585 drms_close_records(outrecset, DRMS_INSERT_RECORD);
00586
00587 wt=getwalltime();
00588 ct=getcputime(&ut, &st);
00589 if (verbflag)
00590 {
00591 printf("number of records created = %d\n", nrecords);
00592 printf("number of segments created = %d\n", nsegments);
00593 fprintf(stdout, "total time spent: %.2f ms wall time, %.2f ms cpu time\n",
00594 wt-wt0, ct-ct0);
00595 }
00596
00597 printf("module %s successful completion\n", cmdparams.argv[0]);
00598
00599 return 0;
00600
00601 }