Index: /branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_catalog_split.c
===================================================================
--- /branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_catalog_split.c	(revision 36995)
+++ /branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_catalog_split.c	(revision 36996)
@@ -134,4 +134,8 @@
   if (!gfits_scan (&catalog[0].header, name,  "%s", 1, string)) {
     free (path);
+    // databases created prior to ~2014.07.01 did not have the LENSING or LENSOBJ paths in their headers.
+    // in these cases, we do not try to lock or open the relevant file
+    if (!strcmp (name, "LENSING")) return (DVO_CAT_OPEN_EMPTY);
+    if (!strcmp (name, "LENSOBJ")) return (DVO_CAT_OPEN_EMPTY);
     return (DVO_CAT_OPEN_FAIL);
   }
@@ -192,10 +196,11 @@
 
   /* get the components from the header - these duplicate information in the split files (NAXIS2) */
+  // NSTARS, NMEAS, NMISS are required; NLENSING, NLENSOBJ are not (0 if not found)
   if (!gfits_scan (&catalog[0].header, "NSTARS",   OFF_T_FMT, 1,  &Naverage)) return (FALSE);
   if (!gfits_scan (&catalog[0].header, "NMEAS",    OFF_T_FMT, 1,  &Nmeasure)) return (FALSE);
   if (!gfits_scan (&catalog[0].header, "NMISS",    OFF_T_FMT, 1,  &Nmissing)) return (FALSE);
-  if (!gfits_scan (&catalog[0].header, "NSECFILT", "%d",   1,               &Nsecfilt)) Nsecfilt = 0;
-  if (!gfits_scan (&catalog[0].header, "NLENSING", OFF_T_FMT, 1,  &Nlensing)) return (FALSE);
-  if (!gfits_scan (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1,  &Nlensobj)) return (FALSE);
+  if (!gfits_scan (&catalog[0].header, "NSECFILT",      "%d", 1,  &Nsecfilt)) Nsecfilt = 0;
+  if (!gfits_scan (&catalog[0].header, "NLENSING", OFF_T_FMT, 1,  &Nlensing)) Nlensing = 0;
+  if (!gfits_scan (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1,  &Nlensobj)) Nlensobj = 0;
 
   /* the OBJID is a counter that uniquely defines an average entry and never changes.  if
@@ -382,9 +387,10 @@
   /*** Lensing Table ***/
   if (!(catalog[0].catflags & SKIP_LENSING)) {
-    // unless we specify 'skip', we still need to load the 
+    // unless we specify 'skip', we still need to load the Lensing table
     status = dvo_catalog_open_subcat (catalog, &catalog[0].lensing_catalog, ftable.header, "LENSING", VERBOSE);
     if (status == DVO_CAT_OPEN_FAIL) {
       return (FALSE);
     }
+    // the Lensing file need not exist, unless we expect data to exist
     if ((status == DVO_CAT_OPEN_EMPTY) && (catalog[0].Nlensing_disk > 0)) {
       return (FALSE);
@@ -392,5 +398,5 @@
   }
   if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_LENSING)) {
-    // XXX this allows an empty Lensing catalog with non-empty Average catalog : is that OK?
+    // only read the Lensing table if the file actually exists
     /* read Lensing table data */
     if (!gfits_fread_ftable_data (catalog[0].lensing_catalog[0].f, &ftable, FALSE)) {
@@ -406,6 +412,4 @@
     catalog[0].Nlensing_off = 0;
   } else {
-    // XXX is it necessary to generate a template header here?
-    // XXX this is a memory leak, right?
     if (catalog[0].lensing_catalog) {
       gfits_free_header (&catalog[0].lensing_catalog[0].header);
@@ -428,4 +432,5 @@
       return (FALSE);
     }
+    // the Lensobj file need not exist, unless we expect data to exist
     if ((status == DVO_CAT_OPEN_EMPTY) && (catalog[0].Nlensobj_disk > 0)) {
       return (FALSE);
@@ -433,5 +438,5 @@
   }
   if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_LENSOBJ)) {
-    // XXX this allows an empty Lensobj catalog with non-empty Average catalog : is that OK?
+    // only read the Lensobj table if the file actually exists
     /* read Lensobj table data */
     if (!gfits_fread_ftable_data (catalog[0].lensobj_catalog[0].f, &ftable, FALSE)) {
@@ -447,6 +452,4 @@
     catalog[0].Nlensobj_off = 0;
   } else {
-    // XXX is it necessary to generate a template header here?
-    // XXX this is a memory leak, right?
     if (catalog[0].lensobj_catalog) {
       gfits_free_header (&catalog[0].lensobj_catalog[0].header);
