Index: trunk/psModules/src/config/pmConfig.c
===================================================================
--- trunk/psModules/src/config/pmConfig.c	(revision 23215)
+++ 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);
     }
 
