IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 20, 2012, 3:18:25 PM (14 years ago)
Author:
eugene
Message:

convert avextract to parallel form

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/avextract.c

    r31450 r33314  
    11# include "dvoshell.h"
     2
     3int HostTableLaunchJobs (HostTable *table, char *basecmd);
     4Vector **MergeVectors (Vector **vec, int *Nvec, Vector **invec, int Ninvec);
     5int HostTableParallelOps (int argc, char **argv, char *ResultFile);
    26
    37int avextract (int argc, char **argv) {
     
    3741  }
    3842
     43  int PARALLEL = FALSE;
     44  if ((N = get_argument (argc, argv, "-parallel"))) {
     45    remove_argument (N, &argc, argv);
     46    PARALLEL = TRUE;
     47  }
     48
     49  // dump results directly to fits file (esp for parallel dvo)
     50  char *ResultFile = NULL;
     51  if ((N = get_argument (argc, argv, "-result"))) {
     52    remove_argument (N, &argc, argv);
     53    ResultFile = strcreate(argv[N]);
     54    remove_argument (N, &argc, argv);
     55  }
     56
    3957  dvo_catalog_init (&catalog, TRUE);
    4058
     
    4361  Nsecfilt = GetPhotcodeNsecfilt ();
    4462
    45   // parse skyregion options
     63  // parse skyregion options.  NOTE: this is stripped off in parallel operation and always
     64  // defined for the client via the -skyregion option.  The dvo_client parses this
     65  // argument in the main program, before it is passed to the command (like mextract)
    4666  if ((selection = SetRegionSelection (&argc, argv)) == NULL) {
    4767    print_error();
    4868    goto escape;
     69  }
     70
     71  // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results
     72  if (PARALLEL && !HOST_ID) {
     73    // not all parallel ops need to set the region selection...
     74    if (!SetSkyRegions (selection)) goto escape;
     75
     76    int status = HostTableParallelOps (argc, argv, ResultFile);
     77    return status;
    4978  }
    5079
     
    114143  interrupt = FALSE;
    115144  for (i = 0; (i < skylist[0].Nregions) && !interrupt; i++) {
     145    // parallel case, wrong client
     146    if (HOST_ID && (HOST_ID != skylist[0].regions[i]->hostID)) continue;
     147
    116148    /* lock, load, unlock catalog */
    117     catalog.filename = skylist[0].filename[i];
     149    char hostfile[1024];
     150    snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, skylist[0].regions[i]->name);
     151    catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i];
    118152    catalog.catflags = LOAD_AVES | LOAD_SECF;
    119153    if (needMeasures) {
     
    169203  interrupt = FALSE;
    170204  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     }
     205    ResetVector (vec[n], fields[n].type, Npts);
     206  }
     207
     208  // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere)
     209  if (ResultFile) {
     210    int status = WriteVectorTableFITS (ResultFile, "RESULT", vec, Nreturn, FALSE, NULL);
     211    if (!status) goto escape;
    177212  }
    178213
Note: See TracChangeset for help on using the changeset viewer.