Add command line arguement parser to swe_simple

parent 5cedcb18
...@@ -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,15 +65,23 @@ int main( int argc, char** argv ) { ...@@ -64,15 +65,23 @@ 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");
<< "\tfor a single block of size 200 * 300" << std::endl; #endif
tools::Args::Result ret = args.parse(argc, argv);
switch (ret)
{
case tools::Args::Error:
return 1; return 1;
case tools::Args::Help:
return 0;
} }
#endif
//! 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_nY = l_nX = atoi(argv[1]); l_nX = args.getArgument<int>("grid-size-x");
l_nY = atoi(argv[2]); l_nY = args.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
......
...@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment