Index: trunk/psModules/configure.ac
===================================================================
--- trunk/psModules/configure.ac	(revision 34062)
+++ trunk/psModules/configure.ac	(revision 34085)
@@ -14,5 +14,5 @@
 AC_SUBST(PSMODULES_LT_VERSION,$PSMODULES_LT_VERSION)
 
-IPP_STDCFLAGS
+IPP_STDLDFLAGS
 
 AC_LANG(C)
@@ -312,6 +312,6 @@
 dnl ------- enable -Werror after all of the probes have run ---------
 IPP_STDOPTS
-
-CFLAGS="${CFLAGS} -Wall -Werror"
+IPP_STDCFLAGS
+
 dnl enable POSIX/XSI and C99 compliance
 CFLAGS="${CFLAGS=} -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112L"
Index: trunk/psModules/src/camera/pmFPAMosaic.c
===================================================================
--- trunk/psModules/src/camera/pmFPAMosaic.c	(revision 34062)
+++ trunk/psModules/src/camera/pmFPAMosaic.c	(revision 34085)
@@ -661,4 +661,7 @@
             good = false;
         }
+    }
+    if (!good) {
+	// XXX do something to address this?
     }
 
Index: trunk/psModules/src/camera/pmFPARead.c
===================================================================
--- trunk/psModules/src/camera/pmFPARead.c	(revision 34062)
+++ trunk/psModules/src/camera/pmFPARead.c	(revision 34085)
@@ -957,10 +957,10 @@
         trimsec->y1 = naxis2 + trimsec->y1;
 
-    int maxSize;                        // Number of cols,rows in image
-    if (readdir == 1) {
-        maxSize = PS_MIN(naxis2, trimsec->y1 - trimsec->y0);
-    } else {
-        maxSize = PS_MIN(naxis1, trimsec->x1 - trimsec->x0);
-    }
+    // XX not used int maxSize;                        // Number of cols,rows in image
+    // XX not used if (readdir == 1) {
+    // XX not used     maxSize = PS_MIN(naxis2, trimsec->y1 - trimsec->y0);
+    // XX not used } else {
+    // XX not used     maxSize = PS_MIN(naxis1, trimsec->x1 - trimsec->x0);
+    // XX not used }
 
     int offset;                         // start of the segment
Index: trunk/psModules/src/camera/pmFPAfileDefine.c
===================================================================
--- trunk/psModules/src/camera/pmFPAfileDefine.c	(revision 34062)
+++ trunk/psModules/src/camera/pmFPAfileDefine.c	(revision 34085)
@@ -333,5 +333,5 @@
         psMetadataItem *fuzz = psMetadataLookup(scheme, "FUZZ"); // Quantisation fuzz?
         if (fuzz) {
-            if (fuzz->type != PS_TYPE_BOOL) {
+            if (fuzz->type != PS_DATA_BOOL) {
                 psWarning("FUZZ in compression scheme %s isn't boolean.", fitsType);
                 goto FITS_OPTIONS_DONE;
Index: trunk/psModules/src/camera/pmReadoutFake.c
===================================================================
--- trunk/psModules/src/camera/pmReadoutFake.c	(revision 34062)
+++ trunk/psModules/src/camera/pmReadoutFake.c	(revision 34085)
@@ -332,5 +332,5 @@
 #define CONCEPT_SET_S32(CONCEPTS, NAME, OLD, NEW) { \
         psMetadataItem *item = psMetadataLookup(CONCEPTS, NAME); \
-        psAssert(item->type == PS_TYPE_S32, "Incorrect type: %x", item->type); \
+        psAssert(item->type == PS_DATA_S32, "Incorrect type: %x", item->type); \
         if (item->data.S32 == OLD) { \
             item->data.S32 = NEW; \
Index: trunk/psModules/src/concepts/pmConceptsStandard.c
===================================================================
--- trunk/psModules/src/concepts/pmConceptsStandard.c	(revision 34062)
+++ trunk/psModules/src/concepts/pmConceptsStandard.c	(revision 34085)
@@ -118,5 +118,5 @@
     assert(concept);
     assert(cell);
-    assert(concept->type == PS_TYPE_F32);
+    assert(concept->type == PS_DATA_F32);
 
     float rn = concept->data.F32;       // Read noise
@@ -930,5 +930,5 @@
     psFree(timesysName);
 
-    if (!item || item->type != PS_TYPE_S32) {
+    if (!item || item->type != PS_DATA_S32) {
         psWarning("Unable to find %s --- assuming UTC", timesysName);
         return PS_TIME_UTC;
@@ -1258,7 +1258,7 @@
 #endif
       default:
-        if (concept->type == PS_TYPE_F32 && concept->data.F32 - (int)concept->data.F32 == 0) {
+        if (concept->type == PS_DATA_F32 && concept->data.F32 - (int)concept->data.F32 == 0) {
             offset = concept->data.F32;
-        } else if (concept->type == PS_TYPE_F64 && concept->data.F64 - (int)concept->data.F64 == 0) {
+        } else if (concept->type == PS_DATA_F64 && concept->data.F64 - (int)concept->data.F64 == 0) {
             offset = concept->data.F64;
         } else {
@@ -1558,5 +1558,5 @@
     assert(cameraFormat);
 
-    if (concept->type != PS_TYPE_S32) {
+    if (concept->type != PS_DATA_S32) {
         psError(PS_ERR_UNKNOWN, true, "Concept %s is not of type S32, as expected.\n", concept->name);
         return NULL;
Index: trunk/psModules/src/concepts/pmConceptsUpdate.c
===================================================================
--- trunk/psModules/src/concepts/pmConceptsUpdate.c	(revision 34062)
+++ trunk/psModules/src/concepts/pmConceptsUpdate.c	(revision 34085)
@@ -30,5 +30,5 @@
             if (isfinite(gain)) {
                 psMetadataItem *rn = psMetadataLookup(cell->concepts, "CELL.READNOISE"); // Read noise
-                psAssert(rn && rn->type == PS_TYPE_F32, "Should be of the correct type");
+                psAssert(rn && rn->type == PS_DATA_F32, "Should be of the correct type");
                 rn->data.F32 *= gain;
                 psMetadataRemoveKey(cell->concepts, "CELL.READNOISE.UPDATE");
Index: trunk/psModules/src/config/pmConfigCommand.c
===================================================================
--- trunk/psModules/src/config/pmConfigCommand.c	(revision 34062)
+++ trunk/psModules/src/config/pmConfigCommand.c	(revision 34085)
@@ -42,5 +42,5 @@
     psMetadataItem *item;               // Item from iteration
     while ((item = psMetadataGetAndIncrement(iter))) {
-        assert(item->type == PS_TYPE_S32);
+        assert(item->type == PS_DATA_S32);
         psStringAppend(command, " -trace %s %d", item->name, item->data.S32);
     }
Index: trunk/psModules/src/detrend/pmFringeStats.c
===================================================================
--- trunk/psModules/src/detrend/pmFringeStats.c	(revision 34062)
+++ trunk/psModules/src/detrend/pmFringeStats.c	(revision 34085)
@@ -662,5 +662,5 @@
         if (item->type == PS_DATA_VECTOR) { \
             ARRAY->data[i] = psMemIncrRefCounter(item->data.V); \
-        } else if (item->type == PS_TYPE_##TYPE) { \
+        } else if (item->type == PS_DATA_##TYPE) { \
             psVector *vector = psVectorAlloc(1, PS_TYPE_##TYPE); \
             vector->data.TYPE[0] = item->data.TYPE; \
Index: trunk/psModules/src/detrend/pmNonLinear.c
===================================================================
--- trunk/psModules/src/detrend/pmNonLinear.c	(revision 34062)
+++ trunk/psModules/src/detrend/pmNonLinear.c	(revision 34085)
@@ -82,7 +82,7 @@
     }
     PS_ASSERT_PTR_NON_NULL(outFlux,NULL);
-    psS32 tableSize = inFlux->n;
+    // XXX unused psS32 tableSize = inFlux->n;
     if (inFlux->n != outFlux->n) {
-        tableSize = PS_MIN(inFlux->n, outFlux->n);
+        // XXX unused tableSize = PS_MIN(inFlux->n, outFlux->n);
         psLogMsg(__func__, PS_LOG_WARN,
                  "WARNING: pmNonLinear.c: pmNonLinearityLookup(): "
@@ -329,4 +329,6 @@
 
     bin = correction_fluxes->n - 1;
+    psTrace("psModules.nonlin",6,"NLMN: %f %d %f %f\n",flux,bin,correction_fluxes->data.F32[0],correction_fluxes->data.F32[bin]);
+    if (bin < 0) { /* warn? */ }
     if (flux < correction_fluxes->data.F32[0]) {
 	return(0.0);
@@ -357,4 +359,5 @@
     bin = correction_fluxes->n - 1;
     psTrace("psModules.nonlin",6,"NLMN: %f %d %f %f\n",flux,bin,correction_fluxes->data.F32[0],correction_fluxes->data.F32[bin]);
+    if (bin < 0) { /* warn? */ }
     if (flux < correction_fluxes->data.F32[0]) {
 	return(0.0);
Index: trunk/psModules/src/detrend/pmShutterCorrection.c
===================================================================
--- trunk/psModules/src/detrend/pmShutterCorrection.c	(revision 34062)
+++ trunk/psModules/src/detrend/pmShutterCorrection.c	(revision 34085)
@@ -406,5 +406,4 @@
 
     // Check input sizes, generate first-pass statistics
-    psRegion refRegion;                 // Reference region
     psVector *refs = psVectorAlloc(num, PS_TYPE_F32); // Reference measurements
     psVectorInit(refs, 0);
@@ -441,5 +440,5 @@
             numCols = image->numCols;
             // define the reference region : a box of size 'size' at the center
-            refRegion = psRegionForSquare(0.5 * numCols, 0.5 * numRows, size);
+            // XXX unused psRegion refRegion = psRegionForSquare(0.5 * numCols, 0.5 * numRows, size);
             // Set up the sample regions : boxes of size 'size' at the 4 image corners
             for (int j = 0; j < MEASURE_SAMPLES; j++) {
Index: trunk/psModules/src/extras/pmVisualUtils.c
===================================================================
--- trunk/psModules/src/extras/pmVisualUtils.c	(revision 34062)
+++ trunk/psModules/src/extras/pmVisualUtils.c	(revision 34085)
@@ -424,4 +424,6 @@
 	    nwritten = fwrite (line, 1, strlen(line), output);
         }
+	if (nwritten < 1) {
+	}
     }
 
Index: trunk/psModules/src/extras/psPipe.c
===================================================================
--- trunk/psModules/src/extras/psPipe.c	(revision 34062)
+++ trunk/psModules/src/extras/psPipe.c	(revision 34085)
@@ -105,7 +105,6 @@
 
         status = execvp (argv[0], argv);
-
-        // this statement exits the child, not the parent, process
-        exit (1);
+        if (status < 0) { psWarning ("error running exec for child process"); }
+        exit (1); // this statement exits the child, not the parent, process
     }
     psFree (cmd);
Index: trunk/psModules/src/objects/models/pmModel_PGAUSS.c
===================================================================
--- trunk/psModules/src/objects/models/pmModel_PGAUSS.c	(revision 34062)
+++ trunk/psModules/src/objects/models/pmModel_PGAUSS.c	(revision 34085)
@@ -261,5 +261,4 @@
 {
     psF64 z;
-    int Nstep = 0;
     psEllipseShape shape;
 
@@ -285,5 +284,4 @@
     // use the fact that f is monotonically decreasing
     z = 0;
-    Nstep = 0;
 
     // choose a z value guaranteed to be beyond our limit
Index: trunk/psModules/src/objects/models/pmModel_PS1_V1.c
===================================================================
--- trunk/psModules/src/objects/models/pmModel_PS1_V1.c	(revision 34062)
+++ trunk/psModules/src/objects/models/pmModel_PS1_V1.c	(revision 34085)
@@ -283,5 +283,4 @@
 {
     psF64 z;
-    int Nstep = 0;
     psEllipseShape shape;
 
@@ -308,5 +307,4 @@
     // use the fact that f is monotonically decreasing
     z = 0;
-    Nstep = 0;
 
     // choose a z value guaranteed to be beyond our limit
Index: trunk/psModules/src/objects/models/pmModel_QGAUSS.c
===================================================================
--- trunk/psModules/src/objects/models/pmModel_QGAUSS.c	(revision 34062)
+++ trunk/psModules/src/objects/models/pmModel_QGAUSS.c	(revision 34085)
@@ -284,5 +284,4 @@
 {
     psF64 z;
-    int Nstep = 0;
     psEllipseShape shape;
 
@@ -312,5 +311,4 @@
     // use the fact that f is monotonically decreasing
     z = 0;
-    Nstep = 0;
 
     // choose a z value guaranteed to be beyond our limit
Index: trunk/psModules/src/objects/models/pmModel_RGAUSS.c
===================================================================
--- trunk/psModules/src/objects/models/pmModel_RGAUSS.c	(revision 34062)
+++ trunk/psModules/src/objects/models/pmModel_RGAUSS.c	(revision 34085)
@@ -273,5 +273,4 @@
 {
     psF64 z;
-    int Nstep = 0;
     psEllipseShape shape;
 
@@ -296,5 +295,4 @@
     // use the fact that f is monotonically decreasing
     z = 0;
-    Nstep = 0;
 
     // choose a z value guaranteed to be beyond our limit
Index: trunk/psModules/src/objects/pmModelFuncs.h
===================================================================
--- trunk/psModules/src/objects/pmModelFuncs.h	(revision 34062)
+++ trunk/psModules/src/objects/pmModelFuncs.h	(revision 34085)
@@ -29,6 +29,4 @@
 # define PM_MODEL_FUNCS_H
 
-# define HAVE_MODEL_VAR 1
-
 /// @addtogroup Objects Object Detection / Analysis Functions
 /// @{
@@ -57,7 +55,5 @@
     PM_MODEL_OP_NORM     = 0x20,
     PM_MODEL_OP_NOISE    = 0x40,
-# if (HAVE_MODEL_VAR)
     PM_MODEL_OP_MODELVAR = 0x80,
-# endif
 } pmModelOpMode;
 
Index: trunk/psModules/src/objects/pmModelUtils.c
===================================================================
--- trunk/psModules/src/objects/pmModelUtils.c	(revision 34062)
+++ trunk/psModules/src/objects/pmModelUtils.c	(revision 34085)
@@ -43,4 +43,13 @@
 
 #include "pmErrorCodes.h"
+
+// XX static bool useModelVar = false;
+// XX 
+// XX void pmModelSetModelVarOption (bool option) {
+// XX   useModelVar = option;
+// XX }
+// XX bool pmModelGetModelVarOption (void) {
+// XX   return useModelVar;
+// XX }
 
 /*****************************************************************************
Index: trunk/psModules/src/objects/pmModelUtils.h
===================================================================
--- trunk/psModules/src/objects/pmModelUtils.h	(revision 34062)
+++ trunk/psModules/src/objects/pmModelUtils.h	(revision 34085)
@@ -46,4 +46,7 @@
 bool pmModelSetShape (float *Sxx, float *Sxy, float *Syy, pmMoments *moments);
 
+// XXX void pmModelSetModelVarOption (bool option);
+// XXX bool pmModelGetModelVarOption (void);
+
 /// @}
 # endif /* PM_MODEL_UTILS_H */
Index: trunk/psModules/src/objects/pmPSFtryMakePSF.c
===================================================================
--- trunk/psModules/src/objects/pmPSFtryMakePSF.c	(revision 34062)
+++ trunk/psModules/src/objects/pmPSFtryMakePSF.c	(revision 34085)
@@ -231,9 +231,6 @@
 	// XXX we are using the same stats structure on each pass: do we need to re-init it?
 	// XXX we hardwire this to SAMPLE stats above (psphotChoosePSF.c), hardwire here instead?
-	psStatsOptions meanOption = psStatsMeanOption(psf->psfTrendStats->options);
-	psStatsOptions stdevOption = psStatsStdevOption(psf->psfTrendStats->options);
-
+     
 	pmTrend2D *trend = NULL;
-	float mean, stdev;
 
 	// XXX we are using the same stats structure on each pass: do we need to re-init it?
@@ -249,7 +246,14 @@
 	    return true;
 	}
+
+# if (PS_TRACE_ON)
+	float mean, stdev;
+	psStatsOptions meanOption = psStatsMeanOption(psf->psfTrendStats->options);
+	psStatsOptions stdevOption = psStatsStdevOption(psf->psfTrendStats->options);
 	mean = psStatsGetValue (trend->stats, meanOption);
 	stdev = psStatsGetValue (trend->stats, stdevOption);
 	psTrace ("psModules.objects", 4, "clipped E0 : %f +/- %f keeping %ld of %ld\n", mean, stdev, psf->psfTrendStats->clippedNvalues, e0->n);
+# endif
+
         if (psf->psfTrendMode == PM_TREND_MAP) psImageMapCleanup (trend->map);
 	pmSourceVisualPSFModelResid (trend, x, y, e0, srcMask);
@@ -264,7 +268,9 @@
 	    return true;
 	}
+# if (PS_TRACE_ON)
 	mean = psStatsGetValue (trend->stats, meanOption);
 	stdev = psStatsGetValue (trend->stats, stdevOption);
 	psTrace ("psModules.objects", 4, "clipped E1 : %f +/- %f keeping %ld of %ld\n", mean, stdev, psf->psfTrendStats->clippedNvalues, e1->n);
+# endif
         if (psf->psfTrendMode == PM_TREND_MAP) psImageMapCleanup (trend->map);
 	pmSourceVisualPSFModelResid (trend, x, y, e1, srcMask);
@@ -279,7 +285,9 @@
 	    return true;
 	}
+# if (PS_TRACE_ON)
 	mean = psStatsGetValue (trend->stats, meanOption);
 	stdev = psStatsGetValue (trend->stats, stdevOption);
 	psTrace ("psModules.objects", 4, "clipped E2 : %f +/- %f keeping %ld of %ld\n", mean, stdev, psf->psfTrendStats->clippedNvalues, e2->n);
+# endif
         if (psf->psfTrendMode == PM_TREND_MAP) psImageMapCleanup (trend->map);
 	pmSourceVisualPSFModelResid (trend, x, y, e2, srcMask);
Index: trunk/psModules/src/objects/pmSource.c
===================================================================
--- trunk/psModules/src/objects/pmSource.c	(revision 34062)
+++ trunk/psModules/src/objects/pmSource.c	(revision 34085)
@@ -51,7 +51,5 @@
     psFree(tmp->pixels);
     psFree(tmp->variance);
-# if (HAVE_MODEL_VAR)
     psFree(tmp->modelVar);
-# endif
     psFree(tmp->maskObj);
     psFree(tmp->maskView);
@@ -80,7 +78,5 @@
     psFree (source->pixels);
     psFree (source->variance);
-# if (HAVE_MODEL_VAR)
     psFree (source->modelVar);
-# endif
     psFree (source->maskObj);
     psFree (source->maskView);
@@ -90,7 +86,5 @@
     source->pixels = NULL;
     source->variance = NULL;
-# if (HAVE_MODEL_VAR)
     source->modelVar = NULL;
-# endif
     source->maskObj = NULL;
     source->maskView = NULL;
@@ -122,7 +116,5 @@
     source->pixels = NULL;
     source->variance = NULL;
-# if (HAVE_MODEL_VAR)
     source->modelVar = NULL;
-# endif
     source->maskObj = NULL;
     source->maskView = NULL;
@@ -212,7 +204,5 @@
     source->pixels   = in->pixels   ? psImageCopyView(NULL, in->pixels)   : NULL;
     source->variance = in->variance ? psImageCopyView(NULL, in->variance) : NULL;
-# if (HAVE_MODEL_VAR)
     source->modelVar = NULL;
-# endif
     source->maskView = in->maskView ? psImageCopyView(NULL, in->maskView) : NULL;
 
@@ -1044,8 +1034,6 @@
     bool addNoise = mode & PM_MODEL_OP_NOISE;
 
-# if (HAVE_MODEL_VAR)
     bool addModelVar = mode & PM_MODEL_OP_MODELVAR;
     if (addModelVar) psAssert (source->modelVar, "programming error");
-# endif
 
     // require the use of pmModelAddWithOffset if we are adding noise (because the model size and norm are rescaled)
@@ -1070,9 +1058,6 @@
         }
 
-# if (HAVE_MODEL_VAR)
-        psF32 **target = addModelVar ? source->modelVar->data.F32 : source->pixels->data.F32;
-# else
-        psF32 **target = source->pixels->data.F32;
-# endif
+	psF32 **target = NULL;
+	target = addModelVar ? source->modelVar->data.F32 : source->pixels->data.F32;
 
         for (int iy = 0; iy < source->modelFlux->numRows; iy++) {
@@ -1089,19 +1074,12 @@
             }
         }
-# if (HAVE_MODEL_VAR)
+	// do not change the flag here if we are adding/subtracting from modelVar
 	if (!addModelVar) {
-	    if (add) {
-		source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED;
-	    } else {
-		source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED;
-	    }
+	  if (add) {
+	    source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED;
+	  } else {
+	    source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED;
+	  }
 	}
-# else
-	if (add) {
-	    source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED;
-	} else {
-	    source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED;
-	}
-# endif
         return true;
     }
@@ -1111,24 +1089,17 @@
         target = source->variance;
     }
-# if (HAVE_MODEL_VAR)
     if (addModelVar) {
-        target = source->modelVar;
-    }
-# endif
+      target = source->modelVar;
+    }
 
     if (add) {
 	status = pmModelAddWithOffset (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal, dx, dy);
-# if (HAVE_MODEL_VAR)
 	if (!addNoise && !addModelVar) source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED;
-# else
-	source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED;
-# endif
     } else {
 	status = pmModelSubWithOffset (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal, dx, dy);
-# if (HAVE_MODEL_VAR)
 	if (!addNoise && !addModelVar) source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED;
-# else
-	source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED;
-# endif
+    }
+    if (!status) {
+	// XXX maybe raise an error or warning?
     }
 
@@ -1200,4 +1171,7 @@
 	status = pmModelSubWithOffset (target, source->maskObj, model, mode, maskVal, dx, dy);
     }
+    if (!status) {
+	// XXX raise an error or warning?
+    }
 
     // restore original values
@@ -1287,4 +1261,7 @@
     } else {
 	status = pmModelSubWithOffset (target, source->maskObj, model, mode, maskVal, dx, dy);
+    }
+    if (!status) {
+	// XXX raise an error or warning?
     }
 
Index: trunk/psModules/src/objects/pmSource.h
===================================================================
--- trunk/psModules/src/objects/pmSource.h	(revision 34062)
+++ trunk/psModules/src/objects/pmSource.h	(revision 34085)
@@ -72,7 +72,5 @@
     psImage *pixels;                    ///< Rectangular region including object pixels.
     psImage *variance;			///< Image variance.
-# if (HAVE_MODEL_VAR)
     psImage *modelVar;			///< variance based on current models
-# endif
     psImage *maskObj;                   ///< unique mask for this object which marks included pixels associated with objects.
     psImage *maskView;                  ///< view into global image mask for this object region
Index: trunk/psModules/src/objects/pmSourceIO_CMP.c
===================================================================
--- trunk/psModules/src/objects/pmSourceIO_CMP.c	(revision 34062)
+++ trunk/psModules/src/objects/pmSourceIO_CMP.c	(revision 34085)
@@ -65,5 +65,5 @@
     int i, type;
     // psMetadataItem *mdi;
-    psF32 *PAR, *dPAR;
+    psF32 *PAR;
     float lsky = 0;
     bool status;
@@ -130,5 +130,4 @@
 
         PAR = model->params->data.F32;
-        dPAR = model->dparams->data.F32;
 
         type = pmSourceGetDophotType (source);
@@ -174,5 +173,5 @@
     bool status;
     int Ninstar;
-    psF32 *PAR, *dPAR;
+    psF32 *PAR;
     psEllipseAxes axes;
 
@@ -185,8 +184,8 @@
     }
 
-    // find config information for output header
-    float ZERO_POINT = psMetadataLookupF32 (&status, header, "ZERO_PT");
-    if (!status)
-        ZERO_POINT = 25.0;
+    // XXX unused // find config information for output header
+    // XXX unused float ZERO_POINT = psMetadataLookupF32 (&status, header, "ZERO_PT");
+    // XXX unused if (!status)
+    // XXX unused     ZERO_POINT = 25.0;
 
     // how many lines in the header?
@@ -273,5 +272,4 @@
 
             PAR = source->modelPSF->params->data.F32;
-            dPAR = source->modelPSF->dparams->data.F32;
 
             PAR[PM_PAR_SKY] = pow (atof (array->data[5]), 10.0);
Index: trunk/psModules/src/objects/pmSourceIO_PS1_CAL_0.c
===================================================================
--- trunk/psModules/src/objects/pmSourceIO_PS1_CAL_0.c	(revision 34062)
+++ trunk/psModules/src/objects/pmSourceIO_PS1_CAL_0.c	(revision 34085)
@@ -322,4 +322,6 @@
 }
 
+# define WRITE_AP_DATA 0
+
 bool pmSourcesWrite_PS1_CAL_0_XSRC (psFits *fits, pmReadout *readout, psArray *sources, psMetadata *imageHeader, char *extname, psMetadata *recipe)
 {
@@ -338,4 +340,5 @@
     }
 
+# if (WRITE_AP_DATA)
     bool calMags = false;
     bool status1 = false;
@@ -350,4 +353,5 @@
 	calMags = true;
     }
+# endif
 
     // create a header to hold the output data
@@ -424,5 +428,5 @@
         psMetadataAdd (row, PS_LIST_TAIL, "Y_EXT_SIG",        PS_DATA_F32, "Sigma in EXT y coordinate",                  yErr);
 
-# if (0)
+# if (WRITE_AP_DATA)
 	// Petrosian measurements
 	// XXX insert header data: petrosian ref radius, flux ratio
Index: trunk/psModules/src/objects/pmSourceIO_SMPDATA.c
===================================================================
--- trunk/psModules/src/objects/pmSourceIO_SMPDATA.c	(revision 34062)
+++ trunk/psModules/src/objects/pmSourceIO_SMPDATA.c	(revision 34085)
@@ -63,5 +63,5 @@
     psMetadata *row;
     int i;
-    psF32 *PAR, *dPAR;
+    psF32 *PAR;
     bool status;
     psEllipseAxes axes;
@@ -85,5 +85,4 @@
         if (model != NULL) {
 	    PAR = model->params->data.F32;
-	    dPAR = model->dparams->data.F32;
 	    xPos = PAR[PM_PAR_XPOS];
 	    yPos = PAR[PM_PAR_YPOS];
@@ -145,5 +144,5 @@
 
     bool status;
-    psF32 *PAR, *dPAR;
+    psF32 *PAR;
     psEllipseAxes axes;
     float lsky;
@@ -176,5 +175,4 @@
 
         PAR = model->params->data.F32;
-        dPAR = model->dparams->data.F32;
 
         psMetadata *row = table->data[i];
Index: trunk/psModules/src/objects/pmSourceIO_SX.c
===================================================================
--- trunk/psModules/src/objects/pmSourceIO_SX.c	(revision 34062)
+++ trunk/psModules/src/objects/pmSourceIO_SX.c	(revision 34085)
@@ -56,5 +56,5 @@
     PS_ASSERT_PTR_NON_NULL(filename, false);
 
-    psF32 *PAR, *dPAR;
+    psF32 *PAR;
     psEllipseAxes axes;
 
@@ -77,5 +77,4 @@
 
         PAR = model->params->data.F32;
-        dPAR = model->dparams->data.F32;
 
         // pmSourceSextractType (source, &type, &flags);
Index: trunk/psModules/src/objects/pmSourcePhotometry.c
===================================================================
--- trunk/psModules/src/objects/pmSourcePhotometry.c	(revision 34062)
+++ trunk/psModules/src/objects/pmSourcePhotometry.c	(revision 34085)
@@ -899,21 +899,14 @@
 }
 
-# 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
+    double flux = 0;
+    double wt = 1.0;
+    double factor = 0;
 
     const psImage *Pi = Mi->modelFlux;
     assert (Pi != NULL);
 
-# if (HAVE_MODEL_VAR)
     const psImage *Wi = NULL;
     switch (fitVarMode) {
@@ -921,4 +914,152 @@
 	break;
       case PM_SOURCE_PHOTFIT_IMAGE_VAR:
+      case PM_SOURCE_PHOTFIT_MODEL_SKY:
+	Wi = Mi->variance;
+	psAssert (Wi, "programming error");
+	break;
+      case PM_SOURCE_PHOTFIT_MODEL_VAR:
+	Wi = Mi->modelVar;
+	psAssert (Wi, "programming error");
+	break;
+      case PM_SOURCE_PHOTFIT_NONE:
+	psAbort("programming error");
+    }	
+    const psImage *Ti = Mi->maskObj;
+    assert (Ti != NULL);
+
+    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 (fitVarMode != PM_SOURCE_PHOTFIT_CONST) {
+		wt = covarFactor * Wi->data.F32[yi][xi];
+		if (wt == 0) continue;
+	    }
+	    switch (term) {
+	      case 0:
+		factor = 1;
+		break;
+	      case 1:
+		factor = xi + Pi->col0;
+		break;
+	      case 2:
+		factor = yi + Pi->row0;
+		break;
+	      default:
+		psAbort("invalid term for pmSourceWeight");
+	    }
+
+	    // wt is 1.0 for CONST
+	    flux += (factor * Pi->data.F32[yi][xi]) / wt;
+	}
+    }
+    return flux;
+}
+
+double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal)
+{
+    PS_ASSERT_PTR_NON_NULL(Mi, NAN);
+    PS_ASSERT_PTR_NON_NULL(Mj, NAN);
+    int Xs, Xe, Ys, Ye;
+    int xi, xj, yi, yj;
+    int xIs, xJs, yIs, yJs;
+    int xIe, yIe;
+    double flux;
+    double wt = 1.0;
+
+    const psImage *Pi = Mi->modelFlux;
+    assert (Pi != NULL);
+    const psImage *Pj = Mj->modelFlux;
+    assert (Pj != NULL);
+
+    const psImage *Wi = NULL;
+    switch (fitVarMode) {
+      case PM_SOURCE_PHOTFIT_CONST:
+	break;
+      case PM_SOURCE_PHOTFIT_IMAGE_VAR:
+      case PM_SOURCE_PHOTFIT_MODEL_SKY:
+	Wi = Mi->variance;
+	psAssert (Wi, "programming error");
+	break;
+      case PM_SOURCE_PHOTFIT_MODEL_VAR:
+	Wi = Mi->modelVar;
+	psAssert (Wi, "programming error");
+	break;
+      case PM_SOURCE_PHOTFIT_NONE:
+	psAbort("programming error");
+    }	
+
+    const psImage *Ti = Mi->maskObj;
+    assert (Ti != NULL);
+    const psImage *Tj = Mj->maskObj;
+    assert (Tj != NULL);
+
+    Xs = PS_MAX (Pi->col0, Pj->col0);
+    Xe = PS_MIN (Pi->col0 + Pi->numCols, Pj->col0 + Pj->numCols);
+
+    Ys = PS_MAX (Pi->row0, Pj->row0);
+    Ye = PS_MIN (Pi->row0 + Pi->numRows, Pj->row0 + Pj->numRows);
+
+    xIs = Xs - Pi->col0;
+    xJs = Xs - Pj->col0;
+    yIs = Ys - Pi->row0;
+    yJs = Ys - Pj->row0;
+
+    xIe = Xe - Pi->col0;
+    yIe = Ye - Pi->row0;
+
+    // note that weight is addressing the same image pixels
+    flux = 0;
+    for (yi = yIs, yj = yJs; yi < yIe; yi++, yj++) {
+        for (xi = xIs, xj = xJs; xi < xIe; xi++, xj++) {
+            if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi] & maskVal)
+                continue;
+            if (Tj->data.PS_TYPE_IMAGE_MASK_DATA[yj][xj] & maskVal)
+                continue;
+
+	    float value = (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
+	    switch (fitVarMode) {
+	      case PM_SOURCE_PHOTFIT_CONST:
+		wt = 1.0;
+		break;
+	      case PM_SOURCE_PHOTFIT_IMAGE_VAR:
+	      case PM_SOURCE_PHOTFIT_MODEL_SKY:
+	      case PM_SOURCE_PHOTFIT_MODEL_VAR:
+		wt = covarFactor * Wi->data.F32[yi][xi];
+		break;
+	      case PM_SOURCE_PHOTFIT_NONE:
+		psAbort("programming error");
+	    }
+	    // skip pixels with nonsense weight values
+	    if (wt <= 0) continue;
+
+	    flux += value / wt;
+        }
+    }
+    return flux;
+}
+
+double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal)
+{
+    PS_ASSERT_PTR_NON_NULL(Mi, NAN);
+    PS_ASSERT_PTR_NON_NULL(Mj, NAN);
+    int Xs, Xe, Ys, Ye;
+    int xi, xj, yi, yj;
+    int xIs, xJs, yIs, yJs;
+    int xIe, yIe;
+    double flux;
+    double wt = 1.0;
+
+    const psImage *Pi = Mi->pixels;
+    assert (Pi != NULL);
+    const psImage *Pj = Mj->modelFlux;
+    assert (Pj != NULL);
+
+    const psImage *Wi = NULL;
+    switch (fitVarMode) {
+      case PM_SOURCE_PHOTFIT_CONST:
+	break;
+      case PM_SOURCE_PHOTFIT_IMAGE_VAR:
+      case PM_SOURCE_PHOTFIT_MODEL_SKY:
 	Wi = Mi->variance;
         psAssert (Wi, "programming error");
@@ -931,105 +1072,4 @@
 	psAbort("programming error");
     }	
-# else
-    const psImage *Wi = Mi->variance;
-    if (!unweighted_sum) {
-        assert (Wi != NULL);
-    }
-# endif
-    const psImage *Ti = Mi->maskObj;
-    assert (Ti != NULL);
-
-    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 (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) {
-	      case 0:
-                factor = 1;
-                break;
-	      case 1:
-                factor = xi + Pi->col0;
-                break;
-	      case 2:
-                factor = yi + Pi->row0;
-                break;
-	      default:
-                psAbort("invalid term for pmSourceWeight");
-            }
-
-# 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
-        }
-    }
-    return flux;
-}
-
-# 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);
-    PS_ASSERT_PTR_NON_NULL(Mj, NAN);
-    int Xs, Xe, Ys, Ye;
-    int xi, xj, yi, yj;
-    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;
-    assert (Pi != NULL);
-    const psImage *Pj = Mj->modelFlux;
-    assert (Pj != NULL);
-
-# if (HAVE_MODEL_VAR)
-    const psImage *Wi = NULL;
-    switch (fitVarMode) {
-      case PM_SOURCE_PHOTFIT_CONST:
-	break;
-      case PM_SOURCE_PHOTFIT_IMAGE_VAR:
-	Wi = Mi->variance;
-        psAssert (Wi, "programming error");
-	break;
-      case PM_SOURCE_PHOTFIT_MODEL_VAR:
-	Wi = Mi->modelVar;
-        psAssert (Wi, "programming error");
-	break;
-      case PM_SOURCE_PHOTFIT_NONE:
-	psAbort("programming error");
-    }	
-# else
-    const psImage *Wi = Mi->variance;
-    if (!unweighted_sum) {
-        assert (Wi != NULL);
-    }
-# endif
 
     const psImage *Ti = Mi->maskObj;
@@ -1052,5 +1092,5 @@
     yIe = Ye - Pi->row0;
 
-    // note that weight is addressing the same image pixels
+    // note that weight is addressing the same image pixels,
     flux = 0;
     for (yi = yIs, yj = yJs; yi < yIe; yi++, yj++) {
@@ -1061,5 +1101,4 @@
                 continue;
 
-# if (HAVE_MODEL_VAR)
 	    float value = (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
 	    switch (fitVarMode) {
@@ -1068,4 +1107,5 @@
 		break;
 	      case PM_SOURCE_PHOTFIT_IMAGE_VAR:
+	      case PM_SOURCE_PHOTFIT_MODEL_SKY:
 	      case PM_SOURCE_PHOTFIT_MODEL_VAR:
                 wt = covarFactor * Wi->data.F32[yi][xi];
@@ -1078,126 +1118,6 @@
 
 	    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
         }
     }
     return flux;
 }
-
-# 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);
-    PS_ASSERT_PTR_NON_NULL(Mj, NAN);
-    int Xs, Xe, Ys, Ye;
-    int xi, xj, yi, yj;
-    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;
-    assert (Pi != NULL);
-    const psImage *Pj = Mj->modelFlux;
-    assert (Pj != NULL);
-
-# if (HAVE_MODEL_VAR)
-    const psImage *Wi = NULL;
-    switch (fitVarMode) {
-      case PM_SOURCE_PHOTFIT_CONST:
-	break;
-      case PM_SOURCE_PHOTFIT_IMAGE_VAR:
-	Wi = Mi->variance;
-        psAssert (Wi, "programming error");
-	break;
-      case PM_SOURCE_PHOTFIT_MODEL_VAR:
-	Wi = Mi->modelVar;
-        psAssert (Wi, "programming error");
-	break;
-      case PM_SOURCE_PHOTFIT_NONE:
-	psAbort("programming error");
-    }	
-# else
-    const psImage *Wi = Mi->variance;
-    if (!unweighted_sum) {
-        assert (Wi != NULL);
-    }
-# endif
-
-    const psImage *Ti = Mi->maskObj;
-    assert (Ti != NULL);
-    const psImage *Tj = Mj->maskObj;
-    assert (Tj != NULL);
-
-    Xs = PS_MAX (Pi->col0, Pj->col0);
-    Xe = PS_MIN (Pi->col0 + Pi->numCols, Pj->col0 + Pj->numCols);
-
-    Ys = PS_MAX (Pi->row0, Pj->row0);
-    Ye = PS_MIN (Pi->row0 + Pi->numRows, Pj->row0 + Pj->numRows);
-
-    xIs = Xs - Pi->col0;
-    xJs = Xs - Pj->col0;
-    yIs = Ys - Pi->row0;
-    yJs = Ys - Pj->row0;
-
-    xIe = Xe - Pi->col0;
-    yIe = Ye - Pi->row0;
-
-    // note that weight is addressing the same image pixels,
-    flux = 0;
-    for (yi = yIs, yj = yJs; yi < yIe; yi++, yj++) {
-        for (xi = xIs, xj = xJs; xi < xIe; xi++, xj++) {
-            if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi] & maskVal)
-                continue;
-            if (Tj->data.PS_TYPE_IMAGE_MASK_DATA[yj][xj] & maskVal)
-                continue;
-
-# if (HAVE_MODEL_VAR)
-	    float value = (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
-	    switch (fitVarMode) {
-	      case PM_SOURCE_PHOTFIT_CONST:
-		wt = 1.0;
-		break;
-	      case PM_SOURCE_PHOTFIT_IMAGE_VAR:
-	      case PM_SOURCE_PHOTFIT_MODEL_VAR:
-                wt = covarFactor * Wi->data.F32[yi][xi];
-		break;
-	      case PM_SOURCE_PHOTFIT_NONE:
-		psAbort("programming error");
-	    }
-            // skip pixels with nonsense weight values
-	    if (wt <= 0) continue;
-
-	    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
-        }
-    }
-    return flux;
-}
Index: trunk/psModules/src/objects/pmSourcePhotometry.h
===================================================================
--- trunk/psModules/src/objects/pmSourcePhotometry.h	(revision 34062)
+++ trunk/psModules/src/objects/pmSourcePhotometry.h	(revision 34085)
@@ -38,5 +38,4 @@
 } pmSourcePhotometryMode;
 
-# if (HAVE_MODEL_VAR)
 typedef enum {
     PM_SOURCE_PHOTFIT_NONE       = 0,
@@ -44,6 +43,6 @@
     PM_SOURCE_PHOTFIT_IMAGE_VAR  = 2,
     PM_SOURCE_PHOTFIT_MODEL_VAR  = 3,
+    PM_SOURCE_PHOTFIT_MODEL_SKY  = 4,   // XXX bad name: set variance floor based on mean variance image (variance of sky)
 } pmSourceFitVarMode;
-# endif
 
 bool pmSourcePhotometryModel(
@@ -84,13 +83,7 @@
 bool pmSourceMeasureDiffStats (pmSource *source, psImageMaskType maskVal, psImageMaskType markVal);
 
-# if (HAVE_MODEL_VAR)
 double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal);
 double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal);
 double pmSourceModelWeight(const pmSource *Mi, int term, 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);
-double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal);
-double pmSourceModelWeight(const pmSource *Mi, int term, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal);
-# endif
 
 bool pmSourceNeighborFlags (pmSource *source);
Index: trunk/psModules/test/tap/src/tap.c
===================================================================
--- trunk/psModules/test/tap/src/tap.c	(revision 34062)
+++ trunk/psModules/test/tap/src/tap.c	(revision 34085)
@@ -87,5 +87,6 @@
     if(test_name != NULL) {
         va_start(ap, test_name);
-        vasprintf(&local_test_name, test_name, ap);
+        int status = vasprintf(&local_test_name, test_name, ap);
+	if (status) {/* warning? */}
         va_end(ap);
 
@@ -303,5 +304,6 @@
 
     va_start(ap, fmt);
-    asprintf(&skip_msg, fmt, ap);
+    int status = asprintf(&skip_msg, fmt, ap);
+    if (status) {/* warning? */}
     va_end(ap);
 
@@ -328,5 +330,6 @@
 
     va_start(ap, fmt);
-    vasprintf(&todo_msg, fmt, ap);
+    int status = vasprintf(&todo_msg, fmt, ap);
+    if (status) {/* warning? */}
     va_end(ap);
 
