Index: trunk/psLib/src/astro/psEarthOrientation.c
===================================================================
--- trunk/psLib/src/astro/psEarthOrientation.c	(revision 13942)
+++ trunk/psLib/src/astro/psEarthOrientation.c	(revision 13950)
@@ -8,6 +8,6 @@
  *  @author Robert Daniel DeSonia, MHPCC
  *
- *  @version $Revision: 1.45 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-02-07 01:15:49 $
+ *  @version $Revision: 1.46 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-06-22 02:28:48 $
  *
  *  Copyright 2005 Maui High Performance Computing Center, University of Hawaii
@@ -93,5 +93,5 @@
     psMetadata* eocMetadata = psMetadataConfigRead(NULL,
                               &nFail,
-                              p_psTimeConfigFileName(),
+                              p_psTimeConfigFilename(NULL),
                               true);
     //Make sure reading of config file worked correctly
Index: trunk/psLib/src/astro/psTime.c
===================================================================
--- trunk/psLib/src/astro/psTime.c	(revision 13942)
+++ trunk/psLib/src/astro/psTime.c	(revision 13950)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.112 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-06-21 18:46:38 $
+ *  @version $Revision: 1.113 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-06-22 02:28:48 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -68,4 +68,7 @@
 #define NSEC_PER_DAY 86400000000000.0
 
+// Time config file path
+static char *timeConfig = NULL;
+
 /** Time metadata read from config file */
 static psMetadata *timeMetadata = NULL;
@@ -96,4 +99,5 @@
 static psTime* convertTimeUTCUT1(psTime* time);
 
+static bool p_psTimeInit(const char *fileName);
 
 /** Removes leading and trailing whitespace and # characters from a string. The cleaned string is a new null
@@ -164,14 +168,29 @@
 }
 
-// get the pslib.config filename by checking environment variable first, then original installation area.
-const char* p_psTimeConfigFileName()
-{
-    const char* filename = getenv("PS_CONFIG_FILE");
-
-    if (filename == NULL) { // environment variable not found
-        filename = PS_CONFIG_FILE_DEFAULT; // this should come from configure.ac
-    }
-
-    return filename;
+// get the pslib.config filename by checking environment variable first, then
+// the possiblity set config file name, then the original installation area.
+const char *p_psTimeConfigFilename(const char *filename)
+{
+    // if filename is provided, set timeConfig to this value
+    if (filename) {
+        psFree(timeConfig);
+        timeConfig = psStringCopy(filename);
+        psMemSetPersistent(timeConfig, true);
+        return timeConfig;
+    }
+
+    // check the env var first
+    const char *PS_CONFIG_FILE = getenv("PS_CONFIG_FILE");
+    if (PS_CONFIG_FILE) {
+        return PS_CONFIG_FILE;
+    }
+
+    // check timeConfig var 2nd
+    if (timeConfig) {
+        return timeConfig;
+    }
+
+    // fall back to the default, this should come from configure.ac
+    return PS_CONFIG_FILE_DEFAULT;
 }
 
@@ -191,5 +210,5 @@
 
     // Check if psTime tables are already loaded
-    if(!p_psTimeInit(p_psTimeConfigFileName())) {
+    if(!p_psTimeInit(p_psTimeConfigFilename(NULL))) {
         *status = PS_LOOKUP_ERROR;
         return NAN;
@@ -269,4 +288,5 @@
     }
 
+    // XXX this is not thread safe as the persistence setting is global
     const bool initialPersistence =
         p_psMemAllocatePersistent(true); // All memory allocated below is "persistent"
@@ -881,4 +901,10 @@
     if((bulletin != PS_IERS_A) && (bulletin != PS_IERS_B)) {
         psError(PS_ERR_BAD_PARAMETER_VALUE,true,"Invalid bulletin specified %d",bulletin);
+        return NAN;
+    }
+
+    // Check if psTime tables are already loaded
+    if(!p_psTimeInit(p_psTimeConfigFilename(NULL))) {
+        psError(PS_ERR_UNKNOWN, true, "failed to init time tables.");
         return NAN;
     }
@@ -1065,4 +1091,10 @@
     }
 
+    // Check if psTime tables are already loaded
+    if(!p_psTimeInit(p_psTimeConfigFilename(NULL))) {
+        psError(PS_ERR_UNKNOWN, true, "failed to init time tables.");
+        return NULL;
+    }
+
     // Attempt to find value through table lookup and interpolation
     mjd = psTimeToMJD(time);
@@ -1194,7 +1226,7 @@
 
     // Check if psTime tables are loaded/loadable
-    if(!p_psTimeInit(p_psTimeConfigFileName())) {
+    if (!p_psTimeInit(p_psTimeConfigFilename(NULL))) {
         psError(PS_ERR_BAD_PARAMETER_VALUE, true, _("Failed to open file %s."),
-                p_psTimeConfigFileName());
+                p_psTimeConfigFilename(NULL));
         return NAN;
     }
@@ -1712,5 +1744,5 @@
     // Error checks
     PS_ASSERT_PTR_NON_NULL(time,NULL);
-    PS_ASSERT_INT_WITHIN_RANGE(time->nsec,0,(psU32)((1e9)-1),NULL);
+    PS_ASSERT_INT_WITHIN_RANGE(time->nsec, (psU32)0, (psU32)((1e9)-1), NULL);
 
     // Convert time to TAI if necessary, but without changing input arguments
@@ -1796,7 +1828,11 @@
 }
 
-void psTimeInitialize(const char *timeConfig)
-{
-    p_psTimeInit(timeConfig);
+// delay actual init until a timefunction is used
+bool psTimeInit(const char *filename)
+{
+    // at present, this function can not fail
+    p_psTimeConfigFilename(filename);
+
+    return true;
 }
 
Index: trunk/psLib/src/astro/psTime.h
===================================================================
--- trunk/psLib/src/astro/psTime.h	(revision 13942)
+++ trunk/psLib/src/astro/psTime.h	(revision 13950)
@@ -11,6 +11,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-02-06 21:36:09 $
+ *  @version $Revision: 1.56 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-06-22 02:28:48 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -75,32 +75,19 @@
 
 
-// get the pslib.config filename by checking environment variable first, then original installation area.
-const char *p_psTimeConfigFileName();
-
-
 /** Initialize time data.
  *
- * Reads config and data files associated with various time conversions.
- *
- * @return bool:    True for success, false for failure.
- */
-bool p_psTimeInit(
-    const char *fileName               ///< File name containing config/data info
-);
-
-/** Initialize time data.
- *
- *  Reads the configuration file and sets up the appropriate psTimeTables and predictions.
- */
-void psTimeInitialize(
-    const char *timeConfig             ///< psTime configuration file
-);
-
-/** Free memory persistant time data.
- *
- * Frees time data to be held in memory until the end of successful program execution.
- *
- * @return void:    void.
- */
+ *  Sets the configuration file and sets up the appropriate psTimeTables and predictions.
+ */
+bool psTimeInit(
+    const char *filename                ///< psTime configuration file
+);
+
+
+/** Frees memory that was allocated by psTime functions.
+ *
+ *  Allows a subsequent search for leaked memory.
+ *
+ * @return true on sucess.
+*/
 bool p_psTimeFinalize(void);
 
@@ -476,4 +463,7 @@
 );
 
+// used by p_psEOCInit()
+const char *p_psTimeConfigFilename(const char *filename);
+
 /// @}
 
Index: trunk/psLib/src/sys/psConfigure.c
===================================================================
--- trunk/psLib/src/sys/psConfigure.c	(revision 13942)
+++ trunk/psLib/src/sys/psConfigure.c	(revision 13950)
@@ -13,6 +13,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-04-06 00:04:15 $
+ *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-06-22 02:28:48 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -26,4 +26,6 @@
 #include <stdlib.h>
 #include <string.h>
+
+#include "psAbort.h"
 #include "psTrace.h"
 #include "psString.h"
@@ -94,13 +96,13 @@
 
 
-void psLibInit(const char* timeConfig)
+bool psLibInit(const char* timeConfig)
 {
     // XXX: Still needs error codes to be set
 
     if (timeConfig && strlen(timeConfig) > 0) {
-        if (!p_psTimeInit(timeConfig)) {
+        if (!psTimeInit(timeConfig)) {
             psError(PS_ERR_BAD_PARAMETER_VALUE, true,
                     _("Failed to initialize %s."), "psTime");
-            return;
+            return false;
         }
     }
@@ -111,4 +113,6 @@
         atexit(&p_psMemoryCheck);
     }
+
+    return true;
 }
 
@@ -122,14 +126,10 @@
     // Free the time tables
     if (!p_psTimeFinalize()) {
-        psError(PS_ERR_UNKNOWN, false,
-                _("Failed to finalize %s."), "psTime");
-        return;
+        psAbort(_("Failed to finalize psTime."));
     }
 
     // Free the precession tables
     if (!p_psEOCFinalize()) {
-        psError(PS_ERR_UNKNOWN, false,
-                _("Failed to finalize %s."), "psEOC");
-        return;
+        psAbort(_("Failed to finalize psEOC."));
     }
 
@@ -139,4 +139,3 @@
     // Free the error system
     psErrorClear();
-
 }
Index: trunk/psLib/src/sys/psConfigure.h
===================================================================
--- trunk/psLib/src/sys/psConfigure.h	(revision 13942)
+++ trunk/psLib/src/sys/psConfigure.h	(revision 13950)
@@ -11,6 +11,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-02-08 01:59:28 $
+ *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-06-22 02:28:48 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -50,5 +50,5 @@
  *
  */
-void psLibInit(
+bool psLibInit(
     const char* timeConfig           ///< Filename of config file for psTime.
 );
