Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Mareframe
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[mareframe] Diff of /trunk/gadget/maininfo.cc
[mareframe] / trunk / gadget / maininfo.cc Repository:
ViewVC logotype

Diff of /trunk/gadget/maininfo.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1, Mon Feb 10 17:09:07 2014 UTC revision 20, Fri Apr 7 09:20:55 2017 UTC
# Line 20  Line 20 
20      << " -n                           perform a network run (using paramin)\n"      << " -n                           perform a network run (using paramin)\n"
21      << " -v --version                 display version information and exit\n"      << " -v --version                 display version information and exit\n"
22      << " -h --help                    display this help screen and exit\n"      << " -h --help                    display this help screen and exit\n"
23    #ifdef _OPENMP
24        << " -parallel  <option>          run in parallel <option> == [spe, rep]. spe=speculative, rep=reproducible. Defaull spe\n"
25    #endif
26      << "\nOptions for specifying the input to Gadget models:\n"      << "\nOptions for specifying the input to Gadget models:\n"
27      << " -i <filename>                read model parameters from <filename>\n"      << " -i <filename>                read model parameters from <filename>\n"
28      << " -opt <filename>              read optimising parameters from <filename>\n"      << " -opt <filename>              read optimising parameters from <filename>\n"
# Line 41  Line 44 
44  }  }
45    
46  MainInfo::MainInfo()  MainInfo::MainInfo()
47    #ifdef _OPENMP
48      : givenOptInfo(0), givenInitialParam(0), runoptimise(0), runparallel(0),
49    #else
50    : givenOptInfo(0), givenInitialParam(0), runoptimise(0),    : givenOptInfo(0), givenInitialParam(0), runoptimise(0),
51    #endif
52      runstochastic(0), runnetwork(0), runprint(1), forceprint(0),      runstochastic(0), runnetwork(0), runprint(1), forceprint(0),
53      printInitialInfo(0), printFinalInfo(0), printLogLevel(0), maxratio(0.95) {      printInitialInfo(0), printFinalInfo(0), printLogLevel(0), maxratio(0.95) {
54    
# Line 78  Line 85 
85      delete[] strMainGadgetFile;      delete[] strMainGadgetFile;
86      strMainGadgetFile = NULL;      strMainGadgetFile = NULL;
87    }    }
88      if (seed != NULL) {
89              delete[] seed;
90              seed = NULL;
91      }
92  }  }
93    
94  void MainInfo::read(int aNumber, char* const aVector[]) {  void MainInfo::read(int aNumber, char* const aVector[]) {
# Line 87  Line 98 
98      return;      return;
99    }    }
100    
101      seed = new unsigned[3];
102      seed[0] = 0;
103      seed[1] = 0;
104      seed[2] = 0;
105    int k = 1;    int k = 1;
106    while (k < aNumber) {    while (k < aNumber) {
107      if (strcasecmp(aVector[k], "-l") == 0) {      if (strcasecmp(aVector[k], "-l") == 0) {
# Line 101  Line 116 
116    
117      } else if (strcasecmp(aVector[k], "-s") == 0) {      } else if (strcasecmp(aVector[k], "-s") == 0) {
118        runstochastic = 1;        runstochastic = 1;
   
119      } else if (strcasecmp(aVector[k], "-m") == 0) {      } else if (strcasecmp(aVector[k], "-m") == 0) {
120        ifstream infile;        ifstream infile;
121        CommentStream incomment(infile);        CommentStream incomment(infile);
# Line 139  Line 153 
153    
154      } else if (strcasecmp(aVector[k], "-co") == 0) {      } else if (strcasecmp(aVector[k], "-co") == 0) {
155        handle.logMessage(LOGFAIL, "The -co switch is no longer supported");        handle.logMessage(LOGFAIL, "The -co switch is no longer supported");
156    #ifdef _OPENMP
157      } else if (strcasecmp(aVector[k], "-printinitial") == 0) {      } else if (strcasecmp(aVector[k], "-parallel") == 0) {
158          handle.logMessage(LOGINFO, "--------parallel option ", aVector[k]);
159        if (k == aNumber - 1)        if (k == aNumber - 1)
160          this->showCorrectUsage(aVector[k]);          this->showCorrectUsage(aVector[k]);
161        k++;        k++;
162        this->setPrintInitialFile(aVector[k]);        this->setParallel(aVector[k]);
163    #endif
164    
165      } else if (strcasecmp(aVector[k], "-printfinal") == 0) {      } else if (strcasecmp(aVector[k], "-printfinal") == 0) {
166        if (k == aNumber - 1)        if (k == aNumber - 1)
# Line 220  Line 236 
236        if (k == aNumber - 1)        if (k == aNumber - 1)
237          this->showCorrectUsage(aVector[k]);          this->showCorrectUsage(aVector[k]);
238        k++;        k++;
239        srand(atoi(aVector[k]));        seed[0] = atoi(aVector[k]);
240          srand(seed[0]);
241          //seedM = seed to set the metropolis acceptance in SA
242        } else if (strcasecmp(aVector[k], "-seedM") == 0) {
243            //JMB experimental setting of random number seed from the commandline
244            //if the "seed" is also specified in the optinfo file then that will override
245            //any seed that is specified on the commandline
246            if (k == aNumber - 1)
247              this->showCorrectUsage(aVector[k]);
248            k++;
249            seed[1] = atoi(aVector[k]);
250            //seedP = seed to set the orden of evaluation of the parameter in SA
251        } else if (strcasecmp(aVector[k], "-seedP") == 0) {
252            //JMB experimental setting of random number seed from the commandline
253            //if the "seed" is also specified in the optinfo file then that will override
254            //any seed that is specified on the commandline
255            if (k == aNumber - 1)
256              this->showCorrectUsage(aVector[k]);
257            k++;
258            seed[2] = atoi(aVector[k]);
259    
260      } else if (strcasecmp(aVector[k], "-maxratio") == 0) {      } else if (strcasecmp(aVector[k], "-maxratio") == 0) {
261        //JMB experimental setting of maximum ratio of stock consumed in one timestep        //JMB experimental setting of maximum ratio of stock consumed in one timestep
# Line 234  Line 269 
269    
270      k++;      k++;
271    }    }
272    
273      if (seed[0] == 0) {
274              seed[0] = unsigned(time(NULL));
275              if (seed[1] == 0)
276                      seed[1] = unsigned(time(NULL));
277              if (seed[2] == 0)
278                      seed[2] = unsigned(time(NULL));
279      } else {
280              if (seed[1] == 0)
281                      seed[1] = seed[0];
282              if (seed[2] == 0)
283                      seed[2] = seed[0];
284      }
285    
286    
287    
288    
289  }  }
290    
291  void MainInfo::checkUsage(const char* const inputdir, const char* const workingdir) {  void MainInfo::checkUsage(const char* const inputdir, const char* const workingdir) {
# Line 380  Line 432 
432      } else if (strcasecmp(text, "-printfinal") == 0) {      } else if (strcasecmp(text, "-printfinal") == 0) {
433        infile >> text >> ws;        infile >> text >> ws;
434        this->setPrintFinalFile(text);        this->setPrintFinalFile(text);
435    #ifdef _OPENMP
436        } else if (strcasecmp(text, "-parallel") == 0) {
437          infile >> text >> ws;
438    handle.logMessage(LOGINFO, "--------parallel option 222 ", text);
439          this->setParallel(text);
440    #endif
441      } else if (strcasecmp(text, "-opt") == 0) {      } else if (strcasecmp(text, "-opt") == 0) {
442        infile >> text >> ws;        infile >> text >> ws;
443        this->setOptInfoFile(text);        this->setOptInfoFile(text);
# Line 436  Line 494 
494    strcpy(strPrintFinalFile, filename);    strcpy(strPrintFinalFile, filename);
495    printFinalInfo = 1;    printFinalInfo = 1;
496  }  }
497    #ifdef _OPENMP
498    void MainInfo::setParallel(char* filename) {
499      if (!strcasecmp(filename,"spe")){
500           runparallel=1;
501    handle.logMessage(LOGINFO, "--------parallel speculative ", filename);
502           return;
503      }
504      if (!strcasecmp(filename,"rep")){
505    handle.logMessage(LOGINFO, "--------parallel reproducible ", filename);
506           runparallel=2;
507           return;
508      }
509      this->showCorrectUsage("opt");
510    
511    }
512    #endif
513    
514  void MainInfo::setMainGadgetFile(char* filename) {  void MainInfo::setMainGadgetFile(char* filename) {
515    if (strMainGadgetFile != NULL) {    if (strMainGadgetFile != NULL) {

Legend:
Removed from v.1  
changed lines
  Added in v.20

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge