From 833be98c0461689eaadc1a126ab93abfe3c41ff2 Mon Sep 17 00:00:00 2001 From: Philipp Nuske <philipp.nuske@mailbox.org> Date: Mon, 13 Feb 2012 17:30:45 +0000 Subject: [PATCH] changed default name of input file to <programname>.input git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@7740 2fb0f335-1f38-0410-981e-8018bf24f1b0 --- dumux/common/start.hh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/dumux/common/start.hh b/dumux/common/start.hh index 2e18406b73..ac9a641566 100644 --- a/dumux/common/start.hh +++ b/dumux/common/start.hh @@ -361,7 +361,7 @@ std::string usageTextBlock() "\t-parameterFile FILENAME File with parameter definitions\n" "\t-restart RESTARTTIME Restart simulation from a restart file\n" "\n" - "For the case of no arguments given, the input parameter file is expected to be named './parameter.input' \n" + "For the case of no arguments given, the input parameter file is expected to be named './<programname>.input' \n" "\n"; } @@ -400,12 +400,18 @@ int start_(int argc, // case print the usage message if (argc == 1) { std::cout<< "\nNo parameter file given. \n" - << "Defaulting to './parameter.input' for input file.\n"; + << "Defaulting to '" + <<argv[0] + <<".input' for input file.\n"; std::ifstream parameterFile; // check whether the parameter file exists. - parameterFile.open("parameter.input"); + std::string defaultName = argv[0]; + defaultName += ".input"; + parameterFile.open(defaultName); if (not parameterFile.is_open()){ - std::cout<< "\n\t -> Could not open file './parameter.input'. <- \n\n\n\n"; + std::cout<< "\n\t -> Could not open file '" + <<defaultName + <<"'. <- \n\n\n\n"; usage(argv[0], usageTextBlock()); return 1; } @@ -436,8 +442,11 @@ int start_(int argc, // read input file, but do not overwrite options specified // on the command line, since the latter have precedence. std::string inputFileName ; - if(argc==1) // if there are no arguments given (and there is a file ./parameter.input) we use it as input file - inputFileName="parameter.input"; + if(argc==1) // if there are no arguments given (and there is a file ./<programname>.input) we use it as input file + { + inputFileName = argv[0]; + inputFileName += ".input"; + } else inputFileName = GET_RUNTIME_PARAM(TypeTag, std::string, parameterFile); // otherwise we read from the command line -- GitLab