Skip to content

Commit ae7b9e1

Browse files
authored
Fix: a bug in atom_spec_test (#1934)
1 parent d1c511c commit ae7b9e1

File tree

8 files changed

+56
-16
lines changed

8 files changed

+56
-16
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/bash -e
22

33
np=`cat /proc/cpuinfo | grep "cpu cores" | uniq| awk '{print $NF}'`
44
echo "nprocs in this machine is $np"
@@ -8,6 +8,6 @@ for i in 3;do
88
continue
99
fi
1010
echo "TEST in parallel, nprocs=$i"
11-
mpirun -np $i ./ParaCommon
11+
mpirun -np $i ./base_ParaCommon
1212
break
1313
done
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/bash -e
22

33
np=`cat /proc/cpuinfo | grep "cpu cores" | uniq| awk '{print $NF}'`
44
echo "nprocs in this machine is $np"
@@ -8,6 +8,6 @@ for i in 4;do
88
continue
99
fi
1010
echo "TEST in parallel, nprocs=$i"
11-
mpirun -np $i ./ParaGlobal
11+
mpirun -np $i ./base_ParaGlobal
1212
break
1313
done
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/bash -e
22

33
np=`cat /proc/cpuinfo | grep "cpu cores" | uniq| awk '{print $NF}'`
44
echo "nprocs in this machine is $np"
@@ -8,6 +8,6 @@ for i in 4;do
88
continue
99
fi
1010
echo "TEST in parallel, nprocs=$i"
11-
mpirun -np $i ./ParaReduce
11+
mpirun -np $i ./base_ParaReduce
1212
break
1313
done

source/module_cell/test/atom_pseudo_test.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ class AtomPseudoTest : public testing::Test
3535

3636
TEST_F(AtomPseudoTest, SetDSo)
3737
{
38+
#ifdef __MPI
39+
if(GlobalV::MY_RANK==0)
40+
{
41+
#endif
3842
std::ifstream ifs;
3943
ifs.open("./support/C.upf");
4044
GlobalV::PSEUDORCUT = 15.0;
@@ -55,6 +59,9 @@ TEST_F(AtomPseudoTest, SetDSo)
5559
atom_pseudo->set_d_so(d_so_in,nproj,nproj_soc,has_so);
5660
EXPECT_NEAR(atom_pseudo->d_so(0,0,0).real(),1e-8,1e-7);
5761
EXPECT_NEAR(atom_pseudo->d_so(0,0,0).imag(),1e-8,1e-7);
62+
#ifdef __MPI
63+
}
64+
#endif
5865
}
5966

6067
#ifdef __MPI

source/module_cell/test/atom_spec_test.cpp

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ class AtomSpecTest : public testing::Test
4242

4343
TEST_F(AtomSpecTest, PrintAtom)
4444
{
45+
#ifdef __MPI
46+
if(GlobalV::MY_RANK==0)
47+
{
48+
#endif
4549
ofs.open("tmp_atom_info");
4650
atom.label = "C";
4751
atom.type = 1;
@@ -74,21 +78,27 @@ TEST_F(AtomSpecTest, PrintAtom)
7478
EXPECT_THAT(str, testing::HasSubstr("atom_position(cartesian) Dimension = 2"));
7579
ifs.close();
7680
remove("tmp_atom_info");
77-
81+
#ifdef __MPI
82+
}
83+
#endif
7884
}
7985

8086
TEST_F(AtomSpecTest, SetIndex)
8187
{
88+
#ifdef __MPI
89+
if(GlobalV::MY_RANK==0)
90+
{
91+
#endif
8292
ifs.open("./support/C.upf");
8393
GlobalV::PSEUDORCUT = 15.0;
8494
upf.read_pseudo_upf201(ifs);
8595
atom.ncpp.set_pseudo_nc(upf);
8696
ifs.close();
8797
EXPECT_TRUE(atom.ncpp.has_so);
8898
atom.nw = 0;
89-
atom.nwl = 2;
99+
atom.nwl = 1;
90100
delete[] atom.l_nchi;
91-
atom.l_nchi = new int[atom.nwl];
101+
atom.l_nchi = new int[atom.nwl+1];
92102
atom.l_nchi[0] = 2;
93103
atom.nw += atom.l_nchi[0];
94104
atom.l_nchi[1] = 4;
@@ -99,6 +109,9 @@ TEST_F(AtomSpecTest, SetIndex)
99109
EXPECT_EQ(atom.iw2m[13],2);
100110
EXPECT_EQ(atom.iw2_ylm[13],3);
101111
EXPECT_TRUE(atom.iw2_new[11]);
112+
#ifdef __MPI
113+
}
114+
#endif
102115
}
103116

104117
#ifdef __MPI
@@ -110,13 +123,33 @@ TEST_F(AtomSpecTest, BcastAtom)
110123
atom.label = "C";
111124
atom.type = 1;
112125
atom.na = 2;
113-
atom.nwl = 2;
126+
atom.nw = 0;
127+
atom.nwl = 1;
114128
atom.Rcut = 1.1;
115-
atom.nw = 14;
129+
delete[] atom.l_nchi;
130+
atom.l_nchi = new int[atom.nwl+1];
131+
atom.l_nchi[0] = 2;
132+
atom.nw += atom.l_nchi[0];
133+
atom.l_nchi[1] = 4;
134+
atom.nw += 3*atom.l_nchi[1];
116135
atom.stapos_wf = 0;
117136
atom.mass = 12.0;
118137
delete[] atom.tau;
138+
delete[] atom.taud;
139+
delete[] atom.vel;
140+
delete[] atom.mag;
141+
delete[] atom.angle1;
142+
delete[] atom.angle2;
143+
delete[] atom.m_loc_;
144+
delete[] atom.mbl;
119145
atom.tau = new ModuleBase::Vector3<double>[atom.na];
146+
atom.taud = new ModuleBase::Vector3<double>[atom.na];
147+
atom.vel = new ModuleBase::Vector3<double>[atom.na];
148+
atom.mag = new double[atom.na];
149+
atom.angle1 = new double[atom.na];
150+
atom.angle2 = new double[atom.na];
151+
atom.m_loc_ = new ModuleBase::Vector3<double>[atom.na];
152+
atom.mbl = new ModuleBase::Vector3<int>[atom.na];
120153
atom.tau[0].x = 0.2;
121154
atom.tau[0].y = 0.2;
122155
atom.tau[0].z = 0.2;
@@ -130,7 +163,7 @@ TEST_F(AtomSpecTest, BcastAtom)
130163
EXPECT_EQ(atom.label,"C");
131164
EXPECT_EQ(atom.type,1);
132165
EXPECT_EQ(atom.na,2);
133-
EXPECT_EQ(atom.nwl,2);
166+
EXPECT_EQ(atom.nwl,1);
134167
EXPECT_DOUBLE_EQ(atom.Rcut,1.1);
135168
EXPECT_EQ(atom.nw,14);
136169
EXPECT_EQ(atom.stapos_wf,0);

source/module_cell/test/bcast_atom_pseudo_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/bash -e
22

33
np=`cat /proc/cpuinfo | grep "cpu cores" | uniq| awk '{print $NF}'`
44
echo "nprocs in this machine is $np"

source/module_cell/test/bcast_atom_spec_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/bash -e
22

33
np=`cat /proc/cpuinfo | grep "cpu cores" | uniq| awk '{print $NF}'`
44
echo "nprocs in this machine is $np"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/bash -e
22

33
np=`cat /proc/cpuinfo | grep "cpu cores" | uniq| awk '{print $NF}'`
44
echo "nprocs in this machine is $np"
@@ -8,6 +8,6 @@ for i in 4;do
88
continue
99
fi
1010
echo "TEST in parallel, nprocs=$i"
11-
mpirun -np $i ./ParaKpoints
11+
mpirun -np $i ./Cell_ParaKpoints
1212
break
1313
done

0 commit comments

Comments
 (0)