Index: trunk/Ohana/src/dvomerge/src/dvomergeUpdate.c
===================================================================
--- trunk/Ohana/src/dvomerge/src/dvomergeUpdate.c	(revision 28329)
+++ trunk/Ohana/src/dvomerge/src/dvomergeUpdate.c	(revision 28330)
@@ -16,9 +16,14 @@
   output = argv[3];
 
-  // the first input defines the photcode table & db layout
-  sprintf (filename, "%s/Photcodes.dat", input);
+  // since we are merging the input db into the output db, the output defines the photcode
+  // table & db layout but, this requires the output to exist.  if it does not, instead use the
+  // input.
+  sprintf (filename, "%s/Photcodes.dat", output);
   if (!LoadPhotcodes (filename, NULL, FALSE)) {
-    fprintf (stderr, "error loading photcode table %s\n", filename);
-    exit (1);
+    sprintf (filename, "%s/Photcodes.dat", input);
+    if (!LoadPhotcodes (filename, NULL, FALSE)) {
+      fprintf (stderr, "error loading photcode table: tried %s/Photcodes.dat and %s/Photcodes.dat\n", output, input);
+      exit (1);
+    }
   }
 
@@ -27,8 +32,14 @@
   // load the sky table for the existing database
   insky = SkyTableLoadOptimal (input, NULL, NULL, FALSE, SKY_DEPTH_HST, VERBOSE);
+  if (!insky) {
+      Shutdown ("can't read SkyTable for %s", input);
+  }
   SkyTableSetFilenames (insky, input, "cpt");
 
   // generate an output table populated at the desired depth
-  outsky = SkyTableLoadOptimal (output, NULL, NULL, TRUE, SKY_DEPTH, VERBOSE);
+  outsky = SkyTableLoadOptimal (output, NULL, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
+  if (!outsky) {
+      Shutdown ("can't read or create SkyTable for %s", output);
+  }
   SkyTableSetFilenames (outsky, output, "cpt");
 
@@ -43,6 +54,6 @@
     if (VERBOSE) fprintf (stderr, "output: %s\n", outsky[0].regions[i].name);
 
-    // load / create output catalog
-    LoadCatalog (&outcatalog, &outsky[0].regions[i], outsky[0].filename[i], "a");
+    // load / create output catalog (if catalog does not exist, it will be created)
+    LoadCatalog (&outcatalog, &outsky[0].regions[i], outsky[0].filename[i], "w");
 
     // combine only tables at equal or larger depth
@@ -102,8 +113,8 @@
   // load the image table 
   if (inDB.dbstate == LCK_EMPTY) {
-    Shutdown ("can't find input (1) image catalog %s", inDB.filename);
+    Shutdown ("can't find input image catalog %s", inDB.filename);
   }
   if (!dvo_image_load (&inDB, VERBOSE, TRUE)) {
-    Shutdown ("can't read input (1) image catalog %s", inDB.filename);
+    Shutdown ("can't read input image catalog %s", inDB.filename);
   }
 
@@ -117,8 +128,9 @@
   /* load the image table */
   if (outDB.dbstate == LCK_EMPTY) {
-    Shutdown ("can't find input (2) image catalog %s", outDB.filename);
-  }
-  if (!dvo_image_load (&outDB, VERBOSE, TRUE)) {
-    Shutdown ("can't read input (2) image catalog %s", outDB.filename);
+    dvo_image_create (&outDB, GetZeroPoint());
+  } else {
+    if (!dvo_image_load (&outDB, VERBOSE, TRUE)) {
+      Shutdown ("can't read output image catalog %s", outDB.filename);
+    }
   }
 
