Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activate GLIFTOPT for use in Pyaction and add warning for required keywords #4398

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion opm/input/eclipse/Schedule/Action/PyAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
18 changes: 17 additions & 1 deletion python/cxx/schedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#include <chrono>
#include <map>

#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/input/eclipse/Deck/Deck.hpp>
#include <opm/input/eclipse/Deck/DeckKeyword.hpp>
Expand Down Expand Up @@ -151,10 +154,23 @@ namespace {
std::vector<std::unique_ptr<DeckKeyword>> 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<std::unique_ptr<DeckKeyword>> 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<DeckKeyword>(keyword));
}
return keywords;
Expand Down