Index: trunk/Ohana/src/relphot/include/relphot.h
===================================================================
--- trunk/Ohana/src/relphot/include/relphot.h	(revision 4810)
+++ trunk/Ohana/src/relphot/include/relphot.h	(revision 4828)
@@ -40,4 +40,6 @@
 char   GSCFILE[256];
 char   CATDIR[256];
+char   CATMODE[16];    /* raw, mef, split, mysql */
+char   CATFORMAT[16];  /* internal, elixir, loneos, panstarrs */
 char   CameraConfig[256];
 
Index: trunk/Ohana/src/relphot/src/ConfigInit.c
===================================================================
--- trunk/Ohana/src/relphot/src/ConfigInit.c	(revision 4810)
+++ trunk/Ohana/src/relphot/src/ConfigInit.c	(revision 4828)
@@ -38,4 +38,6 @@
   GetConfig (config, "GSCFILE",                "%s",  0, GSCFILE);
   GetConfig (config, "CATDIR",                 "%s",  0, CATDIR);
+  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
+  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
   GetConfig (config, "PHOTCODE_FILE",          "%s",  0, PhotCodeFile);
   GetConfig (config, "ZERO_PT",                "%lf", 0, &ZERO_POINT);
@@ -45,4 +47,7 @@
   GetConfig (config, "RELPHOT_GRID_BINNING",   "%d",  0, &RELPHOT_GRID_BINNING);
   GetConfig (config, "CAMERA_CONFIG",          "%s",  0, CameraConfig);
+
+  if (*CATMODE == 0) strcpy (CATMODE, "RAW");
+  if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
 
   if (!LoadPhotcodes (PhotCodeFile)) {
Index: trunk/Ohana/src/relphot/src/gcatalog.c
===================================================================
--- trunk/Ohana/src/relphot/src/gcatalog.c	(revision 4810)
+++ trunk/Ohana/src/relphot/src/gcatalog.c	(revision 4828)
@@ -4,4 +4,7 @@
   
   char mode;
+
+  /* no autodetect for CATMODE yet */
+  strcpy (catalog[0].catmode, CATMODE);
 
   if (FINAL) {
Index: trunk/Ohana/src/relphot/src/wcatalog.c
===================================================================
--- trunk/Ohana/src/relphot/src/wcatalog.c	(revision 4810)
+++ trunk/Ohana/src/relphot/src/wcatalog.c	(revision 4828)
@@ -3,7 +3,17 @@
 void wcatalog (Catalog *catalog) {
   
-  fits_modify (&catalog[0].header, "NRPHOT", "%t", 1, TRUE);
+  /* set catalog format (elixir, loneos, etc) */
+  if (!strcmp (CATFORMAT, "INTERNAL")) {
+    sprintf (catalog[0].average_format, "DVO_AVERAGE");
+    sprintf (catalog[0].measure_format, "DVO_MEASURE");
+  } else {
+    sprintf (catalog[0].average_format, "DVO_AVERAGE_%s", CATFORMAT);
+    sprintf (catalog[0].measure_format, "DVO_MEASURE_%s", CATFORMAT);
+  }
 
-  save_catalog (catalog, VERBOSE);
+  if (!save_catalog (catalog, VERBOSE)) {
+    fprintf (stderr, "ERROR: failure saving catalog\n");
+    exit (1);
+  }
 
   if (catalog[0].Naverage) {
@@ -23,3 +33,4 @@
     catalog[0].Nsecfilt = 0;
   }
+  fits_free_header (&catalog[0].header);
 }
