diff --git a/opm/input/eclipse/Schedule/Action/PyAction.cpp b/opm/input/eclipse/Schedule/Action/PyAction.cpp index 2dd9bc0455c..7eac4569cff 100644 --- a/opm/input/eclipse/Schedule/Action/PyAction.cpp +++ b/opm/input/eclipse/Schedule/Action/PyAction.cpp @@ -43,7 +43,7 @@ bool PyAction::valid_keyword(const std::string& keyword) { "COMPSEGS", "FIELD", "ENDBOX", "EXIT", - "GCONINJE", "GCONPROD", "GCONSUMP","GRUPTREE", + "GCONINJE", "GCONPROD", "GCONSUMP","GLIFTOPT", "GRUPTREE", "METRIC", "MULTX", "MULTX-", "MULTY", "MULTY-", "MULTZ", "MULTZ-", "NEXT", "NEXTSTEP", "WCONINJE", "WCONPROD", "WECON", "WEFAC", "WELOPEN", "WELTARG", "WGRUPCON", "WELSEGS", "WELSPECS", "WSEGVALV", "WTEST" diff --git a/python/cxx/schedule.cpp b/python/cxx/schedule.cpp index 7f6e1c5fc46..2f355662bde 100644 --- a/python/cxx/schedule.cpp +++ b/python/cxx/schedule.cpp @@ -2,6 +2,9 @@ #include #include +#include +#include +#include #include #include #include @@ -151,10 +154,23 @@ namespace { std::vector> parseKeywords(const std::string& deck_string, const UnitSystem& unit_system) { Parser parser; + ParseContext parseContext; + // The next line will suppress PARSE_INVALID_KEYWORD_COMBINATION errors. This is needed when a keyword requires other keywords, since the + // required keywords might be in the original .DATA file, to which we do not have access here. + // When inserting keywords that can cause a PARSE_INVALID_KEYWORD_COMBINATION error, i.e. keywords with required or prohibited keywords, + // a warning will be added to the OpmLog. + parseContext.update(ParseContext::PARSE_INVALID_KEYWORD_COMBINATION , InputErrorAction::IGNORE ); std::string str {unit_system.deck_name() + "\n\n" + deck_string}; - auto deck = parser.parseString(str); + auto deck = parser.parseString(str, parseContext); std::vector> keywords; for (auto &keyword : deck) { + auto parserKeyword = parser.getKeyword(keyword.name()); + std::for_each(parserKeyword.requiredKeywords().begin(), parserKeyword.requiredKeywords().end(), [&keyword](const auto& requiredKeyword) { + Opm::OpmLog::warning("Attention, the keyword " + keyword.name() + " needs the keywords " + requiredKeyword + " before."); + }); + std::for_each(parserKeyword.prohibitedKeywords().begin(), parserKeyword.prohibitedKeywords().end(), [&keyword](const auto& prohibitedKeyword) { + Opm::OpmLog::warning("Attention, the keyword " + keyword.name() + " is incompatible with the keyword " + prohibitedKeyword + "."); + }); keywords.push_back(std::make_unique(keyword)); } return keywords;