diff --git a/opm/simulators/wells/GuideRateHandler.cpp b/opm/simulators/wells/GuideRateHandler.cpp index 8ac8b5c204..061f9b0d6a 100644 --- a/opm/simulators/wells/GuideRateHandler.cpp +++ b/opm/simulators/wells/GuideRateHandler.cpp @@ -128,13 +128,13 @@ GuideRateHandler:: sendSlaveGroupPotentialsToMaster(const GroupState& group_state) { assert(this->isReservoirCouplingSlave()); - auto& rescoup_slave = this->reservoirCouplingSlave(); - const auto& slave_master_group_map = rescoup_slave.getSlaveToMasterGroupNameMap(); - std::vector potentials; if (this->comm_.rank() == 0) { // NOTE: Traversing a std::map is guaranteed to iterate the keys in lexical order for // std::string keys, so the master can from this order determine which potentials // correspond to which slave group. + auto& rescoup_slave = this->reservoirCouplingSlave(); + const auto& slave_master_group_map = rescoup_slave.getSlaveToMasterGroupNameMap(); + std::vector potentials; for (const auto& item : slave_master_group_map) { const auto& slave_group_name = item.first; Potentials pot;