@@ -42,6 +42,10 @@ class AtomSpecTest : public testing::Test
4242
4343TEST_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
8086TEST_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 );
0 commit comments