Index: trunk/psModules/src/config/pmConfig.c
===================================================================
--- trunk/psModules/src/config/pmConfig.c	(revision 23244)
+++ trunk/psModules/src/config/pmConfig.c	(revision 23259)
@@ -13,4 +13,5 @@
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <strings.h>            /* for strn?casecmp */
@@ -24,9 +25,11 @@
 #include <pslib.h>
 
-#include "pmConfig.h"
 #include "pmErrorCodes.h"
 #include "pmFPALevel.h"
 #include "pmConfigRecipes.h"
 #include "pmConfigCamera.h"
+#include "pmConfigRun.h"
+
+#include "pmConfig.h"
 
 #ifdef HAVE_NEBCLIENT
@@ -432,8 +435,7 @@
     // variable will contain the name of the configuration file.
 
-    char *configFile = NULL;
-    //
+    char *configFile = NULL;            // Name of configuration file
+
     // First, try command line
-    //
     psS32 argNum = psArgumentGet(*argc, argv, "-ipprc");
     if (argNum != 0) {
@@ -447,17 +449,14 @@
         }
     }
-    //
+
     // Next, try environment variable
-    //
     if (!configFile) {
         configFile = getenv(IPPRC_ENV);
         if (configFile) {
-            configFile = psStringCopy (configFile);
-        }
-    }
-
-    //
+            configFile = psStringCopy(configFile);
+        }
+    }
+
     // Last chance is ~/.ipprc
-    //
     if (!configFile) {
         char *home = getenv("HOME");
@@ -466,8 +465,6 @@
     }
 
-    // We have the configuration filename; now we read and parse the config
-    // file and store in psMetadata struct user.
+    // Read and parse the config file and store in struct user.
     // XXX move this section to pmConfigReadUser.c ?
-
     if (!pmConfigFileRead(&config->user, configFile, "user")) {
         psFree(config);
@@ -477,11 +474,10 @@
     psFree(configFile);
 
-    // XXX why was this being called here?  Is someone calling pmConfigRead multiple times?
-    // pmConfigDone();
-    assert (configPath == NULL);
+    pmConfigRunCommand(config, *argc, argv);
 
     // define the config-file search path (configPath).
+    psAssert(configPath == NULL, "Configuration path is already defined.");
     psString path = psMetadataLookupStr(NULL, config->user, "PATH");
-    pmConfigSet (path);
+    pmConfigSet(path);
 
     // read the SITE file
@@ -525,5 +521,4 @@
             psLogSetLevel(logLevel);
         }
-
 
         // Set logging format
@@ -646,4 +641,26 @@
             psTimeInit(timeName);
         }
+    }
+
+    // Set the random number generator seed
+    {
+        psU64 seed = 0;                 // RNG seed
+        int argNum = psArgumentGet(*argc, argv, "-seed"); // Argument number
+        if (argNum > 0) {
+            psArgumentRemove(argNum, argc, argv);
+            if (argNum >= *argc) {
+                psWarning("-seed command-line switch provided without the required seed value --- ignored.");
+            } else {
+                char *end = NULL;       // Pointer to end of consumed string
+                seed = strtoll(argv[argNum], &end, 0);
+                if (strlen(end) > 0) {
+                    psError(PS_ERR_IO, true, "Unable to read random number generator seed: %s", argv[argNum]);
+                    psFree(config);
+                    return NULL;
+                }
+                psArgumentRemove(argNum, argc, argv);
+            }
+        }
+        pmConfigRunSeed(config, seed);
     }
 
Index: trunk/psModules/src/config/pmConfigCamera.c
===================================================================
--- trunk/psModules/src/config/pmConfigCamera.c	(revision 23244)
+++ trunk/psModules/src/config/pmConfigCamera.c	(revision 23259)
@@ -213,4 +213,5 @@
     psStringAppend(&newName, "_%s-SKYCELL", name);
     if (psMetadataLookup(oldCameras, newName)) {
+        psFree(newName);
         return true;
     }
@@ -469,4 +470,5 @@
     psStringAppend(&newName, "_%s-%s", name, mosaicLevel == PM_FPA_LEVEL_CHIP ? "CHIP" : "FPA");
     if (psMetadataLookup(oldCameras, newName)) {
+        psFree(newName);
         return true;
     }
Index: trunk/psModules/src/config/pmConfigRecipes.h
===================================================================
--- trunk/psModules/src/config/pmConfigRecipes.h	(revision 23244)
+++ trunk/psModules/src/config/pmConfigRecipes.h	(revision 23259)
@@ -1,9 +1,9 @@
 /*  @file pmConfigRecipes.h
  *  @brief Configuration Recipe functions
- * 
+ *
  *  @author ?, MHPCC
  *  @author Paul Price, IfA
  *  @author Eugene Magnier, IfA
- * 
+ *
  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
  *  @date $Date: 2007-04-19 02:10:12 $
@@ -13,4 +13,6 @@
 #ifndef PM_CONFIG_RECIPES_H
 #define PM_CONFIG_RECIPES_H
+
+#include <pmConfig.h>
 
 /// @addtogroup Config Configuration System
@@ -26,7 +28,7 @@
 
 
-bool pmConfigLoadRecipeArguments (int *argc, char **argv, pmConfig *config);
-bool pmConfigLoadRecipeOptions (int *argc, char **argv, pmConfig *config, char *flag);
-psMetadata *pmConfigRecipeOptions (pmConfig *config, char *recipe);
+bool pmConfigLoadRecipeArguments(int *argc, char **argv, pmConfig *config);
+bool pmConfigLoadRecipeOptions(int *argc, char **argv, pmConfig *config, char *flag);
+psMetadata *pmConfigRecipeOptions(pmConfig *config, char *recipe);
 
 /// @}
Index: trunk/psModules/src/config/pmConfigRun.c
===================================================================
--- trunk/psModules/src/config/pmConfigRun.c	(revision 23244)
+++ trunk/psModules/src/config/pmConfigRun.c	(revision 23259)
@@ -72,5 +72,5 @@
 
 
-bool pmConfigRunCommand(pmConfig *config, int argc, const char **argv)
+bool pmConfigRunCommand(pmConfig *config, int argc, char **argv)
 {
     PS_ASSERT_PTR_NON_NULL(config, false);
@@ -81,5 +81,5 @@
     psString command = NULL;
     for (int i = 0; i < argc; i++) {
-        psStringAppend(&command, "%s", argv[i]);
+        psStringAppend(&command, "%s ", argv[i]);
     }
 
@@ -89,2 +89,25 @@
     return true;
 }
+
+
+bool pmConfigRunSeed(pmConfig *config, psU64 seed)
+{
+    PS_ASSERT_PTR_NON_NULL(config, false);
+
+    psMetadata *run = configRun(config);// Run-time information
+    psAssert(run, "Require run-time information");
+
+    if (!seed) {
+        bool mdok;                          // Status of MD lookup
+        seed = psMetadataLookupU64(&mdok, run, "SEED");
+    }
+    if (!seed) {
+        bool mdok;                          // Status of MD lookup
+        seed = psMetadataLookupU64(&mdok, config->user, "SEED");
+    }
+
+    // seed may still be zero by this point
+    seed = psRandomSeed(seed);
+    return psMetadataAddU64(run, PS_LIST_TAIL, "SEED", PS_META_REPLACE, "Random number generator seed", seed);
+}
+
Index: trunk/psModules/src/config/pmConfigRun.h
===================================================================
--- trunk/psModules/src/config/pmConfigRun.h	(revision 23244)
+++ trunk/psModules/src/config/pmConfigRun.h	(revision 23259)
@@ -4,4 +4,5 @@
 #include <pslib.h>
 #include <pmConfig.h>
+#include <pmFPAfile.h>
 
 /// Add a file to the list of files used in the run-time information
@@ -12,6 +13,13 @@
 
 /// Add the command line to the run-time information
-bool pmConfigRunCommand(pmConfig *config, ///< Configuration
-                        int argc, const char **argv ///< Command line arguments
+bool pmConfigRunCommand(
+    pmConfig *config,                   ///< Configuration
+    int argc, char **argv               ///< Command line arguments
+    );
+
+/// Record the random number generator seed in the run-time information
+bool pmConfigRunSeed(
+    pmConfig *config,                   ///< Configuration
+    psU64 seed                          ///< RNG seed
     );
 
