diff --git a/source/source_pw/module_stodft/sto_elecond.cpp b/source/source_pw/module_stodft/sto_elecond.cpp index b705960abc..6a6ea4526f 100644 --- a/source/source_pw/module_stodft/sto_elecond.cpp +++ b/source/source_pw/module_stodft/sto_elecond.cpp @@ -203,13 +203,13 @@ void Sto_EleCond::cal_jmatrix(StoHamiltPW, #ifdef __MPI info_gatherv* ks_fact = static_cast(gatherinfo_ks); info_gatherv* sto_npwx = static_cast(gatherinfo_sto); - rightchi_all = gatherchi_op()(rightchi, chi_all, npwx, sto_npwx->nrecv, sto_npwx->displs, perbands_sto); - righthchi_all = gatherchi_op()(right_hchi, hchi_all, npwx, sto_npwx->nrecv, sto_npwx->displs, perbands_sto); + rightchi_all = gatherchi_op()(rightchi, chi_all, npwx, sto_npwx->nrecv.data(), sto_npwx->displs.data(), perbands_sto); + righthchi_all = gatherchi_op()(right_hchi, hchi_all, npwx, sto_npwx->nrecv.data(), sto_npwx->displs.data(), perbands_sto); if (PARAM.inp.bndpar > 1 && rightfact != nullptr) { vec_rightf_all.resize(allbands_ks); rightf_all = vec_rightf_all.data(); - Parallel_Common::gatherv_data(rightfact, perbands_ks, rightf_all, ks_fact->nrecv, ks_fact->displs, BP_WORLD); + Parallel_Common::gatherv_data(rightfact, perbands_ks, rightf_all, ks_fact->nrecv.data(), ks_fact->displs.data(), BP_WORLD); } #endif diff --git a/source/source_pw/module_stodft/sto_tool.h b/source/source_pw/module_stodft/sto_tool.h index e2a04f07da..c2fa7fcad3 100644 --- a/source/source_pw/module_stodft/sto_tool.h +++ b/source/source_pw/module_stodft/sto_tool.h @@ -1,5 +1,8 @@ #ifndef STO_TOOL_H #define STO_TOOL_H + +#include + #include "source_cell/klist.h" #include "source_pw/module_stodft/sto_hamilt_pw.h" #include "source_pw/module_stodft/sto_wf.h" @@ -65,10 +68,9 @@ struct parallel_distribution struct info_gatherv { info_gatherv(const int& ngroup_per, const int& np, const int& num_in_group, MPI_Comm comm_world) + : nrecv(np), displs(np) { - nrecv = new int[np]; - displs = new int[np]; - MPI_Allgather(&ngroup_per, 1, MPI_INT, nrecv, 1, MPI_INT, comm_world); + MPI_Allgather(&ngroup_per, 1, MPI_INT, nrecv.data(), 1, MPI_INT, comm_world); displs[0] = 0; for (int i = 1; i < np; ++i) { @@ -80,13 +82,8 @@ struct info_gatherv displs[i] *= num_in_group; } } - ~info_gatherv() - { - delete[] nrecv; - delete[] displs; - } - int* nrecv = nullptr; - int* displs = nullptr; + std::vector nrecv; + std::vector displs; }; #endif