From 56cb9e23c6b88606d2717f7a698ab57cd58a6187 Mon Sep 17 00:00:00 2001 From: dyzheng Date: Thu, 20 Jul 2023 17:06:13 +0800 Subject: [PATCH 1/2] Fix: potential error in issue 2208 --- source/module_io/write_HS_R.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/module_io/write_HS_R.cpp b/source/module_io/write_HS_R.cpp index 69b8c2da6c0..fdcfb2a86b4 100644 --- a/source/module_io/write_HS_R.cpp +++ b/source/module_io/write_HS_R.cpp @@ -36,7 +36,8 @@ void ModuleIO::output_HS_R(const int& istep, GlobalV::CURRENT_SPIN = kv.isk[ik]; } - const double* vr_eff1 = &(v_eff(GlobalV::CURRENT_SPIN, 0)); + //note: some MPI process will not have grids when MPI cores is too many, v_eff in these processes are empty + const double* vr_eff1 = v_eff.nc * v_eff.nr > 0? &(v_eff(GlobalV::CURRENT_SPIN, 0)):nullptr; if(!GlobalV::GAMMA_ONLY_LOCAL) { From a619d0a3d016fc735958512b53f5e02476e575a4 Mon Sep 17 00:00:00 2001 From: dyzheng Date: Fri, 21 Jul 2023 16:18:38 +0800 Subject: [PATCH 2/2] update the fix --- source/module_io/write_HS_R.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/module_io/write_HS_R.cpp b/source/module_io/write_HS_R.cpp index fdcfb2a86b4..0ca5f368c60 100644 --- a/source/module_io/write_HS_R.cpp +++ b/source/module_io/write_HS_R.cpp @@ -91,7 +91,8 @@ void ModuleIO::output_dH_R(const int& istep, GlobalV::CURRENT_SPIN = kv.isk[ik]; } - const double* vr_eff1 = &(v_eff(GlobalV::CURRENT_SPIN, 0)); + //note: some MPI process will not have grids when MPI cores is too many, v_eff in these processes are empty + const double* vr_eff1 = v_eff.nc * v_eff.nr > 0? &(v_eff(GlobalV::CURRENT_SPIN, 0)):nullptr; if(!GlobalV::GAMMA_ONLY_LOCAL) {