Index: /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/avextract.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/avextract.c	(revision 33313)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/avextract.c	(revision 33314)
@@ -1,3 +1,7 @@
 # include "dvoshell.h"
+
+int HostTableLaunchJobs (HostTable *table, char *basecmd);
+Vector **MergeVectors (Vector **vec, int *Nvec, Vector **invec, int Ninvec);
+int HostTableParallelOps (int argc, char **argv, char *ResultFile);
 
 int avextract (int argc, char **argv) {
@@ -37,4 +41,18 @@
   }
 
+  int PARALLEL = FALSE;
+  if ((N = get_argument (argc, argv, "-parallel"))) {
+    remove_argument (N, &argc, argv);
+    PARALLEL = TRUE;
+  }
+
+  // dump results directly to fits file (esp for parallel dvo)
+  char *ResultFile = NULL;
+  if ((N = get_argument (argc, argv, "-result"))) {
+    remove_argument (N, &argc, argv);
+    ResultFile = strcreate(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
   dvo_catalog_init (&catalog, TRUE);
 
@@ -43,8 +61,19 @@
   Nsecfilt = GetPhotcodeNsecfilt ();
 
-  // parse skyregion options
+  // parse skyregion options.  NOTE: this is stripped off in parallel operation and always
+  // defined for the client via the -skyregion option.  The dvo_client parses this
+  // argument in the main program, before it is passed to the command (like mextract)
   if ((selection = SetRegionSelection (&argc, argv)) == NULL) {
     print_error(); 
     goto escape; 
+  }
+
+  // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results
+  if (PARALLEL && !HOST_ID) {
+    // not all parallel ops need to set the region selection...
+    if (!SetSkyRegions (selection)) goto escape;
+
+    int status = HostTableParallelOps (argc, argv, ResultFile);
+    return status;
   }
 
@@ -114,6 +143,11 @@
   interrupt = FALSE;
   for (i = 0; (i < skylist[0].Nregions) && !interrupt; i++) {
+    // parallel case, wrong client
+    if (HOST_ID && (HOST_ID != skylist[0].regions[i]->hostID)) continue;
+
     /* lock, load, unlock catalog */
-    catalog.filename = skylist[0].filename[i];
+    char hostfile[1024];
+    snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, skylist[0].regions[i]->name);
+    catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i];
     catalog.catflags = LOAD_AVES | LOAD_SECF;
     if (needMeasures) {
@@ -169,10 +203,11 @@
   interrupt = FALSE;
   for (n = 0; n < Nreturn; n++) {
-    vec[n][0].Nelements = Npts;
-    if (vec[n][0].type == OPIHI_FLT) {
-      REALLOCATE (vec[n][0].elements.Flt, opihi_flt, MAX(1,Npts));
-    } else {
-      REALLOCATE (vec[n][0].elements.Int, opihi_int, MAX(1,Npts));
-    }
+    ResetVector (vec[n], fields[n].type, Npts);
+  }
+
+  // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere)
+  if (ResultFile) {
+    int status = WriteVectorTableFITS (ResultFile, "RESULT", vec, Nreturn, FALSE, NULL);
+    if (!status) goto escape;
   }
 
Index: /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/mextract.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/mextract.c	(revision 33313)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/mextract.c	(revision 33314)
@@ -1,5 +1,5 @@
 # include "dvoshell.h"
 
-# define DEBUG 1
+# define DEBUG 0
 # define PARALLEL_MANUAL 0
 # define PARALLEL_SERIAL 0
@@ -60,8 +60,15 @@
   dvo_catalog_init (&catalog, TRUE);
 
+  /* load photcode information */
+  if (!InitPhotcodes ()) goto escape;
+  Nsecfilt = GetPhotcodeNsecfilt ();
+  
   // parse skyregion options.  NOTE: this is stripped off in parallel operation and always
   // defined for the client via the -skyregion option.  The dvo_client parses this
   // argument in the main program, before it is passed to the command (like mextract)
-  if ((selection = SetRegionSelection (&argc, argv)) == NULL) goto escape;
+  if ((selection = SetRegionSelection (&argc, argv)) == NULL) {
+    print_error();
+    goto escape;
+  }
 
   // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results
@@ -74,12 +81,8 @@
   }
 
-  /* load photcode information */
-  if (!InitPhotcodes ()) goto escape;
-  Nsecfilt = GetPhotcodeNsecfilt ();
-  
   // init locally static variables (time refs)
   dbExtractMeasuresInit();
 
-  // command-line is of the form: avextract field,field, field [where (field op value)...]
+  // command-line is of the form: mextract field,field, field [where (field op value)...]
 
   // parse the fields to be extracted and returned
@@ -156,5 +159,4 @@
 
   for (i = 0; (i < skylist[0].Nregions) && !interrupt; i++) {
-
     // parallel case, wrong client
     if (HOST_ID && (HOST_ID != skylist[0].regions[i]->hostID)) continue;
