Skip to content

Commit 53268bc

Browse files
committed
fix a bug that can lead to segmental fault in 817_NO_LT_fcc
1 parent 5dbe07a commit 53268bc

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

source/src_lcao/grid_meshball.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,17 @@ void Grid_MeshBall::init_meshball(void)
4040
// select a ball in a cubic.
4141
double pos[3];
4242
double r2=0.0;
43-
const double rcut2 = this->meshball_radius * this->meshball_radius;
43+
44+
//------------------------------------------------------------------
45+
// const double rcut2 = this->meshball_radius * this->meshball_radius;
46+
// qianrui fix a bug and add 0.001 2022-4-30
47+
// Sometimes r2 is equal to rcut2, for example they are 36.
48+
// However, r2 is either 35.99.. or 36.0..001, which makes count != this->meshball_ncells
49+
// and segment fault.
50+
// I do not know how to solve it and this may occurs in somewhere else in ABACUS.
51+
// May some genius can give a better solution.
52+
//------------------------------------------------------------------
53+
const double rcut2 = this->meshball_radius * this->meshball_radius + 0.001;
4454

4555
//-------------------------------------------------------------------
4656
// calculate twice, the first time find the number of mesh points,

0 commit comments

Comments
 (0)