Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
utilities/rocflu/pick/main.C
Go to the documentation of this file.
1 /* *******************************************************************
2  * Rocstar Simulation Suite *
3  * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4  * *
5  * Illinois Rocstar LLC *
6  * Champaign, IL *
7  * www.illinoisrocstar.com *
8  * sales@illinoisrocstar.com *
9  * *
10  * License: See LICENSE file in top level of distribution package or *
11  * http://opensource.org/licenses/NCSA *
12  *********************************************************************/
13 /* *******************************************************************
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22  *********************************************************************/
23 #include <iostream>
24 #include <vector>
25 #include <list>
26 #include <sstream>
27 
28 using namespace std;
29 
30 #include "clop.H"
31 
32 extern "C" {
33  void RFLUPICK(const char *,const char *,int *,long int,long int);
34 }
35 
36 void
37 Usage(const string &pn)
38 {
39  cout << endl << "Usage: " << pn << " -c <casename> -s <stamp> [-v 0-2]"
40  << endl << endl
41  << " -c | --casename : Specifies the casename" << endl
42  << " -s | --stamp : Iteration or time stamp" << endl
43  << " -v | --verbosity : Verbosity level:" << endl
44  << " 0 - Nothing but warnings" << endl
45  << " 1 - Normal verbosity" << endl
46  << " 2 - More verbose" << endl
47  << " 3 - Ridiculously verbose" << endl
48  << endl;
49 }
50 
51 int
52 main(int argc,char *argv[])
53 {
54  // Get the commandline into a string vector - it's easier
55  // to deal with that way.
56  vector<string> args = Vectize((const char **)argv,argc);
57 
58  // Get the name of the executable by stripping off any leading
59  // directory names
60  string program_name(stripdir(args[0]));
61 
62  // Specify the allowable options to the program
63  AddOp("casename",'c');
64  AddOp("verbosity",'v');
65  AddOp("help",'h');
66  AddOp("stamp",'s');
67 
68  // Declare some variables for command line argument handling
69  string casename;
70  string sverb;
71  string stamp;
72  int verbosity;
73  bool help;
74  bool isset;
75 
76  // See if the help option is specified, if so give'm the usage text
77  if(help = GetOp("help",args)){
78  Usage(program_name);
79  exit(0);
80  }
81 
82  // Process casename option, if it's not set then fail
83  if(GetOp("casename",casename,args)){
84  if(casename.empty()){ // casename was empty
85  cerr << program_name
86  << ": Expected casename after casename option."
87  << " Use -h for usage instructions."
88  << endl;
89  exit(1);
90  }
91  }
92  else{ // option not specified (but it's required!)
93  cerr << program_name
94  << ": Missing required casename option."
95  << " Use -h for usage instructions."
96  << endl;
97  exit(1);
98  }
99 
100  // Process stamp option, if it's not set then fail
101  if(GetOp("stamp",stamp,args)){
102  if(casename.empty()){ // stamp was empty
103  cerr << program_name
104  << ": Expected stamp after stamp option."
105  << " Use -h for usage instructions."
106  << endl;
107  exit(1);
108  }
109  }
110  else{ // option not specified (but it's required!)
111  cerr << program_name
112  << ": Missing required stamp option."
113  << " Use -h for usage instructions."
114  << endl;
115  exit(1);
116  }
117 
118  // Process verbosity option
119  if(GetOp("verbosity",sverb,args)){
120  if(sverb.empty()){
121  cerr << program_name
122  << ": Expected verbosity level. "
123  << "Use -h for usage instructions." << endl;
124  exit(1);
125  }
126  istringstream Istr(sverb);
127  Istr >> verbosity;
128  if(verbosity < 0 || verbosity > 3){ // Some jerk specified a non numeric or negative
129  cerr << program_name
130  << ": Invalid verbosity value. Use -h for usage "
131  << "instructions." << endl;
132  exit(1);
133  }
134  }
135  else{ // Default verbosity
136  verbosity = 1;
137  }
138 
139  RFLUPICK(casename.c_str(),stamp.c_str(),&verbosity,casename.length(),stamp.length());
140 }
141 
142 
143 
144 
145 
146 
const string stripdir(const string &)
void RFLUPICK(const char *, const char *, int *, long int, long int)
bool GetOp(const string &ops, const vector< string > &args)
void AddOp(const string &lo, const char &so)
void Usage(const string &pn)
int main(int argc, char *argv[])
Definition: blastest.C:94
vector< string > Vectize(const char **)
Definition: clop.C:182