Index: trunk/psModules/src/objects/pmSourceIO.c
===================================================================
--- trunk/psModules/src/objects/pmSourceIO.c	(revision 12398)
+++ trunk/psModules/src/objects/pmSourceIO.c	(revision 12402)
@@ -3,6 +3,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-03-10 07:03:20 $
+ *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-03-11 18:56:38 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -329,11 +329,31 @@
 	}
 
-        exttype = psStringCopy ("SMPDATA");  // XXX derive this from the recipes
+	psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, "PSPHOT");
+	if (!status) {
+	  psError(PS_ERR_UNKNOWN, true, "missing recipe PSPHOT in config data");
+	  return false;
+	}
+	exttype = psMetadataLookupMetadata(&status, recipe, "OUTPUT.FORMAT");
+	if (!status) {
+	  psError(PS_ERR_UNKNOWN, true, "missing OUTPUT.FORMAT in PSPHOT recipe");
+	  return false;
+	}
+
         psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTHEAD", PS_META_REPLACE, "name of image extension w/", headname);
         psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTTYPE", PS_META_REPLACE, "extension type", exttype);
         psFree (exttype);
 
-        if (!pmSourcesWriteCMF (file->fits, sources, outhead, dataname)) {
-            psError(PS_ERR_IO, false, "writing CMF data to %s\n", file->filename);
+	// XXX these are case-sensitive since the EXTYPE is case-sensitive
+
+	status = false;
+	if (!strcmp (exttype, "SMPDATA")) {
+	  status = pmSourcesWrite_SMPDATA (file->fits, sources, outhead, dataname);
+	}
+	if (!strcmp (exttype, "PS1_DEV_0")) {
+	  status = pmSourcesWrite_PS1_DEV_0 (file->fits, sources, outhead, dataname);
+	}
+
+        if (!status) {
+            psError(PS_ERR_IO, false, "writing CMF data to %s with format %s\n", file->filename, exttype);
             psFree (headname);
             psFree (dataname);
@@ -497,4 +517,6 @@
         }
 
+	XXX need to test for EXTNAME vs SMPDATA, PS1_DEV_0, etc
+
         // we need to find the corresponding table EXTNAME.
         // first check the header
