Index: /trunk/Ohana/src/dvosplit/Makefile
===================================================================
--- /trunk/Ohana/src/dvosplit/Makefile	(revision 41424)
+++ /trunk/Ohana/src/dvosplit/Makefile	(revision 41425)
@@ -1,3 +1,3 @@
-default: dvosplit
+default: all
 help:
 	@echo "make options: dvosplit (default)"
@@ -18,5 +18,7 @@
 
 dvosplit     : $(BIN)/dvosplit.$(ARCH)
-all: dvosplit
+dvosplitsky  : $(BIN)/dvosplitsky.$(ARCH)
+
+all: dvosplit dvosplitsky
 
 DVOSPLIT = \
@@ -34,5 +36,16 @@
 $(BIN)/dvosplit.$(ARCH) : $(DVOSPLIT)
 
-INSTALL = dvosplit
+DVOSPLITSKY = \
+$(SRC)/dvosplitsky.$(ARCH).o \
+$(SRC)/SetSignals.$(ARCH).o \
+$(SRC)/ConfigInit.$(ARCH).o \
+$(SRC)/Shutdown.$(ARCH).o \
+$(SRC)/args_sky.$(ARCH).o
+
+$(DVOSPLITSKY)  : $(INC)/dvosplit.h
+
+$(BIN)/dvosplitsky.$(ARCH) : $(DVOSPLITSKY)
+
+INSTALL = dvosplit dvosplitsky
 
 # dependancy rules for binary code #########################
Index: /trunk/Ohana/src/dvosplit/src/args_sky.c
===================================================================
--- /trunk/Ohana/src/dvosplit/src/args_sky.c	(revision 41425)
+++ /trunk/Ohana/src/dvosplit/src/args_sky.c	(revision 41425)
@@ -0,0 +1,60 @@
+# include "dvosplit.h"
+
+static void help (void);
+
+int args (int argc, char **argv) {
+  
+  int N;
+
+  /* check for help request */
+  if (get_argument (argc, argv, "-help") ||
+      get_argument (argc, argv, "-h")) {
+    help ();
+  }
+
+  // -region is required for dvosplitsky
+  UserPatch.Rmin = NAN;
+  UserPatch.Rmax = NAN;
+  UserPatch.Dmin = NAN;
+  UserPatch.Dmax = NAN;
+  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);
+  }
+  if (isnan(UserPatch.Rmin)) help();
+  if (isnan(UserPatch.Rmax)) help();
+  if (isnan(UserPatch.Dmin)) help();
+  if (isnan(UserPatch.Dmax)) help();
+
+  /* extra error messages */
+  VERBOSE = FALSE;
+  if ((N = get_argument (argc, argv, "-v"))) {
+    VERBOSE = TRUE;
+    remove_argument (N, &argc, argv);
+  }
+
+  if (argc == 2) return (TRUE);
+
+  fprintf (stderr, "USAGE: dvosplit (catdir) (newlevel) [-outdir outdir] [-region (Rmin) (Rmax) (Dmin) (Dmax)]\n");
+  exit (2);
+}
+
+static void help () {
+
+  fprintf (stderr, "USAGE\n");
+  fprintf (stderr, "  dvosplitsky (catdir) -region Rmin Rmax Dmin Dmax \n\n");
+  fprintf (stderr, "  NOTE : region is required for dvosplitsky\n");
+  fprintf (stderr, "  optional flags:\n");
+  fprintf (stderr, "  -v                    	  : verbose mode\n");
+  fprintf (stderr, "  -help                 	  : this list\n");
+  fprintf (stderr, "  -h                    	  : this list\n\n");
+  exit (2);
+}
+
Index: /trunk/Ohana/src/dvosplit/src/dvosplitsky.c
===================================================================
--- /trunk/Ohana/src/dvosplit/src/dvosplitsky.c	(revision 41425)
+++ /trunk/Ohana/src/dvosplit/src/dvosplitsky.c	(revision 41425)
@@ -0,0 +1,57 @@
+# include "dvosplit.h"
+
+// dvosplitsky (catdir) -region Rmin Rmax Dmin Dmax
+// subdivide the SkyTable by one level for the given region (L4 -> L5 only for now)
+int main (int argc, char **argv) {
+
+  SetSignals ();
+  ConfigInit (&argc, argv);
+  args (argc, argv);
+
+  char *CATDIR = strcreate (argv[1]);
+
+  // load the photcode table (for Nsecfilt and related)
+  /* XXX should not be needed for dvosplitsky
+  char photcodeFile[1024];
+  snprintf (photcodeFile, 1024, "%s/Photcodes.dat", CATDIR);
+  if (!LoadPhotcodes (photcodeFile, NULL, FALSE)) {
+    fprintf (stderr, "error loading photcode table %s\n", photcodeFile);
+    exit (1);
+  }
+  */
+
+  // load the sky table for the existing database
+  SkyTable *sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, TRUE, SKY_DEPTH_HST, VERBOSE);
+  // SkyTableSetFilenames (sky, CATDIR, "cpt"); XXX probably not needed
+
+  // for L4 entries in a certain ra,dec range, generate L5 entries:
+  SkyTable L5; 
+  L5.Nregions = 0;
+  L5.Nalloc   = 1000;
+  ALLOCATE (L5.regions, SkyRegion, L5.Nalloc);
+
+  // get the list of populated regions at Level 4
+  SkyList *skylist  = SkyListByPatch (sky, 4, &UserPatch);
+  
+  for (int i = 0; i < skylist->Nregions; i++) {
+    SkyTableL5fromL4_List (skylist->regions[i], &L5, sky->Nregions);
+  }
+
+  // the third argument is the depth of the sky table.  it is used to set the
+  // boolean which specifies that a table exists at that depth.  we assume that
+  // a table does not since we are now splitting the table.  use -1 to prevent.
+  SkyTableExtend (sky, &L5, -1);
+  free (L5.regions);
+
+  char *skytable_file = SkyTableFilename (CATDIR);
+  int success = SkyTableSave (sky, skytable_file);
+
+  if (!success) fprintf (stderr, "ERROR: failed to write updated sky table to %s\n", skytable_file);
+
+  free (skytable_file);
+  SkyTableFree (sky);
+  SkyListFree (skylist);
+
+  if (!success) exit (2);
+  exit (0);
+}
