- Timestamp:
- Jun 19, 2012, 5:24:19 PM (14 years ago)
- Location:
- branches/meh_branches/ppstack_test
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
Ohana/src/opihi/dvo/avextract.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/meh_branches/ppstack_test
- Property svn:mergeinfo changed
-
branches/meh_branches/ppstack_test/Ohana/src/opihi/dvo/avextract.c
r31450 r34041 37 37 } 38 38 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 39 85 dvo_catalog_init (&catalog, TRUE); 40 86 … … 43 89 Nsecfilt = GetPhotcodeNsecfilt (); 44 90 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) 46 94 if ((selection = SetRegionSelection (&argc, argv)) == NULL) { 47 95 print_error(); 48 96 goto escape; 49 97 } 98 99 // init locally static variables (time refs) 100 dbExtractAveragesInit (); 50 101 51 102 // command-line is of the form: avextract field,field, field [where (field op value)...] … … 85 136 /* load region corresponding to selection above */ 86 137 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 } 87 151 88 152 /* create output storage vectors */ … … 114 178 interrupt = FALSE; 115 179 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 116 184 /* 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]; 118 193 catalog.catflags = LOAD_AVES | LOAD_SECF; 119 if (needMeasures) { 120 catalog.catflags |= LOAD_MEAS; 121 } 194 catalog.catflags |= needMeasures ? LOAD_MEAS : SKIP_MEAS; 122 195 catalog.Nsecfilt = 0; 123 196 … … 125 198 126 199 // 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")) { 128 201 gprint (GP_ERR, "ERROR: failure to open catalog file %s\n", catalog.filename); 129 202 exit (2); … … 137 210 m = catalog.average[j].measureOffset; 138 211 139 // reset counters for saved fields, extract fields140 dbExtractAveragesInit (); 212 dbExtractAveragesInitAve (); // reset counters for saved fields (costs very little) 213 141 214 for (n = 0; n < Nfields; n++) { 142 215 values[n] = dbExtractAverages (&catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], &fields[n]); … … 169 242 interrupt = FALSE; 170 243 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); 179 256 if (vec) free (vec); 180 257 if (values) free (values); … … 187 264 188 265 escape: 266 if (table) free (table); 189 267 if (vec) free (vec); 190 268 if (values) free (values);
Note:
See TracChangeset
for help on using the changeset viewer.
