diff --git a/source/source_base/parallel_reduce.cpp b/source/source_base/parallel_reduce.cpp index c44bd8fb66..03535573b7 100644 --- a/source/source_base/parallel_reduce.cpp +++ b/source/source_base/parallel_reduce.cpp @@ -13,6 +13,15 @@ void Parallel_Reduce::reduce_all(int& object) return; } +template <> +void Parallel_Reduce::reduce_all(long long& object) +{ +#ifdef __MPI + MPI_Allreduce(MPI_IN_PLACE, &object, 1, MPI_LONG_LONG, MPI_SUM, MPI_COMM_WORLD); +#endif + return; +} + void Parallel_Reduce::reduce_int_diag(int& object) { #ifdef __MPI @@ -48,6 +57,15 @@ void Parallel_Reduce::reduce_all(int* object, const int n) return; } +template <> +void Parallel_Reduce::reduce_all(long long* object, const int n) +{ +#ifdef __MPI + MPI_Allreduce(MPI_IN_PLACE, object, n, MPI_LONG_LONG, MPI_SUM, MPI_COMM_WORLD); +#endif + return; +} + void Parallel_Reduce::reduce_int_grid(int* object, const int n) { #ifdef __MPI diff --git a/source/source_io/single_R_io.cpp b/source/source_io/single_R_io.cpp index f2bc24886f..ff65386f1a 100644 --- a/source/source_io/single_R_io.cpp +++ b/source/source_io/single_R_io.cpp @@ -23,7 +23,7 @@ void ModuleIO::output_single_R(std::ofstream& ofs, const bool& reduce) { T* line = nullptr; - std::vector indptr; + std::vector indptr; indptr.reserve(PARAM.globalv.nlocal + 1); indptr.push_back(0); diff --git a/source/source_io/write_HS_sparse.cpp b/source/source_io/write_HS_sparse.cpp index 505933ad0d..8abd808cba 100644 --- a/source/source_io/write_HS_sparse.cpp +++ b/source/source_io/write_HS_sparse.cpp @@ -716,7 +716,7 @@ void ModuleIO::save_sparse( ModuleBase::timer::tick("ModuleIO", "save_sparse"); int total_R_num = all_R_coor.size(); - std::vector nonzero_num(total_R_num, 0); + std::vector nonzero_num(total_R_num, 0); int count = 0; for (auto& R_coor: all_R_coor) { auto iter = smat.find(R_coor);