Rocstar
1.0
Rocstar multiphysics simulation application
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
utilities/rocflu/post/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
RFLUPOST
(
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 - Quiet"
<< endl
45
<<
" 1 - Moderately verbose"
<< endl
46
<<
" 2 - Ridiculously verbose"
<< endl
47
<< endl;
48
}
49
50
int
51
main
(
int
argc,
char
*argv[])
52
{
53
// Get the commandline into a string vector - it's easier
54
// to deal with that way.
55
vector<string> args =
Vectize
((
const
char
**)argv,argc);
56
57
// Get the name of the executable by stripping off any leading
58
// directory names
59
string
program_name(
stripdir
(args[0]));
60
61
// Specify the allowable options to the program
62
AddOp
(
"casename"
,
'c'
);
63
AddOp
(
"verbosity"
,
'v'
);
64
AddOp
(
"help"
,
'h'
);
65
AddOp
(
"stamp"
,
's'
);
66
67
// Declare some variables for command line argument handling
68
string
casename;
69
string
sverb;
70
string
stamp;
71
int
verbosity;
72
bool
help;
73
bool
isset;
74
75
// See if the help option is specified, if so give'm the usage text
76
if
(help =
GetOp
(
"help"
,args)){
77
Usage
(program_name);
78
exit(0);
79
}
80
81
// Process casename option, if it's not set then fail
82
if
(
GetOp
(
"casename"
,casename,args)){
83
if
(casename.empty()){
// casename was empty
84
cerr << program_name
85
<<
": Expected casename after casename option."
86
<<
" Use -h for usage instructions."
87
<< endl;
88
exit(1);
89
}
90
}
91
else
{
// option not specified (but it's required!)
92
cerr << program_name
93
<<
": Missing required casename option."
94
<<
" Use -h for usage instructions."
95
<< endl;
96
exit(1);
97
}
98
99
// Process stamp option, if it's not set then fail
100
if
(
GetOp
(
"stamp"
,stamp,args)){
101
if
(casename.empty()){
// stamp was empty
102
cerr << program_name
103
<<
": Expected stamp after stamp option."
104
<<
" Use -h for usage instructions."
105
<< endl;
106
exit(1);
107
}
108
}
109
else
{
// option not specified (but it's required!)
110
cerr << program_name
111
<<
": Missing required stamp option."
112
<<
" Use -h for usage instructions."
113
<< endl;
114
exit(1);
115
}
116
117
// Process verbosity option
118
if
(
GetOp
(
"verbosity"
,sverb,args)){
119
if
(sverb.empty()){
120
cerr << program_name
121
<<
": Expected verbosity level. "
122
<<
"Use -h for usage instructions."
<< endl;
123
exit(1);
124
}
125
istringstream Istr(sverb);
126
Istr >> verbosity;
127
if
(verbosity < 0 || verbosity > 2){
// Some jerk specified a non numeric or negative
128
cerr << program_name
129
<<
": Invalid verbosity value. Use -h for usage "
130
<<
"instructions."
<< endl;
131
exit(1);
132
}
133
}
134
else
{
// Default verbosity
135
verbosity = 1;
136
}
137
138
RFLUPOST
(casename.c_str(),stamp.c_str(),&verbosity,casename.length(),stamp.length());
139
}
140
141
142
143
144
145
stripdir
const string stripdir(const string &)
RFLUPOST
void RFLUPOST(const char *, const char *, int *, long int, long int)
clop.H
GetOp
bool GetOp(const string &ops, const vector< string > &args)
AddOp
void AddOp(const string &lo, const char &so)
Usage
void Usage(const string &pn)
Definition:
standalone/main.C:37
main
int main(int argc, char *argv[])
Definition:
blastest.C:94
Vectize
vector< string > Vectize(const char **)
Definition:
clop.C:182
RocfluidMP
utilities
rocflu
post
main.C
Generated on Wed Nov 30 2016 16:56:08 for Rocstar by
1.8.5