Index: trunk/psModules/src/objects/pmSourcePhotometry.c
===================================================================
--- trunk/psModules/src/objects/pmSourcePhotometry.c	(revision 33963)
+++ trunk/psModules/src/objects/pmSourcePhotometry.c	(revision 33993)
@@ -899,12 +899,21 @@
 }
 
+# if (HAVE_MODEL_VAR) 
 double pmSourceModelWeight(const pmSource *Mi, int term, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal)
+# else
+double pmSourceModelWeight(const pmSource *Mi, int term, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal)
+# endif
 {
     PS_ASSERT_PTR_NON_NULL(Mi, NAN);
+# if (HAVE_MODEL_VAR) 
     double flux = 0, wt = 1.0, factor = 0;
+# else
+    double flux = 0, wt = 0, factor = 0;
+# endif
 
     const psImage *Pi = Mi->modelFlux;
     assert (Pi != NULL);
 
+# if (HAVE_MODEL_VAR)
     const psImage *Wi = NULL;
     switch (fitVarMode) {
@@ -922,5 +931,10 @@
 	psAbort("programming error");
     }	
-
+# else
+    const psImage *Wi = Mi->variance;
+    if (!unweighted_sum) {
+        assert (Wi != NULL);
+    }
+# endif
     const psImage *Ti = Mi->maskObj;
     assert (Ti != NULL);
@@ -928,9 +942,18 @@
     for (int yi = 0; yi < Pi->numRows; yi++) {
         for (int xi = 0; xi < Pi->numCols; xi++) {
-            if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi] & maskVal) continue;
+            if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi] & maskVal)
+                continue;
+# if (HAVE_MODEL_VAR)
             if (fitVarMode != PM_SOURCE_PHOTFIT_CONST) {
                 wt = covarFactor * Wi->data.F32[yi][xi];
                 if (wt == 0) continue;
             }
+# else
+            if (!unweighted_sum) {
+                wt = covarFactor * Wi->data.F32[yi][xi];
+                if (wt == 0)
+                    continue;
+            }
+# endif
 
             switch (term) {
@@ -948,6 +971,14 @@
             }
 
+# if (HAVE_MODEL_VAR)
 	    // wt is 1.0 for CONST
 	    flux += (factor * Pi->data.F32[yi][xi]) / wt;
+# else
+            if (unweighted_sum) {
+                flux += (factor * Pi->data.F32[yi][xi]);
+            } else {
+                flux += (factor * Pi->data.F32[yi][xi]) / wt;
+            }
+# endif
         }
     }
@@ -955,5 +986,9 @@
 }
 
+# if (HAVE_MODEL_VAR)
 double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal)
+# else
+double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal)
+# endif
 {
     PS_ASSERT_PTR_NON_NULL(Mi, NAN);
@@ -963,6 +998,10 @@
     int xIs, xJs, yIs, yJs;
     int xIe, yIe;
+# if (HAVE_MODEL_VAR)
     double flux;
     double wt = 1.0;
+# else
+    double flux, wt;
+# endif
 
     const psImage *Pi = Mi->modelFlux;
@@ -971,4 +1010,5 @@
     assert (Pj != NULL);
 
+# if (HAVE_MODEL_VAR)
     const psImage *Wi = NULL;
     switch (fitVarMode) {
@@ -986,4 +1026,10 @@
 	psAbort("programming error");
     }	
+# else
+    const psImage *Wi = Mi->variance;
+    if (!unweighted_sum) {
+        assert (Wi != NULL);
+    }
+# endif
 
     const psImage *Ti = Mi->maskObj;
@@ -1015,4 +1061,5 @@
                 continue;
 
+# if (HAVE_MODEL_VAR)
 	    float value = (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
 	    switch (fitVarMode) {
@@ -1031,4 +1078,15 @@
 
 	    flux += value / wt;
+# else
+            // XXX skip the nonsense weight pixels?
+            if (unweighted_sum) {
+                flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
+            } else {
+                wt = covarFactor * Wi->data.F32[yi][xi];
+                if (wt > 0) {
+                    flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]) / wt;
+                }
+            }
+# endif
         }
     }
@@ -1036,5 +1094,9 @@
 }
 
+# if (HAVE_MODEL_VAR)
 double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal)
+# else
+double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal)
+# endif
 {
     PS_ASSERT_PTR_NON_NULL(Mi, NAN);
@@ -1044,6 +1106,10 @@
     int xIs, xJs, yIs, yJs;
     int xIe, yIe;
+# if (HAVE_MODEL_VAR)
     double flux;
     double wt = 1.0;
+# else
+    double flux, wt;
+# endif
 
     const psImage *Pi = Mi->pixels;
@@ -1052,4 +1118,5 @@
     assert (Pj != NULL);
 
+# if (HAVE_MODEL_VAR)
     const psImage *Wi = NULL;
     switch (fitVarMode) {
@@ -1067,4 +1134,10 @@
 	psAbort("programming error");
     }	
+# else
+    const psImage *Wi = Mi->variance;
+    if (!unweighted_sum) {
+        assert (Wi != NULL);
+    }
+# endif
 
     const psImage *Ti = Mi->maskObj;
@@ -1096,4 +1169,5 @@
                 continue;
 
+# if (HAVE_MODEL_VAR)
 	    float value = (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
 	    switch (fitVarMode) {
@@ -1113,4 +1187,15 @@
 	    flux += value / wt;
 
+# else
+            // XXX skip the nonsense weight pixels?
+            if (unweighted_sum) {
+                flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
+            } else {
+                wt = covarFactor * Wi->data.F32[yi][xi];
+                if (wt > 0) {
+                    flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]) / wt;
+                }
+            }
+# endif
         }
     }
