@@ -217,15 +217,21 @@ inline int setBufferParameter(
217217 for (int irow=0 , grow=0 ; grow<GlobalV::NLOCAL; ++irow)
218218 {
219219 grow=Local_Orbital_wfc::globalIndex (irow, nblk, nprows, iprow);
220- int lrow=GlobalC::GridT.trace_lo [grow];
220+ if (grow >= GlobalV::NLOCAL)
221+ continue ;
222+ int lrow = GlobalC::GridT.trace_lo [grow];
221223
222- if (lrow < 0 || grow >= GlobalV::NLOCAL) continue ;
224+ if (lrow < 0 )
225+ continue ;
223226
224227 for (int icol=0 , gcol=0 ; gcol<GlobalV::NLOCAL; ++icol)
225228 {
226229 gcol=Local_Orbital_wfc::globalIndex (icol,nblk, npcols, ipcol);
227- int lcol=GlobalC::GridT.trace_lo [gcol];
228- if (lcol < 0 || gcol >= GlobalV::NLOCAL) continue ;
230+ if (gcol >= GlobalV::NLOCAL)
231+ continue ;
232+ int lcol = GlobalC::GridT.trace_lo [gcol];
233+ if (lcol < 0 )
234+ continue ;
229235 // if(pos<0 || pos >= current_s_index_siz)
230236 // {
231237 // OUT(GlobalV::ofs_running, "pos error, pos:", pos);
@@ -365,7 +371,7 @@ Gint_Tools::Array_Pool<double> Gint_Gamma::gamma_vlocal(const double*const vloca
365371 // whether the atom-grid distance is larger than cutoff
366372 // ------------------------------------------------------
367373 bool **cal_flag = Gint_Tools::get_cal_flag (na_grid, grid_index);
368-
374+
369375 // ------------------------------------------------------------------
370376 // compute atomic basis phi(r) with both radial and angular parts
371377 // ------------------------------------------------------------------
@@ -387,7 +393,7 @@ Gint_Tools::Array_Pool<double> Gint_Gamma::gamma_vlocal(const double*const vloca
387393 this ->cal_meshball_vlocal (
388394 na_grid, LD_pool, block_iw, block_size, block_index, cal_flag,
389395 vldr3, psir_ylm.ptr_2D , psir_vlbr3.ptr_2D , lgd_now, GridVlocal_thread.ptr_2D );
390-
396+
391397 free (vldr3); vldr3=nullptr ;
392398 delete[] block_iw;
393399 delete[] block_index;
@@ -425,10 +431,10 @@ Gint_Tools::Array_Pool<double> Gint_Gamma::gamma_vlocal(const double*const vloca
425431 MPI_Barrier (MPI_COMM_WORLD);
426432#endif
427433 ModuleBase::timer::tick (" Gint_Gamma" ," distri_vl" );
428-
434+
429435 return GridVlocal;
430436}
431-
437+
432438void Gint_Gamma::vl_grid_to_2D (const Gint_Tools::Array_Pool<double > &GridVlocal, LCAO_Matrix &lm)
433439{
434440 // setup send buffer and receive buffer size
0 commit comments