diff --git a/src/delegator.cpp b/src/delegator.cpp index f231283bccc3e08f79271ce0ce21e6741a311c00..60f68f55374260eb8eba5af1cfc61f344c4d57ac 100644 --- a/src/delegator.cpp +++ b/src/delegator.cpp @@ -68,7 +68,7 @@ void Delegator::Init(std::string_view nesting_mode, << " and Backend: " << backend << std::endl; } - // detect nesting mode requested by the user + // detect nesting mode specified by the user if (nesting_mode.compare("?") == 0) { nesting_mode_ = NestingMode::Detection; } else if (nesting_mode.compare("ProperlyNested") == 0) { @@ -81,16 +81,16 @@ void Delegator::Init(std::string_view nesting_mode, // Some debug output switch (nesting_mode_) { case NestingMode::Detection: - std::cout << "Selecting nesting mode to: " - << "detecting nesting behavior" << std::endl; + std::cout << "nesting mode set to: " + << "Detection (?)" << std::endl; break; case NestingMode::NotProperlyNested: - std::cout << "Selecting nesting mode to: " - << "non properly nested behavior" << std::endl; + std::cout << "nesting mode set to: " + << "NotProperlyNested" << std::endl; break; case NestingMode::ProperlyNested: - std::cout << "Selecting nesting mode to: " - << "assume properly nested behavior" << std::endl; + std::cout << "nesting mode set to: " + << "ProperlyNested" << std::endl; break; case NestingMode::ProperlyNestedButOtherBackend: std::cout << "Something went wrong when selecting the nesting mode" @@ -111,31 +111,37 @@ void Delegator::Init(std::string_view nesting_mode, // Unwraping the std::optional is safe because the variable is required. backend = env_backend.getValue().value(); + if (mpi_helper_->IsRankNumber(0)) { + std::cout << "Reading Backend from environment variable: " + << env_backend.getEnvName() << "=" << backend << std::endl; + } } // next choose backend switch (nesting_mode_) { + case NestingMode::ProperlyNestedButOtherBackend: + break; case NestingMode::Detection: InitDetectionBackend(backend); break; case NestingMode::ProperlyNested: - case NestingMode::NotProperlyNested: + InitProperlyNestedBackends(backend); // we preferably use a Properly nested backend, // but if this is not possible, we will select the not properly nested // one - InitProperlyNestedBackends(backend); - if (pn_annotation_strategy_ == nullptr) { - if (mpi_helper_->IsRankNumber(0)) { - std::cout - << "Could not find a matching ProperlyNested backend with name " - << backend << std::endl; - std::cout << "Now looking for a NonProperlyNested backend, as they " - "support ProperlyNested ones" - << std::endl; - } - InitNonProperlyNestedBackends(backend); + [[fallthrough]]; + case NestingMode::NotProperlyNested: + if (pn_annotation_strategy_ == nullptr && mpi_helper_->IsRankNumber(0)) { + std::cout + << "Could not find a matching ProperlyNested backend with name " + << backend << std::endl; + std::cout << "Now looking for a NotProperlyNested backend, as they " + "support ProperlyNested ones" + << std::endl; nesting_mode_ = NestingMode::ProperlyNestedButOtherBackend; } + + InitNonProperlyNestedBackends(backend); break; } @@ -214,6 +220,7 @@ void Delegator::RegionStopLast() { void Delegator::Finalize() { switch (nesting_mode_) { case NestingMode::NotProperlyNested: + case NestingMode::ProperlyNestedButOtherBackend: return npn_annotation_strategy_->Finalize(); break; case NestingMode::Detection: diff --git a/src/utils/environment_variable.hpp b/src/utils/environment_variable.hpp index edf98f3ddf319d3a50882842e7cf107a80251fd1..e370c67a5bbf47a119f79528170719234d849b30 100644 --- a/src/utils/environment_variable.hpp +++ b/src/utils/environment_variable.hpp @@ -51,6 +51,9 @@ class EnvironmentVariable { public: std::optional getValue() const { return value_; } bool isSet() const { return value_.has_value(); } + std::string getEnvName() const { + return EnvironmentVariable::PREFIX + variable_name_; + } }; #endif // NESMIK_ENVIROMENT_VARIABLE_HPP