From 6c489892f33ef7ce5133ac588e35b5b336ceef7c Mon Sep 17 00:00:00 2001 From: Nora Abi Akar <nora.abiakar@gmail.com> Date: Tue, 14 Dec 2021 14:48:53 +0100 Subject: [PATCH] modcc: exit solvers early if errors encountered (#1755) Check for errors in the solvers before the `finalize` stage and return early if errors were encountered. Fixes #1722. --- modcc/solvers.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modcc/solvers.cpp b/modcc/solvers.cpp index a636c9ee..4e49ded0 100644 --- a/modcc/solvers.cpp +++ b/modcc/solvers.cpp @@ -448,6 +448,7 @@ void SparseSolverVisitor::visit(ConserveExpression *e) { } void SparseSolverVisitor::finalize() { + if (has_error()) return; if (solve_variant_ == solverVariant::steadystate && !conserve_) { error({"Conserve statement(s) missing in steady-state solver", {}}); @@ -537,6 +538,8 @@ void LinearSolverVisitor::visit(LinearExpression *e) { } void LinearSolverVisitor::finalize() { + if (has_error()) return; + system_.augment(rhs_); // Reduce the system @@ -750,6 +753,7 @@ void SparseNonlinearSolverVisitor::visit(AssignmentExpression *e) { } void SparseNonlinearSolverVisitor::finalize() { + if (has_error()) return; // Create rhs of A_ std::vector<std::string> rhs; -- GitLab