Index: trunk/psastro/src/psastroDefineFiles.c
===================================================================
--- trunk/psastro/src/psastroDefineFiles.c	(revision 15891)
+++ trunk/psastro/src/psastroDefineFiles.c	(revision 17039)
@@ -29,9 +29,27 @@
     }
     if (fixChips || useModel) {
-        if (!psastroDefineFile (config, input->fpa, "PSASTRO.MODEL", "ASTROM.MODEL", PM_FPA_FILE_ASTROM, PM_DETREND_TYPE_ASTROM)) {
+        if (!psastroDefineFile (config, input->fpa, "PSASTRO.MODEL", "ASTROM.MODEL", PM_FPA_FILE_ASTROM_MODEL, PM_DETREND_TYPE_ASTROM)) {
             psError (PS_ERR_IO, false, "Can't find an astrometry model file");
             return NULL;
         }
     }
+
+    bool saveRefstars = psMetadataLookupBool (&status, config->arguments, "PSASTRO.SAVE.REFSTARS");
+    if (!status) {
+      saveRefstars = psMetadataLookupBool (&status, recipe, "PSASTRO.SAVE.REFSTARS");
+    }
+    if (saveRefstars) {
+	// look for the file in the camera config table
+	pmFPAfile *file = pmFPAfileDefineFromConf  (&status, config, "PSASTRO.REFSTARS");
+	if (!status) {
+	    psError (PS_ERR_IO, false, "Can't find the astrometry refstars file definition");
+	    return NULL;
+	}
+	if (file->type != PM_FPA_FILE_ASTROM_REFSTARS) {
+	    psError(PS_ERR_IO, true, "%s is not of type %s", "PSASTRO.REFSTARS", pmFPAfileStringFromType (PM_FPA_FILE_ASTROM_REFSTARS));
+	    return NULL;
+	}
+    }
+
 
 # if (0)
