Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
SWE
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gaurav Kukreja
SWE
Commits
e38b8970
Commit
e38b8970
authored
Jun 26, 2013
by
Sebastian Rettenberger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add command line arguement parser to swe_simple
parent
5cedcb18
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
10 deletions
+20
-10
swe_simple.cpp
src/examples/swe_simple.cpp
+19
-10
args.hh
src/tools/args.hh
+1
-0
No files found.
src/examples/swe_simple.cpp
View file @
e38b8970
...
@@ -53,6 +53,7 @@
...
@@ -53,6 +53,7 @@
#include "tools/CXMLConfig.hpp"
#include "tools/CXMLConfig.hpp"
#endif
#endif
#include "tools/args.hh"
#include "tools/help.hh"
#include "tools/help.hh"
#include "tools/Logger.hh"
#include "tools/Logger.hh"
#include "tools/ProgressBar.hh"
#include "tools/ProgressBar.hh"
...
@@ -64,16 +65,24 @@ int main( int argc, char** argv ) {
...
@@ -64,16 +65,24 @@ int main( int argc, char** argv ) {
/**
/**
* Initialization.
* Initialization.
*/
*/
// check if the necessary command line input parameters are given
// Parse command line parameters
tools
::
Args
args
;
#ifndef READXML
#ifndef READXML
if
(
argc
!=
4
)
{
args
.
addOption
(
"grid-size-x"
,
'x'
,
"Number of cell in x direction"
);
std
::
cout
<<
"Aborting ... please provide proper input parameters."
<<
std
::
endl
args
.
addOption
(
"grid-size-y"
,
'y'
,
"Number of cell in y direction"
);
<<
"Example: ./SWE_parallel 200 300 /work/openmp_out"
<<
std
::
endl
args
.
addOption
(
"output-basepath"
,
'o'
,
"Output base file name"
);
<<
"
\t
for a single block of size 200 * 300"
<<
std
::
endl
;
return
1
;
}
#endif
#endif
tools
::
Args
::
Result
ret
=
args
.
parse
(
argc
,
argv
);
switch
(
ret
)
{
case
tools
:
:
Args
::
Error
:
return
1
;
case
tools
:
:
Args
::
Help
:
return
0
;
}
//! number of grid cells in x- and y-direction.
//! number of grid cells in x- and y-direction.
int
l_nX
,
l_nY
;
int
l_nX
,
l_nY
;
...
@@ -82,9 +91,9 @@ int main( int argc, char** argv ) {
...
@@ -82,9 +91,9 @@ int main( int argc, char** argv ) {
// read command line parameters
// read command line parameters
#ifndef READXML
#ifndef READXML
l_n
Y
=
l_nX
=
atoi
(
argv
[
1
]
);
l_n
X
=
args
.
getArgument
<
int
>
(
"grid-size-x"
);
l_nY
=
a
toi
(
argv
[
2
]
);
l_nY
=
a
rgs
.
getArgument
<
int
>
(
"grid-size-y"
);
l_baseName
=
std
::
string
(
argv
[
3
]
);
l_baseName
=
args
.
getArgument
<
std
::
string
>
(
"output-basepath"
);
#endif
#endif
// read xml file
// read xml file
...
...
src/tools/args.hh
View file @
e38b8970
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
#define TOOLS_ARGS_H
#define TOOLS_ARGS_H
#include <getopt.h>
#include <getopt.h>
#include <algorithm>
#include <map>
#include <map>
#include <iomanip>
#include <iomanip>
#include <string>
#include <string>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment