(file) Return to jretile_manytofew.c CVS log (file) (dir) Up to [Development] / JSOC / proj / globalhs / apps

Diff for /JSOC/proj/globalhs/apps/jretile_manytofew.c between version 1.4 and 1.7

version 1.4, 2012/09/20 17:33:45 version 1.7, 2013/07/02 20:33:38
Line 1 
Line 1 
 #define MODES(L)        ((((L)+1)*(L))/2)  char *cvsinfo_jretile_manytofew = "cvsinfo: $Header$";
 #define MINIMUM(X,Y)    (((X)<(Y))?(X):(Y))  
 #define MAXIMUM(X,Y)    (((X)>(Y))?(X):(Y))  
  
 int jretile_manytofew(void) int jretile_manytofew(void)
 { {
Line 31  int jretile_manytofew(void)
Line 29  int jretile_manytofew(void)
   int mapmmax=-1;   int mapmmax=-1;
   int sinbdivs=-1;   int sinbdivs=-1;
   double cadence=0;   double cadence=0;
     int i;
  
   TIME tnow, UNIX_epoch = -220924792.000; /* 1970.01.01_00:00:00_UTC */   TIME tnow, UNIX_epoch = -220924792.000; /* 1970.01.01_00:00:00_UTC */
   char tstartstr[100], tscrstr[100];   char tstartstr[100], tscrstr[100];
Line 68  int jretile_manytofew(void)
Line 67  int jretile_manytofew(void)
     lifetime = DRMS_PERMANENT;     lifetime = DRMS_PERMANENT;
   else   else
     lifetime = DRMS_TRANSIENT;     lifetime = DRMS_TRANSIENT;
     unsigned short calverkey = (unsigned short)cmdparams_save_int(&cmdparams, "CALVERKEY", &newstat);
  
   char *histlinkname = (char *)cmdparams_save_str(&cmdparams, "histlink", &newstat);   char *histlinkname = (char *)cmdparams_save_str(&cmdparams, "histlink", &newstat);
  
Line 121  int jretile_manytofew(void)
Line 121  int jretile_manytofew(void)
   }   }
  
 // set up ancillary dataseries for processing metadata // set up ancillary dataseries for processing metadata
   char *cvsinfo = strdup("$Header$");  //  char *cvsinfo = strdup("$Header$");
   DRMS_Link_t *histlink = hcon_lookup_lower(&tempoutrec->links, histlinkname);   DRMS_Link_t *histlink = hcon_lookup_lower(&tempoutrec->links, histlinkname);
   if (histlink != NULL)   if (histlink != NULL)
   {   {
     histrecnum=set_history(histlink, cvsinfo);      histrecnum=set_history(histlink);
     if (histrecnum < 0)     if (histrecnum < 0)
     {     {
       drms_close_record(tempoutrec, DRMS_FREE_RECORD);       drms_close_record(tempoutrec, DRMS_FREE_RECORD);
Line 210  int jretile_manytofew(void)
Line 210  int jretile_manytofew(void)
     fprintf(stderr, "ERROR: problem opening input recordset: status = %d\n", status);     fprintf(stderr, "ERROR: problem opening input recordset: status = %d\n", status);
     return 1;     return 1;
   }   }
   nrecsin = inrecset->n;  //  nrecsin = inrecset->n;
     nrecsin = drms_count_records(drms_env, inrecquery, &status);
     if (status != DRMS_SUCCESS)
     {
       fprintf(stderr, "ERROR: problem counting input records: status = %d, nrecs = %d\n", status, nrecsin);
       return 1;
     }
  
   if (verbflag)   if (verbflag)
     printf("input recordset opened, nrecs = %d\n", nrecsin);     printf("input recordset opened, nrecs = %d\n", nrecsin);
Line 287  int jretile_manytofew(void)
Line 293  int jretile_manytofew(void)
     return 1;     return 1;
   }   }
  
   long long calversout, calvers;    unsigned long long calversout, calvers;
   int calversunset=1;    int fixflagarr[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
     for (i=0;i<16;i++)
     {
       if (getbits(calverkey,i,1))
         fixflagarr[i]=1;
     }
   
     unsigned int *nybblearrout = (unsigned int *)malloc(16*nrecsout*sizeof(unsigned int));
     int *mixflagarr    = (int *)calloc(16*nrecsout,sizeof(int));
     int *calverssetarr = (int *)calloc(16*nrecsout,sizeof(int));
     unsigned long long *calversoutarr = (unsigned long long *)malloc(nrecsout*sizeof(unsigned long long));
  
   int firsttimethrough=1;   int firsttimethrough=1;
   int *nskiparr=(int *)calloc(nrecsout,sizeof(int));   int *nskiparr=(int *)calloc(nrecsout,sizeof(int));
Line 302  int jretile_manytofew(void)
Line 318  int jretile_manytofew(void)
     lmaxin=drms_getkey_int(inrec, "LMAX", &status);     lmaxin=drms_getkey_int(inrec, "LMAX", &status);
     tstepin=tstopin-tstartin;     tstepin=tstopin-tstartin;
  
       if (verbflag > 1)
       {
         sprint_time(tscrstr, tstartin, "TAI", 0);
         printf("processing input %d, tstart = %s, lmin = %d, lmax = %d\n", irecin, tscrstr, lminin, lmaxin);
       }
   
     quality=drms_getkey_int(inrec, "QUALITY", &status);     quality=drms_getkey_int(inrec, "QUALITY", &status);
     if (status != DRMS_SUCCESS || (quality & QUAL_NODATA)) //may want stricter test on quality here     if (status != DRMS_SUCCESS || (quality & QUAL_NODATA)) //may want stricter test on quality here
     {     {
       if (verbflag > 2)       if (verbflag > 2)
       {       {
         sprint_time(tscrstr, tstartin, "TAI", 0);  //        sprint_time(tscrstr, tstartin, "TAI", 0);
         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",         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",
                                                                       tscrstr, lminin, lmaxin, inrec->recnum, irecin, status, quality);                                                                       tscrstr, lminin, lmaxin, inrec->recnum, irecin, status, quality);
       }       }
Line 317  int jretile_manytofew(void)
Line 339  int jretile_manytofew(void)
 //      continue; //      continue;
     }     }
  
     if (calversunset)  
     {  
       calversout=drms_getkey_longlong(inrec, "CALVER64", &status);  
       if (status != DRMS_SUCCESS)  
         calversout = 0;  
       calversunset=0;  
     }  
   
     calvers=drms_getkey_longlong(inrec, "CALVER64", &status);  
     if (status != DRMS_SUCCESS)  
       calvers = 0;  
   
     if (calvers != calversout)  
     {  
       fprintf(stderr, "ERROR: input data has mixed CALVER64: %lld and %lld, recnum = %lld, histrecnum = %lld\n", calversout, calvers, inrec->recnum, histrecnum);  
       return 0;  
     }  
   
     if (seginflag)     if (seginflag)
       segin = drms_segment_lookup(inrec, segnamein);       segin = drms_segment_lookup(inrec, segnamein);
     else     else
Line 356  int jretile_manytofew(void)
Line 360  int jretile_manytofew(void)
       inptr=(float *)(inarr->data);       inptr=(float *)(inarr->data);
     }     }
  
   
       calvers=drms_getkey_longlong(inrec, "CALVER64", &status);
       if (status != DRMS_SUCCESS)
         calvers = 0;
   
     irecout=0;     irecout=0;
     for (iset=0; iset < ntimechunks; iset++)     for (iset=0; iset < ntimechunks; iset++)
     {     {
Line 376  int jretile_manytofew(void)
Line 385  int jretile_manytofew(void)
           if (histlink != NULL)           if (histlink != NULL)
             drms_setlink_static(outrec, histlinkname,  histrecnum);             drms_setlink_static(outrec, histlinkname,  histrecnum);
           drms_copykeys(outrec, inrec, 0, kDRMS_KeyClass_Explicit);           drms_copykeys(outrec, inrec, 0, kDRMS_KeyClass_Explicit);
 // copykeys takes care of MAPMMAX, SINBDIVS, CALVER64, etc. that should be constant across the input  // copykeys takes care of MAPMMAX, SINBDIVS, etc. that should be constant across the input
           drms_setkey_int(outrec, "LMIN", lminout);           drms_setkey_int(outrec, "LMIN", lminout);
           drms_setkey_int(outrec, "LMAX", lmaxout);           drms_setkey_int(outrec, "LMAX", lmaxout);
           drms_setkey_time(outrec, "T_START", tstartout);           drms_setkey_time(outrec, "T_START", tstartout);
Line 391  int jretile_manytofew(void)
Line 400  int jretile_manytofew(void)
           continue;           continue;
         }         }
  
           int index0 = 16*irecout;
   
           if (!calverssetarr[irecout])
           {
             calversoutarr[irecout]=calvers;
             calverssetarr[irecout]=1;
             for (i=0;i<16;i++)
               nybblearrout[index0 + i]=getbits(calvers,4*i+3,4);
           }
   
           for (i=0;i<16;i++)
           {
             int nybble=getbits(calvers,4*i+3,4);
             if (fixflagarr[i])
             {
               if (nybble != nybblearrout[index0 + i])
               {
                 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);
                 return 0;
               }
             }
             else
             {
               if (nybble < nybblearrout[index0 + i])
                 nybblearrout[index0 + i]=nybble;
             }
           }
   
           if (!mixflagarr[irecout] && (quality & QUAL_MIXEDCALVER || calvers != calversoutarr[irecout]))
             mixflagarr[irecout]=1;
   
         if (segoutflag)         if (segoutflag)
           segout = drms_segment_lookup(outrec, segnameout);           segout = drms_segment_lookup(outrec, segnameout);
         else         else
Line 478  int jretile_manytofew(void)
Line 518  int jretile_manytofew(void)
     {     {
       drms_setkey_int(outrec, "QUALITY", QUAL_NODATA);       drms_setkey_int(outrec, "QUALITY", QUAL_NODATA);
     }     }
       else if (mixflagarr[irecout])
       {
         drms_setkey_int(outrec, "QUALITY", QUAL_MIXEDCALVER);
         nsegments++;
       }
     else     else
     {     {
       drms_setkey_int(outrec, "QUALITY", 0);       drms_setkey_int(outrec, "QUALITY", 0);
       nsegments++;       nsegments++;
     }     }
  
       for (i=0;i<16;i++)
         calversout=setbits(calversout,4*i+3,4,nybblearrout[16*irecout + i]);
       drms_setkey_longlong(outrec, "CALVER64", calversout);
   
     tnow = (double)time(NULL);     tnow = (double)time(NULL);
     tnow += UNIX_epoch;     tnow += UNIX_epoch;
     drms_setkey_time(outrec, "DATE", tnow);     drms_setkey_time(outrec, "DATE", tnow);


Legend:
Removed from v.1.4  
changed lines
  Added in v.1.7

Karen Tian
Powered by
ViewCVS 0.9.4