mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
start.hh: move check for nonexistent parameter file into parseParameterFile
now we don't have to pull in <fstream> in start.hh
This commit is contained in:
@@ -559,10 +559,14 @@ void printUsage(const std::string& helpPreamble,
|
||||
}
|
||||
}
|
||||
|
||||
void parseParameterFile(const std::string& fileName, bool overwrite)
|
||||
bool parseParameterFile(const std::string& fileName, bool overwrite)
|
||||
{
|
||||
std::set<std::string> seenKeys;
|
||||
std::ifstream ifs(fileName);
|
||||
if (!ifs.is_open()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned curLineNum = 0;
|
||||
while (ifs) {
|
||||
// string and file processing in c++ is quite blunt!
|
||||
@@ -624,6 +628,8 @@ void parseParameterFile(const std::string& fileName, bool overwrite)
|
||||
MetaData::tree()[canonicalKey] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string parseCommandLineOptions(int argc,
|
||||
|
||||
@@ -146,7 +146,7 @@ parseCommandLineOptions(int argc,
|
||||
*
|
||||
* This function does some basic syntax checks.
|
||||
*/
|
||||
void parseParameterFile(const std::string& fileName, bool overwrite = true);
|
||||
bool parseParameterFile(const std::string& fileName, bool overwrite = true);
|
||||
|
||||
/*!
|
||||
* \ingroup Parameter
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
#include <dune/fem/misc/mpimanager.hh>
|
||||
#endif
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
@@ -145,9 +144,7 @@ static inline int setupParameters_(int argc,
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
// check whether the parameter file is readable.
|
||||
std::ifstream tmp;
|
||||
tmp.open(paramFileName.c_str());
|
||||
if (!tmp.is_open()) {
|
||||
if (!Parameters::parseParameterFile(paramFileName, /*overwrite=*/false)) {
|
||||
std::ostringstream oss;
|
||||
if (myRank == 0) {
|
||||
oss << "Parameter file \"" << paramFileName
|
||||
@@ -156,9 +153,6 @@ static inline int setupParameters_(int argc,
|
||||
}
|
||||
return /*status=*/1;
|
||||
}
|
||||
|
||||
// read the parameter file.
|
||||
Parameters::parseParameterFile(paramFileName, /*overwrite=*/false);
|
||||
}
|
||||
|
||||
// make sure that no unknown parameters are encountered
|
||||
|
||||
Reference in New Issue
Block a user