Index: /trunk/Ohana/src/dvomerge/include/dvomerge.h
===================================================================
--- /trunk/Ohana/src/dvomerge/include/dvomerge.h	(revision 40804)
+++ /trunk/Ohana/src/dvomerge/include/dvomerge.h	(revision 40805)
@@ -31,4 +31,5 @@
 int    IMAGES_ONLY;
 int    ACCEPT_MOTION;
+int    RETAIN_AVE_PHOTOMETRY;
 char   CATDIR[DVO_MAX_PATH];
 char   GSCFILE[DVO_MAX_PATH];
Index: /trunk/Ohana/src/dvomerge/src/args.c
===================================================================
--- /trunk/Ohana/src/dvomerge/src/args.c	(revision 40804)
+++ /trunk/Ohana/src/dvomerge/src/args.c	(revision 40805)
@@ -117,4 +117,12 @@
     remove_argument (N, argc, argv);
     ACCEPT_MOTION = TRUE;
+  }
+
+  /* limit the impact of a dvomerge -parallel */
+  RETAIN_AVE_PHOTOMETRY = FALSE;
+  if ((N = get_argument (*argc, argv, "-retain-ave-photometry"))) {
+    remove_argument (N, argc, argv);
+    RETAIN_AVE_PHOTOMETRY = TRUE;
+    remove_argument (N, argc, argv);
   }
 
@@ -336,4 +344,12 @@
   }
 
+  /* limit the impact of a dvomerge -parallel */
+  RETAIN_AVE_PHOTOMETRY = FALSE;
+  if ((N = get_argument (*argc, argv, "-retain-ave-photometry"))) {
+    remove_argument (N, argc, argv);
+    RETAIN_AVE_PHOTOMETRY = TRUE;
+    remove_argument (N, argc, argv);
+  }
+
   /* extra error messages */
   MATCHED_TABLES = FALSE;
Index: /trunk/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c
===================================================================
--- /trunk/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c	(revision 40804)
+++ /trunk/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c	(revision 40805)
@@ -320,18 +320,19 @@
 	       UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, RADIUS);
 
-    if (VERBOSE)             { strextend (&command, "-v"); }
-    if (VERIFY)              { strextend (&command, "-verify"); }
-    if (VERIFY_CATALOG_ONLY) { strextend (&command, "-verify-catalogs"); }
-    if (REPLACE_BY_PHOTCODE) { strextend (&command, "-replace"); }
-    if (REPLACE_TYCHO)       { strextend (&command, "-replace-tycho"); }
-    if (PARALLEL_INPUT)      { strextend (&command, "-parallel-input"); }
-    if (FORCE_MERGE)         { strextend (&command, "-force-merge"); }
-    if (ACCEPT_MOTION)       { strextend (&command, "-accept-motion"); }
-    if (MATCHED_TABLES)      { strextend (&command, "-matched-tables"); }
-    if (MATCH_BY_EXTERN_ID)  { strextend (&command, "-match-by-extern-id"); }
-    if (ONLY_MATCHES)        { strextend (&command, "-only-matches"); }
-    if (UPDATE_CATFORMAT)    { strextend (&command, "-update-catformat %s", UPDATE_CATFORMAT); }
-    if (UPDATE_CATCOMPRESS)  { strextend (&command, "-update-catcompress %s", UPDATE_CATCOMPRESS); }
-    if (REPAIR_BY_OBJID)     { strextend (&command, "-repair-by-objid"); }
+    if (VERBOSE)               { strextend (&command, "-v"); }
+    if (VERIFY)                { strextend (&command, "-verify"); }
+    if (VERIFY_CATALOG_ONLY)   { strextend (&command, "-verify-catalogs"); }
+    if (REPLACE_BY_PHOTCODE)   { strextend (&command, "-replace"); }
+    if (REPLACE_TYCHO)         { strextend (&command, "-replace-tycho"); }
+    if (PARALLEL_INPUT)        { strextend (&command, "-parallel-input"); }
+    if (FORCE_MERGE)           { strextend (&command, "-force-merge"); }
+    if (ACCEPT_MOTION)         { strextend (&command, "-accept-motion"); }
+    if (RETAIN_AVE_PHOTOMETRY) { strextend (&command, "-retain-ave-photometry"); }
+    if (MATCHED_TABLES)        { strextend (&command, "-matched-tables"); }
+    if (MATCH_BY_EXTERN_ID)    { strextend (&command, "-match-by-extern-id"); }
+    if (ONLY_MATCHES)          { strextend (&command, "-only-matches"); }
+    if (UPDATE_CATFORMAT)      { strextend (&command, "-update-catformat %s", UPDATE_CATFORMAT); }
+    if (UPDATE_CATCOMPRESS)    { strextend (&command, "-update-catcompress %s", UPDATE_CATCOMPRESS); }
+    if (REPAIR_BY_OBJID)       { strextend (&command, "-repair-by-objid"); }
 
     if (SKIP_MEASURE)               { strextend (&command, "-skip-measure"); }
Index: /trunk/Ohana/src/dvomerge/src/merge_catalogs_old.c
===================================================================
--- /trunk/Ohana/src/dvomerge/src/merge_catalogs_old.c	(revision 40804)
+++ /trunk/Ohana/src/dvomerge/src/merge_catalogs_old.c	(revision 40805)
@@ -1,4 +1,5 @@
 # include "dvomerge.h"
 # define PSPS_ID TRUE
+# define D_ITEM 100000
 
 # define IN_REGION(R,D) (					\
@@ -187,25 +188,25 @@
     /* make sure there is space for next Nmeasure entries */
     if (Nmeasure + input[0].average[N].Nmeasure >= NMEASURE) {
-      NMEASURE = Nmeasure + input[0].average[N].Nmeasure + 1000;
+      NMEASURE = Nmeasure + input[0].average[N].Nmeasure + D_ITEM;
       REALLOCATE (next_measure, off_t, NMEASURE);
       REALLOCATE (output[0].measure, Measure, NMEASURE);
     }
     if (Nlensing + input[0].average[N].Nlensing >= NLENSING) {
-      NLENSING = Nlensing + input[0].average[N].Nlensing + 1000;
+      NLENSING = Nlensing + input[0].average[N].Nlensing + D_ITEM;
       REALLOCATE (next_lensing, off_t, NLENSING);
       REALLOCATE (output[0].lensing, Lensing, NLENSING);
     }
     if (Nlensobj + input[0].average[N].Nlensobj >= NLENSOBJ) {
-      NLENSOBJ = Nlensobj + input[0].average[N].Nlensobj + 1000;
+      NLENSOBJ = Nlensobj + input[0].average[N].Nlensobj + D_ITEM;
       REALLOCATE (next_lensobj, off_t, NLENSOBJ);
       REALLOCATE (output[0].lensobj, Lensobj, NLENSOBJ);
     }
     if (Nstarpar + input[0].average[N].Nstarpar >= NSTARPAR) {
-      NSTARPAR = Nstarpar + input[0].average[N].Nstarpar + 1000;
+      NSTARPAR = Nstarpar + input[0].average[N].Nstarpar + D_ITEM;
       REALLOCATE (next_starpar, off_t, NSTARPAR);
       REALLOCATE (output[0].starpar, StarPar, NSTARPAR);
     }
     if (Ngalphot + input[0].average[N].Ngalphot >= NGALPHOT) {
-      NGALPHOT = Ngalphot + input[0].average[N].Ngalphot + 1000;
+      NGALPHOT = Ngalphot + input[0].average[N].Ngalphot + D_ITEM;
       REALLOCATE (next_galphot, off_t, NGALPHOT);
       REALLOCATE (output[0].galphot, GalPhot, NGALPHOT);
@@ -363,9 +364,12 @@
 
     // update the average properties to reflect the incoming entries:
-    // if the original value is NAN but the input value is not, accept the input:
+    // if RETAIN_AVE_PHOTOMETRY is true and the original value is NAN, but the input value is not, accept the input:
+    // if RETAIN_AVE_PHOTOMETRY is false and the input value is not NAN, accept the input
+    // if RETAIN_AVE_PHOTOMETRY is true and the original value is not NAN, the keep the existing average photometry
+    
     if (!secfiltMap) {
       // secfilt tables of input and output are the same
       for (k = 0; k < NsecfiltIn; k++) {
-        if ( isfinite(output[0].secfilt[n*NsecfiltIn+k].MpsfChp)) continue;
+        if (RETAIN_AVE_PHOTOMETRY && isfinite(output[0].secfilt[n*NsecfiltIn+k].MpsfChp)) continue;
         if (!isfinite( input[0].secfilt[N*NsecfiltIn+k].MpsfChp)) continue;
         output[0].secfilt[n*NsecfiltIn+k] = input[0].secfilt[N*NsecfiltIn+k];
@@ -378,5 +382,5 @@
         int outputIndex = n * NsecfiltOut + secfiltMap[k];
         
-        if ( isfinite(output[0].secfilt[outputIndex].MpsfChp)) continue;
+        if (RETAIN_AVE_PHOTOMETRY && isfinite(output[0].secfilt[outputIndex].MpsfChp)) continue;
         if (!isfinite( input[0].secfilt[N*NsecfiltIn+k].MpsfChp)) continue;
         output[0].secfilt[outputIndex] = input[0].secfilt[N*NsecfiltIn+k];
@@ -411,30 +415,30 @@
     /* make sure there is space for next entry */
     if (Nmeasure + input[0].average[N].Nmeasure >= NMEASURE) {
-      NMEASURE = Nmeasure + input[0].average[N].Nmeasure + 1000;
+      NMEASURE = Nmeasure + input[0].average[N].Nmeasure + D_ITEM;
       REALLOCATE (next_measure, off_t, NMEASURE);
       REALLOCATE (output[0].measure, Measure, NMEASURE);
     }
     if (Nlensing + input[0].average[N].Nlensing >= NLENSING) {
-      NLENSING = Nlensing + input[0].average[N].Nlensing + 1000;
+      NLENSING = Nlensing + input[0].average[N].Nlensing + D_ITEM;
       REALLOCATE (next_lensing, off_t, NLENSING);
       REALLOCATE (output[0].lensing, Lensing, NLENSING);
     }
     if (Nlensobj + input[0].average[N].Nlensobj >= NLENSOBJ) {
-      NLENSOBJ = Nlensobj + input[0].average[N].Nlensobj + 1000;
+      NLENSOBJ = Nlensobj + input[0].average[N].Nlensobj + D_ITEM;
       REALLOCATE (next_lensobj, off_t, NLENSOBJ);
       REALLOCATE (output[0].lensobj, Lensobj, NLENSOBJ);
     }
     if (Nstarpar + input[0].average[N].Nstarpar >= NSTARPAR) {
-      NSTARPAR = Nstarpar + input[0].average[N].Nstarpar + 1000;
+      NSTARPAR = Nstarpar + input[0].average[N].Nstarpar + D_ITEM;
       REALLOCATE (next_starpar, off_t, NSTARPAR);
       REALLOCATE (output[0].starpar, StarPar, NSTARPAR);
     }
     if (Ngalphot + input[0].average[N].Ngalphot >= NGALPHOT) {
-      NGALPHOT = Ngalphot + input[0].average[N].Ngalphot + 1000;
+      NGALPHOT = Ngalphot + input[0].average[N].Ngalphot + D_ITEM;
       REALLOCATE (next_galphot, off_t, NGALPHOT);
       REALLOCATE (output[0].galphot, GalPhot, NGALPHOT);
     }
     if (Nave >= NAVE) {
-      NAVE = Nave + 1000;
+      NAVE = Nave + D_ITEM;
       REALLOCATE (output[0].average, Average, NAVE);
       REALLOCATE (output[0].secfilt, SecFilt, NAVE*NsecfiltOut);
