Index: /branches/eam_branch_20071130/Ohana/src/dvosplit/Makefile
===================================================================
--- /branches/eam_branch_20071130/Ohana/src/dvosplit/Makefile	(revision 15735)
+++ /branches/eam_branch_20071130/Ohana/src/dvosplit/Makefile	(revision 15735)
@@ -0,0 +1,48 @@
+default: dvosplit
+help:
+	@echo "make options: dvosplit (default)"
+
+include ../../Makefile.System
+HOME 	=	$(ROOT)/src/dvosplit
+BIN	=	$(HOME)/bin
+LIB	=	$(HOME)/lib
+SRC	=	$(HOME)/src
+MAN	=	$(HOME)/doc
+INC	= 	$(HOME)/include
+include ../../Makefile.Common
+
+# programs may add their own internal requirements here
+FULL_CFLAGS   = $(BASE_CFLAGS)
+FULL_CPPFLAGS = $(BASE_CPPFLAGS)
+FULL_LDFLAGS  = -lkapa -ldvo -lFITS -lohana $(BASE_LDFLAGS)
+
+dvosplit     : $(BIN)/dvosplit.$(ARCH)
+all: dvosplit
+
+DVOSPLIT = \
+$(SRC)/dvosplit.$(ARCH).o \
+$(SRC)/SetSignals.$(ARCH).o \
+$(SRC)/ConfigInit.$(ARCH).o \
+$(SRC)/Shutdown.$(ARCH).o \
+$(SRC)/args.$(ARCH).o \
+$(SRC)/split_averages.$(ARCH).o \
+$(SRC)/split_measures.$(ARCH).o \
+$(SRC)/open_output_catalogs.$(ARCH).o
+
+$(DVOSPLIT)  : $(INC)/dvosplit.h
+
+$(BIN)/dvosplit.$(ARCH) : $(DVOSPLIT)
+
+INSTALL = dvosplit
+
+# dependancy rules for binary code #########################
+$(INSTALL): % : $(BIN)/%.$(ARCH)
+
+%.clean :
+	rm -f $(BIN)/$*.$(ARCH)
+
+%.install:
+	make $(DESTBIN)/$*
+
+install:
+	for i in $(INSTALL); do make $$i.install || exit; done
Index: /branches/eam_branch_20071130/Ohana/src/dvosplit/src/ConfigInit.c
===================================================================
--- /branches/eam_branch_20071130/Ohana/src/dvosplit/src/ConfigInit.c	(revision 15735)
+++ /branches/eam_branch_20071130/Ohana/src/dvosplit/src/ConfigInit.c	(revision 15735)
@@ -0,0 +1,57 @@
+# include "dvosplit.h"
+
+void GetConfig (char *config, char *field, char *format, int N, void *ptr);
+
+int ConfigInit (int *argc, char **argv) {
+
+  double ZERO_POINT;
+  char *config, *file;
+  char CatdirPhotcodeFile[256];
+  char MasterPhotcodeFile[256];
+
+  /*** load configuration info ***/
+  file = SelectConfigFile (argc, argv, "ptolemy");
+  config = LoadConfigFile (file);
+  if (config == (char *) NULL) {
+    fprintf (stderr, "ERROR: can't find configuration file %s\n", file);
+    if (file != (char *) NULL) free (file);
+    exit (1);
+  }
+  if (VERBOSE) fprintf (stderr, "loaded config file: %s\n", file);
+
+  GetConfig (config, "CATDIR",                 	"%s",  0, CATDIR);
+  GetConfig (config, "PHOTCODE_FILE",          	"%s",  0, MasterPhotcodeFile);
+
+  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
+  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
+
+  /* default mode, format, if not specified */
+  if (*CATMODE == 0) strcpy (CATMODE, "RAW");
+  if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
+
+  GetConfig (config, "ZERO_PT",                "%lf", 0, &ZERO_POINT);
+  SetZeroPoint (ZERO_POINT);
+
+  /* XXX this does not yet write out the master photcode table */
+  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
+  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
+    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
+    exit (1);
+  }
+
+  free (config);
+  free (file);
+  return (TRUE);
+}
+
+void GetConfig (char *config, char *field, char *format, int N, void *ptr) {
+
+  char *status;
+
+  status = ScanConfig (config, field, format, N, ptr);
+  if (status == NULL) {
+    fprintf (stderr, "error in config, cannot find %s\n", field);
+    exit (1);
+  }
+  return;
+}
Index: /branches/eam_branch_20071130/Ohana/src/dvosplit/src/SetSignals.c
===================================================================
--- /branches/eam_branch_20071130/Ohana/src/dvosplit/src/SetSignals.c	(revision 15735)
+++ /branches/eam_branch_20071130/Ohana/src/dvosplit/src/SetSignals.c	(revision 15735)
@@ -0,0 +1,122 @@
+# include "dvosplit.h"
+
+static int Protect = FALSE;
+static int Trapped = FALSE;
+
+void TrapSignal (int sig) {
+    fprintf (stderr, "trapped signal %d\n", sig);
+    if (sig == 11) {
+      fprintf (stderr, "seg fault\n");
+      exit (1);
+    }
+    if (Protect) {
+      Trapped = TRUE;
+      fprintf (stderr, "blocking until protected sections are clear\n");
+      return;
+    }
+    Shutdown ("halted by signal (trapped)");
+}    
+
+void SetProtect (int mode) {
+  Protect = mode;
+  if (Trapped && !Protect) Shutdown ("halted by signal (protect)");
+}
+
+int SetSignals () {
+
+  int i;
+
+  /* disable almost all signal interrupts */
+  for (i = 0; i < 36; i++) {
+    switch (i) {
+      /* can't redirect these signals */
+    case SIGKILL:    /* kill -9: cannot be caught or ignored (POSIX.1-1990) */
+    case SIGSTOP:    /* SIGSTOP: cannot be caught or ignored (POSIX.1-1990) */
+      /* ignore these signals */
+    case SIGCHLD:    /* child halted: ignore (POSIX.1-1990) */
+    case SIGCONT:    /* continue - maintain this action (POSIX.1-1990) */
+    case SIGTSTP:    /* stop signal sent from tty - why ignore? (POSIX.1-1990) */
+    case SIGURG:     /* socket signal, ignore this (POSIX.1-2001) */
+# ifdef SIGPWR
+    case SIGPWR:     /* power failure - why ignore this? (Sys V) */
+# endif
+# ifdef SIGWINCH
+    case SIGWINCH:   /* window resized (4.3BSD) */
+# endif
+      break;
+      
+    default:
+      signal (i, TrapSignal);
+    }
+  }
+  return (TRUE);
+}
+/*
+
+       Signal     Value     Action   Comment
+       -------------------------------------------------------------------------
+       SIGHUP        1        A      Hangup detected on controlling terminal
+                                     or death of controlling process
+       SIGINT        2        A      Interrupt from keyboard
+       SIGQUIT       3        A      Quit from keyboard
+       SIGILL        4        A      Illegal Instruction
+       SIGABRT       6        C      Abort signal from abort(3)
+       SIGFPE        8        C      Floating point exception
+       SIGKILL       9       AEF     Kill signal
+       SIGSEGV      11        C      Invalid memory reference
+       SIGPIPE      13        A      Broken pipe: write to pipe with no readers
+       SIGALRM      14        A      Timer signal from alarm(2)
+       SIGTERM      15        A      Termination signal
+       SIGUSR1   30,10,16     A      User-defined signal 1
+       SIGUSR2   31,12,17     A      User-defined signal 2
+       SIGCHLD   20,17,18     B      Child stopped or terminated
+       SIGCONT   19,18,25            Continue if stopped
+       SIGSTOP   17,19,23    DEF     Stop process
+       SIGTSTP   18,20,24     D      Stop typed at tty
+       SIGTTIN   21,21,26     D      tty input for background process
+       SIGTTOU   22,22,27     D      tty output for background process
+
+       Next various other signals.
+
+       Signal       Value     Action   Comment
+       ---------------------------------------------------------------------
+       SIGTRAP        5         CG     Trace/breakpoint trap
+       SIGIOT         6         CG     IOT trap. A synonym for SIGABRT
+       SIGEMT       7,-,7       G
+       SIGBUS      10,7,10      AG     Bus error
+       SIGSYS      12,-,12      G      Bad argument to routine (SVID)
+       SIGSTKFLT    -,16,-      AG     Stack fault on coprocessor
+       SIGURG      16,23,21     BG     Urgent condition on socket (4.2 BSD)
+       SIGIO       23,29,22     AG     I/O now possible (4.2 BSD)
+       SIGPOLL                  AG     A synonym for SIGIO (System V)
+       SIGCLD       -,-,18      G      A synonym for SIGCHLD
+       SIGXCPU     24,24,30     AG     CPU time limit exceeded (4.2 BSD)
+       SIGXFSZ     25,25,31     AG     File size limit exceeded (4.2 BSD)
+       SIGVTALRM   26,26,28     AG     Virtual alarm clock (4.2 BSD)
+       SIGPROF     27,27,29     AG     Profile alarm clock
+       SIGPWR      29,30,19     AG     Power failure (System V)
+       SIGINFO      29,-,-      G      A synonym for SIGPWR
+       SIGLOST      -,-,-       AG     File lock lost
+       SIGWINCH    28,28,20     BG     Window resize signal (4.3 BSD, Sun)
+       SIGUNUSED    -,31,-      AG     Unused signal
+       (Here - denotes that a signal is absent; there where three values are given, the first one is usually  valid  for  alpha  and
+       sparc,  the  middle  one  for i386 and ppc, the last one for mips. Signal 29 is SIGINFO / SIGPWR on an alpha but SIGLOST on a
+       sparc.)
+
+       The letters in the "Action" column have the following meanings:
+
+       A      Default action is to terminate the process.
+
+       B      Default action is to ignore the signal.
+
+       C      Default action is to dump core.
+
+       D      Default action is to stop the process.
+
+       E      Signal cannot be caught.
+
+       F      Signal cannot be ignored.
+
+       G      Not a POSIX.1 conformant signal.
+
+*/
Index: /branches/eam_branch_20071130/Ohana/src/dvosplit/src/Shutdown.c
===================================================================
--- /branches/eam_branch_20071130/Ohana/src/dvosplit/src/Shutdown.c	(revision 15735)
+++ /branches/eam_branch_20071130/Ohana/src/dvosplit/src/Shutdown.c	(revision 15735)
@@ -0,0 +1,20 @@
+# include "dvosplit.h"
+
+/* clean up open / locked ImageCat before shutting down */
+int Shutdown (char *format, ...) {  
+  va_list argp;
+  char *formatplus;
+  
+  ALLOCATE (formatplus, char, strlen(format) + 2);
+  strcpy (formatplus, format);
+  strcat (formatplus, "\n");
+
+  va_start (argp, format);
+  vfprintf (stderr, formatplus, argp);
+  free (formatplus);
+  va_end (argp);
+
+  fprintf (stderr, "ERROR: addstar halted\n");
+  exit (1);
+}
+
Index: /branches/eam_branch_20071130/Ohana/src/dvosplit/src/args.c
===================================================================
--- /branches/eam_branch_20071130/Ohana/src/dvosplit/src/args.c	(revision 15735)
+++ /branches/eam_branch_20071130/Ohana/src/dvosplit/src/args.c	(revision 15735)
@@ -0,0 +1,87 @@
+# include "dvosplit.h"
+static void help (void);
+
+int args (int argc, char **argv) {
+  
+  int i, N, CONFIRM;
+
+  /* check for help request */
+  if (get_argument (argc, argv, "-help") ||
+      get_argument (argc, argv, "-h")) {
+    help ();
+  }
+
+  /*** check for command line options ***/
+
+  /*** provide additional data ***/ 
+  /* restrict to a portion of the sky? (REFCAT only) */
+  UserPatch.Rmin = 0;
+  UserPatch.Rmax = 360;
+  UserPatch.Dmin = -90;
+  UserPatch.Dmax = +90;
+  CONFIRM = TRUE;
+  if ((N = get_argument (argc, argv, "-region"))) {
+    remove_argument (N, &argc, argv);
+    UserPatch.Rmin = atof (argv[N]);
+    remove_argument (N, &argc, argv);
+    UserPatch.Rmax = atof (argv[N]);
+    remove_argument (N, &argc, argv);
+    UserPatch.Dmin = atof (argv[N]);
+    remove_argument (N, &argc, argv);
+    UserPatch.Dmax = atof (argv[N]);
+    remove_argument (N, &argc, argv);
+    CONFIRM = FALSE;
+  }
+
+  /* extra error messages */
+  VERBOSE = FALSE;
+  if ((N = get_argument (argc, argv, "-v"))) {
+    VERBOSE = TRUE;
+    remove_argument (N, &argc, argv);
+  }
+
+  if (argc == 2) {
+    if (CONFIRM) {
+      fprintf (stderr, "you are splitting the entire sky in one pass\n");
+      fprintf (stderr, "this could be a time consuming operation.  type Ctrl-C within 5 seconds to cancel\n");
+      for (i = 5; i > 0; i--) {
+	fprintf (stderr, "%d.. ", i);
+	usleep (1000000);
+      }
+      fprintf (stderr, "\n");
+    }    
+    return (TRUE);
+  }
+
+  fprintf (stderr, "USAGE: dvosplit (newlevel) [-region (Rmin) (Rmax) (Dmin) (Dmax)]\n");
+  exit (2);
+}
+
+static void help () {
+
+  fprintf (stderr, "USAGE\n");
+  fprintf (stderr, "  dvosplit (newlevel)\n\n");
+  fprintf (stderr, "  optional flags:\n");
+  fprintf (stderr, "  -region ra ra dec dec 	  : migrate catalogs in specified region\n");
+  fprintf (stderr, "  -v                    	  : verbose mode\n");
+  fprintf (stderr, "  -help                 	  : this list\n");
+  fprintf (stderr, "  -h                    	  : this list\n\n");
+  exit (2);
+}
+
+/** addstar modes:
+ 
+    addstar (image.smp)  - add cmp/smp image data to db
+    addstar -ref (file.dat) (photcode) 
+    addstar -cat (USNO/2MASS/GSC) -region (ra dec - ra dec)
+
+    -replace : ref/cat - replace existing match (photcode/time)
+    -match   : ref/cat - only add measures to existing averages
+
+    ref types: 
+    ASCII - RA,DEC,M,dM in a table
+
+    addstar 
+
+**/
+
Index: /branches/eam_branch_20071130/Ohana/src/dvosplit/src/dvosplit.c
===================================================================
--- /branches/eam_branch_20071130/Ohana/src/dvosplit/src/dvosplit.c	(revision 15734)
+++ /branches/eam_branch_20071130/Ohana/src/dvosplit/src/dvosplit.c	(revision 15735)
@@ -1,12 +1,19 @@
 # include "dvosplit.h"
 
+// dvosplit (outlevel) [-region Rmin Rmax Dmin Dmax]
 int main (int argc, char **argv) {
 
-  // USAGE: dvosplit (outlevel) [-region RA RA DEC DEC]
+  int i, j, OUT_DEPTH;
+  SkyTable *sky;
+  SkyList *skylist, *outlist;
+  Catalog incatalog, *outcatalogs;
+  AveLinks *avelinks;
+  char filename[256];
 
-  // the output catalog needs to inherit the SKY_DEPTH of the input catalog. 
-  // if the CATDIR/SkyTable.fits is not found, assume the HST layout (old default)
+  SetSignals ();
+  ConfigInit (&argc, argv);
+  args (argc, argv);
 
-  // force the output to have SPLIT mode?
+  OUT_DEPTH = atoi (argv[1]);
 
   // load the sky table for the existing database
@@ -14,11 +21,6 @@
   SkyTableSetFilenames (sky, CATDIR, "cpt");
 
-  // XXX I should just be copying the input sky and setting the output names on that
-  // load the sky table for the existing database, generate output names
-  outsky = SkyTableLoadOptimal (CATDIR, NULL, NULL, SKY_DEPTH_HST, VERBOSE);
-  SkyTableSetFilenames (outsky, OUTDIR, "cpt");
-
   // get the list of populated regions
-  skylist  = SkyListByPatch (sky, -1, &REGION);
+  skylist  = SkyListByPatch (sky, -1, &UserPatch);
   
   for (i = 0; i < skylist[0].Nregions; i++) {
@@ -28,5 +30,4 @@
     // if (current level == out level) skip: no action is needed
     if (skylist[0].regions[i][0].depth >= OUT_DEPTH) continue;
-    // XXX : we need to copy these files to their new names
 
     // set the parameters which guide catalog open/load/create
@@ -48,6 +49,6 @@
     }
 
-    // change outsky.regions[i].depth for these regions
-    outlist = SkyListByPatch (outsky, OUT_DEPTH, skylist[0].regions[i]);
+    // change sky.regions[i].depth for these regions
+    outlist = SkyListByPatch (sky, OUT_DEPTH, skylist[0].regions[i]);
 
     outcatalogs = open_output_catalogs (outlist);
@@ -60,10 +61,26 @@
     // split_missings (&incatalog, outlist, outcatalogs, avelinks); 
 
-    dvo_catalog_close (&incatalog);
+    dvo_catalog_unlock (&incatalog);
 
     for (j = 0; j < outlist[0].Nregions; j++) {
-      dvo_catalog_close (&outcatalogs[j]);
+      dvo_catalog_unlock (&outcatalogs[j]);
     }
+
+    // adjust depth
+    skylist[0].regions[i][0].table = FALSE;
+    for (j = 0; j < outlist[0].Nregions; j++) {
+      outlist[0].regions[j][0].table = TRUE;
+    }
+
   }
+
+  // save sky table copy
+  sprintf (filename, "%s/SkyTable.fits", CATDIR);
+  check_file_access (filename, FALSE, VERBOSE);
+  if (!SkyTableSave (sky, filename)) {
+    fprintf (stderr, "ERROR: failed to save sky table for %s\n", CATDIR);
+    exit (1);
+  }
+
   exit (0);
 }
Index: /branches/eam_branch_20071130/Ohana/src/dvosplit/src/open_output_catalogs.c
===================================================================
--- /branches/eam_branch_20071130/Ohana/src/dvosplit/src/open_output_catalogs.c	(revision 15734)
+++ /branches/eam_branch_20071130/Ohana/src/dvosplit/src/open_output_catalogs.c	(revision 15735)
@@ -3,4 +3,5 @@
 Catalog *open_output_catalogs (SkyList *outlist) {
 
+  int i;
   Catalog *outcatalogs;
 
@@ -11,7 +12,9 @@
     
     // set the parameters which guide catalog open/load/create
-    outcatalogs[i].filename = skylist[0].filename[i];
-    outcatalogs[i].Nsecfilt = GetPhotcodeNsecfilt ();
-    outcatalogs[i].catflags = LOAD_NONE;
+    outcatalogs[i].filename  = outlist[0].filename[i];
+    outcatalogs[i].Nsecfilt  = GetPhotcodeNsecfilt ();
+    outcatalogs[i].catflags  = LOAD_NONE;
+    outcatalogs[i].catformat = dvo_catalog_catformat (CATFORMAT);  // set the default catformat from config data
+    outcatalogs[i].catmode   = dvo_catalog_catmode (CATMODE);      // set the default catmode from config data
 
     if (!dvo_catalog_open (&outcatalogs[i], outlist[0].regions[i], VERBOSE, "w")) {
Index: /branches/eam_branch_20071130/Ohana/src/dvosplit/src/split_averages.c
===================================================================
--- /branches/eam_branch_20071130/Ohana/src/dvosplit/src/split_averages.c	(revision 15734)
+++ /branches/eam_branch_20071130/Ohana/src/dvosplit/src/split_averages.c	(revision 15735)
@@ -5,5 +5,5 @@
 
   double inR, inD;
-  int block, ave, cat, Nblocks, Ncat, Nout;
+  int n, block, ave, cat, averef, Nblocks, Ncat, Nout, Nsecfilt;
   int *outref, *outcat;
   AveLinks *avelinks;
@@ -17,6 +17,6 @@
   // contains primary photcodes, which will increase Nsecfilt by one.
   for (cat = 0; cat < outlist[0].Nregions; cat++) {
-    REALLOCATE (outcatalog[cat].average, Average, NROWS);
-    REALLOCATE (outcatalog[cat].secfilt, SecFilt, NROWS*(Nsecfilt + 1));
+    REALLOCATE (outcatalogs[cat].average, Average, NROWS);
+    REALLOCATE (outcatalogs[cat].secfilt, SecFilt, NROWS*(Nsecfilt + 1));
   }
 
@@ -27,6 +27,6 @@
 
     // read up to NROWS at a time
-    dvo_catalog_load_segment (&incatalog, VERBOSE, block*NROWS, NROWS);
-    assert (block*NROWS == incatalogs[0].Naves_off);
+    dvo_catalog_load_segment (incatalog, VERBOSE, block*NROWS, NROWS);
+    assert (block*NROWS == incatalog[0].Naves_off);
 
     for (ave = 0; ave < incatalog[0].Naverage; ave++) {
@@ -53,16 +53,16 @@
       }
 
-      Nout = outcatalog[Ncat].Naverage;
-      outref[averef] = Nout + outcatalog[Ncat].Naves_off;
+      Nout = outcatalogs[Ncat].Naverage;
+      outref[averef] = Nout + outcatalogs[Ncat].Naves_off;
       outcat[averef] = Ncat;
 
       // assign the value to the next element of the output catalog
-      outcatalog[Ncat].average[Nout] = incatalog[0].average[k];
-      outcatalog[Ncat].Naverage++;
+      outcatalogs[Ncat].average[Nout] = incatalog[0].average[ave];
+      outcatalogs[Ncat].Naverage ++;
 
       // update secfilt at the same time
       for (n = 0; n < Nsecfilt; n++) {
-	outcatalog[Ncat].secfilt[Nout*Nsecfilt + n] = incatalog[0].secfilt[ave*Nsecfilt + n];
-	outcatalog[Ncat].Nsecf_mem++;
+	outcatalogs[Ncat].secfilt[Nout*Nsecfilt + n] = incatalog[0].secfilt[ave*Nsecfilt + n];
+	outcatalogs[Ncat].Nsecf_mem++;
       }
     }
@@ -72,16 +72,16 @@
     // write out the new values
     for (cat = 0; cat < outlist[0].Nregions; cat++) {
-      outcatalog[cat].catflags = LOAD_AVES | LOAD_SECF;
-      dvo_catalog_save_segment (&outcatalog[cat], VERBOSE);
+      outcatalogs[cat].catflags = LOAD_AVES | LOAD_SECF;
+      dvo_catalog_save (&outcatalogs[cat], VERBOSE);
 
       // XXX I need to advance the pointers and free the current data
       // XXX these should be done within save segment:
-      outcatalog[cat].Naves_disk += outcatalog[cat].Naverage;
-      outcatalog[cat].Naves_off  += outcatalog[cat].Naverage;
-      outcatalog[cat].Naverage    = 0;
+      outcatalogs[cat].Naves_disk += outcatalogs[cat].Naverage;
+      outcatalogs[cat].Naves_off  += outcatalogs[cat].Naverage;
+      outcatalogs[cat].Naverage    = 0;
 
-      outcatalog[cat].Nsecf_disk += Nsecfilt * outcatalog[cat].Naverage;
-      outcatalog[cat].Nsecf_off  += Nsecfilt * outcatalog[cat].Naverage;
-      outcatalog[cat].Nsecf_mem   = 0;
+      outcatalogs[cat].Nsecf_disk += Nsecfilt * outcatalogs[cat].Naverage;
+      outcatalogs[cat].Nsecf_off  += Nsecfilt * outcatalogs[cat].Naverage;
+      outcatalogs[cat].Nsecf_mem   = 0;
     }
   }
Index: /branches/eam_branch_20071130/Ohana/src/dvosplit/src/split_measures.c
===================================================================
--- /branches/eam_branch_20071130/Ohana/src/dvosplit/src/split_measures.c	(revision 15734)
+++ /branches/eam_branch_20071130/Ohana/src/dvosplit/src/split_measures.c	(revision 15735)
@@ -4,4 +4,5 @@
 int split_measures (Catalog *incatalog, SkyList *outlist, Catalog *outcatalogs, AveLinks *avelinks) {
 
+  int block, meas, cat, Nblocks, Ncat, Nout, averef;
   int *outref, *outcat;
 
@@ -11,5 +12,5 @@
   // allocate enough space for the output buffer
   for (cat = 0; cat < outlist[0].Nregions; cat++) {
-    REALLOCATE (outcatalog[cat].measure, Measure, NROWS);
+    REALLOCATE (outcatalogs[cat].measure, Measure, NROWS);
   }
 
@@ -27,17 +28,17 @@
       Ncat = outcat[averef];
 
-      Nout = outcatalog[Ncat].Nmeasure;
-      outcatalog[Ncat].measure[Nout] = incatalog[0].measure[meas];
-      outcatalog[Ncat].measure[Nout].averef = outref[averef];
-      outcatalog[Ncat].Nmeasure++;
+      Nout = outcatalogs[Ncat].Nmeasure;
+      outcatalogs[Ncat].measure[Nout] = incatalog[0].measure[meas];
+      outcatalogs[Ncat].measure[Nout].averef = outref[averef];
+      outcatalogs[Ncat].Nmeasure++;
     }
 
     for (cat = 0; cat < outlist[0].Nregions; cat++) {
       outcatalogs[cat].catflags = LOAD_AVES | LOAD_SECF;
-      dvo_catalog_save_segment (&outcatalog[cat], VERBOSE);
+      dvo_catalog_save (&outcatalogs[cat], VERBOSE);
 
-      outcatalog[cat].Nmeas_disk += outcatalog[cat].Nmeasure;
-      outcatalog[cat].Nmeas_off  += outcatalog[cat].Nmeasure;
-      outcatalog[cat].Nmeasure    = 0;
+      outcatalogs[cat].Nmeas_disk += outcatalogs[cat].Nmeasure;
+      outcatalogs[cat].Nmeas_off  += outcatalogs[cat].Nmeasure;
+      outcatalogs[cat].Nmeasure    = 0;
 
     }
