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; }