Index: trunk/Ohana/src/dvomerge/src/dvomergeUpdate.c
===================================================================
--- trunk/Ohana/src/dvomerge/src/dvomergeUpdate.c	(revision 28856)
+++ trunk/Ohana/src/dvomerge/src/dvomergeUpdate.c	(revision 28857)
@@ -24,12 +24,4 @@
   }
 
-  // since we are merging the input db into the output db, the output defines the photcode
-  sprintf (filename, "%s/Photcodes.dat", output);
-  if (!LoadPhotcodes (filename, NULL, FALSE)) {
-    fprintf (stderr, "error loading photcode table: %s/Photcodes.dat\n", output);
-    exit (1);
-  }
-  outputPhotcodes = GetPhotcodeTable();
-
   SetPhotcodeTable(NULL);
   sprintf (filename, "%s/Photcodes.dat", input);
@@ -39,8 +31,32 @@
   }	
   inputPhotcodes = GetPhotcodeTable();
-  secfiltMap = GetSecFiltMap(outputPhotcodes, inputPhotcodes);
-  if (!secfiltMap) {
-    fprintf (stderr, "failed to map input secfilt photcodes to output photcodes table\n");
-    exit (1);
+
+  // 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.
+
+  SetPhotcodeTable(NULL);
+  sprintf (filename, "%s/Photcodes.dat", output);
+  if (LoadPhotcodes (filename, NULL, FALSE)) {
+
+    outputPhotcodes = GetPhotcodeTable();
+
+    secfiltMap = GetSecFiltMap(outputPhotcodes, inputPhotcodes);
+    if (!secfiltMap) {
+      fprintf (stderr, "failed to map input secfilt photcodes to output photcodes table\n");
+      exit (1);
+    }
+  } else {
+    fprintf(stderr, "%s not found using photcodes from %s/Photcodes.dat\n", filename, input);
+    outputPhotcodes = inputPhotcodes;
+    if (!check_dir_access (output, VERBOSE)) {
+      fprintf (stderr, "error creating output database directory %s\n", output);
+      exit (1);
+    }
+    SetPhotcodeTable(inputPhotcodes);
+    if (!SavePhotcodesFITS (filename)) {
+      fprintf (stderr, "error saving photcode table in %s/Photcodes.dat\n", output);
+      exit (1);
+    }
   }
 
