Index: trunk/Ohana/src/relphot/include/relphot.h
===================================================================
--- trunk/Ohana/src/relphot/include/relphot.h	(revision 38923)
+++ trunk/Ohana/src/relphot/include/relphot.h	(revision 38986)
@@ -14,4 +14,10 @@
 // # define IDX_T off_t
 # define IDX_T int 
+
+typedef enum {
+  STAGE_CHIP  = 0x01,
+  STAGE_WARP  = 0x02,
+  STAGE_STACK = 0x04,
+} RelphotStages;
 
 typedef enum {
@@ -327,4 +333,6 @@
 int USE_BASIC_CHECK;
 int USE_FULL_OVERLAP;
+
+RelphotStages STAGES;
 
 # ifdef GRID_V1
Index: trunk/Ohana/src/relphot/src/Shutdown.c
===================================================================
--- trunk/Ohana/src/relphot/src/Shutdown.c	(revision 38923)
+++ trunk/Ohana/src/relphot/src/Shutdown.c	(revision 38986)
@@ -21,6 +21,4 @@
   va_end (argp);
 
-  SetProtect (TRUE);
-  if (db) gfits_db_close (db);
   fprintf (stderr, "ERROR: relphot halted\n");
   exit (1);
Index: trunk/Ohana/src/relphot/src/args.c
===================================================================
--- trunk/Ohana/src/relphot/src/args.c	(revision 38923)
+++ trunk/Ohana/src/relphot/src/args.c	(revision 38986)
@@ -344,4 +344,22 @@
   }
 
+  STAGES = STAGE_CHIP | STAGE_WARP | STAGE_STACK;
+  if ((N = get_argument (argc, argv, "-skip-chip"))) {
+    remove_argument (N, &argc, argv);
+    STAGES &= ~STAGE_CHIP;
+  }
+  if ((N = get_argument (argc, argv, "-skip-warp"))) {
+    remove_argument (N, &argc, argv);
+    STAGES &= ~STAGE_WARP;
+  }
+  if ((N = get_argument (argc, argv, "-skip-stack"))) {
+    remove_argument (N, &argc, argv);
+    STAGES &= ~STAGE_STACK;
+  }
+  if (!STAGES) {
+    fprintf (stderr, "ERROR: no valid stages selected\n");
+    exit (3);
+  }
+
   REGION_FILE = NULL;
   if ((N = get_argument (argc, argv, "-region-hosts"))) {
@@ -664,4 +682,22 @@
   }
 
+  STAGES = STAGE_CHIP | STAGE_WARP | STAGE_STACK;
+  if ((N = get_argument (argc, argv, "-skip-chip"))) {
+    remove_argument (N, &argc, argv);
+    STAGES &= ~STAGE_CHIP;
+  }
+  if ((N = get_argument (argc, argv, "-skip-warp"))) {
+    remove_argument (N, &argc, argv);
+    STAGES &= ~STAGE_WARP;
+  }
+  if ((N = get_argument (argc, argv, "-skip-stack"))) {
+    remove_argument (N, &argc, argv);
+    STAGES &= ~STAGE_STACK;
+  }
+  if (!STAGES) {
+    fprintf (stderr, "ERROR: no valid stages selected\n");
+    exit (3);
+  }
+
   if ((MODE == MODE_SYNTH_PHOT)  && (argc == 1)) return TRUE;
   if ((MODE == MODE_UPDATE_OBJECTS)  && (argc == 1)) return TRUE;
Index: trunk/Ohana/src/relphot/src/load_catalogs.c
===================================================================
--- trunk/Ohana/src/relphot/src/load_catalogs.c	(revision 38923)
+++ trunk/Ohana/src/relphot/src/load_catalogs.c	(revision 38986)
@@ -253,5 +253,4 @@
   Catalog *catalog = catalogs->catalog;
   *Ncatalog = catalogs->Ncatalog;
-  BrightCatalogSplitFree (catalogs);
 
   int Nmeasure = 0;
@@ -263,4 +262,7 @@
 
   fprintf (stderr, "loaded %d catalogs, using a total of %d stars (%d measures)\n", catalogs->Ncatalog, Naverage, Nmeasure);
+  client_logger_message ("loaded %d catalogs, using a total of %d stars (%d measures)\n", catalogs->Ncatalog, Naverage, Nmeasure);
+
+  BrightCatalogSplitFree (catalogs);
 
   return (catalog);
Index: trunk/Ohana/src/relphot/src/load_images.c
===================================================================
--- trunk/Ohana/src/relphot/src/load_images.c	(revision 38923)
+++ trunk/Ohana/src/relphot/src/load_images.c	(revision 38986)
@@ -31,7 +31,9 @@
   MARKTIME("build chip match for %d images: %f sec\n", (int) Nimage, dtime);
 
+  // XXX consider allowing relphot to skip the AstroMap load (do we need precise astrometry here?)
+
   char mapfile[DVO_MAX_PATH];
   snprintf (mapfile, DVO_MAX_PATH, "%s/AstroMap.fits", CATDIR);
-  AstromOffsetTable *table = AstromOffsetMapLoad (mapfile, VERBOSE);
+  AstromOffsetTable *table = AstromOffsetMapLoad (mapfile, 100000, VERBOSE);
 
   // assign images.coords.offsetMap -> table->map[i]
Index: trunk/Ohana/src/relphot/src/reload_catalogs.c
===================================================================
--- trunk/Ohana/src/relphot/src/reload_catalogs.c	(revision 38923)
+++ trunk/Ohana/src/relphot/src/reload_catalogs.c	(revision 38986)
@@ -105,6 +105,8 @@
     free (moddate);
 
-    dvo_catalog_save (&catalog, VERBOSE); 
-    dvo_catalog_unlock (&catalog);
+    SetProtect (TRUE);
+    if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); }
+    if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); }
+    SetProtect (FALSE);
 
     free_tiny_values(&catalog);
@@ -244,4 +246,8 @@
     if (SYNTH_ZERO_POINTS) { strextend (&command, "-synthphot-zpts %s", SYNTH_ZERO_POINTS); }
 
+    if (!(STAGES & STAGE_CHIP))  { strextend (&command, "-skip-chip"); }
+    if (!(STAGES & STAGE_WARP))  { strextend (&command, "-skip-warp"); }
+    if (!(STAGES & STAGE_STACK)) { strextend (&command, "-skip-stack"); }
+
     // deprecate
     // if (SET_MREL_VERSION != 1) { snprintf (tmpline, 1024, "%s -set-mrel-version %d", SET_MREL_VERSION); } // XXXX deprecate this...
Index: trunk/Ohana/src/relphot/src/relphot.c
===================================================================
--- trunk/Ohana/src/relphot/src/relphot.c	(revision 38923)
+++ trunk/Ohana/src/relphot/src/relphot.c	(revision 38986)
@@ -4,4 +4,5 @@
 
   // get configuration info, args
+  SetSignals ();
   RelphotMode mode = initialize (argc, argv);
   if (!mode) exit (2);
Index: trunk/Ohana/src/relphot/src/relphot_client.c
===================================================================
--- trunk/Ohana/src/relphot/src/relphot_client.c	(revision 38923)
+++ trunk/Ohana/src/relphot/src/relphot_client.c	(revision 38986)
@@ -18,4 +18,5 @@
 
   // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, etc) 
+  SetSignals ();
   initialize_client (argc, argv);
   client_logger_init (HOSTDIR);
Index: trunk/Ohana/src/relphot/src/relphot_objects.c
===================================================================
--- trunk/Ohana/src/relphot/src/relphot_objects.c	(revision 38923)
+++ trunk/Ohana/src/relphot/src/relphot_objects.c	(revision 38986)
@@ -101,6 +101,8 @@
     // but it would be better to define a dvo crawler program to do this
     // catalog.catformat = DVO_FORMAT_PS1_V1;  
-    dvo_catalog_save (&catalog, VERBOSE); 
-    dvo_catalog_unlock (&catalog);
+    SetProtect (TRUE);
+    if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); }
+    if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); }
+    SetProtect (FALSE);
     free_tiny_values(&catalog);
     dvo_catalog_free (&catalog);
@@ -155,4 +157,8 @@
     if (SYNTH_ZERO_POINTS) { strextend (&command, "-synthphot-zpts %s", SYNTH_ZERO_POINTS); }
 
+    if (!(STAGES & STAGE_CHIP))  { strextend (&command, "-skip-chip"); }
+    if (!(STAGES & STAGE_WARP))  { strextend (&command, "-skip-warp"); }
+    if (!(STAGES & STAGE_STACK)) { strextend (&command, "-skip-stack"); }
+
     // if (SET_MREL_VERSION != 1) { strextend (&command, "-set-mrel-version %d", SET_MREL_VERSION); } 
 
Index: trunk/Ohana/src/relphot/src/relphot_parallel_images.c
===================================================================
--- trunk/Ohana/src/relphot/src/relphot_parallel_images.c	(revision 38923)
+++ trunk/Ohana/src/relphot/src/relphot_parallel_images.c	(revision 38986)
@@ -34,4 +34,5 @@
     exit (2);
   }
+  client_logger_message ("loaded images\n");
 
   // once we have read this table, we should remove it for repeat runs
@@ -53,4 +54,5 @@
   // the following function correctly chooses the sky regions on the 0,360 boundary
   SkyList *skylist = SkyListByBounds (sky, -1, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax);
+  client_logger_message ("prepare to load catalogs\n");
 
   /* load catalog data from region files (hostID is 0 since we are not a client */
Index: trunk/Ohana/src/relphot/src/relphot_synthphot.c
===================================================================
--- trunk/Ohana/src/relphot/src/relphot_synthphot.c	(revision 38923)
+++ trunk/Ohana/src/relphot/src/relphot_synthphot.c	(revision 38986)
@@ -71,6 +71,8 @@
     // but it would be better to define a dvo crawler program to do this
     // catalog.catformat = DVO_FORMAT_PS1_V1;  
-    dvo_catalog_save (&catalog, VERBOSE); 
-    dvo_catalog_unlock (&catalog);
+    SetProtect (TRUE);
+    if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); }
+    if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); }
+    SetProtect (FALSE);
     dvo_catalog_free (&catalog);
   }
Index: trunk/Ohana/src/relphot/src/setMrelCatalog.c
===================================================================
--- trunk/Ohana/src/relphot/src/setMrelCatalog.c	(revision 38923)
+++ trunk/Ohana/src/relphot/src/setMrelCatalog.c	(revision 38986)
@@ -52,13 +52,15 @@
   for (j = 0; j < catalog[Nc].Naverage; j++) {
 
-    setMrelAverageExposure (&catalog[Nc], Nc, j, Nsecfilt, isSetMrelFinal, flatcorr, results);
+    if (STAGES & STAGE_CHIP) {
+      setMrelAverageExposure (&catalog[Nc], Nc, j, Nsecfilt, isSetMrelFinal, flatcorr, results);
+    }
 
     // only apply Stack operation on setMrelFinal in first pass 
-    if (isSetMrelFinal && !IS_DIFF_DB) {
+    if (isSetMrelFinal && (STAGES & STAGE_STACK) && !IS_DIFF_DB) {
       setMrelAverageStack (&catalog[Nc], Nc, j, Nsecfilt, flatcorr);
     }
 
     // only measure force-warp mean values if issetMrelFinal (make it optional?)
-    if (isSetMrelFinal) {
+    if (isSetMrelFinal && (STAGES & STAGE_WARP)) {
       setMrelAverageForcedWarp (&catalog[Nc], Nc, j, Nsecfilt, flatcorr, results);
     }
