MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
setupenv.cpp
Go to the documentation of this file.
1 // setupenv.cpp ---
2 //
3 // Filename: setupenv.cpp
4 // Description:
5 // Author: Subhasis Ray
6 // Maintainer:
7 // Copyright (C) 2010 Subhasis Ray, all rights reserved.
8 // Created: Sat Mar 26 22:36:10 2011 (+0530)
9 // Version:
10 // Last-Updated: Fri Aug 10 17:15:17 2012 (+0530)
11 // By: subha
12 // Update #: 31
13 // URL:
14 // Keywords:
15 // Compatibility:
16 //
17 //
18 
19 // Commentary:
20 //
21 //
22 //
23 //
24 
25 // Change log:
26 //
27 //
28 //
29 
30 // Code:
31 
32 #include <map>
33 #include <string>
34 #include <sstream>
35 #include <cstdlib>
36 using namespace std;
37 
38 extern unsigned getNumCores();
39 
40 namespace moose {
41  const map<string, string>& getArgMap()
42  {
43  static map<string, string> argmap;
44  if (argmap.empty()){
45  char * verbosity = getenv("VERBOSITY");
46  if (verbosity != NULL){
47  argmap.insert(pair<string, string>("VERBOSITY", string(verbosity)));
48  } else {
49  argmap.insert(pair<string, string>("VERBOSITY", "0"));
50  }
51  char * isSingleThreaded = getenv("SINGLETHREADED");
52  if (isSingleThreaded != NULL){
53  argmap.insert(pair<string, string>("SINGLETHREADED", string(isSingleThreaded)));
54  }
55  else {
56  argmap.insert(pair<string, string>("SINGLETHREADED", "0"));
57  }
58  char * isInfinite = getenv("INFINITE");
59  if (isInfinite != NULL){
60  argmap.insert(pair<string, string>("INFINITE", string(isInfinite)));
61  }
62  // else {
63  // argmap.insert(pair<string, string>("INFINITE", "0"));
64  // }
65 
66  char * numCores = getenv("NUMCORES");
67  if (numCores != NULL){
68  argmap.insert(pair<string, string>("NUMCORES", string(numCores)));
69  } else {
70  unsigned int cores = getNumCores();
71  stringstream s;
72  s << cores;
73  argmap.insert(pair<string, string>("NUMCORES", s.str()));
74  }
75  char * numNodes = getenv("NUMNODES");
76  if (numNodes != NULL){
77  argmap.insert(pair<string, string>("NUMNODES", string(numNodes)));
78  } // else {
79  // argmap.insert(pair<string, string>("NUMNODES", "1"));
80  // }
81  char * numProcessThreads = getenv("NUMPTHREADS");
82  if (numProcessThreads != NULL){
83  argmap.insert(pair<string, string>("NUMPTHREADS", string(numProcessThreads)));
84  }
85  char * doQuit = getenv("QUIT");
86  if (doQuit != NULL){
87  argmap.insert(pair<string, string>("QUIT", string(doQuit)));
88  } // else {
89  // argmap.insert(pair<string, string>("QUIT", "0"));
90  // }
91  char * doUnitTests = getenv("DOUNITTESTS");
92  if (doUnitTests != NULL){
93  argmap.insert(pair<string, string>("DOUNITTESTS", string(doUnitTests)));
94  } // else {
95  // argmap.insert(pair<string, string>("DOUNITTESTS", "0"));
96  // }
97  char * doRegressionTests = getenv("DOREGRESSIONTESTS");
98  if (doRegressionTests != NULL){
99  argmap.insert(pair<string, string>("DOREGRESSIONTESTS", string(doRegressionTests)));
100  } // else {
101  // argmap.insert(pair<string, string>("DOREGRESSIONTESTS", "0"));
102  // }
103 
104  }
105  return argmap;
106  }
107 
108 }
109 
110 
111 //
112 // setupenv.cpp ends here
static unsigned int numCores
static int isInfinite
static int doRegressionTests
unsigned getNumCores()
Definition: main.cpp:93
int verbosity
const map< string, string > & getArgMap()
Definition: setupenv.cpp:41
static unsigned int numNodes
static int doUnitTests