PlasCom2  1.0
XPACC Multi-physics simluation application
CheckResults.C
Go to the documentation of this file.
1 #include <iostream>
2 #include <limits>
3 
4 #include "CheckResults.H"
5 
6 namespace ix {
7  namespace util {
8  int CheckResults(int argc,char *argv[])
9  {
10  CheckResultsComLine comline((const char **)argv);
11  comline.Initialize();
12  int clerr = comline.ProcessOptions();
13  if(!comline.GetOption("help").empty()){
14  std::cout << comline.LongUsage() << std::endl;
15  return(0);
16  }
17  int verb_level = 1;
18  std::string sverb = comline.GetOption("verbosity");
19  std::istringstream Istr(sverb);
20  Istr >> verb_level;
21  if(verb_level < 0 || verb_level > 3)
22  verb_level = 1;
23  double lower_limit = -std::numeric_limits<double>::max();
24  double upper_limit = std::numeric_limits<double>::max();
25  std::string range = comline.GetOption("range");
26  std::string ident = comline.GetOption("identifier");
27  std::string name = comline.GetOption("name");
28  bool passed = false;
29  if(name.empty())
30  name = ident;
31  if(verb_level > 2)
32  std::cerr << "Identifier: " << ident << std::endl;
33  comline.ProcessRange<double>(lower_limit,upper_limit,range);
34  if(verb_level > 2)
35  std::cerr << "Processed range: (" << lower_limit << ":" << upper_limit
36  << ")" << std::endl;
37  std::string line;
38  while(std::getline(std::cin,line)){
39  std::string::size_type x = line.find(ident);
40  if(x != std::string::npos){
41  x = line.find(":");
42  if(x != std::string::npos){
43  std::string snumbers = line.substr(x+1);
44  std::istringstream NumIn(snumbers);
45  double cnum = 0;
46  NumIn >> cnum;
47  passed = ((cnum >= lower_limit) && (cnum <= upper_limit));
48  if(verb_level)
49  std::cout << name << " = " << (passed ? 1 : 0) << std::endl;
50  if((verb_level > 1) && !passed){
51  std::cerr << "Test failed: " << cnum << " is not in range ("
52  << lower_limit << ":" << upper_limit << ")" << std::endl;
53  }
54  break;
55  }
56  }
57  }
58  if(!passed)
59  return(1);
60  return(0);
61  }
62  } }
63 
64 int main(int argc,char *argv[])
65 {
66  return(ix::util::CheckResults(argc,argv));
67 }
int ProcessOptions()
Processes all command line tokens.
Definition: ComLine.C:330
std::string GetOption(const char &s)
Get the value of an option.
Definition: ComLine.H:291
int main(int argc, char *argv[])
Definition: CheckResults.C:64
The ComLineObject for the example programs.
Definition: CheckResults.H:46
void ProcessRange(NumType &t1, NumType &t2, const std::string stinter)
Process a range in the format "t1:t2".
Definition: ComLine.H:335
int CheckResults(int argc, char *argv[])
Check numerical results utility.
Definition: CheckResults.C:8
Performs various checks on numerical test results.
Defines MPI-specific parallel global and program classes.
void const size_t const size_t const size_t const double const double * x
void Initialize()
This is where the actual options and arguments are described.
Definition: CheckResults.H:61
std::string LongUsage()
Generate long usage string.
Definition: ComLine.C:188