Index: /branches/eam_branches/ipp-20111122/Ohana/src/libdvo/src/HostTable.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/libdvo/src/HostTable.c	(revision 33482)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/libdvo/src/HostTable.c	(revision 33483)
@@ -211,4 +211,6 @@
   // XXX can I set the fd_sets once, since I am not actually closing the fd's?
 
+  int globalStatus = TRUE;
+
   int i;
   int Nmax = 0;
@@ -318,8 +320,10 @@
 	  if (host->status) {
 	    fprintf (stdout, "job failed on %s\n", host->hostname);
+	    globalStatus = FALSE;
 	  }
 	} else {
 	  host->status = -1;
 	  fprintf (stdout, "job exited abnormally on %s\n", host->hostname);
+	  globalStatus = FALSE;
 	  continue;
 	}
@@ -335,4 +339,4 @@
 
 escape:
-  return TRUE;
-}
+  return globalStatus;
+}
Index: /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/BrightCatalog.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/BrightCatalog.c	(revision 33482)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/BrightCatalog.c	(revision 33483)
@@ -102,5 +102,5 @@
       measure[i].photcode  = photcode[i];
     }
-    // fprintf (stderr, "loaded data for %lld measures\n", (long long) Nrow);
+    fprintf (stderr, "loaded data for %lld measure\n", (long long) Nrow);
 
     free (dR      );
@@ -154,5 +154,5 @@
       average[i].catID          = catID[i];
     }
-    fprintf (stderr, "loaded data for %lld averages\n", (long long) Nrow);
+    fprintf (stderr, "loaded data for %lld average\n", (long long) Nrow);
 
     free (R             );
@@ -200,5 +200,5 @@
       secfilt[i].M_80  = M_80[i];
     }
-    fprintf (stderr, "loaded data for %lld averages\n", (long long) Nrow);
+    fprintf (stderr, "loaded data for %lld secfilt\n", (long long) Nrow);
 
     free (M    );
@@ -557,6 +557,6 @@
     dvo_catalog_init (&catalogs->catalog[i], TRUE);
     catalogs->catIDs[i] = 0;
-    catalogs->NAVERAGE[i] = 100;
-    catalogs->NMEASURE[i] = 100;
+    catalogs->NAVERAGE[i] = 256;
+    catalogs->NMEASURE[i] = 256;
     catalogs->catalog[i].Naverage = 0;
     catalogs->catalog[i].Nmeasure = 0;
@@ -591,4 +591,6 @@
 
   int i;
+
+  int D_NCATALOG = 16;
 
   int Nsecfilt = catalogs->Nsecfilt;
@@ -632,5 +634,7 @@
 
     if (catalogs->Ncatalog >= catalogs->NCATALOG) {
-      catalogs->NCATALOG += 16;
+      catalogs->NCATALOG += D_NCATALOG;
+      D_NCATALOG = MAX(2000, 2*D_NCATALOG);
+
       // fprintf (stderr, "realloc catalogs->catalog: old: %llx  ", (long long) catalogs->catalog);
       REALLOCATE (catalogs->catalog, Catalog, catalogs->NCATALOG);
@@ -651,6 +655,6 @@
 	dvo_catalog_init (&catalogs->catalog[j], TRUE);
 	catalogs->catIDs[j] = 0;
-	catalogs->NAVERAGE[j] = 100;
-	catalogs->NMEASURE[j] = 100;
+	catalogs->NAVERAGE[j] = 256;
+	catalogs->NMEASURE[j] = 256;
 	catalogs->catalog[j].Naverage = 0;
 	catalogs->catalog[j].Nmeasure = 0;
@@ -684,5 +688,5 @@
     catalogs->catalog[Nc].Naverage ++;
     if (catalogs->catalog[Nc].Naverage >= catalogs->NAVERAGE[Nc]) {
-      catalogs->NAVERAGE[Nc] += 100;
+      catalogs->NAVERAGE[Nc] += MAX(catalogs->NAVERAGE[Nc], 1024);
       REALLOCATE (catalogs->catalog[Nc].averageT, AverageTiny, catalogs->NAVERAGE[Nc]);
       REALLOCATE (catalogs->catalog[Nc].secfilt,  SecFilt,     catalogs->NAVERAGE[Nc]*Nsecfilt);
@@ -701,5 +705,5 @@
     catalogs->catalog[Nc].Nmeasure ++;
     if (catalogs->catalog[Nc].Nmeasure >= catalogs->NMEASURE[Nc]) {
-      catalogs->NMEASURE[Nc] += 100;
+      catalogs->NMEASURE[Nc] += MAX(catalogs->NMEASURE[Nc], 4096);
       REALLOCATE (catalogs->catalog[Nc].measureT, MeasureTiny, catalogs->NMEASURE[Nc]);
     }	       
Index: /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/bcatalog.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/bcatalog.c	(revision 33482)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/bcatalog.c	(revision 33483)
@@ -4,5 +4,5 @@
   
   off_t i, j, offset;
-  int found, Ns;
+  int found, Ns, *Nvalid;
   off_t NAVERAGE, NMEASURE, Naverage, Nmeasure, Nm;
   float mag;
@@ -27,4 +27,7 @@
   subcatalog[0].filename = catalog[0].filename;
 
+  // array to count measures with photcodes->equiv to each of the secfilts
+  ALLOCATE (Nvalid, int, Nsecfilt);
+
   // flags used by the photometry analysis (excluding UBERCAL)
   unsigned int PHOTOM_FLAGS = 
@@ -44,4 +47,5 @@
     for (j = 0; j < Nsecfilt; j++) {
       subcatalog[0].secfilt[Nsecfilt*Naverage+j] = catalog[0].secfilt[Nsecfilt*i+j];
+      Nvalid[j] = 0; // reset the Nvalid array for this star
     }
 
@@ -86,6 +90,9 @@
       if (!code) continue;
       found = FALSE;
+      int Nsec = -1; // Nsec equivalent for the measurement
       for (Ns = 0; !found && (Ns < Nphotcodes); Ns++) {
-	if (code->equiv == photcodes[Ns][0].code) found = TRUE;
+	if (code->equiv != photcodes[Ns][0].code) continue;
+	found = TRUE;
+	Nsec = GetPhotcodeNsec(code->equiv);
       }
       if (!found) {
@@ -134,4 +141,10 @@
 	if (mag < ImagMin) { Nimag ++; continue; }
 	if (mag > ImagMax) { Nimag ++; continue; }
+      }
+
+      // count this measurement as valid for this secfilt entry
+      if (Nsec > -1) {
+	assert (Nsec < Nsecfilt);
+	Nvalid[Nsec] ++;
       }
 
@@ -162,9 +175,20 @@
 
     // XXXX test : what checks do I need to make elsewhere to avoid problems here?
-    if (Nm <= STAR_TOOFEW) { /* enough measurements in band? */
+    if (Nm <= STAR_TOOFEW) { /* enough measurements total? */
       Nmeasure -= Nm;
       Nfew ++;
       continue; 
     }
+    int anySecfiltGood = FALSE;
+    for (Ns = 0; Ns < Nsecfilt; Ns++) { /* enough measurements in at least one band? */
+      if (Nvalid[Ns] <= STAR_TOOFEW) continue;
+      anySecfiltGood = TRUE;
+    }
+    if (!anySecfiltGood) {
+      Nmeasure -= Nm;
+      Nfew ++;
+      continue; 
+    }
+
     subcatalog[0].averageT[Naverage].Nmeasure = Nm;
     Naverage ++;
Index: /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/select_images.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/select_images.c	(revision 33482)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/select_images.c	(revision 33483)
@@ -267,4 +267,6 @@
   REALLOCATE (line_number, off_t, MAX (nimage, 1));
   free (skycoords);
+  free (RmaxSky);
+  free (index);
 
   *Nimage  = nimage;
Index: /branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/setphot.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/setphot.c	(revision 33482)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/setphot.c	(revision 33483)
@@ -43,12 +43,13 @@
 
   if (!IMAGES_ONLY) {
-    update_dvo_setphot (image, Nimage, &flatcorrTable);
+    status = update_dvo_setphot (image, Nimage, &flatcorrTable);
   }
 
-  // write image table
+  // write image table (even if some remote clients failed)
   if (UPDATE) {
     dvo_image_save (&db, VERBOSE);
   }
 
+  if (!status) exit (1);
   exit (0);
 }
Index: /branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/update_dvo_setphot.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/update_dvo_setphot.c	(revision 33482)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/update_dvo_setphot.c	(revision 33483)
@@ -147,5 +147,6 @@
   }
   if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) {
-    HostTableWaitJobsGetIO (table, __FILE__, __LINE__);
+    int status = HostTableWaitJobsGetIO (table, __FILE__, __LINE__);
+    if (!status) return FALSE;
   }
 
