diff --git a/ebos/eclbasevanguard.hh b/ebos/eclbasevanguard.hh index a2f97f8ca..34641b547 100644 --- a/ebos/eclbasevanguard.hh +++ b/ebos/eclbasevanguard.hh @@ -65,7 +65,7 @@ struct EnableOpmRstFile { using type = UndefinedProperty; }; template -struct EclStrictParsing { +struct ParsingStrictness { using type = UndefinedProperty; }; template @@ -134,8 +134,8 @@ struct EnableOpmRstFile { static constexpr bool value = false; }; template -struct EclStrictParsing { - static constexpr bool value = false; +struct ParsingStrictness { + static constexpr auto value = "normal"; }; template struct SchedRestart { @@ -231,8 +231,8 @@ public: "Include OPM-specific keywords in the ECL restart file to enable restart of OPM simulators from these files"); EWOMS_REGISTER_PARAM(TypeTag, std::string, IgnoreKeywords, "List of Eclipse keywords which should be ignored. As a ':' separated string."); - EWOMS_REGISTER_PARAM(TypeTag, bool, EclStrictParsing, - "Use strict mode for parsing - all errors are collected before the applicaton exists."); + EWOMS_REGISTER_PARAM(TypeTag, std::string, ParsingStrictness, + "Set strictness of parsing process. Avaliable options are normal (stop for critical errors), high (stop for all errors) and low (as normal, except do not stop due to unsupported keywords even if marked critical"); EWOMS_REGISTER_PARAM(TypeTag, bool, SchedRestart, "When restarting: should we try to initialize wells and groups from historical SCHEDULE section."); EWOMS_REGISTER_PARAM(TypeTag, int, EdgeWeightsMethod, @@ -290,7 +290,6 @@ public: #endif enableDistributedWells_ = EWOMS_GET_PARAM(TypeTag, bool, AllowDistributedWells); ignoredKeywords_ = EWOMS_GET_PARAM(TypeTag, std::string, IgnoreKeywords); - eclStrictParsing_ = EWOMS_GET_PARAM(TypeTag, bool, EclStrictParsing); int output_param = EWOMS_GET_PARAM(TypeTag, int, EclOutputInterval); if (output_param >= 0) outputInterval_ = output_param; diff --git a/ebos/eclgenericvanguard.cc b/ebos/eclgenericvanguard.cc index bb88829cd..d64b73e5d 100644 --- a/ebos/eclgenericvanguard.cc +++ b/ebos/eclgenericvanguard.cc @@ -133,7 +133,7 @@ void EclGenericVanguard::readDeck(const std::string& filename) modelParams_.actionState_, modelParams_.wtestState_, modelParams_.eclSummaryConfig_, - nullptr, false, false, false, {}); + nullptr, "normal", false, false, {}); modelParams_.setupTime_ = setupTimer.stop(); } diff --git a/ebos/eclgenericvanguard.hh b/ebos/eclgenericvanguard.hh index 3fdffd4ee..0f0edcb74 100644 --- a/ebos/eclgenericvanguard.hh +++ b/ebos/eclgenericvanguard.hh @@ -296,7 +296,6 @@ protected: #endif bool enableDistributedWells_; std::string ignoredKeywords_; - bool eclStrictParsing_; std::optional outputInterval_; bool useMultisegmentWell_; bool enableExperiments_; diff --git a/opm/simulators/flow/Main.cpp b/opm/simulators/flow/Main.cpp index cf44e423d..347004851 100644 --- a/opm/simulators/flow/Main.cpp +++ b/opm/simulators/flow/Main.cpp @@ -171,7 +171,7 @@ void Main::readDeck(const std::string& deckFilename, const std::string& outputMode, const bool init_from_restart_file, const bool allRanksDbgPrtLog, - const bool strictParsing, + const std::string& parsingStrictness, const int mpiRank, const int output_param, const std::string& parameters, @@ -202,7 +202,7 @@ void Main::readDeck(const std::string& deckFilename, wtestState_, summaryConfig_, std::make_shared(), - strictParsing, + parsingStrictness, init_from_restart_file, outputCout_, outputInterval); diff --git a/opm/simulators/flow/Main.hpp b/opm/simulators/flow/Main.hpp index 498f44d43..dd1283f01 100644 --- a/opm/simulators/flow/Main.hpp +++ b/opm/simulators/flow/Main.hpp @@ -374,7 +374,7 @@ private: EWOMS_GET_PARAM(PreTypeTag, std::string, OutputMode), !EWOMS_GET_PARAM(PreTypeTag, bool, SchedRestart), EWOMS_GET_PARAM(PreTypeTag, bool, EnableLoggingFalloutWarning), - EWOMS_GET_PARAM(PreTypeTag, bool, EclStrictParsing), + EWOMS_GET_PARAM(PreTypeTag, std::string, ParsingStrictness), mpiRank, EWOMS_GET_PARAM(PreTypeTag, int, EclOutputInterval), cmdline_params, @@ -626,7 +626,7 @@ private: const std::string& outputMode, const bool init_from_restart_file, const bool allRanksDbgPrtLog, - const bool strictParsing, + const std::string& parsingStrictness, const int mpiRank, const int output_param, const std::string& parameters, diff --git a/opm/simulators/utils/readDeck.cpp b/opm/simulators/utils/readDeck.cpp index 9d745a4b2..c40d643bb 100644 --- a/opm/simulators/utils/readDeck.cpp +++ b/opm/simulators/utils/readDeck.cpp @@ -191,6 +191,7 @@ namespace { const bool checkDeck, const Opm::Parser& parser, const Opm::ParseContext& parseContext, + const bool treatCriticalAsNonCritical, Opm::ErrorGuard& errorGuard) { Opm::Deck deck(parser.parseFile(deckFilename, parseContext, errorGuard)); @@ -203,7 +204,7 @@ namespace { Opm::KeywordValidation::specialValidation() }; - keyword_validator.validateDeck(deck, parseContext, true, errorGuard); + keyword_validator.validateDeck(deck, parseContext, treatCriticalAsNonCritical, errorGuard); if (checkDeck) { Opm::checkDeck(deck, parser, parseContext, errorGuard); @@ -235,6 +236,7 @@ namespace { std::shared_ptr python, const bool initFromRestart, const bool checkDeck, + const bool treatCriticalAsNonCritical, const std::optional& outputInterval, Opm::ErrorGuard& errorGuard) { @@ -248,7 +250,7 @@ namespace { auto parser = Opm::Parser{}; const auto deck = readDeckFile(deckFilename, checkDeck, parser, - *parseContext, errorGuard); + *parseContext, treatCriticalAsNonCritical, errorGuard); if (eclipseState == nullptr) { eclipseState = createEclipseState(comm, deck); @@ -490,7 +492,7 @@ void Opm::readDeck(Opm::Parallel::Communication comm, std::unique_ptr& wtestState, std::shared_ptr& summaryConfig, std::shared_ptr python, - const bool strictParsing, + const std::string& parsingStrictness, const bool initFromRestart, const bool checkDeck, const std::optional& outputInterval) @@ -500,13 +502,20 @@ void Opm::readDeck(Opm::Parallel::Communication comm, int parseSuccess = 1; // > 0 is success std::string failureMessage; + if (parsingStrictness != "high" && parsingStrictness != "normal" && parsingStrictness != "low") { + OPM_THROW(std::runtime_error, + fmt::format("Incorrect value {} for parameter ParsingStrictness, must be 'high', 'normal', or 'low'")); + } + if (comm.rank() == 0) { // Always true when !HAVE_MPI + const bool exitOnAllErrors = (parsingStrictness == "high"); + const bool treatCriticalAsNonCritical = (parsingStrictness == "low"); try { - auto parseContext = setupParseContext(strictParsing); + auto parseContext = setupParseContext(exitOnAllErrors); readOnIORank(comm, deckFilename, parseContext.get(), eclipseState, schedule, udqState, actionState, wtestState, summaryConfig, std::move(python), initFromRestart, - checkDeck, outputInterval, *errorGuard); + checkDeck, treatCriticalAsNonCritical, outputInterval, *errorGuard); } catch (const OpmInputError& input_error) { failureMessage = input_error.what(); diff --git a/opm/simulators/utils/readDeck.hpp b/opm/simulators/utils/readDeck.hpp index 189069fc8..3ee94d904 100644 --- a/opm/simulators/utils/readDeck.hpp +++ b/opm/simulators/utils/readDeck.hpp @@ -60,7 +60,7 @@ enum class FileOutputMode { void ensureOutputDirExists(const std::string& cmdline_output_dir); -std::unique_ptr setupParseContext(const bool strictParsing); +std::unique_ptr setupParseContext(const bool exitOnAllErrors); // Setup the OpmLog backends FileOutputMode @@ -85,7 +85,7 @@ void readDeck(Parallel::Communication comm, std::unique_ptr& wtestState, std::shared_ptr& summaryConfig, std::shared_ptr python, - bool strictParsing, + const std::string& parsingStrictness, bool initFromRestart, bool checkDeck, const std::optional& outputInterval);