--- trunk/gadget/maininfo.cc 2015/06/10 13:01:42 10 +++ trunk/gadget/maininfo.cc 2015/07/23 19:00:38 11 @@ -41,7 +41,7 @@ } MainInfo::MainInfo() - : givenOptInfo(0), givenInitialParam(0), runoptimise(0), + : givenOptInfo(0), givenInitialParam(0), runoptimise(0), runomp(0), runstochastic(0), runnetwork(0), runprint(1), forceprint(0), printInitialInfo(0), printFinalInfo(0), printLogLevel(0), maxratio(0.95) { @@ -78,6 +78,10 @@ delete[] strMainGadgetFile; strMainGadgetFile = NULL; } + if (seed != NULL) { + delete[] seed; + seed = NULL; + } } void MainInfo::read(int aNumber, char* const aVector[]) { @@ -87,6 +91,10 @@ return; } + seed = new unsigned[3]; + seed[0] = 0; + seed[1] = 0; + seed[2] = 0; int k = 1; while (k < aNumber) { if (strcasecmp(aVector[k], "-l") == 0) { @@ -100,7 +108,10 @@ #endif } else if (strcasecmp(aVector[k], "-s") == 0) { - runstochastic = 1; + runstochastic = 1; +//FIXME + }else if (strcasecmp(aVector[k], "-omp") == 0) { + runomp = 1; } else if (strcasecmp(aVector[k], "-m") == 0) { ifstream infile; @@ -220,7 +231,26 @@ if (k == aNumber - 1) this->showCorrectUsage(aVector[k]); k++; - srand(atoi(aVector[k])); + seed[0] = atoi(aVector[k]); + srand(seed[0]); +//FIXME + } else if (strcasecmp(aVector[k], "-seedM") == 0) { + //JMB experimental setting of random number seed from the commandline + //if the "seed" is also specified in the optinfo file then that will override + //any seed that is specified on the commandline + if (k == aNumber - 1) + this->showCorrectUsage(aVector[k]); + k++; + seed[1] = atoi(aVector[k]); + + } else if (strcasecmp(aVector[k], "-seedP") == 0) { + //JMB experimental setting of random number seed from the commandline + //if the "seed" is also specified in the optinfo file then that will override + //any seed that is specified on the commandline + if (k == aNumber - 1) + this->showCorrectUsage(aVector[k]); + k++; + seed[2] = atoi(aVector[k]); } else if (strcasecmp(aVector[k], "-maxratio") == 0) { //JMB experimental setting of maximum ratio of stock consumed in one timestep @@ -234,6 +264,23 @@ k++; } + + if (seed[0] == 0) { + seed[0] = unsigned(time(NULL)); + if (seed[1] == 0) + seed[1] = unsigned(time(NULL)); + if (seed[2] == 0) + seed[2] = unsigned(time(NULL)); + } else { + if (seed[1] == 0) + seed[1] = seed[0]; + if (seed[2] == 0) + seed[2] = seed[0]; + } + + + + } void MainInfo::checkUsage(const char* const inputdir, const char* const workingdir) {