mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Make KeywordValidation::validateDeck() more flexible.
Adding a bool argument 'treat_critical_as_noncritical' to possibly reduce terminating errors to warnings.
This commit is contained in:
parent
77d151e0b5
commit
04d2b8f39d
@ -85,6 +85,7 @@ namespace KeywordValidation
|
|||||||
void
|
void
|
||||||
KeywordValidator::validateDeck(const Deck& deck,
|
KeywordValidator::validateDeck(const Deck& deck,
|
||||||
const ParseContext& parse_context,
|
const ParseContext& parse_context,
|
||||||
|
const bool treat_critical_as_noncritical,
|
||||||
ErrorGuard& error_guard) const
|
ErrorGuard& error_guard) const
|
||||||
{
|
{
|
||||||
// Make a vector with all problems encountered in the deck.
|
// Make a vector with all problems encountered in the deck.
|
||||||
@ -99,18 +100,27 @@ namespace KeywordValidation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// First report non-critical problems as a warning.
|
if (treat_critical_as_noncritical) {
|
||||||
auto warning_report = get_error_report(errors, true, false);
|
// Get both critical and noncritical errors.
|
||||||
if (!warning_report.empty()) {
|
auto warning_report = get_error_report(errors, true, true);
|
||||||
parse_context.handleError(
|
if (!warning_report.empty()) {
|
||||||
ParseContext::SIMULATOR_KEYWORD_NOT_SUPPORTED, warning_report, std::nullopt, error_guard);
|
// Report all as warnings.
|
||||||
}
|
parse_context.handleError(ParseContext::SIMULATOR_KEYWORD_NOT_SUPPORTED, warning_report, std::nullopt, error_guard);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// First report non-critical problems as a warning.
|
||||||
|
auto warning_report = get_error_report(errors, true, false);
|
||||||
|
if (!warning_report.empty()) {
|
||||||
|
parse_context.handleError(
|
||||||
|
ParseContext::SIMULATOR_KEYWORD_NOT_SUPPORTED, warning_report, std::nullopt, error_guard);
|
||||||
|
}
|
||||||
|
|
||||||
// Then report critical problems as an error.
|
// Then report critical problems as an error.
|
||||||
auto error_report = get_error_report(errors, false, true);
|
auto error_report = get_error_report(errors, false, true);
|
||||||
if (!error_report.empty()) {
|
if (!error_report.empty()) {
|
||||||
parse_context.handleError(
|
parse_context.handleError(
|
||||||
ParseContext::SIMULATOR_KEYWORD_NOT_SUPPORTED_CRITICAL, error_report, std::nullopt, error_guard);
|
ParseContext::SIMULATOR_KEYWORD_NOT_SUPPORTED_CRITICAL, error_report, std::nullopt, error_guard);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,9 +110,12 @@ namespace KeywordValidation
|
|||||||
|
|
||||||
// Validate a deck, reporting warnings and errors. If there are only
|
// Validate a deck, reporting warnings and errors. If there are only
|
||||||
// warnings, these will be reported. If there are errors, these are
|
// warnings, these will be reported. If there are errors, these are
|
||||||
// reported, and execution of the program is halted.
|
// reported, and execution of the program is halted, unless the argument
|
||||||
|
// treat_critical_as_noncritical is true, then these also will only be
|
||||||
|
// reported and not cause termination.
|
||||||
void validateDeck(const Deck& deck,
|
void validateDeck(const Deck& deck,
|
||||||
const ParseContext& parse_context,
|
const ParseContext& parse_context,
|
||||||
|
const bool treat_critical_as_noncritical,
|
||||||
ErrorGuard& error_guard) const;
|
ErrorGuard& error_guard) const;
|
||||||
|
|
||||||
// Validate a single deck keyword. If a problem is encountered, add the
|
// Validate a single deck keyword. If a problem is encountered, add the
|
||||||
|
@ -203,7 +203,7 @@ namespace {
|
|||||||
Opm::KeywordValidation::specialValidation()
|
Opm::KeywordValidation::specialValidation()
|
||||||
};
|
};
|
||||||
|
|
||||||
keyword_validator.validateDeck(deck, parseContext, errorGuard);
|
keyword_validator.validateDeck(deck, parseContext, true, errorGuard);
|
||||||
|
|
||||||
if (checkDeck) {
|
if (checkDeck) {
|
||||||
Opm::checkDeck(deck, parser, parseContext, errorGuard);
|
Opm::checkDeck(deck, parser, parseContext, errorGuard);
|
||||||
|
Loading…
Reference in New Issue
Block a user