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::set<std::string> seenKeys;
|
||||||
std::ifstream ifs(fileName);
|
std::ifstream ifs(fileName);
|
||||||
|
if (!ifs.is_open()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned curLineNum = 0;
|
unsigned curLineNum = 0;
|
||||||
while (ifs) {
|
while (ifs) {
|
||||||
// string and file processing in c++ is quite blunt!
|
// 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;
|
MetaData::tree()[canonicalKey] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string parseCommandLineOptions(int argc,
|
std::string parseCommandLineOptions(int argc,
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ parseCommandLineOptions(int argc,
|
|||||||
*
|
*
|
||||||
* This function does some basic syntax checks.
|
* 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
|
* \ingroup Parameter
|
||||||
|
|||||||
@@ -44,7 +44,6 @@
|
|||||||
#include <dune/fem/misc/mpimanager.hh>
|
#include <dune/fem/misc/mpimanager.hh>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -145,9 +144,7 @@ static inline int setupParameters_(int argc,
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// check whether the parameter file is readable.
|
// check whether the parameter file is readable.
|
||||||
std::ifstream tmp;
|
if (!Parameters::parseParameterFile(paramFileName, /*overwrite=*/false)) {
|
||||||
tmp.open(paramFileName.c_str());
|
|
||||||
if (!tmp.is_open()) {
|
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
if (myRank == 0) {
|
if (myRank == 0) {
|
||||||
oss << "Parameter file \"" << paramFileName
|
oss << "Parameter file \"" << paramFileName
|
||||||
@@ -156,9 +153,6 @@ static inline int setupParameters_(int argc,
|
|||||||
}
|
}
|
||||||
return /*status=*/1;
|
return /*status=*/1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read the parameter file.
|
|
||||||
Parameters::parseParameterFile(paramFileName, /*overwrite=*/false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure that no unknown parameters are encountered
|
// make sure that no unknown parameters are encountered
|
||||||
|
|||||||
Reference in New Issue
Block a user