diff --git a/examples/sim_fibo_ad.cpp b/examples/sim_fibo_ad.cpp index 6f86cf435..708418d37 100644 --- a/examples/sim_fibo_ad.cpp +++ b/examples/sim_fibo_ad.cpp @@ -102,10 +102,29 @@ try double gravity[3] = { 0.0 }; std::string deck_filename = param.get("deck_filename"); - Opm::ParserPtr newParser(new Opm::Parser() ); + Opm::ParserPtr parser(new Opm::Parser() ); + Opm::ParserLogPtr parserLog(new Opm::ParserLog()); bool strict_parsing = param.getDefault("strict_parsing", true); - Opm::DeckConstPtr deck = newParser->parseFile(deck_filename, strict_parsing); - std::shared_ptr eclipseState(new EclipseState(deck)); + Opm::DeckConstPtr deck; + std::shared_ptr eclipseState; + try { + deck = parser->parseFile(deck_filename, strict_parsing, parserLog); + EclipseState::checkDeck(deck, parserLog); + eclipseState.reset(new EclipseState(deck, parserLog)); + } + catch (const std::invalid_argument& e) { + if (parserLog->size() > 0) { + std::cerr << "Issues found while parsing the deck file:\n"; + parserLog->printAll(std::cerr); + } + std::cerr << "error while parsing the deck file: " << e.what() << "\n"; + return EXIT_FAILURE; + } + + if (parserLog->size() > 0) { + std::cerr << "Issues found while parsing the deck file:\n"; + parserLog->printAll(std::cerr); + } // Grid init std::vector porv; diff --git a/examples/sim_fibo_ad_cp.cpp b/examples/sim_fibo_ad_cp.cpp index 1a7a37863..f25fde751 100644 --- a/examples/sim_fibo_ad_cp.cpp +++ b/examples/sim_fibo_ad_cp.cpp @@ -128,10 +128,29 @@ try double gravity[3] = { 0.0 }; std::string deck_filename = param.get("deck_filename"); - Opm::ParserPtr newParser(new Opm::Parser() ); + Opm::ParserPtr parser(new Opm::Parser() ); + Opm::ParserLogPtr parserLog(new Opm::ParserLog()); bool strict_parsing = param.getDefault("strict_parsing", true); - Opm::DeckConstPtr deck = newParser->parseFile(deck_filename, strict_parsing); - std::shared_ptr eclipseState(new EclipseState(deck)); + Opm::DeckConstPtr deck; + std::shared_ptr eclipseState; + try { + deck = parser->parseFile(deck_filename, strict_parsing, parserLog); + EclipseState::checkDeck(deck, parserLog); + eclipseState.reset(new EclipseState(deck, parserLog)); + } + catch (const std::invalid_argument& e) { + if (parserLog->size() > 0) { + std::cerr << "Issues found while parsing the deck file:\n"; + parserLog->printAll(std::cerr); + } + std::cerr << "error while parsing the deck file: " << e.what() << "\n"; + return EXIT_FAILURE; + } + + if (parserLog->size() > 0) { + std::cerr << "Issues found while parsing the deck file:\n"; + parserLog->printAll(std::cerr); + } // Grid init grid.reset(new Dune::CpGrid());