Skip to content

Commit 68a31e7

Browse files
committed
< fix >
fix a bug in get_ig2isz_is2ixy, when this->npw==0, ModuleBase::GlobalFunc::ZEROS will raise a error, so that I add a few code to deal with this case.
1 parent aa1086f commit 68a31e7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

source/module_pw/pw_distributeg_method1.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,12 +475,21 @@ void PW_Basis::get_ig2isz_is2ixy(
475475
int* st_length2D // the stick on (x, y) consists of st_length[x*ny+y] planewaves.
476476
)
477477
{
478+
if (this->npw == 0)
479+
{
480+
this->ig2isz = new int[1]; // map ig to the z coordinate of this planewave.
481+
this->ig2isz[0] = 0;
482+
this->is2ixy = new int[1]; // map is (index of sticks) to ixy (ix + iy * nx).
483+
this->is2ixy[0] = -1;
484+
return;
485+
}
486+
478487
this->ig2isz = new int[this->npw]; // map ig to the z coordinate of this planewave.
479488
ModuleBase::GlobalFunc::ZEROS(this->ig2isz, this->npw);
480489
this->is2ixy = new int[this->nst]; // map is (index of sticks) to ixy (ix + iy * nx).
481490
for (int is = 0; is < this->nst; ++is)
482491
{
483-
is2ixy[is] = -1;
492+
this->is2ixy[is] = -1;
484493
}
485494

486495
int st_move = 0; // this is the st_move^th stick on current core.

0 commit comments

Comments
 (0)