Index: /branches/eam_branches/ipp-20130509/Ohana/src/uniphot/Makefile
===================================================================
--- /branches/eam_branches/ipp-20130509/Ohana/src/uniphot/Makefile	(revision 35705)
+++ /branches/eam_branches/ipp-20130509/Ohana/src/uniphot/Makefile	(revision 35706)
@@ -1,3 +1,3 @@
-default: uniphot setphot setphot_client setfwhm setposangle setposangle_client setastrom setastrom_client fiximids fiximids_client fixstkids fixstkids_client
+default: uniphot setphot setphot_client setfwhm setposangle setposangle_client setastrom setastrom_client fiximids fiximids_client fixstkids fixstkids_client ckids ckids_client
 help:
 @echo "make options: uniphot setphot setfwhm default help install default (uniphot setphot setfwhm)"
@@ -29,6 +29,8 @@
 fixstkids: $(BIN)/fixstkids.$(ARCH)
 fixstkids_client: $(BIN)/fixstkids_client.$(ARCH)
-
-install: $(DESTBIN)/uniphot $(DESTBIN)/setfwhm $(DESTBIN)/setphot $(DESTBIN)/setphot_client $(DESTBIN)/setposangle $(DESTBIN)/setposangle_client $(DESTBIN)/setastrom $(DESTBIN)/setastrom_client $(DESTBIN)/fiximids $(DESTBIN)/fiximids_client $(DESTBIN)/fixstkids $(DESTBIN)/fixstkids_client
+ckids: $(BIN)/ckids.$(ARCH)
+ckids_client: $(BIN)/ckids_client.$(ARCH)
+
+install: $(DESTBIN)/uniphot $(DESTBIN)/setfwhm $(DESTBIN)/setphot $(DESTBIN)/setphot_client $(DESTBIN)/setposangle $(DESTBIN)/setposangle_client $(DESTBIN)/setastrom $(DESTBIN)/setastrom_client $(DESTBIN)/fiximids $(DESTBIN)/fiximids_client $(DESTBIN)/fixstkids $(DESTBIN)/fixstkids_client $(DESTBIN)/ckids $(DESTBIN)/ckids_client
 
 UNIPHOT = \
@@ -194,2 +196,20 @@
 $(BIN)/fixstkids_client.$(ARCH): $(FIXSTKIDS_CLIENT)
 
+CKIDS = \
+$(SRC)/ckids.$(ARCH).o	         \
+$(SRC)/initialize_ckids.$(ARCH).o     \
+$(SRC)/update_dvo_ckids.$(ARCH).o     \
+$(SRC)/update_catalog_ckids.$(ARCH).o
+
+$(CKIDS): $(INC)/ckids.h
+$(BIN)/ckids.$(ARCH): $(CKIDS)
+
+CKIDS_CLIENT = \
+$(SRC)/ckids_client.$(ARCH).o	 \
+$(SRC)/initialize_ckids.$(ARCH).o     \
+$(SRC)/update_dvo_ckids.$(ARCH).o     \
+$(SRC)/update_catalog_ckids.$(ARCH).o
+
+$(CKIDS_CLIENT): $(INC)/ckids.h
+$(BIN)/ckids_client.$(ARCH): $(CKIDS_CLIENT)
+
Index: /branches/eam_branches/ipp-20130509/Ohana/src/uniphot/include/ckids.h
===================================================================
--- /branches/eam_branches/ipp-20130509/Ohana/src/uniphot/include/ckids.h	(revision 35706)
+++ /branches/eam_branches/ipp-20130509/Ohana/src/uniphot/include/ckids.h	(revision 35706)
@@ -0,0 +1,35 @@
+# include <ohana.h>
+# include <dvo.h>
+# include <signal.h>
+
+/* global variables set in parameter file */
+# define DVO_MAX_PATH 1024
+char         ImageCat[DVO_MAX_PATH];
+char        *CATDIR;
+int          HOST_ID;
+char        *HOSTDIR;
+char        *SINGLE_CPT;
+int          VERBOSE;
+int          UPDATE;
+int          PARALLEL;
+int          PARALLEL_MANUAL;
+int          PARALLEL_SERIAL;
+
+SkyRegion    UserPatch;
+
+/***** prototypes ****/
+int           main                              PROTO((int argc, char **argv));
+void          ConfigInit                        PROTO((int *argc, char **argv));
+
+void          usage_ckids                       PROTO(());
+void          initialize_ckids                  PROTO((int argc, char **argv));
+int           args_ckids                        PROTO((int argc, char **argv));
+					            
+void          usage_ckids_client                PROTO(());
+void          initialize_ckids_client           PROTO((int argc, char **argv));
+int           args_ckids_client                 PROTO((int argc, char **argv));
+
+int           update_dvo_ckids                  PROTO(());
+int           update_dvo_ckids_parallel         PROTO((SkyList *sky));
+					            
+void          update_catalog_ckids              PROTO((Catalog *catalog));
Index: /branches/eam_branches/ipp-20130509/Ohana/src/uniphot/src/ckids.c
===================================================================
--- /branches/eam_branches/ipp-20130509/Ohana/src/uniphot/src/ckids.c	(revision 35706)
+++ /branches/eam_branches/ipp-20130509/Ohana/src/uniphot/src/ckids.c	(revision 35706)
@@ -0,0 +1,20 @@
+# include "ckids.h"
+
+int main (int argc, char **argv) {
+
+  int status;
+
+  /* get configuration info, args, lockfile */
+  initialize_ckids (argc, argv);
+
+  status = update_dvo_ckids ();
+
+  if (!status) exit (1);
+  exit (0);
+}
+  
+
+/* ckids : check for duplicate IDs for measurements in the db
+   ** load catalogs 
+   ** count duplicate detections
+ */
Index: /branches/eam_branches/ipp-20130509/Ohana/src/uniphot/src/ckids_client.c
===================================================================
--- /branches/eam_branches/ipp-20130509/Ohana/src/uniphot/src/ckids_client.c	(revision 35706)
+++ /branches/eam_branches/ipp-20130509/Ohana/src/uniphot/src/ckids_client.c	(revision 35706)
@@ -0,0 +1,19 @@
+# include "ckids.h"
+
+// ckids_client is run on a remote host and is responsible for updating the catalogs
+// owned by that host.  
+
+// ckids_client -hostname (hostname) -catdir (catdir) -hostdir (hostdir)
+// load the SkyTable and HostTable from (catdir) [contains the host responsibilities]
+// loop over tables from SkyTable with my host ID
+// the calling program tells the client which host they are (or host ID?); we do not actually have to run this on the real host
+
+int main (int argc, char **argv) {
+
+  // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, IMAGES)
+  initialize_ckids_client (argc, argv);
+
+  update_dvo_ckids ();
+
+  exit (0);
+}
Index: /branches/eam_branches/ipp-20130509/Ohana/src/uniphot/src/initialize_ckids.c
===================================================================
--- /branches/eam_branches/ipp-20130509/Ohana/src/uniphot/src/initialize_ckids.c	(revision 35706)
+++ /branches/eam_branches/ipp-20130509/Ohana/src/uniphot/src/initialize_ckids.c	(revision 35706)
@@ -0,0 +1,265 @@
+# include "ckids.h"
+
+void usage_ckids () {
+    fprintf (stderr, "USAGE: ckids [options]\n");
+    fprintf (stderr, "  options:\n");
+    fprintf (stderr, "    -v : verbose mode\n");
+    fprintf (stderr, "    -cpt n0000/0000.00.cpt : only repair this cpt file \n");
+    fprintf (stderr, "    -region Rmin Rmax Dmin Dmax : only repair this region\n");
+    fprintf (stderr, "    -update : actually write results to detections tables\n");
+    fprintf (stderr, "    -parallel : run in parallel mode\n\n");
+
+    fprintf (stderr, "    -h     : this help list\n");
+    fprintf (stderr, "    -help  : this help list\n");
+    fprintf (stderr, "    --h    : this help list\n");
+    fprintf (stderr, "    --help : this help list\n");
+    
+    fprintf (stderr, "    Note that the dvo db can be specified by -D CATDIR (directory)\n");
+    exit (2);
+}
+
+void initialize_ckids (int argc, char **argv) {
+
+  int N;
+  struct stat statbuffer;
+  char CatdirPhotcodeFile[256];
+
+  if ((N = get_argument (argc, argv, "-h"))) usage_ckids();
+  if ((N = get_argument (argc, argv, "-help"))) usage_ckids();
+  if ((N = get_argument (argc, argv, "--h"))) usage_ckids();
+  if ((N = get_argument (argc, argv, "--help"))) usage_ckids();
+
+  /* are these set correctly? */
+  ConfigInit (&argc, argv);
+  args_ckids (argc, argv);
+
+  if (stat (CATDIR, &statbuffer)) {
+    fprintf (stderr, "error accessing dvo database directory '%s'\n", CATDIR);
+    exit (1);
+  }
+
+  // load the photcode table
+  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
+  if (!LoadPhotcodes (CatdirPhotcodeFile, NULL, FALSE)) {
+    fprintf (stderr, "error loading photcode table %s\n", CatdirPhotcodeFile);
+    exit (1);
+  }
+}
+
+int args_ckids (int argc, char **argv) {
+
+  int N;
+
+  VERBOSE = FALSE;
+  if ((N = get_argument (argc, argv, "-v"))) {
+    VERBOSE = TRUE;
+    remove_argument (N, &argc, argv);
+  }
+
+  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);
+  }
+
+  // region of interest
+  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"))) {
+    PARALLEL = TRUE;
+    remove_argument (N, &argc, argv);
+  }
+  // this is a test mode : rather than launching the remote jobs and waiting for completion,
+  // ckids will simply list the remote command and wait for the user to signal completion
+  PARALLEL_MANUAL = FALSE;
+  if ((N = get_argument (argc, argv, "-parallel-manual"))) {
+    PARALLEL = TRUE; // -parallel-manual implies -parallel
+    PARALLEL_MANUAL = TRUE;
+    remove_argument (N, &argc, argv);
+  }
+  // this is a test mode : rather than launching the ckids_client jobs remotely, they are 
+  // run in serial via 'system'
+  PARALLEL_SERIAL = FALSE;
+  if ((N = get_argument (argc, argv, "-parallel-serial"))) {
+    if (PARALLEL_MANUAL) {
+      fprintf (stderr, "ERROR: cannot mix -parallel-manual and -parallel-serial\n");
+      exit (1);
+    }
+    PARALLEL = TRUE; // -parallel-serial implies -parallel
+    PARALLEL_SERIAL = TRUE;
+    remove_argument (N, &argc, argv);
+  }
+
+  UPDATE = FALSE;
+  if ((N = get_argument (argc, argv, "-update"))) {
+    remove_argument (N, &argc, argv);
+    UPDATE = TRUE;
+  }
+
+  if (argc != 1) usage_ckids();
+
+  return (TRUE);
+}
+
+void usage_ckids_client () {
+  fprintf (stderr, "USAGE: ckids_client -hostID (hostID) -catdir (catdir) -hostdir (hostdir) [options]\n");
+  fprintf (stderr, "  options:\n");
+  fprintf (stderr, "    -v : verbose mode\n");
+  fprintf (stderr, "    -update : actually write results to detections tables\n");
+  exit (2);
+}
+
+void initialize_ckids_client (int argc, char **argv) {
+
+  int N;
+  struct stat statbuffer;
+  char CatdirPhotcodeFile[256];
+
+  if ((N = get_argument (argc, argv, "-h"))) usage_ckids_client();
+  if ((N = get_argument (argc, argv, "-help"))) usage_ckids_client();
+  if ((N = get_argument (argc, argv, "--h"))) usage_ckids_client();
+  if ((N = get_argument (argc, argv, "--help"))) usage_ckids_client();
+
+  SetZeroPoint (25.0); // XXX is this needed?
+  args_ckids_client (argc, argv);
+
+  if (stat (CATDIR, &statbuffer)) {
+    fprintf (stderr, "error accessing dvo database directory '%s'\n", CATDIR);
+    exit (1);
+  }
+
+  // load the photcode table : XXX needed?
+  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
+  if (!LoadPhotcodes (CatdirPhotcodeFile, NULL, FALSE)) {
+    fprintf (stderr, "error loading photcode table %s\n", CatdirPhotcodeFile);
+    exit (1);
+  }
+}
+
+int args_ckids_client (int argc, char **argv) {
+
+  int N;
+
+  VERBOSE = FALSE;
+  if ((N = get_argument (argc, argv, "-v"))) {
+    VERBOSE = TRUE;
+    remove_argument (N, &argc, argv);
+  }
+
+  UPDATE = FALSE;
+  if ((N = get_argument (argc, argv, "-update"))) {
+    remove_argument (N, &argc, argv);
+    UPDATE = TRUE;
+  }
+
+  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);
+  }
+
+  // region of interest
+  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"))) {
+    remove_argument (N, &argc, argv);
+    HOST_ID = atoi (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  if (!HOST_ID) usage_ckids_client();
+
+  HOSTDIR = NULL;
+  if ((N = get_argument (argc, argv, "-hostdir"))) {
+    remove_argument (N, &argc, argv);
+    HOSTDIR = strcreate (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  if (!HOSTDIR) usage_ckids_client();
+
+  if ((N = get_argument (argc, argv, "-catdir"))) {
+    remove_argument (N, &argc, argv);
+    CATDIR = strcreate (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  if (!CATDIR) usage_ckids_client();
+
+  if (argc != 1) usage_ckids_client();
+  return (TRUE);
+}
+
+void GetConfig (char *config, char *field, char *format, int N, void *ptr);
+
+void ConfigInit (int *argc, char **argv) {
+
+  double ZERO_POINT;
+  char  *config, *file;
+
+  /*** load configuration info ***/
+  file = SelectConfigFile (argc, argv, "ptolemy");
+  config = LoadConfigFile (file);
+  if (config == (char *) NULL) {
+    fprintf (stderr, "ERROR: can't find configuration file %s\n", file);
+    if (file != (char *) NULL) free (file);
+    exit (0);
+  }
+  if (VERBOSE) fprintf (stderr, "loaded config file: %s\n", file);
+
+  // force CATDIR to be absolute (so parallel mode will work)
+  char *tmpcatdir = NULL;
+  ALLOCATE (tmpcatdir, char, DVO_MAX_PATH);
+  GetConfig (config, "CATDIR",                 "%s",  0, tmpcatdir);
+  CATDIR = abspath (tmpcatdir, DVO_MAX_PATH);
+  free (tmpcatdir);
+
+  sprintf (ImageCat, "%s/Images.dat", CATDIR);
+
+  ScanConfig (config, "ZERO_PT",                "%lf", 0, &ZERO_POINT);
+  SetZeroPoint (ZERO_POINT);
+
+  free (config);
+  free (file);
+}
+
+void GetConfig (char *config, char *field, char *format, int N, void *ptr) {
+
+  char *status;
+
+  status = ScanConfig (config, field, format, N, ptr);
+  if (status == NULL) {
+    fprintf (stderr, "error in config, cannot find %s\n", field);
+    exit (1);
+  }
+  return;
+}
Index: /branches/eam_branches/ipp-20130509/Ohana/src/uniphot/src/update_catalog_ckids.c
===================================================================
--- /branches/eam_branches/ipp-20130509/Ohana/src/uniphot/src/update_catalog_ckids.c	(revision 35706)
+++ /branches/eam_branches/ipp-20130509/Ohana/src/uniphot/src/update_catalog_ckids.c	(revision 35706)
@@ -0,0 +1,81 @@
+# include "ckids.h"
+void sort_fullIDs (uint64_t *I, int *S, off_t N);
+
+void update_catalog_ckids (Catalog *catalog) {
+
+  // I am looking for duplicate detections based on the image ID + detection ID values
+  // I assume that all duplicate detections land in the same catalog, so I don't have to do a global search
+
+  // 1) make an array (int64) of the full ID (imageID & detID) [I could do this in a 32bit value by finding the max values, but why bother?]
+  // 2) sort the array
+  // 3) identify unique values (count number of duplciates)
+
+  // what do I want in the end?
+  // a) unique[i] == 0, 1, count[j] : (i = 0, Nmeasure) [so I can tell which ones to drop / flag]
+
+  off_t i;
+  uint64_t *fullID;
+  int *seq, *duplicates;
+
+  if (catalog[0].Nmeasure == 0) return;
+
+  Measure *measure = catalog[0].measure;
+  Average *average = catalog[0].average;
+
+  ALLOCATE (fullID, uint64_t, catalog[0].Nmeasure);
+  ALLOCATE (seq,         int, catalog[0].Nmeasure);
+  ALLOCATE (duplicates,  int, catalog[0].Nmeasure);
+
+  memset (duplicates, 0, sizeof(int) * catalog[0].Nmeasure);
+
+  // make an array of the full IDs
+  for (i = 0; i < catalog[0].Nmeasure; i++) {
+   
+    // is an OR faster or a PLUS?
+    fullID[i] = ((uint64_t) (measure[i].imageID) << 32) | (measure[i].detID);
+    seq[i] = i;
+  }
+
+  // sort the array and sequence number
+  sort_fullIDs (fullID, seq, catalog[0].Nmeasure);
+
+  uint64_t current = fullID[0];	      // current unique value
+  int count = 0;		      // number of duplicates for the current unique value
+  duplicates[0] = count;	      // duplicate sequence
+
+  for (i = 1; i < catalog[0].Nmeasure; i++) {
+    if (fullID[i] == current) {
+      count ++;
+    } else {
+      count = 0;
+      current = fullID[i];
+    }
+    duplicates[i] = count;
+  }
+    
+  for (i = 0; i < catalog[0].Nmeasure; i++) {
+    if (!duplicates[i]) continue;
+    off_t j = seq[i];
+    off_t N = measure[j].averef;
+    fprintf (stderr, "duplicate entry "OFF_T_FMT" : 0x%08x 0x%08x : 0x%08x : %10.6f %10.6f\n", j, measure[j].imageID, measure[j].detID, measure[j].objID, average[N].R, average[N].D);
+  }
+
+  return;
+}
+
+// sort fullId vector and an index vector
+void sort_fullIDs (uint64_t *I, int *S, off_t N) {
+
+# define SWAPFUNC(A,B){ uint64_t tmp_i; int tmp_s;	\
+  tmp_i = I[A]; I[A] = I[B]; I[B] = tmp_i; \
+  tmp_s = S[A]; S[A] = S[B]; S[B] = tmp_s; \
+}
+# define COMPARE(A,B)(I[A] < I[B])
+
+  OHANA_SORT (N, COMPARE, SWAPFUNC);
+
+# undef SWAPFUNC
+# undef COMPARE
+
+}
+
Index: /branches/eam_branches/ipp-20130509/Ohana/src/uniphot/src/update_dvo_ckids.c
===================================================================
--- /branches/eam_branches/ipp-20130509/Ohana/src/uniphot/src/update_dvo_ckids.c	(revision 35706)
+++ /branches/eam_branches/ipp-20130509/Ohana/src/uniphot/src/update_dvo_ckids.c	(revision 35706)
@@ -0,0 +1,148 @@
+# include "ckids.h"
+
+int update_dvo_ckids () {
+
+  SkyTable *sky = NULL;
+  SkyList *skylist = NULL;
+  Catalog catalog;
+  off_t i;
+
+  // load the current sky table (layout of all SkyRegions) 
+  sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, FALSE, -1, VERBOSE);
+  SkyTableSetFilenames (sky, CATDIR, "cpt");
+  
+  // 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!");
+
+  if (PARALLEL && !HOST_ID) {
+    update_dvo_ckids_parallel (skylist);
+    return TRUE;
+  }
+
+  // update measurements for each populated catalog
+  for (i = 0; i < skylist[0].Nregions; i++) {
+
+    // does this host ID match the desired location for the table?
+    if (!HostTableTestHost(skylist[0].regions[i], HOST_ID)) continue;
+
+    char localFilename[1024];
+    snprintf (localFilename, 1024, "%s/%s.cpt", HOSTDIR, skylist->regions[i]->name);
+
+    // set up the basic catalog info
+    catalog.filename  = HOST_ID ? localFilename : skylist[0].filename[i];
+    catalog.catformat = DVO_FORMAT_UNDEF; // not needed since we skip empty catalogs
+    catalog.catmode   = DVO_MODE_UNDEF;	  // not needed since we skip empty catalogs
+    catalog.catflags  = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
+    catalog.Nsecfilt  = GetPhotcodeNsecfilt ();
+
+    if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "w")) {
+      fprintf (stderr, "ERROR: failure reading catalog %s\n", catalog.filename);
+      exit (1);
+    }
+    if (!catalog.Naves_disk) {
+      if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename);
+      dvo_catalog_unlock (&catalog);
+      dvo_catalog_free (&catalog);
+      continue;
+    }
+
+    update_catalog_ckids (&catalog);
+
+    if (!UPDATE) {
+      dvo_catalog_unlock (&catalog);
+      dvo_catalog_free (&catalog);
+      continue;
+    }
+    
+    if (VERBOSE) fprintf (stderr, "saving catalog %s\n", catalog.filename);
+    
+    dvo_catalog_save (&catalog, VERBOSE); 
+    dvo_catalog_unlock (&catalog);
+    dvo_catalog_free (&catalog);
+  }
+
+  return (TRUE);
+}      
+
+# define DEBUG 1
+
+int update_dvo_ckids_parallel (SkyList *sky) {
+
+  // now launch the ckids_client jobs to the parallel hosts
+
+  // load the list of hosts
+  HostTable *table = HostTableLoad (CATDIR, sky->hosts);
+
+  int i, j;
+  for (i = 0; i < table->Nhosts; i++) {
+
+    if (sky->Nregions < table->Nhosts) {
+      // do any of the regions want this host?
+      int wantThisHost = FALSE;
+      for (j = 0; j < sky->Nregions; j++) {
+	if (HostTableTestHost (sky->regions[j], table->hosts[i].hostID)) {
+	  wantThisHost = TRUE;
+	  break;
+	}
+      }
+      if (!wantThisHost) {
+	// fprintf (stderr, "skip host %s\n", table->hosts[i].hostname);
+	continue;
+      }
+    }
+
+    // ensure that the paths are absolute path names
+    char *tmppath = abspath (table->hosts[i].pathname, DVO_MAX_PATH);
+    free (table->hosts[i].pathname);
+    table->hosts[i].pathname = tmppath;
+
+    char command[1024];
+    snprintf (command, 1024, "ckids_client -hostID %d -catdir %s -hostdir %s -region %f %f %f %f", 
+	      table->hosts[i].hostID, CATDIR, table->hosts[i].pathname,
+	      UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax);
+
+    char tmpline[1024];
+    if (VERBOSE)     { snprintf (tmpline, 1024, "%s -v",          command);                          strcpy (command, tmpline); }
+    if (SINGLE_CPT)  { snprintf (tmpline, 1024, "%s -cpt %s",     command, SINGLE_CPT);              strcpy (command, tmpline); }
+    if (UPDATE)      { snprintf (tmpline, 1024, "%s -update",     command);                          strcpy (command, tmpline); }
+
+    fprintf (stderr, "command: %s\n", command);
+
+    if (PARALLEL_MANUAL) continue;
+
+    if (PARALLEL_SERIAL) {
+      int status = system (command);
+      if (status) {
+	fprintf (stderr, "ERROR running ckids_client\n");
+	exit (2);
+      }
+    } else {
+      // launch the job on the remote machine (no handshake)
+      int errorInfo = 0;
+      int pid = rconnect ("ssh", table->hosts[i].hostname, command, table->hosts[i].stdio, &errorInfo, FALSE);
+      if (!pid) {
+	if (DEBUG) fprintf (stderr, "failure to start %s (error %d)\n", table->hosts[i].hostname, errorInfo);
+	exit (1);
+      }
+      table->hosts[i].pid = pid; // save for future reference
+    }
+  }
+
+  // wait for the remote jobs to be completed
+  if (PARALLEL_MANUAL) {
+    fprintf (stderr, "run the ckids_client commands above.  when these are done, hit return\n");
+    getchar();
+  }
+  if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) {
+    int status = HostTableWaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE);
+    if (!status) return FALSE;
+  }
+
+  return (TRUE);
+}      
+
