Index: /branches/eam_branches/ipp-20111122/Ohana/src/addstar/test/relphot.parallel.dvo
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/addstar/test/relphot.parallel.dvo	(revision 33296)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/addstar/test/relphot.parallel.dvo	(revision 33297)
@@ -114,4 +114,7 @@
   end
 
+  # XXX tmp
+  exec rsync -aub $catdir/ $catdir.raw/
+
   # parallel-ize the database
   mkparallel $catdir
@@ -130,4 +133,6 @@
   # run relphot on the parallel db and check that the images now match the expected values
   exec relphot -parallel-serial g,r,i -v -region 9.5 10.5 19.5 20.5 -D CATDIR $catdir.p0 -D STAR_TOOFEW 1 -D SIGMA_LIM 0.07 -statmode WT_MEAN -cloud-limit 0.5 -keep-ubercal -D IMAGE_OFFSET 0.5 -update >& log.relphot.p0
+
+  exec dvodist -in $catdir.p0
 
   for i 0 mjd_nc[]
Index: /branches/eam_branches/ipp-20111122/Ohana/src/relphot/include/relphot.h
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/relphot/include/relphot.h	(revision 33296)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/relphot/include/relphot.h	(revision 33297)
@@ -100,4 +100,5 @@
 int    PARALLEL;
 int    PARALLEL_MANUAL;
+int    PARALLEL_SERIAL;
 
 int    VERBOSE;
@@ -129,4 +130,6 @@
 int    PLOTDELAY;
 int    UpdateAverages;
+
+char  *PhotcodeList;
 
 int    RELPHOT_GRID_X;
Index: /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/ImageSubset.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/ImageSubset.c	(revision 33296)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/ImageSubset.c	(revision 33297)
@@ -41,10 +41,15 @@
 
   // load data for this header 
-  if (!gfits_load_header (f, &theader)) return (NULL);
+  if (!gfits_load_header (f, &theader)) {
+    fclose (f);
+    return (NULL);
+  }
 
   // read the fits table bytes
-  if (!gfits_fread_ftable_data (f, &ftable, FALSE)) return (NULL);
-  
-  // XXX close the fits file here
+  if (!gfits_fread_ftable_data (f, &ftable, FALSE)) {
+    fclose (f);
+    return (NULL);
+  }
+  fclose (f);
 
   // a bit annoying : we read the entire block of data, then extract the columns, then set the image structure values.
@@ -59,5 +64,5 @@
   GET_COLUMN (flags,   "FLAGS",      int);
   GET_COLUMN (tzero,   "TZERO",      int);
-  GET_COLUMN (trate,   "TRATE",      char);
+  GET_COLUMN (trate,   "TRATE",      short);
 
   // XXX free the fits table data here 
@@ -117,14 +122,14 @@
   float *Mcal, *dMcal;
   unsigned int *imageID, *map, *flags, *tzero;
-  unsigned char *trate;
+  unsigned short *trate;
 
-  // create interme  diate storage arrays
-  ALLOCATE (Mcal,    float, 	   Nimage);
-  ALLOCATE (dMcal,   float, 	   Nimage);
-  ALLOCATE (imageID, unsigned int, Nimage);
-  ALLOCATE (map,     unsigned int, Nimage);
-  ALLOCATE (flags,   unsigned int, Nimage);
-  ALLOCATE (tzero,   unsigned int, Nimage);
-  ALLOCATE (trate,   unsigned char, Nimage);
+  // create intermediate storage arrays
+  ALLOCATE (Mcal,    float, 	     Nimage);
+  ALLOCATE (dMcal,   float, 	     Nimage);
+  ALLOCATE (imageID, unsigned int,   Nimage);
+  ALLOCATE (map,     unsigned int,   Nimage);
+  ALLOCATE (flags,   unsigned int,   Nimage);
+  ALLOCATE (tzero,   unsigned int,   Nimage);
+  ALLOCATE (trate,   unsigned short, Nimage);
 
   // assign the storage arrays
@@ -137,4 +142,5 @@
     tzero[i]   = image[i].tzero;
     trate[i]   = image[i].trate;
+    fprintf (stderr, "time: %d, trate: %d\n", image[i].tzero, image[i].trate);
   }
 
@@ -172,4 +178,7 @@
   gfits_free_table (&ftable);
 
+  fclose (f);
+  fflush (f);
+
   return TRUE;
 }
Index: /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/args.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/args.c	(revision 33296)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/args.c	(revision 33297)
@@ -89,4 +89,16 @@
     remove_argument (N, &argc, argv);
   }
+  // this is a test mode : rather than launching the relphot_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);
+  }
 
   PLOTSTUFF = FALSE;
@@ -112,5 +124,5 @@
   }      
 
-  strcpy (STATMODE, "CHI_INNER_WTMEAN");
+  strcpy (STATMODE, "WT_MEAN");
   if ((N = get_argument (argc, argv, "-statmode"))) {
     remove_argument (N, &argc, argv);
@@ -293,4 +305,6 @@
   // by definition, the client is not parallel 
   PARALLEL = FALSE;
+  PARALLEL_MANUAL = FALSE;
+  PARALLEL_SERIAL = FALSE;
 
   if ((N = get_argument (argc, argv, "-v"))) {
@@ -344,4 +358,11 @@
   if (!MODE) relphot_client_usage();
 
+  strcpy (STATMODE, "WT_MEAN");
+  if ((N = get_argument (argc, argv, "-statmode"))) {
+    remove_argument (N, &argc, argv);
+    strcpy (STATMODE, argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
   /* specify portion of the sky */
   UserPatch.Rmin = 0;
Index: /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/initialize.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/initialize.c	(revision 33296)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/initialize.c	(revision 33297)
@@ -12,5 +12,6 @@
     // load the list of photcodes into the globals (photcodes, Nphotcodes)
     // only a single remaining argument in this mode (the list of photcodes, eg g,r,i)
-    ParsePhotcodeList (argv[1]);
+    PhotcodeList = strcreate (argv[1]);
+    ParsePhotcodeList (PhotcodeList);
   }
   if (USE_GRID && (Nphotcodes > 1)) {
@@ -58,4 +59,6 @@
 void initialize_client (int argc, char **argv) {
 
+  // XXX need to determine which globals can affect relphot_client in either mode and pass appropriately
+
   relphot_client_help (argc, argv);
   ConfigInit (&argc, argv);
@@ -63,5 +66,6 @@
 
   // load the list of photcodes into the globals (photcodes, Nphotcodes)
-  ParsePhotcodeList (argv[1]);
+  PhotcodeList = strcreate (argv[1]);
+  ParsePhotcodeList (PhotcodeList);
 }
 
@@ -80,6 +84,4 @@
   while ((codename = strtok_r (list, ",", &ptr)) != NULL) {
     list = NULL; // pass NULL on successive strtok_r calls
-    fprintf (stderr, "PHOTCODE LIST: %s\n", myList);
-    fprintf (stderr, "codename: %s\n", codename);
     if ((photcodes[Nphotcodes] = GetPhotcodebyName (codename)) == NULL) {
       fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", codename);
Index: /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/load_catalogs.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/load_catalogs.c	(revision 33296)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/load_catalogs.c	(revision 33297)
@@ -76,5 +76,6 @@
 
   fprintf (stderr, "using "OFF_T_FMT" of "OFF_T_FMT" stars ("OFF_T_FMT" of "OFF_T_FMT" measurements)\n", Nstar, Nstar_total, Nmeas, Nmeas_total);
-  if (Nstar < 1) Shutdown ("%s", "ERROR: no stars match the minimum requirements; exiting \n");
+  if (!hostID && (Nstar < 1)) Shutdown ("%s", "ERROR: no stars match the minimum requirements; exiting \n");
+  // in regular relphot, we shutdown here; in relphot_client, we generate and return an empty table (for consistency)
    
 
@@ -108,10 +109,18 @@
 
     char command[1024];
-    snprintf (command, 1024, "relphot_client -test -load %s -hostID %d -catdir %s -hostdir %s", 
-	      catalogFile, table->hosts[i].hostID, CATDIR, table->hosts[i].pathname);
+    snprintf (command, 1024, "relphot_client %s -load %s -hostID %d -D CATDIR %s -hostdir %s", 
+	      PhotcodeList, catalogFile, table->hosts[i].hostID, CATDIR, table->hosts[i].pathname);
 
     fprintf (stderr, "command: %s\n", command);
 
-    if (!PARALLEL_MANUAL) {
+    if (PARALLEL_MANUAL) continue;
+
+    if (PARALLEL_SERIAL) {
+      int status = system (command);
+      if (status) {
+	fprintf (stderr, "ERROR running relphot_client\n");
+	exit (2);
+      }
+    } else {
       // launch the job on the remote machine (no handshake)
       int errorInfo = 0;
Index: /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/reload_catalogs.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/reload_catalogs.c	(revision 33296)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/reload_catalogs.c	(revision 33297)
@@ -134,10 +134,18 @@
 
     char command[1024];
-    snprintf (command, 1024, "relphot_client -reload %s -hostname %s -catdir %s -hostdir %s", 
-	      imageFile, table->hosts[i].hostname, CATDIR, table->hosts[i].pathname);
+    snprintf (command, 1024, "relphot_client %s -update %s -hostID %d -D CATDIR %s -hostdir %s", 
+	      PhotcodeList, imageFile, table->hosts[i].hostID, CATDIR, table->hosts[i].pathname);
 
     fprintf (stderr, "command: %s\n", command);
 
-    if (!PARALLEL_MANUAL) {
+    if (PARALLEL_MANUAL) continue;
+
+    if (PARALLEL_SERIAL) {
+      int status = system (command);
+      if (status) {
+	fprintf (stderr, "ERROR running relphot_client\n");
+	exit (2);
+      }
+    } else {
       // launch the job on the remote machine (no handshake)
       int errorInfo = 0;
