From 70c9e5345d3557b812a039be2ae44881e1151773 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 19 Apr 2024 18:52:13 +0200 Subject: [PATCH] fixed: do not send and recv from same buffer even though it's perfectly fine to do so in this case, mpich will error out with an error if send and recv buffer is the same --- opm/simulators/flow/RSTConv.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/opm/simulators/flow/RSTConv.cpp b/opm/simulators/flow/RSTConv.cpp index a7947aff4..316863b65 100644 --- a/opm/simulators/flow/RSTConv.cpp +++ b/opm/simulators/flow/RSTConv.cpp @@ -86,15 +86,17 @@ void RSTConv::gatherAndAccumulate(const std::vector& lIdx, return; } - std::vector values(comm_.rank() == 0 ? comm_.size() * N_ : N_); - std::vector gIdx(comm_.rank() == 0 ? comm_.size() * N_ : N_); + std::vector send_values(N_); + std::vector values(comm_.rank() == 0 ? comm_.size() * N_ : 0); + std::vector send_idx(N_); + std::vector gIdx(comm_.rank() == 0 ? comm_.size() * N_ : 0); for (int i = 0; i < N_; ++i) { - values[i] = std::abs(resid[lIdx[i]][compIdx_[comp]]); - gIdx[i] = globalCell_[lIdx[i]]; + send_values[i] = std::abs(resid[lIdx[i]][compIdx_[comp]]); + send_idx[i] = globalCell_[lIdx[i]]; } - comm_.gather(gIdx.data(), gIdx.data(), N_, 0); - comm_.gather(values.data(), values.data(), N_, 0); + comm_.gather(send_idx.data(), gIdx.data(), N_, 0); + comm_.gather(send_values.data(), values.data(), N_, 0); if (comm_.rank() != 0) { return; }