IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 19, 2012, 5:24:19 PM (14 years ago)
Author:
mhuber
Message:

merging latest r34040 trunk changes to branch

Location:
branches/meh_branches/ppstack_test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/meh_branches/ppstack_test

  • branches/meh_branches/ppstack_test/Ohana/src/opihi/dvo/avextract.c

    r31450 r34041  
    3737  }
    3838
     39  int VERBOSE2 = FALSE;
     40  if ((N = get_argument (argc, argv, "-vv"))) {
     41    remove_argument (N, &argc, argv);
     42    VERBOSE = TRUE;
     43    VERBOSE2 = TRUE;
     44  }
     45
     46  int PARALLEL = FALSE;
     47  if ((N = get_argument (argc, argv, "-parallel"))) {
     48    remove_argument (N, &argc, argv);
     49    PARALLEL = TRUE;
     50  }
     51
     52  // use remote tables, but not dvo_client..
     53  int PARALLEL_LOCAL = FALSE;
     54  HostTable *table = NULL;
     55  if ((N = get_argument (argc, argv, "-parallel-local"))) {
     56    remove_argument (N, &argc, argv);
     57    PARALLEL_LOCAL = TRUE;
     58
     59    char *CATDIR = GetCATDIR();
     60    if (!CATDIR) {
     61      gprint (GP_ERR, "CATDIR is not set\n");
     62      return FALSE;
     63    }
     64    SkyTable *sky = GetSkyTable();
     65    if (!sky) {
     66      gprint (GP_ERR, "failed to load sky table for database\n");
     67      return FALSE;
     68    }
     69    table = HostTableLoad (CATDIR, sky->hosts);
     70    if (!table) {
     71      gprint (GP_ERR, "ERROR: failure reading Host Table %s for database %s\n", sky->hosts, CATDIR);
     72      return FALSE;
     73    }   
     74  }
     75
     76  // this is used to NOT save the results in the results file
     77  // use this option when mextract is used in a script which does its
     78  // own job of packaging the results
     79  int SKIP_RESULTS = FALSE;
     80  if ((N = get_argument (argc, argv, "-skip-results"))) {
     81    remove_argument (N, &argc, argv);
     82    SKIP_RESULTS = TRUE;
     83  }
     84
    3985  dvo_catalog_init (&catalog, TRUE);
    4086
     
    4389  Nsecfilt = GetPhotcodeNsecfilt ();
    4490
    45   // parse skyregion options
     91  // parse skyregion options.  NOTE: this is stripped off in parallel operation and always
     92  // defined for the client via the -skyregion option.  The dvo_client parses this
     93  // argument in the main program, before it is passed to the command (like mextract)
    4694  if ((selection = SetRegionSelection (&argc, argv)) == NULL) {
    4795    print_error();
    4896    goto escape;
    4997  }
     98
     99  // init locally static variables (time refs)
     100  dbExtractAveragesInit ();
    50101
    51102  // command-line is of the form: avextract field,field, field [where (field op value)...]
     
    85136  /* load region corresponding to selection above */
    86137  if ((skylist = SelectRegions (selection)) == NULL) goto escape;
     138
     139  // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results
     140  if (PARALLEL && !HOST_ID) {
     141    int status = HostTableParallelOps (argc, argv, RESULT_FILE, 0, VERBOSE);
     142
     143    dbFreeFields (fields, Nfields);
     144    dbFreeStack (stack, Nstack);
     145    free (stack);
     146    FreeSkyRegionSelection (selection);
     147    dvo_catalog_free (&catalog);
     148
     149    return status;
     150  }
    87151
    88152  /* create output storage vectors */
     
    114178  interrupt = FALSE;
    115179  for (i = 0; (i < skylist[0].Nregions) && !interrupt; i++) {
     180
     181    // does this host ID match the desired location for the table?
     182    if (!HostTableTestHost(skylist[0].regions[i], HOST_ID)) continue;
     183
    116184    /* lock, load, unlock catalog */
    117     catalog.filename = skylist[0].filename[i];
     185    char hostfile[1024];
     186    if (PARALLEL_LOCAL) {
     187      int hostID = (skylist[0].regions[i]->hostFlags & DATA_USE_BCK) ? skylist[0].regions[i]->backupID : skylist[0].regions[i]->hostID;
     188      int seq = table->index[hostID];
     189      HOSTDIR = table->hosts[seq].pathname;
     190    }
     191    snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, skylist[0].regions[i]->name);
     192    catalog.filename = (HOST_ID || PARALLEL_LOCAL) ? hostfile : skylist[0].filename[i];
    118193    catalog.catflags = LOAD_AVES | LOAD_SECF;
    119     if (needMeasures) {
    120       catalog.catflags |= LOAD_MEAS;
    121     }
     194    catalog.catflags |= needMeasures ? LOAD_MEAS : SKIP_MEAS;
    122195    catalog.Nsecfilt = 0;
    123196
     
    125198     
    126199    // an error exit status here is a significant error
    127     if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {
     200    if (!dvo_catalog_open (&catalog, NULL, VERBOSE2, "r")) {
    128201      gprint (GP_ERR, "ERROR: failure to open catalog file %s\n", catalog.filename);
    129202      exit (2);
     
    137210      m = catalog.average[j].measureOffset;
    138211
    139       // reset counters for saved fields, extract fields
    140       dbExtractAveragesInit ();
     212      dbExtractAveragesInitAve ();  // reset counters for saved fields (costs very little)
     213
    141214      for (n = 0; n < Nfields; n++) {
    142215        values[n] = dbExtractAverages (&catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], &fields[n]);
     
    169242  interrupt = FALSE;
    170243  for (n = 0; n < Nreturn; n++) {
    171     vec[n][0].Nelements = Npts;
    172     if (vec[n][0].type == OPIHI_FLT) {
    173       REALLOCATE (vec[n][0].elements.Flt, opihi_flt, MAX(1,Npts));
    174     } else {
    175       REALLOCATE (vec[n][0].elements.Int, opihi_int, MAX(1,Npts));
    176     }
    177   }
    178 
     244    ResetVector (vec[n], fields[n].type, Npts);
     245  }
     246
     247  // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere)
     248  if (RESULT_FILE && !SKIP_RESULTS) {
     249    int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nreturn, FALSE, NULL);
     250    if (!status) {
     251      goto escape;
     252    }
     253  }
     254
     255  if (table) free (table);
    179256  if (vec) free (vec);
    180257  if (values) free (values);
     
    187264
    188265 escape:
     266  if (table) free (table);
    189267  if (vec) free (vec);
    190268  if (values) free (values);
Note: See TracChangeset for help on using the changeset viewer.