Index: trunk/psphot/src/psphotImageLoop.c
===================================================================
--- trunk/psphot/src/psphotImageLoop.c	(revision 6117)
+++ trunk/psphot/src/psphotImageLoop.c	(revision 6311)
@@ -5,5 +5,4 @@
     bool status;
     ppImageLoadDepth imageLoadDepth;
-    char filename[1024];
 
     // determine the load depth
@@ -27,8 +26,4 @@
     }
 
-    char *outputRoot = psMetadataLookupPtr (&status, config->arguments, "-output");
-    if (!status) psAbort ("psphot", "output file not specified");
-
-    int Nout = 0;
     for (int i = 0; i < file->fpa->chips->n; i++) {
         pmChip *chip = file->fpa->chips->data[i]; // Chip of interest in input image
@@ -53,4 +48,6 @@
             }
 
+	    // XXX optional mask and weight input image should be loaded here?
+	    // this sets the weight map and basic mask applying CELL.BAD and CELL.SATURATION
 	    pmCellSetWeights(cell);
 
@@ -58,23 +55,13 @@
 	    pmCellSetMask (cell, config->recipe); 
 
-
 	    // process each of the readouts
 	    for (int k = 0; k < cell->readouts->n; k++) {
 		pmReadout *readout = cell->readouts->data[k]; // Readout of interest in input image
 
-		// psphotSaveImage (NULL, readout->image, "image.fits");
-		// psphotSaveImage (NULL, readout->weight, "weight.fits");
-		// psphotSaveImage (NULL, readout->mask, "mask.fits");
+		// run a single-model test if desired
+		psphotModelTest (readout, config->arguments, config->recipe);
 
 		psphotReadout (readout, config->recipe);
-
-		// XXX EAM : temporarily write out only CMF with fixed extension
-		sprintf (filename, "%s.%02d.cmf", outputRoot, Nout);
-		psMetadata *header = pmReadoutGetHeader (readout);
-
-		psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES");
-
-		pmSourcesWriteCMF (sources, filename, header);
-		Nout++;
+		psphotOutput (readout, config->arguments);
 	    }
         }
