Index: /branches/eam_branches/ipp-20120627/psModules/src/objects/Makefile.am
===================================================================
--- /branches/eam_branches/ipp-20120627/psModules/src/objects/Makefile.am	(revision 34184)
+++ /branches/eam_branches/ipp-20120627/psModules/src/objects/Makefile.am	(revision 34185)
@@ -133,5 +133,5 @@
 
 # pmSourceID_CMF_* functions use a common framework
-BUILT_SOURCES = pmSourceIO_CMF_PS1_V1.c pmSourceIO_CMF_PS1_V2.c pmSourceIO_CMF_PS1_V3.c pmSourceIO_CMF_PS1_V4.c
+BUILT_SOURCES = pmSourceIO_CMF_PS1_V1.c pmSourceIO_CMF_PS1_V2.c pmSourceIO_CMF_PS1_V3.c pmSourceIO_CMF_PS1_DV1.c pmSourceIO_CMF_PS1_DV2.c pmSourceIO_CMF_PS1_SV1.c
 
 pmSourceIO_CMF_PS1_V1.c : pmSourceIO_CMF.c.in mksource.pl
@@ -147,3 +147,12 @@
 	mksource.pl pmSourceIO_CMF.c.in PS1_V4 pmSourceIO_CMF_PS1_V4.c
 
+pmSourceIO_CMF_PS1_DV1.c : pmSourceIO_CMF.c.in mksource.pl
+	mksource.pl pmSourceIO_CMF.c.in PS1_DV1 pmSourceIO_CMF_PS1_DV1.c
+
+pmSourceIO_CMF_PS1_DV2.c : pmSourceIO_CMF.c.in mksource.pl
+	mksource.pl pmSourceIO_CMF.c.in PS1_DV2 pmSourceIO_CMF_PS1_DV2.c
+
+pmSourceIO_CMF_PS1_SV1.c : pmSourceIO_CMF.c.in mksource.pl
+	mksource.pl pmSourceIO_CMF.c.in PS1_SV1 pmSourceIO_CMF_PS1_SV1.c
+
 # EXTRA_DIST = pmErrorCodes.h.in pmErrorCodes.dat pmErrorCodes.c.in
Index: /branches/eam_branches/ipp-20120627/psModules/src/objects/mksource.pl
===================================================================
--- /branches/eam_branches/ipp-20120627/psModules/src/objects/mksource.pl	(revision 34184)
+++ /branches/eam_branches/ipp-20120627/psModules/src/objects/mksource.pl	(revision 34185)
@@ -58,5 +58,5 @@
 
     # grab the rules and the rest of the line
-    ($prefix,$rules,$content) = ($line =~ m|(.*)\@(.*)\@(.*)|);
+    ($prefix,$rules,$content) = ($line =~ m|(.*)\@(.*)\@\s*(.*)|);
     
     # split the rules into separate items
Index: /branches/eam_branches/ipp-20120627/psModules/src/objects/pmSourceIO_CMF.c.in
===================================================================
--- /branches/eam_branches/ipp-20120627/psModules/src/objects/pmSourceIO_CMF.c.in	(revision 34184)
+++ /branches/eam_branches/ipp-20120627/psModules/src/objects/pmSourceIO_CMF.c.in	(revision 34185)
@@ -89,5 +89,9 @@
     // by the time we call this function, all values should be assigned.  let's use asserts to be sure in some cases.
     for (int i = 0; i < sources->n; i++) {
-        pmSource *source = (pmSource *) sources->data[i];
+	// this is the source associated with this image
+        pmSource *thisSource = sources->data[i];
+
+	// this is the "real" version of this source 
+	pmSource *source = thisSource->parent ? thisSource->parent : thisSource;
 
         // If source->seq is -1, source was generated in this analysis.  If source->seq is
@@ -128,6 +132,6 @@
         @ALL@      		  psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        source->psfMagErr);
 
-	@ALL,!PS1_V1@             psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX",    PS_DATA_F32, "PSF fit instrumental flux (counts)",         source->psfFlux);
-	@ALL,!PS1_V1@             psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX_SIG",PS_DATA_F32, "Sigma of PSF instrumental flux",             source->psfFluxErr);
+	@ALL,!PS1_V1,!PS1_V2@     psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX",    PS_DATA_F32, "PSF fit instrumental flux (counts)",         source->psfFlux);
+	@ALL,!PS1_V1,!PS1_V2@     psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX_SIG",PS_DATA_F32, "Sigma of PSF instrumental flux",             source->psfFluxErr);
 
         @ALL@      		  psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG",           PS_DATA_F32, "magnitude in standard aperture",             source->apMag);
@@ -195,5 +199,6 @@
         @ALL@     		  psMetadataAdd (row, PS_LIST_TAIL, "FLAGS",            PS_DATA_U32, "psphot analysis flags",                      source->mode);
 	@>PS1_V2,PS1_SV1,PS1_DV2@ psMetadataAdd (row, PS_LIST_TAIL, "FLAGS2",           PS_DATA_U32, "psphot analysis flags",                      source->mode2);
-	@>PS1_V2,PS1_SV1,PS1_DV?@ psMetadataAdd (row, PS_LIST_TAIL, "PADDING2",         PS_DATA_S32, "more padding", 0);
+	@>PS1_V2@                 psMetadataAdd (row, PS_LIST_TAIL, "PADDING2",         PS_DATA_S32, "more padding", 0);
+	@PS1_SV1@ // XXX do I need PADDING2 or not?
 
         // XXX not sure how to get this : need to load Nimages with weight?
@@ -383,5 +388,5 @@
 	@PS1_DV2@      source->diffStats->Rm         = psMetadataLookupF32 (&status, row, "DIFF_R_M");
 	@PS1_DV2@      source->diffStats->SNm        = psMetadataLookupF32 (&status, row, "DIFF_SN_M");
-	@DV1,DV2@  }
+	@PS1_DV?@  }
 
         @ALL@                     source->mode  = psMetadataLookupU32 (&status, row, "FLAGS");
@@ -589,5 +594,5 @@
 }
 
-bool pmSourcesRead_CMF_PS1_@CMFMODE@_XSRC(psFits *fits, psMetadata *hduHeader, psArray *sources, long *sourceIndex)
+bool pmSourcesRead_CMF_@CMFMODE@_XSRC(psFits *fits, psMetadata *hduHeader, psArray *sources, long *sourceIndex)
 {
     PS_ASSERT_PTR_NON_NULL(fits, false);
@@ -813,7 +818,7 @@
 
                 if (k < model->params->n) {
-                    psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "", model->params->data.F32[k]);
+                    psMetadataAddF32 (row, PS_LIST_TAIL, name, 0, "", model->params->data.F32[k]);
                 } else {
-                    psMetadataAddF32 (row, PS_LIST_TAIL, name, PS_DATA_F32, "", NAN);
+                    psMetadataAddF32 (row, PS_LIST_TAIL, name, 0, "", NAN);
                 }
             }
@@ -859,5 +864,5 @@
 }
 
-bool pmSourcesRead_CMF_PS1_@CMFMODE@_XFIT(psFits *fits, psMetadata *hduHeader, psArray *sources, long *sourceIndex)
+bool pmSourcesRead_CMF_@CMFMODE@_XFIT(psFits *fits, psMetadata *hduHeader, psArray *sources, long *sourceIndex)
 {
     PS_ASSERT_PTR_NON_NULL(fits, false);
@@ -961,5 +966,5 @@
 // **** write out the radial flux values for the sources for a given matched-PSF image
 // **** how do we distinguish the matched-PSF images from the non-matched version
-bool pmSourcesWrite_CMF_PS1_@CMFMODE@_XRAD(psFits *fits, pmReadout *readout, psArray *sources, psMetadata *imageHeader, char *extname, psMetadata *recipe)
+bool pmSourcesWrite_CMF_@CMFMODE@_XRAD(psFits *fits, pmReadout *readout, psArray *sources, psMetadata *imageHeader, char *extname, psMetadata *recipe)
 {
     bool status = false;
@@ -1104,5 +1109,5 @@
 }
 
-bool pmSourcesRead_CMF_PS1_@CMFMODE@_XRAD(psFits *fits, pmReadout *readout, psMetadata *hduHeader, psArray *sources, long *sourceIndex)
+bool pmSourcesRead_CMF_@CMFMODE@_XRAD(psFits *fits, pmReadout *readout, psMetadata *hduHeader, psArray *sources, long *sourceIndex)
 {
     PS_ASSERT_PTR_NON_NULL(fits, false);
