Index: /trunk/Ohana/src/gastro/Makefile
===================================================================
--- /trunk/Ohana/src/gastro/Makefile	(revision 4827)
+++ /trunk/Ohana/src/gastro/Makefile	(revision 4828)
@@ -17,5 +17,5 @@
 #  
 INCS	= 	-I$(INC) -I$(LINC) -I$(XINC)
-LIBS	= 	-L$(LLIB) -lFITS -lohana -lm -lsocket -lnsl 
+LIBS	= 	-L$(LLIB) -lohana -lFITS -lm -lsocket -lnsl 
 CFLAGS	=	$(INCS)
 LFLAGS	=	$(LIBS) 
Index: /trunk/Ohana/src/gastro/include/gastro.h
===================================================================
--- /trunk/Ohana/src/gastro/include/gastro.h	(revision 4827)
+++ /trunk/Ohana/src/gastro/include/gastro.h	(revision 4828)
@@ -31,4 +31,6 @@
 char CDROM[256];
 char CATDIR[256];
+char CATMODE[16];    /* raw, mef, split, mysql */
+char CATFORMAT[16];  /* internal, elixir, loneos, panstarrs */
 char REFCAT[256];
 char HEADER[256];
Index: /trunk/Ohana/src/gastro/src/ConfigInit.c
===================================================================
--- /trunk/Ohana/src/gastro/src/ConfigInit.c	(revision 4827)
+++ /trunk/Ohana/src/gastro/src/ConfigInit.c	(revision 4828)
@@ -44,6 +44,11 @@
   ScanConfig (config, "ASTRO_REFCAT",      "%s",  0, REFCAT);
   ScanConfig (config, "CATDIR",            "%s",  0, CATDIR);
+  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
+  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
   ScanConfig (config, "ROUGH_ASTROMETRY",  "%s",  0, ROUGH_ASTROMETRY);
   ScanConfig (config, "PHOTCODE_FILE",     "%s",  0, PhotCodeFile);
+
+  if (*CATMODE == 0) strcpy (CATMODE, "RAW");
+  if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
 
   if (strcasecmp (ROUGH_ASTROMETRY, "header") && 
Index: /trunk/Ohana/src/gastro/src/gptolemy.c
===================================================================
--- /trunk/Ohana/src/gastro/src/gptolemy.c	(revision 4827)
+++ /trunk/Ohana/src/gastro/src/gptolemy.c	(revision 4828)
@@ -8,4 +8,6 @@
   char filename[256], *fileroot, *filepath, *subdir;
   Catalog catalog;
+
+  strcpy (catalog.catmode, CATMODE);
 
   filepath = pathname (fullpath);
Index: /trunk/Ohana/src/gastro2/include/gastro2.h
===================================================================
--- /trunk/Ohana/src/gastro2/include/gastro2.h	(revision 4827)
+++ /trunk/Ohana/src/gastro2/include/gastro2.h	(revision 4828)
@@ -114,4 +114,6 @@
 char CDROM[256];
 char CATDIR[256];
+char   CATMODE[16];    /* raw, mef, split, mysql */
+char   CATFORMAT[16];  /* internal, elixir, loneos, panstarrs */
 char REFCAT[256];
 char HEADER[256];
Index: /trunk/Ohana/src/gastro2/src/ConfigInit.c
===================================================================
--- /trunk/Ohana/src/gastro2/src/ConfigInit.c	(revision 4827)
+++ /trunk/Ohana/src/gastro2/src/ConfigInit.c	(revision 4828)
@@ -43,8 +43,13 @@
   ScanConfig (config, "ASTRO_REFCAT",      "%s",  0, REFCAT);
   ScanConfig (config, "CATDIR",            "%s",  0, CATDIR);
+  ScanConfig (config, "CATMODE",           "%s",  0, CATMODE);
+  ScanConfig (config, "CATFORMAT",         "%s",  0, CATFORMAT);
   ScanConfig (config, "ROUGH_ASTROMETRY",  "%s",  0, ROUGH_ASTROMETRY);
   ScanConfig (config, "PHOTCODE_FILE",     "%s",  0, PhotCodeFile);
   ScanConfig (config, "GASTRO_MAX_NSTARS", "%d",  0, &GASTRO_MAX_NSTARS);
   ScanConfig (config, "GASTRO_MAX_MAG_ERROR", "%lf", 0, &MAX_ERROR);
+
+  if (*CATMODE == 0) strcpy (CATMODE, "RAW");
+  if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
 
   if (strcasecmp (ROUGH_ASTROMETRY, "header") && 
Index: /trunk/Ohana/src/gastro2/src/gptolemy2.c
===================================================================
--- /trunk/Ohana/src/gastro2/src/gptolemy2.c	(revision 4827)
+++ /trunk/Ohana/src/gastro2/src/gptolemy2.c	(revision 4828)
@@ -10,5 +10,7 @@
   GSCdata *stars;
 
-  filepath = pathname (fullpath);
+  strcpy (catalog.catmode, CATMODE);
+
+ filepath = pathname (fullpath);
   fileroot = filebasename (fullpath);
   subdir = filebasename (filepath);
Index: /trunk/Ohana/src/getstar/include/getstar.h
===================================================================
--- /trunk/Ohana/src/getstar/include/getstar.h	(revision 4827)
+++ /trunk/Ohana/src/getstar/include/getstar.h	(revision 4828)
@@ -22,4 +22,6 @@
 char   GSCFILE[256];
 char   CATDIR[256];
+char   CATMODE[16];    /* raw, mef, split, mysql */
+char   CATFORMAT[16];  /* internal, elixir, loneos, panstarrs */
 double DEFAULT_RADIUS, NSIGMA, SNLIMIT;
 double ZeroPt;
Index: /trunk/Ohana/src/getstar/src/ConfigInit.c
===================================================================
--- /trunk/Ohana/src/getstar/src/ConfigInit.c	(revision 4827)
+++ /trunk/Ohana/src/getstar/src/ConfigInit.c	(revision 4828)
@@ -40,4 +40,6 @@
   ScanConfig (config, "GSCFILE",                "%s", 0, GSCFILE);
   ScanConfig (config, "CATDIR",                 "%s", 0, CATDIR);
+  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
+  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
   ScanConfig (config, "MIN_SN_FSTAT",           "%lf", 0, &SNLIMIT);
   ScanConfig (config, "PHOTCODE_FILE",          "%s", 0, PhotCodeFile);
@@ -53,4 +55,7 @@
   ScanConfig (config, "CCDNUM-KEYWORD",         "%s", 0, CCDNumKeyword);
 
+  if (*CATMODE == 0) strcpy (CATMODE, "RAW");
+  if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
+
   if (!LoadPhotcodes (PhotCodeFile)) {
     fprintf (stderr, "error loading photcodes\n");
Index: /trunk/Ohana/src/getstar/src/gcatalog.c
===================================================================
--- /trunk/Ohana/src/getstar/src/gcatalog.c	(revision 4827)
+++ /trunk/Ohana/src/getstar/src/gcatalog.c	(revision 4828)
@@ -5,4 +5,7 @@
   int Nsecfilt;
   char mode;
+
+  /* no autodetect for CATMODE yet */
+  strcpy (catalog[0].catmode, CATMODE);
 
   /* read catalog header */
Index: /trunk/Ohana/src/markrock/include/markrock.h
===================================================================
--- /trunk/Ohana/src/markrock/include/markrock.h	(revision 4827)
+++ /trunk/Ohana/src/markrock/include/markrock.h	(revision 4828)
@@ -29,4 +29,6 @@
 char   GSCDIR[256];
 char   CATDIR[256];
+char   CATMODE[16];    /* raw, mef, split, mysql */
+char   CATFORMAT[16];  /* internal, elixir, loneos, panstarrs */
 char   RockCat[256];
 
Index: /trunk/Ohana/src/markrock/src/ConfigInit.c
===================================================================
--- /trunk/Ohana/src/markrock/src/ConfigInit.c	(revision 4827)
+++ /trunk/Ohana/src/markrock/src/ConfigInit.c	(revision 4828)
@@ -18,4 +18,6 @@
   /* used in other pipeline functions */
   ScanConfig (config, "CATDIR",                 "%s",  0, CATDIR);
+  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
+  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
 
   /* unique to markrock */
@@ -36,4 +38,7 @@
   ScanConfig (config, "ZERO_PT",                "%lf", 0, &ZERO_POINT);
 
+  if (*CATMODE == 0) strcpy (CATMODE, "RAW");
+  if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
+
   if (!LoadPhotcodes (PhotCodeFile, &photcodes)) {
     fprintf (stderr, "error loading photcodes\n");
Index: /trunk/Ohana/src/markrock/src/gcatalog.c
===================================================================
--- /trunk/Ohana/src/markrock/src/gcatalog.c	(revision 4827)
+++ /trunk/Ohana/src/markrock/src/gcatalog.c	(revision 4828)
@@ -9,4 +9,7 @@
 
   mode = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
+
+  /* no autodetect for CATMODE yet */
+  strcpy (catalog[0].catmode, CATMODE);
 
   if (!load_catalog (catalog, mode, VERBOSE)) {
Index: /trunk/Ohana/src/markrock/src/wcatalog.c
===================================================================
--- /trunk/Ohana/src/markrock/src/wcatalog.c	(revision 4827)
+++ /trunk/Ohana/src/markrock/src/wcatalog.c	(revision 4828)
@@ -3,10 +3,19 @@
 wcatalog (Catalog *catalog) {
   
-  int status;
-  char filename[256];
+  /* 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);
+  }
 
-  fits_modify (&catalog[0].header, "MARKROCK", "%t", 1, TRUE);
+  if (!save_catalog (catalog, VERBOSE)) {
+    fprintf (stderr, "ERROR: failure saving catalog\n");
+    exit (1);
+  }
 
-  save_catalog (catalog, VERBOSE);
+  /* free, initialize data structures */
 
   if (catalog[0].Naverage) {
@@ -26,16 +35,5 @@
     catalog[0].Nsecfilt = 0;
   }
-
-  switch (status) {
-  case 0:
-    fprintf (stderr, "error saving catalog\n");
-    exit (0);
-  case 1:
-  case 2:
-    return (status);
-  default:
-    fprintf (stderr, "unknown exit status for save_catalog\n");
-    return (FALSE);
-  }
+  fits_free_header (&catalog[0].header);
 }
 
Index: /trunk/Ohana/src/markstar/include/markstar.h
===================================================================
--- /trunk/Ohana/src/markstar/include/markstar.h	(revision 4827)
+++ /trunk/Ohana/src/markstar/include/markstar.h	(revision 4828)
@@ -8,4 +8,7 @@
 /* global variables set in parameter file */
 char   CATDIR[256];
+char   CATMODE[16];    /* raw, mef, split, mysql */
+char   CATFORMAT[16];  /* internal, elixir, loneos, panstarrs */
+
 char   GSCDIR[256];
 char   ImageCat[256];
Index: /trunk/Ohana/src/markstar/src/ConfigInit.c
===================================================================
--- /trunk/Ohana/src/markstar/src/ConfigInit.c	(revision 4827)
+++ /trunk/Ohana/src/markstar/src/ConfigInit.c	(revision 4828)
@@ -19,4 +19,7 @@
   ScanConfig (config, "IMAGE_CATALOG",   "%s",  0, ImageCat);
   ScanConfig (config, "CATDIR",          "%s",  0, CATDIR);
+  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
+  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
+
   ScanConfig (config, "GSCDIR",          "%s",  0, GSCDIR);
   ScanConfig (config, "GSCFILE",         "%s",  0, GSCFILE);
@@ -44,4 +47,7 @@
   ScanConfig (config, "PHOTCODE_FILE",          "%s", 0, PhotCodeFile);
  
+  if (*CATMODE == 0) strcpy (CATMODE, "RAW");
+  if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
+
   if (!LoadPhotcodes (PhotCodeFile, &photcodes)) {
     fprintf (stderr, "error loading photcodes\n");
Index: /trunk/Ohana/src/markstar/src/gcatalog.c
===================================================================
--- /trunk/Ohana/src/markstar/src/gcatalog.c	(revision 4827)
+++ /trunk/Ohana/src/markstar/src/gcatalog.c	(revision 4828)
@@ -9,4 +9,7 @@
 
   sprintf (filename, "%s/%s\0", CATDIR, catname);
+
+  /* no autodetect for CATMODE yet */
+  strcpy (catalog[0].catmode, CATMODE);
 
   mode = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
Index: /trunk/Ohana/src/markstar/src/wcatalog.c
===================================================================
--- /trunk/Ohana/src/markstar/src/wcatalog.c	(revision 4827)
+++ /trunk/Ohana/src/markstar/src/wcatalog.c	(revision 4828)
@@ -1,13 +1,19 @@
 # include "markstar.h"
 
-wcatalog (char *catname, Catalog *catalog) {
+wcatalog (Catalog *catalog) {
   
-  int status;
-  char filename[256];
+  /* 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);
+  }
 
-  fits_modify (&catalog[0].header, "MARKSTAR", "%t", 1, TRUE);
-
-  sprintf (filename, "%s/%s\0", CATDIR, catname);
-  status = save_catalog (filename, catalog, VERBOSE);
+  if (!save_catalog (catalog, VERBOSE)) {
+    fprintf (stderr, "ERROR: failure saving catalog\n");
+    exit (1);
+  }
 
   if (catalog[0].Naverage) {
@@ -27,15 +33,5 @@
     catalog[0].Nsecfilt = 0;
   }
-
-  switch (status) {
-  case 0:
-    exit (0);
-  case 1:
-  case 2:
-    return (status);
-  default:
-    fprintf (stderr, "unknown exit status for save_catalog\n");
-    return (FALSE);
-  }
+  fits_free_header (&catalog[0].header);
 }
 
Index: /trunk/Ohana/src/mosastro/include/mosastro.h
===================================================================
--- /trunk/Ohana/src/mosastro/include/mosastro.h	(revision 4827)
+++ /trunk/Ohana/src/mosastro/include/mosastro.h	(revision 4828)
@@ -108,4 +108,6 @@
 char REFCAT[256];
 char CATDIR[256];
+char   CATMODE[16];    /* raw, mef, split, mysql */
+char   CATFORMAT[16];  /* internal, elixir, loneos, panstarrs */
 char ExptimeKeyword[256];
 char DateKeyword[256];
Index: /trunk/Ohana/src/mosastro/src/ConfigInit.c
===================================================================
--- /trunk/Ohana/src/mosastro/src/ConfigInit.c	(revision 4827)
+++ /trunk/Ohana/src/mosastro/src/ConfigInit.c	(revision 4828)
@@ -27,4 +27,6 @@
   GetConfig (config, "ASTRO_REFCAT",      "%s",  0, REFCAT);
   ScanConfig (config, "CATDIR",           "%s",  0, CATDIR);
+  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
+  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
   ScanConfig (config, "GSCFILE",          "%s",  0, GSCFILE);
   ScanConfig (config, "GSCDIR",           "%s",  0, GSC_DIR);
@@ -47,4 +49,7 @@
   ScanConfig (config, "INST_BRIGHT",      "%lf", 0, &INST_BRIGHT);
   
+  if (*CATMODE == 0) strcpy (CATMODE, "RAW");
+  if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
+
   free (config);
   free (file);
Index: /trunk/Ohana/src/mosastro/src/gptolemy.c
===================================================================
--- /trunk/Ohana/src/mosastro/src/gptolemy.c	(revision 4827)
+++ /trunk/Ohana/src/mosastro/src/gptolemy.c	(revision 4828)
@@ -6,4 +6,7 @@
   Catalog catalog;
   StarData *stars;
+
+  /* no autodetect for CATMODE yet */
+  strcpy (catalog.catmode, CATMODE);
 
   Nstars = 0;
Index: /trunk/Ohana/src/photdbc/include/photdbc.h
===================================================================
--- /trunk/Ohana/src/photdbc/include/photdbc.h	(revision 4827)
+++ /trunk/Ohana/src/photdbc/include/photdbc.h	(revision 4828)
@@ -32,4 +32,6 @@
 char   GSCFILE[256];
 char   CATDIR[256];
+char   CATMODE[16];    /* raw, mef, split, mysql */
+char   CATFORMAT[16];  /* internal, elixir, loneos, panstarrs */
 char   PhotCodeFile[256];
 
Index: /trunk/Ohana/src/photdbc/src/ConfigInit.c
===================================================================
--- /trunk/Ohana/src/photdbc/src/ConfigInit.c	(revision 4827)
+++ /trunk/Ohana/src/photdbc/src/ConfigInit.c	(revision 4828)
@@ -51,4 +51,7 @@
   WarnConfig (config, "GSCFILE",                "%s",  0, GSCFILE);
   WarnConfig (config, "CATDIR",                 "%s",  0, CATDIR);
+  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
+  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
+
   WarnConfig (config, "PHOTCODE_FILE",          "%s",  0, PhotCodeFile);
   WarnConfig (config, "ZERO_PT",                "%lf", 0, &ZERO_POINT);
@@ -61,4 +64,7 @@
   SetZeroPoint (ZERO_POINT);
 
+  if (*CATMODE == 0) strcpy (CATMODE, "RAW");
+  if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
+
   if (!LoadPhotcodes (PhotCodeFile)) {
     fprintf (stderr, "error loading photcodes\n");
Index: /trunk/Ohana/src/photdbc/src/gcatalog.c
===================================================================
--- /trunk/Ohana/src/photdbc/src/gcatalog.c	(revision 4827)
+++ /trunk/Ohana/src/photdbc/src/gcatalog.c	(revision 4828)
@@ -5,6 +5,9 @@
   char mode;
 
+  /* no autodetect for CATMODE yet */
+  strcpy (catalog[0].catmode, CATMODE);
+
+  /* read catalog header */
   mode = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
-
   if (!load_catalog (catalog, mode, VERBOSE)) {
     fprintf (stderr, "ERROR: failure loading catalog %s\n", catalog[0].filename);
Index: /trunk/Ohana/src/photdbc/src/wcatalog.c
===================================================================
--- /trunk/Ohana/src/photdbc/src/wcatalog.c	(revision 4827)
+++ /trunk/Ohana/src/photdbc/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);
 }
Index: /trunk/Ohana/src/relphot/include/relphot.h
===================================================================
--- /trunk/Ohana/src/relphot/include/relphot.h	(revision 4827)
+++ /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 4827)
+++ /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 4827)
+++ /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 4827)
+++ /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);
 }
Index: /trunk/Ohana/src/uniphot/include/uniphot.h
===================================================================
--- /trunk/Ohana/src/uniphot/include/uniphot.h	(revision 4827)
+++ /trunk/Ohana/src/uniphot/include/uniphot.h	(revision 4828)
@@ -41,4 +41,6 @@
 char         ImageCat[256];
 char         CATDIR[256];
+char         CATMODE[16];    /* raw, mef, split, mysql */
+char         CATFORMAT[16];  /* internal, elixir, loneos, panstarrs */
 char         STATMODE[64];
 int          VERBOSE;
Index: /trunk/Ohana/src/uniphot/src/ConfigInit.c
===================================================================
--- /trunk/Ohana/src/uniphot/src/ConfigInit.c	(revision 4827)
+++ /trunk/Ohana/src/uniphot/src/ConfigInit.c	(revision 4828)
@@ -18,4 +18,7 @@
 
   ScanConfig (config, "CATDIR",                 "%s",  0, CATDIR);
+  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
+  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
+
   ScanConfig (config, "IMAGE_CATALOG",          "%s",  0, ImageCat);
   ScanConfig (config, "PHOTCODE_FILE",          "%s",  0, PhotCodeFile);
@@ -26,4 +29,7 @@
   free (file);
 
+  if (*CATMODE == 0) strcpy (CATMODE, "RAW");
+  if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
+
   if (!LoadPhotcodes (PhotCodeFile)) {
     fprintf (stderr, "error loading photcodes\n");
Index: /trunk/Ohana/src/uniphot/src/gcatalog.c
===================================================================
--- /trunk/Ohana/src/uniphot/src/gcatalog.c	(revision 4827)
+++ /trunk/Ohana/src/uniphot/src/gcatalog.c	(revision 4828)
@@ -4,4 +4,7 @@
 
   int mode;
+
+  /* no autodetect for CATMODE yet */
+  strcpy (catalog[0].catmode, CATMODE);
 
   mode = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
Index: /trunk/Ohana/src/uniphot/src/wcatalog.c
===================================================================
--- /trunk/Ohana/src/uniphot/src/wcatalog.c	(revision 4827)
+++ /trunk/Ohana/src/uniphot/src/wcatalog.c	(revision 4828)
@@ -3,6 +3,18 @@
 void wcatalog (Catalog *catalog) {
 
+  /* 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);
+  }
+
   /** write out catalog, free memory **/
-  save_catalog (catalog, VERBOSE);
+  if (!save_catalog (catalog, VERBOSE)) {
+    fprintf (stderr, "ERROR: failure saving catalog\n");
+    exit (1);
+  }
       
   if (catalog[0].Naverage) {
@@ -22,4 +34,5 @@
     catalog[0].Nsecfilt = 0;
   }
+  fits_free_header (&catalog[0].header);
   unlock_catalog (catalog);
 }
