Index: trunk/psastro/src/psastroMosaicAstrom.c
===================================================================
--- trunk/psastro/src/psastroMosaicAstrom.c	(revision 19310)
+++ trunk/psastro/src/psastroMosaicAstrom.c	(revision 19386)
@@ -2,11 +2,14 @@
 # define NONLIN_TOL 0.001 /* tolerance in pixels */
 
-bool psastroMosaicFit (pmFPA *fpa, psMetadata *recipe, int pass);
+bool psastroMosaicFit (pmFPA *fpa, psMetadata *recipe, const char *rootname, int pass);
 
 // XXX require this fpa to have multiple chip extensions and a PHU?
 bool psastroMosaicAstrom (pmConfig *config) {
 
+    bool status;
+    char filename[256];
+
     // select the current recipe
-    psMetadata *recipe  = psMetadataLookupPtr (NULL, config->recipes, PSASTRO_RECIPE);
+    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSASTRO_RECIPE);
     if (!recipe) {
 	psError(PSASTRO_ERR_CONFIG, false, "Can't find PSASTRO recipe!\n");
@@ -36,8 +39,11 @@
     # endif
 
-    if (!psastroMosaicFit (fpa, recipe, 0)) return false;
-    if (!psastroMosaicFit (fpa, recipe, 1)) return false;
-    if (!psastroMosaicFit (fpa, recipe, 2)) return false;
-    if (!psastroMosaicFit (fpa, recipe, 3)) return false;
+    char *outroot = psMetadataLookupStr (&status, config->arguments, "OUTPUT");
+    if (!status || !outroot) psAbort ("Can't find outroot on config->arguments");
+
+    if (!psastroMosaicFit (fpa, recipe, outroot, 0)) return false;
+    if (!psastroMosaicFit (fpa, recipe, outroot, 1)) return false;
+    if (!psastroMosaicFit (fpa, recipe, outroot, 2)) return false;
+    if (!psastroMosaicFit (fpa, recipe, outroot, 3)) return false;
 
     // now fit the chips under the common distortion with higher-order terms
@@ -51,5 +57,8 @@
 	return false;
     }
-    if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.10.dat"); }
+    if (psTraceGetLevel("psastro.dump") > 0) { 
+	snprintf (filename, 256, "%s.10.dat", outroot);
+	psastroDumpMatches (fpa, filename); 
+    }
 
     // save WCS and analysis metadata in update header.
@@ -84,7 +93,7 @@
 // 2: match 6,7
 // 3: match 8,9
-bool psastroMosaicFit (pmFPA *fpa, psMetadata *recipe, int pass) {
+bool psastroMosaicFit (pmFPA *fpa, psMetadata *recipe, const char *rootname, int pass) {
 
-    char filename[16];
+    char filename[256];
 
     // given the existing per-chip astrometry, determine matches between raw and ref stars
@@ -95,5 +104,8 @@
     }
 
-    if ((pass == 0) && (psTraceGetLevel("psastro.dump.psastroMosaicAstrom") > 0)) { psastroDumpMatches (fpa, "match.0.dat"); }
+    if ((pass == 0) && (psTraceGetLevel("psastro.dump.psastroMosaicAstrom") > 0)) { 
+	snprintf (filename, 256, "%s.0.dat", rootname);
+	psastroDumpMatches (fpa, filename); 
+    }
 
     // fitted chips will follow the local plate-scale, hiding the distortion
@@ -105,5 +117,8 @@
     }
 
-    if ((pass == 0) && (psTraceGetLevel("psastro.dump.psastroMosaicAstrom") > 0)) { psastroDumpMatches (fpa, "match.1.dat"); }
+    if ((pass == 0) && (psTraceGetLevel("psastro.dump.psastroMosaicAstrom") > 0)) { 
+	snprintf (filename, 256, "%s.1.dat", rootname);
+	psastroDumpMatches (fpa, filename); 
+    }
 
     // fit the distortion by fitting its gradient
@@ -115,5 +130,5 @@
     }
 
-    snprintf (filename, 16, "match.%d.dat", 2*pass + 2);
+    snprintf (filename, 256, "%s.%d.dat", rootname, 2*pass + 2);
     if (psTraceGetLevel("psastro.dump.psastroMosaicAstrom") > 0) { psastroDumpMatches (fpa, filename); }
     
@@ -124,5 +139,5 @@
     }
 
-    snprintf (filename, 16, "match.%d.dat", 2*pass + 3);
+    snprintf (filename, 256, "%s.%d.dat", rootname, 2*pass + 3);
     if (psTraceGetLevel("psastro.dump.psastroMosaicAstrom") > 0) { psastroDumpMatches (fpa, filename); }
 
