diff --git a/src/delegator.cpp b/src/delegator.cpp index b8a59f58760396d2000427771f47b1786f0d4940..9f128dbcbbc83268206a3a187eea55a841dcb978 100644 --- a/src/delegator.cpp +++ b/src/delegator.cpp @@ -276,12 +276,26 @@ void Delegator::Finalize() { if (!nesmik_on_) { return; } + // Check double finalize + if (did_finalize_) { + if (mpi_helper_->IsUsingMPI()) { + std::cout << "neSmiK Warning: neSmiK already finalized for rank: " + << mpi_helper_->getRankNumber() << std::endl; + } else { + std::cout << "neSmiK Warning: neSmiK already finalized" << std::endl; + } + + return; + } + switch (backend_selection_) { case BackendMode::NotProperlyNested: - return npn_annotation_strategy_->Finalize(); + npn_annotation_strategy_->Finalize(); break; case BackendMode::ProperlyNested: - return pn_annotation_strategy_->Finalize(); + pn_annotation_strategy_->Finalize(); break; } + + did_finalize_ = true; }; diff --git a/src/delegator.hpp b/src/delegator.hpp index a9f0055c94fe339ca509ecb66b7887e27113f297..57ab41d5237968949c69fd5c6d402b1b28a5b1e5 100644 --- a/src/delegator.hpp +++ b/src/delegator.hpp @@ -28,6 +28,7 @@ class Delegator { inline static BackendMode backend_selection_; inline static bool nesmik_on_{false}; inline static bool did_initialize_{false}; + inline static bool did_finalize_{false}; inline static std::unique_ptr mpi_helper_;