Index: /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/Makefile
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/Makefile	(revision 33614)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/Makefile	(revision 33615)
@@ -50,4 +50,5 @@
 $(SRC)/fitsed.$(ARCH).o                \
 $(SRC)/gcat.$(ARCH).o		  	\
+$(SRC)/catlist.$(ARCH).o		  	\
 $(SRC)/gimages.$(ARCH).o	  	\
 $(SRC)/gstar.$(ARCH).o		  	\
@@ -72,4 +73,5 @@
 $(SRC)/paverage.$(ARCH).o	  	\
 $(SRC)/procks.$(ARCH).o	  	\
+$(SRC)/remote.$(ARCH).o	  	\
 $(SRC)/skycat.$(ARCH).o	  	\
 $(SRC)/skycoverage.$(ARCH).o	  	\
Index: /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/catlist.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/catlist.c	(revision 33615)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/catlist.c	(revision 33615)
@@ -0,0 +1,105 @@
+# include "dvoshell.h"
+
+// find the catalog files which are in a given region, possibly only by host
+int catlist (int argc, char **argv) {
+  
+  int i, N;
+  struct stat filestat;
+
+  int VERBOSE = FALSE;
+  if ((N = get_argument (argc, argv, "-v"))) {
+    remove_argument (N, &argc, argv);
+    VERBOSE = TRUE;
+  }
+  int ShowAll = FALSE;
+  if ((N = get_argument (argc, argv, "-all"))) {
+    remove_argument (N, &argc, argv);
+    ShowAll = TRUE;
+  }
+  int Depth = -1;
+  if ((N = get_argument (argc, argv, "-depth"))) {
+    remove_argument (N, &argc, argv);
+    Depth = atoi (argv[N]);
+    remove_argument (N, &argc, argv);    
+  }
+  int ThisHost = FALSE;
+  if ((N = get_argument (argc, argv, "-this-host"))) {
+    remove_argument (N, &argc, argv);
+    ThisHost = TRUE;
+  }
+
+  // use remote tables, but not dvo_client..
+  int PARALLEL_LOCAL = FALSE;
+  HostTable *table = NULL;
+  if ((N = get_argument (argc, argv, "-parallel-local"))) {
+    remove_argument (N, &argc, argv);
+    PARALLEL_LOCAL = TRUE;
+  }
+
+  if (argc != 5) {
+    gprint (GP_ERR, "USAGE: catlist Rmin Rmax Dmin Dmax\n");
+    return (FALSE);
+  }
+
+  float Rmin = atof(argv[1]);
+  float Rmax = atof(argv[2]);
+  float Dmin = atof(argv[3]);
+  float Dmax = atof(argv[4]);
+
+  SkyTable *sky = GetSkyTable ();
+  SkyList *skylist = SkyListByBounds (sky, Depth, Rmin, Rmax, Dmin, Dmax);
+  
+  SkyRegion **regions = skylist[0].regions;
+
+
+  if (PARALLEL_LOCAL) {
+    char *CATDIR = GetCATDIR();
+    if (!CATDIR) {
+      gprint (GP_ERR, "CATDIR is not set\n");
+      return FALSE;
+    }
+    table = HostTableLoad (CATDIR, sky->hosts);
+    if (!table) {
+      gprint (GP_ERR, "ERROR: failure reading Host Table %s for database %s\n", sky->hosts, CATDIR);
+      return FALSE;
+    }    
+  }
+
+  int Nregion = 0;
+  for (i = 0; i < skylist[0].Nregions; i++) {
+
+    // skip tables that are not on this host (if -this-host supplied)
+    if (ThisHost && !HostTableTestHost (regions[i], HOST_ID)) continue;
+
+    if (PARALLEL_LOCAL) {
+      int hostID = (skylist[0].regions[i]->hostFlags & DATA_USE_BCK) ? skylist[0].regions[i]->backupID : skylist[0].regions[i]->hostID;
+      int seq = table->index[hostID];
+      HOSTDIR = table->hosts[seq].pathname;
+    }
+    char hostfile[1024];
+    snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, skylist[0].regions[i]->name);
+    char *filename = (HOST_ID || PARALLEL_LOCAL) ? hostfile : skylist[0].filename[i];
+
+    if (ShowAll || (stat (filename, &filestat) != -1)) {
+      if (VERBOSE) gprint (GP_ERR, "%3d %s %6.2f - %6.2f, %6.2f - %6.2f\n", i, regions[i][0].name, 
+			   regions[i][0].Rmin, regions[i][0].Rmax, regions[i][0].Dmin, regions[i][0].Dmax);
+      
+      char name[64], nameRmin[64], nameRmax[64], nameDmin[64], nameDmax[64];
+      snprintf (name, 64, "region:%d", Nregion);
+      snprintf (nameRmin, 64, "region_Rmin:%d", Nregion);
+      snprintf (nameRmax, 64, "region_Rmax:%d", Nregion);
+      snprintf (nameDmin, 64, "region_Dmin:%d", Nregion);
+      snprintf (nameDmax, 64, "region_Dmax:%d", Nregion);
+      set_str_variable (name,     regions[i][0].name);
+      set_variable (nameRmin, regions[i][0].Rmin);
+      set_variable (nameRmax, regions[i][0].Rmax);
+      set_variable (nameDmin, regions[i][0].Dmin);
+      set_variable (nameDmax, regions[i][0].Dmax);
+      Nregion ++;
+    }
+  }
+  set_int_variable ("region:n", Nregion);
+
+  if (table) free (table);
+  return (TRUE);
+}
Index: /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/dvo.c.in
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/dvo.c.in	(revision 33614)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/dvo.c.in	(revision 33615)
@@ -29,4 +29,5 @@
   set_str_variable ("PROMPT", opihi_prompt);
   set_str_variable ("RCFILE", opihi_rcfile);
+  set_int_variable ("DVO_CLIENT", FALSE);
 
   {
Index: /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/dvo_client.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/dvo_client.c	(revision 33614)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/dvo_client.c	(revision 33615)
@@ -28,4 +28,7 @@
     free (modules);
   }
+
+  set_int_variable ("DVO_CLIENT", TRUE);
+  set_int_variable ("SCRIPT", FALSE);
 
   // dvo_client should have 2 standard arguments: -hostID and -hostdir
Index: /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/gcat.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/gcat.c	(revision 33614)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/gcat.c	(revision 33615)
@@ -27,5 +27,5 @@
 
   if ((argc != 3) && (argc != 4)) {
-    gprint (GP_ERR, "USAGE: gcat RA DEC [Radius]\n");
+    gprint (GP_ERR, "USAGE: gcat RA DEC [Radius] [-host] [-backup] [-flags]\n");
     return (FALSE);
   }
Index: /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/hosts.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/hosts.c	(revision 33614)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/hosts.c	(revision 33615)
@@ -74,4 +74,5 @@
 
   if (!strncmp(argv[1], "get.results", MAX(strlen(argv[1]), 3))) {
+    int N;
 
     char *varname = NULL;
Index: /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/init.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/init.c	(revision 33614)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/init.c	(revision 33615)
@@ -23,4 +23,5 @@
 int fitsed          PROTO((int, char **));
 int gcat            PROTO((int, char **));
+int catlist         PROTO((int, char **));
 int getxtra         PROTO((int, char **));
 int gimages         PROTO((int, char **));
@@ -48,4 +49,5 @@
 int paverage        PROTO((int, char **));
 int procks          PROTO((int, char **));
+int remote          PROTO((int, char **));
 int showtile        PROTO((int, char **));
 int skycat          PROTO((int, char **));
@@ -78,4 +80,5 @@
   {1, "fitsed",      fitsed,       "fit stellar SEDs to objects"},
   {1, "gcat",        gcat,         "get catalog at location"},
+  {1, "catlist",     catlist,      "get list of catalogs for region / host"},
   {1, "gimages",     gimages,      "get images at location"},
   {1, "gstar",       gstar,        "get star statistics"},
@@ -101,4 +104,5 @@
   {1, "paverage",    paverage,     "plot average magnitude"},
   {1, "procks",      procks,       "plot rocks"},
+  {1, "remote",      remote,       "generic remote dvo client operation"},
   {1, "showtile",    showtile,     "plot tile pattern"},
   {1, "skycat",      skycat,       "show sky catalog boundaries"},
Index: /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/mextract.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/mextract.c	(revision 33614)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/mextract.c	(revision 33615)
@@ -25,4 +25,5 @@
   selection = NULL;
 
+  fprintf (stderr, "start...");
   if ((N = get_argument (argc, argv, "-h"))) goto help;
   if ((N = get_argument (argc, argv, "--help"))) goto help;
@@ -145,4 +146,6 @@
   interrupt = FALSE;
 
+  fprintf (stderr, "done setup...");
+
   for (i = 0; (i < skylist[0].Nregions) && !interrupt; i++) {
 
@@ -168,4 +171,6 @@
     /* XXX need to call dvo_catalog_chipcoords here passing the loaded images */
 
+    fprintf (stderr, "done read...");
+
     for (j = 0; (j < catalog.Naverage) && !interrupt; j++) {
       m = catalog.average[j].measureOffset;
@@ -175,5 +180,5 @@
       }
 
-      dbExtractMeasuresInitAve (); // reset counters for saved fields 
+      dbExtractMeasuresInitAve (); // reset counters for saved fields (costs very little
 
       for (k = 0; (k < catalog.average[j].Nmeasure); k++, m++) {
@@ -184,5 +189,5 @@
 
 	// extract the relevant values for this measurement
-	dbExtractMeasuresInitMeas (); // reset counters for saved fields 
+	dbExtractMeasuresInitMeas (); // reset counters for saved fields  (costs very little
 	for (n = 0; n < Nfields; n++) {
 	  values[n] = dbExtractMeasures (&catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], &fields[n]);
@@ -218,4 +223,6 @@
   interrupt = FALSE;
 
+  fprintf (stderr, "done load...");
+
   for (n = 0; n < Nreturn; n++) {
     ResetVector (vec[n], fields[n].type, Npts);
@@ -236,4 +243,6 @@
   SkyListFree (skylist);
   FreeSkyRegionSelection (selection);
+
+  fprintf (stderr, "done extr...\n");
   return (TRUE);
 
Index: /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/region_list.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/region_list.c	(revision 33614)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/region_list.c	(revision 33615)
@@ -195,4 +195,5 @@
     sprintf (filename, "%s/%s.cpt", CATDIR, selection->name);
     skylist[0].filename[0] = strcreate (filename);
+    skylist[0].Nregions = 1;
     return (skylist);
   } 
Index: /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/skyregion.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/skyregion.c	(revision 33614)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/skyregion.c	(revision 33615)
@@ -1,21 +1,31 @@
 # include "dvoshell.h"
-
-#ifdef NO_MOVED_TO_DVO
-static double RAs = 0.0;
-static double RAe = 0.0;
-static double DECs = 0.0;
-static double DECe = 0.0;
-#endif
 
 // define the sky region for which extractions are limited
 int skyregion (int argc, char **argv) {
   
+  int N;
+
+  // dvo_client should have 2 standard arguments: -hostID and -hostdir
+  int SaveRegion = FALSE;
+  if ((N = get_argument (argc, argv, "-save"))) {
+    remove_argument (N, &argc, argv);
+    SaveRegion = TRUE;
+  }
+
   if (argc == 1) {
-    double RAs, RAe, DECs, DECe;
-    get_skyregion(&RAs, &RAe, &DECs, &DECe);
+    double Rmin, Rmax, Dmin, Dmax;
+    get_skyregion(&Rmin, &Rmax, &Dmin, &Dmax);
 
-    gprint (GP_ERR, "current skyregion: %f - %f : %f - %f\n", RAs, RAe, DECs, DECe);
-    gprint (GP_ERR, "USAGE:  skyregion (min RA) (max RA) (min DEC) (max DEC)\n");
-    return (FALSE);
+    if (SaveRegion) {
+      set_variable ("Rmin", Rmin);
+      set_variable ("Rmax", Rmax);
+      set_variable ("Dmin", Dmin);
+      set_variable ("Dmax", Dmax);
+      return TRUE;
+    } else {
+      gprint (GP_ERR, "current skyregion: %f - %f : %f - %f\n", Rmin, Rmax, Dmin, Dmax);
+      gprint (GP_ERR, "USAGE:  skyregion (min RA) (max RA) (min DEC) (max DEC)\n");
+      return FALSE;
+    }
   }
 
@@ -29,25 +39,4 @@
   return (TRUE);
 }
-#ifdef NOT_MOVED_TO_LIBDVO
-int get_skyregion (double *Rs, double *Re, double *Ds, double *De) {
-
-  *Rs = RAs;
-  *Re = RAe;
-  *Ds = DECs;
-  *De = DECe;
-
-  return TRUE;
-}
-
-int set_skyregion (double Rs, double Re, double Ds, double De) {
-
-  RAs  = Rs;
-  RAe  = Re;
-  DECs = Ds;
-  DECe = De;
-
-  return TRUE;
-}
-#endif
 
 /* find region which overlaps c at given depth (-1 : populated ) */
Index: /branches/eam_branches/ipp-20111122/Ohana/src/opihi/lib.shell/parse.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/opihi/lib.shell/parse.c	(revision 33614)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/opihi/lib.shell/parse.c	(revision 33615)
@@ -101,5 +101,9 @@
     V1 ++;
     while (isspace (*V1)) V1++;
-    if (*V1 == 0) goto error;
+    if (*V1 == 0) {
+      // assign empty vector
+      set_str_variable (V0, "");
+      goto escape;
+    }
 
     /* command replacement.  execute the line, place answer in val. */
