Index: /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/UpdateObjectOffsets.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/UpdateObjectOffsets.c	(revision 37694)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/UpdateObjectOffsets.c	(revision 37695)
@@ -78,4 +78,6 @@
   return (TRUE);
 }
+
+int UpdateObjectOffsets_parallel_group (HostTableGroup *group, SkyList *sky);
 
 // CATDIR is supplied globally
@@ -92,12 +94,31 @@
   }    
 
+  int Ngroups;
+  HostTableGroup *groups = HostTableGroups (table, &Ngroups);
+  // split the table into Ngroups, each with a unique set of machines (this avoids overloading the remote host machines)
+
+  int i;
+  for (i = 0; i < Ngroups; i++) {
+    // update only a group of unique machines at a time
+    UpdateObjectOffsets_parallel_group (&groups[i], sky);
+  }
+
+  return TRUE;
+}      
+
+// CATDIR is supplied globally
+# define DEBUG 1
+int UpdateObjectOffsets_parallel_group (HostTableGroup *group, SkyList *sky) {
+
+  // launch the relastro_client jobs to the parallel hosts
+
   int i, j;
-  for (i = 0; i < table->Nhosts; i++) {
-
-    if (sky->Nregions < table->Nhosts) {
+  for (i = 0; i < group->Nhosts; i++) {
+
+    if (sky->Nregions < group->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)) {
+	if (HostTableTestHost (sky->regions[j], group->hosts[i][0].hostID)) {
 	  wantThisHost = TRUE;
 	  break;
@@ -105,5 +126,5 @@
       }
       if (!wantThisHost) {
-	// fprintf (stderr, "skip host %s\n", table->hosts[i].hostname);
+	// fprintf (stderr, "skip host %s\n", group->hosts[i][0].hostname);
 	continue;
       }
@@ -111,7 +132,7 @@
 
     // 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 *tmppath = abspath (group->hosts[i][0].pathname, DVO_MAX_PATH);
+    free (group->hosts[i][0].pathname);
+    group->hosts[i][0].pathname = tmppath;
 
     // options / arguments that can affect relastro_client -load:
@@ -125,5 +146,5 @@
     char command[1024];
     snprintf (command, 1024, "relastro_client -update-offsets -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -statmode %s -minerror %f", 
-	      table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, STATMODE, MIN_ERROR);
+	      group->hosts[i][0].hostID, CATDIR, group->hosts[i][0].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, STATMODE, MIN_ERROR);
 
     if (FIT_MODE == FIT_PM_ONLY)  	 strextend (command, "-pm");
@@ -184,10 +205,10 @@
       // 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);
+      int pid = rconnect ("ssh", group->hosts[i][0].hostname, command, group->hosts[i][0].stdio, &errorInfo, FALSE);
       if (!pid) {
-	if (DEBUG) fprintf (stderr, "failure to start %s (error %d)\n", table->hosts[i].hostname, errorInfo);
+	if (DEBUG) fprintf (stderr, "failure to start %s (error %d)\n", group->hosts[i][0].hostname, errorInfo);
 	exit (1);
       }
-      table->hosts[i].pid = pid; // save for future reference
+      group->hosts[i][0].pid = pid; // save for future reference
     }
   }
@@ -198,5 +219,5 @@
   }
   if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) {
-    HostTableWaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE);
+    HostTableGroupWaitJobsGetIO (group, __FILE__, __LINE__, VERBOSE);
   }
 
