Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
utilities/rocflu/map/main.C File Reference
#include <iostream>
#include <vector>
#include <list>
#include <sstream>
#include "clop.H"
#include "FC.h"
Include dependency graph for utilities/rocflu/map/main.C:

Go to the source code of this file.

Functions

void FC_GLOBAL (rflumap, RFLUMAP) const
 
int main (int argc, char *argv[])
 

Function Documentation

void FC_GLOBAL ( rflumap  ,
RFLUMAP   
) const

Definition at line 64 of file utilities/rocflu/map/main.C.

69 {
70  cout << endl << "Usage: " << pn << " -c <casename> -r <n> -p <m> [-v 0-2]" << endl << endl
71  << " -c | --casename : Specifies the casename" << endl
72  << " -m | --mode : Mapping mode:" << endl
73  << " 1 - Initial mapping" << endl
74  << " 2 - Final mapping" << endl
75  << " -r | --nregions : Specifies the number of regions" << endl
76  << " -p | --nprocs : Specifies the number of processes" << endl
77  << " -v | --verbosity : Verbosity level:" << endl
78  << " 0 - Quiet" << endl
79  << " 1 - Moderately verbose" << endl
80  << " 2 - Ridiculously verbose" << endl
81  << endl;
82 }
int main ( int  argc,
char *  argv[] 
)

Definition at line 85 of file utilities/rocflu/map/main.C.

References AddOp(), FC_GLOBAL, GetOp(), rflumap(), RFLUMAP, stripdir(), Usage(), and Vectize().

86 {
87  // Get the commandline into a string vector - it's easier
88  // to deal with that way.
89  vector<string> args = Vectize((const char **)argv,argc);
90 
91  // Get the name of the executable by stripping off any leading
92  // directory names
93  string program_name(stripdir(args[0]));
94 
95  // Specify the allowable options to the program
96  AddOp("casename",'c');
97  AddOp("mode",'m');
98  AddOp("nregions",'r');
99  AddOp("nprocs",'p');
100  AddOp("verbosity",'v');
101  AddOp("help",'h');
102 
103  // Declare some variables for command line argument handling
104  string casename;
105  string smode,sprocs,sregs,sverb;
106  int mode;
107  int nprocs;
108  int nregions;
109  int verbosity;
110  bool help;
111  bool isset;
112 
113  // See if the help option is specified, if so give'm the usage text
114  if(help = GetOp("help",args)){
115  Usage(program_name);
116  exit(0);
117  }
118 
119  // Process casename option, if it's not set then fail
120  if(GetOp("casename",casename,args)){
121  if(casename.empty()){ // casename was empty
122  cerr << program_name
123  << ": Expected casename after casename option."
124  << " Use -h for usage instructions."
125  << endl;
126  exit(1);
127  }
128  }
129  else{ // option not specified (but it's required!)
130  cerr << program_name
131  << ": Missing required casename option."
132  << " Use -h for usage instructions."
133  << endl;
134  exit(1);
135  }
136 
137  // Process mode option
138  if(GetOp("mode",smode,args)){
139  if(smode.empty()){
140  cerr << program_name
141  << ": Expected mode value. "
142  << "Use -h for usage instructions." << endl;
143  exit(1);
144  }
145  istringstream Istr(smode);
146  Istr >> mode;
147  if(mode < 1 || mode > 2){ // Some jerk specified an invalid number
148  cerr << program_name
149  << ": Invalid mode value. Use -h for usage "
150  << "instructions." << endl;
151  exit(1);
152  }
153  }
154  else{ // option not specified (but it's required!)
155  cerr << program_name
156  << ": Missing mode value."
157  << " Use -h for usage instructions."
158  << endl;
159  exit(1);
160  }
161 
162  // Process nregions option
163  if(GetOp("nregions",sregs,args)){
164  if(sregs.empty()){
165  cerr << program_name
166  << ": Expected number of regions. "
167  << "Use -h for usage instructions." << endl;
168  exit(1);
169  }
170  istringstream Istr(sregs);
171  Istr >> nregions;
172  if(nregions < 1){ // Some jerk specified zero or a negative number
173  cerr << program_name
174  << ": Invalid number of regions. Use -h for usage "
175  << "instructions." << endl;
176  exit(1);
177  }
178  }
179  else{ // option not specified
180  if(mode == 1){
181  cerr << program_name
182  << ": Missing number of regions."
183  << " Use -h for usage instructions."
184  << endl;
185  exit(1);
186  }
187  else {
188  nregions = -1;
189  }
190  }
191 
192  // Process nprocs option
193  if(GetOp("nprocs",sprocs,args)){
194  if(sprocs.empty()){
195  cerr << program_name
196  << ": Expected number of processes. "
197  << "Use -h for usage instructions." << endl;
198  exit(1);
199  }
200  istringstream Istr(sprocs);
201  Istr >> nprocs;
202  if(nprocs < 1){ // Some jerk specified zero or a negative number
203  cerr << program_name
204  << ": Invalid number of processes. Use -h for usage "
205  << "instructions." << endl;
206  exit(1);
207  }
208  if(nprocs > nregions){
209  cerr << program_name
210  << ": Number of processes must not exceed number of regions." << endl;
211  exit(1);
212  }
213  }
214  else{ // option not specified
215  if(mode == 1){
216  cerr << program_name
217  << ": Missing number of processes."
218  << " Use -h for usage instructions."
219  << endl;
220  exit(1);
221  }
222  else {
223  nprocs = -1;
224  }
225  }
226 
227  // Process verbosity option
228  if(GetOp("verbosity",sverb,args)){
229  if(sverb.empty()){
230  cerr << program_name
231  << ": Expected verbosity level. "
232  << "Use -h for usage instructions." << endl;
233  exit(1);
234  }
235  istringstream Istr(sverb);
236  Istr >> verbosity;
237  if(verbosity < 0 || verbosity > 2){ // Some jerk specified a non numeric or negative
238  cerr << program_name
239  << ": Invalid verbosity value. Use -h for usage "
240  << "instructions." << endl;
241  exit(1);
242  }
243  }
244  else{ // Default verbosity
245  verbosity = 1;
246  }
247 
248  FC_GLOBAL(rflumap,RFLUMAP)(casename.c_str(),&mode,&nregions,&nprocs,&verbosity,casename.length());
249 }
const string stripdir(const string &)
bool GetOp(const string &ops, const vector< string > &args)
void AddOp(const string &lo, const char &so)
void Usage(const string &pn)
#define RFLUMAP
Definition: clop.H:115
subroutine rflumap(caseString, mapOption, nRegions, nProcs, verbLevel)
Definition: rflumap.F90:48
#define FC_GLOBAL(name, NAME)
Definition: FC.h:5
vector< string > Vectize(const char **)
Definition: clop.C:182

Here is the call graph for this function: