diff --git a/dumux/common/start.hh b/dumux/common/start.hh index d28aee7e306ef373be1197e8674b8556ffa1f838..132892ea84ca39757ee5169a2a2a40684a685939 100644 --- a/dumux/common/start.hh +++ b/dumux/common/start.hh @@ -62,29 +62,30 @@ NEW_PROP_TAG(TimeManager); std::string readOptions_(int argc, char **argv, Dune::ParameterTree ¶mTree) { // 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