Commit 836b7f21 authored by Kilian Weishaupt's avatar Kilian Weishaupt
Browse files

Merge branch 'bugfix/pass-negative-values' into 'master'

Bugfix/pass negative values



See merge request !53
parents 496eb859 ea601ec3
......@@ -62,29 +62,30 @@ NEW_PROP_TAG(TimeManager);
std::string readOptions_(int argc, char **argv, Dune::ParameterTree &paramTree)
{
// All command line options need to start with '-'
for (int i = 1; i < argc; ++i) {
if (argv[i][0] != '-') {
if (i == 1) {
// try to pass first argument as parameter file
paramTree["ParameterFile"] = argv[1];
continue;
}
else {
std::ostringstream oss;
oss << "\n -> Command line argument " << i << " (='" << argv[i] << "') is invalid. <- \n\n\n\n";
return oss.str();
}
for (int i = 1; i < argc; ++i)
{
if (argv[i][0] != '-' && i == 1)
{
// try to pass first argument as parameter file
paramTree["ParameterFile"] = argv[1];
continue;
}
// read a -MyOpt VALUE option
std::string paramName = argv[i] + 1;
std::ostringstream oss;
if (argv[i][0] != '-')
{
oss << "\n -> Command line argument " << i << " (='" << argv[i] << "') is invalid. <- \n\n\n\n";
return oss.str();
}
if (argc == i + 1 || argv[i+1][0] == '-') {
std::ostringstream oss;
oss << "\n -> No argument given for parameter '" << argv[i] << "'! <- \n\n\n\n";
if (i+1 == argc)
{
oss << "\n -> No argument2 given for parameter '" << argv[i] << "'! <- \n\n\n\n";
return oss.str();
}
// read a -MyOpt VALUE option
std::string paramName = argv[i] + 1;
std::string paramValue = argv[i+1];
++i; // In the case of '-MyOpt VALUE' each pair counts as two arguments
......
Supports Markdown
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