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

Go to the source code of this file.

Functions

void FC_GLOBAL (rfluinit, RFLUINIT) const
 
int main (int argc, char *argv[])
 

Function Documentation

void FC_GLOBAL ( rfluinit  ,
RFLUINIT   
) const

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

69 {
70  cout << endl << "Usage: " << pn << " -c <casename> [-v 0-2]" << endl << endl
71  << " -c | --casename : Specifies the casename" << endl
72  << " -v | --verbosity : Verbosity level:" << endl
73  << " 0 - Quiet" << endl
74  << " 1 - Moderately verbose" << endl
75  << " 2 - Ridiculously verbose" << endl
76  << endl;
77 }
int main ( int  argc,
char *  argv[] 
)

Definition at line 80 of file utilities/rocflu/init/main.C.

References AddOp(), FC_GLOBAL, GetOp(), rfluinit(), RFLUINIT, stripdir(), Usage(), and Vectize().

81 {
82  // Get the commandline into a string vector - it's easier
83  // to deal with that way.
84  vector<string> args = Vectize((const char **)argv,argc);
85 
86  // Get the name of the executable by stripping off any leading
87  // directory names
88  string program_name(stripdir(args[0]));
89 
90  // Specify the allowable options to the program
91  AddOp("casename",'c');
92  AddOp("verbosity",'v');
93  AddOp("help",'h');
94 
95  // Declare some variables for command line argument handling
96  string casename;
97  string sverb;
98  int verbosity;
99  bool help;
100  bool isset;
101 
102  // See if the help option is specified, if so give'm the usage text
103  if(help = GetOp("help",args)){
104  Usage(program_name);
105  exit(0);
106  }
107 
108  // Process casename option, if it's not set then fail
109  if(GetOp("casename",casename,args)){
110  if(casename.empty()){ // casename was empty
111  cerr << program_name
112  << ": Expected casename after casename option."
113  << " Use -h for usage instructions."
114  << endl;
115  exit(1);
116  }
117  }
118  else{ // option not specified (but it's required!)
119  cerr << program_name
120  << ": Missing required casename option."
121  << " Use -h for usage instructions."
122  << endl;
123  exit(1);
124  }
125 
126  // Process verbosity option
127  if(GetOp("verbosity",sverb,args)){
128  if(sverb.empty()){
129  cerr << program_name
130  << ": Expected verbosity level. "
131  << "Use -h for usage instructions." << endl;
132  exit(1);
133  }
134  istringstream Istr(sverb);
135  Istr >> verbosity;
136  if(verbosity < 0 || verbosity > 2){ // Some jerk specified a non numeric or negative
137  cerr << program_name
138  << ": Invalid verbosity value. Use -h for usage "
139  << "instructions." << endl;
140  exit(1);
141  }
142  }
143  else{ // Default verbosity
144  verbosity = 1;
145  }
146 
147  FC_GLOBAL(rfluinit,RFLUINIT)(casename.c_str(),&verbosity,casename.length());
148 }
subroutine rfluinit(caseString, verbLevel)
Definition: rfluinit.F90:45
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 RFLUINIT
Definition: clop.H:114
#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: