Index: /branches/eam_branches/ipp-20130307/Ohana/src/dvomerge/include/dvomerge.h
===================================================================
--- /branches/eam_branches/ipp-20130307/Ohana/src/dvomerge/include/dvomerge.h	(revision 35335)
+++ /branches/eam_branches/ipp-20130307/Ohana/src/dvomerge/include/dvomerge.h	(revision 35336)
@@ -36,4 +36,5 @@
 int    REPLACE_BY_PHOTCODE;
 
+char *SINGLE_CPT;
 SkyRegion UserPatch;  // used by MODE CAT
 
@@ -108,5 +109,5 @@
 int  	   dvosecfilt_client_args  PROTO((int *argc, char **argv));
 
-int        dvosecfilt_catalogs     PROTO((SkyTable *insky, int Nsecfilt));
+int        dvosecfilt_catalogs     PROTO((int Nsecfilt));
 int        dvosecfilt_parallel     PROTO((SkyTable *insky, int Nsecfilt));
 
Index: /branches/eam_branches/ipp-20130307/Ohana/src/dvomerge/src/args.c
===================================================================
--- /branches/eam_branches/ipp-20130307/Ohana/src/dvomerge/src/args.c	(revision 35335)
+++ /branches/eam_branches/ipp-20130307/Ohana/src/dvomerge/src/args.c	(revision 35336)
@@ -179,4 +179,28 @@
   }
 
+  SINGLE_CPT = NULL;
+  if ((N = get_argument (*argc, argv, "-cpt"))) {
+    remove_argument (N, argc, argv);
+    SINGLE_CPT = strcreate (argv[N]);
+    remove_argument (N, argc, argv);
+  }
+
+  /* specify portion of the sky : allow default of all sky? */
+  UserPatch.Rmin = 0;
+  UserPatch.Rmax = 360;
+  UserPatch.Dmin = -90;
+  UserPatch.Dmax = +90;
+  if ((N = get_argument (*argc, argv, "-region"))) {
+    remove_argument (N, argc, argv);
+    UserPatch.Rmin = atof (argv[N]);
+    remove_argument (N, argc, argv);
+    UserPatch.Rmax = atof (argv[N]);
+    remove_argument (N, argc, argv);
+    UserPatch.Dmin = atof (argv[N]);
+    remove_argument (N, argc, argv);
+    UserPatch.Dmax = atof (argv[N]);
+    remove_argument (N, argc, argv);
+  } 
+
   PARALLEL = FALSE;
   if ((N = get_argument (*argc, argv, "-parallel"))) {
@@ -219,4 +243,28 @@
   PARALLEL_SERIAL = FALSE;
 
+  SINGLE_CPT = NULL;
+  if ((N = get_argument (*argc, argv, "-cpt"))) {
+    remove_argument (N, argc, argv);
+    SINGLE_CPT = strcreate (argv[N]);
+    remove_argument (N, argc, argv);
+  }
+
+  /* specify portion of the sky : allow default of all sky? */
+  UserPatch.Rmin = 0;
+  UserPatch.Rmax = 360;
+  UserPatch.Dmin = -90;
+  UserPatch.Dmax = +90;
+  if ((N = get_argument (*argc, argv, "-region"))) {
+    remove_argument (N, argc, argv);
+    UserPatch.Rmin = atof (argv[N]);
+    remove_argument (N, argc, argv);
+    UserPatch.Rmax = atof (argv[N]);
+    remove_argument (N, argc, argv);
+    UserPatch.Dmin = atof (argv[N]);
+    remove_argument (N, argc, argv);
+    UserPatch.Dmax = atof (argv[N]);
+    remove_argument (N, argc, argv);
+  } 
+
   HOST_ID = 0;
   if ((N = get_argument (*argc, argv, "-hostID"))) {
Index: /branches/eam_branches/ipp-20130307/Ohana/src/dvomerge/src/dvosecfilt.c
===================================================================
--- /branches/eam_branches/ipp-20130307/Ohana/src/dvomerge/src/dvosecfilt.c	(revision 35335)
+++ /branches/eam_branches/ipp-20130307/Ohana/src/dvomerge/src/dvosecfilt.c	(revision 35336)
@@ -12,9 +12,5 @@
   int Nsecfilt = atoi(argv[2]);
 
-  // load the sky table for the existing database
-  SkyTable *insky = SkyTableLoadOptimal (CATDIR, NULL, NULL, FALSE, SKY_DEPTH_HST, VERBOSE);
-  SkyTableSetFilenames (insky, CATDIR, "cpt");
-
-  dvosecfilt_catalogs (insky, Nsecfilt);
+  dvosecfilt_catalogs (Nsecfilt);
 
   exit (0);
Index: /branches/eam_branches/ipp-20130307/Ohana/src/dvomerge/src/dvosecfilt_catalogs.c
===================================================================
--- /branches/eam_branches/ipp-20130307/Ohana/src/dvomerge/src/dvosecfilt_catalogs.c	(revision 35335)
+++ /branches/eam_branches/ipp-20130307/Ohana/src/dvomerge/src/dvosecfilt_catalogs.c	(revision 35336)
@@ -1,5 +1,5 @@
 # include "dvomerge.h"
 
-int dvosecfilt_catalogs (SkyTable *insky, int Nsecfilt) {
+int dvosecfilt_catalogs (int Nsecfilt) {
 
   off_t i, j, k, NsecInput, Nstart;
@@ -7,21 +7,33 @@
   SecFilt *insec, *outsec;
   char filename[DVO_MAX_PATH];
+  SkyList *skylist;
+
+  SkyTable *sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, FALSE, SKY_DEPTH_HST, VERBOSE);
+  SkyTableSetFilenames (sky, CATDIR, "cpt");
 
   if (PARALLEL && !HOST_ID) {
-    int status = dvosecfilt_parallel (insky, Nsecfilt);
+    int status = dvosecfilt_parallel (sky, Nsecfilt);
     return status;
   }
 
+  // determine the populated SkyRegions overlapping the requested area (default depth)
+  if (SINGLE_CPT) {
+      skylist = SkyRegionByCPT (sky, SINGLE_CPT);
+  } else {
+      skylist = SkyListByPatch (sky, -1, &UserPatch);
+  }
+  myAssert (skylist, "ooops!");
+
   // loop over all input catalogs
-  for (i = 0; i < insky[0].Nregions; i++) {
-    if (!insky[0].regions[i].table) continue;
-    if (VERBOSE) fprintf (stderr, "table: %s\n", insky[0].regions[i].name);
+  for (i = 0; i < skylist->Nregions; i++) {
+    if (!skylist->regions[i]->table) continue;
+    if (VERBOSE) fprintf (stderr, "table: %s\n", skylist->regions[i]->name);
 
     // does this host ID match the desired location for the table?
-    if (!HostTableTestHost(&insky[0].regions[i], HOST_ID)) continue;
+    if (!HostTableTestHost(skylist->regions[i], HOST_ID)) continue;
 
     char hostfile[1024];
-    snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, insky[0].regions[i].name);
-    catalog.filename  = HOST_ID ? hostfile : insky[0].filename[i];
+    snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, skylist->regions[i]->name);
+    catalog.filename  = HOST_ID ? hostfile : skylist->filename[i];
 
     // always load all of the data (if any exists)
@@ -31,5 +43,5 @@
     catalog.catmode   = dvo_catalog_catmode (CATMODE);      // set the default catmode from config data
 
-    if (!dvo_catalog_open (&catalog, &insky[0].regions[i], VERBOSE, "w")) {
+    if (!dvo_catalog_open (&catalog, skylist->regions[i], VERBOSE, "w")) {
 	fprintf (stderr, "ERROR: failure to open catalog file %s\n", filename);
 	exit (2);
@@ -77,5 +89,5 @@
 
 // launch the dvosecfilt_client jobs to the parallel hosts
-int dvosecfilt_parallel (SkyTable *insky, int Nsecfilt) {
+int dvosecfilt_parallel (SkyTable *sky, int Nsecfilt) {
 
   // ensure that the paths are absolute path names
@@ -83,7 +95,7 @@
 
   // load the list of hosts
-  HostTable *table = HostTableLoad (CATDIR, insky->hosts);
+  HostTable *table = HostTableLoad (CATDIR, sky->hosts);
   if (!table) {
-    fprintf (stderr, "ERROR: failure reading Host Table %s for database %s\n", insky->hosts, CATDIR);
+    fprintf (stderr, "ERROR: failure reading Host Table %s for database %s\n", sky->hosts, CATDIR);
     exit (1);
   }    
@@ -99,10 +111,12 @@
     // options / arguments that can affect relastro_client -update-objects:
     char command[DVO_MAX_PATH];
-    snprintf (command, DVO_MAX_PATH, "dvosecfilt_client %s %d -hostID %d -hostdir %s", 
-	      abscatdir, Nsecfilt, table->hosts[i].hostID, table->hosts[i].pathname
+    snprintf (command, DVO_MAX_PATH, "dvosecfilt_client %s %d -hostID %d -hostdir %s -region %f %f %f %f", 
+	      abscatdir, Nsecfilt, table->hosts[i].hostID, table->hosts[i].pathname, 
+	      UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax
       );
 
     char tmpline[DVO_MAX_PATH];
-    if (VERBOSE)         { snprintf (tmpline, DVO_MAX_PATH, "%s -v", command); strcpy (command, tmpline); }
+    if (VERBOSE)    { snprintf (tmpline, DVO_MAX_PATH, "%s -v",      command);             strcpy (command, tmpline); }
+    if (SINGLE_CPT) { snprintf (tmpline, DVO_MAX_PATH, "%s -cpt %s", command, SINGLE_CPT); strcpy (command, tmpline); }
 
     fprintf (stderr, "command: %s\n", command);
Index: /branches/eam_branches/ipp-20130307/Ohana/src/dvomerge/src/dvosecfilt_client.c
===================================================================
--- /branches/eam_branches/ipp-20130307/Ohana/src/dvomerge/src/dvosecfilt_client.c	(revision 35335)
+++ /branches/eam_branches/ipp-20130307/Ohana/src/dvomerge/src/dvosecfilt_client.c	(revision 35336)
@@ -12,9 +12,5 @@
   int Nsecfilt = atoi(argv[2]);
 
-  // load the sky table for the existing database
-  SkyTable *insky = SkyTableLoadOptimal (CATDIR, NULL, NULL, FALSE, SKY_DEPTH_HST, VERBOSE);
-  SkyTableSetFilenames (insky, CATDIR, "cpt");
-
-  dvosecfilt_catalogs (insky, Nsecfilt);
+  dvosecfilt_catalogs (Nsecfilt);
 
   exit (0);
Index: /branches/eam_branches/ipp-20130307/Ohana/src/dvomerge/test/dvosecfilt.parallel.sh
===================================================================
--- /branches/eam_branches/ipp-20130307/Ohana/src/dvomerge/test/dvosecfilt.parallel.sh	(revision 35336)
+++ /branches/eam_branches/ipp-20130307/Ohana/src/dvomerge/test/dvosecfilt.parallel.sh	(revision 35336)
@@ -0,0 +1,9 @@
+#!/bin/csh -f
+
+ rm -rf catdir.merge
+ rm -rf catdir.merge.p?
+ rsync -auv catdir.2mass/ catdir.merge/
+ cp HostTable.dat catdir.merge/
+ dvodist -out catdir.merge
+ dvomerge -parallel catdir.grizy into catdir.merge
+ dvosecfilt -parallel catdir.merge 10
