Skip to content

Commit c8afa94

Browse files
committed
fix issue
1 parent 4f499a6 commit c8afa94

File tree

3 files changed

+30
-27
lines changed

3 files changed

+30
-27
lines changed

source/module_cell/read_atom_species.cpp

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ bool read_atom_species(std::ifstream& ifa,
2020
//==========================================
2121
// read in information of each type of atom
2222
//==========================================
23-
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "ATOMIC_SPECIES") )
23+
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "ATOMIC_SPECIES") )
2424
{
2525
ModuleBase::GlobalFunc::OUT(ofs_running,"ntype",ntype);
2626
for (int i = 0;i < ntype;i++)
@@ -51,7 +51,8 @@ bool read_atom_species(std::ifstream& ifa,
5151

5252
if (!end && ss >> one_string && one_string[0] != '#')
5353
{
54-
if (one_string == "auto" || one_string == "upf" || one_string == "vwr" || one_string == "upf201" || one_string == "blps")
54+
if (one_string == "auto" || one_string == "upf"
55+
|| one_string == "vwr" || one_string == "upf201" || one_string == "blps")
5556
{
5657
ucell.pseudo_type[i] = one_string;
5758
}
@@ -61,15 +62,17 @@ bool read_atom_species(std::ifstream& ifa,
6162
}
6263
else
6364
{
64-
GlobalV::ofs_warning << "unrecongnized pseudopotential type: " << one_string << ", check your STRU file." << std::endl;
65+
GlobalV::ofs_warning << "unrecongnized pseudopotential type: "
66+
<< one_string << ", check your STRU file." << std::endl;
6567
ModuleBase::WARNING_QUIT("read_atom_species", "unrecongnized pseudo type.");
6668
}
6769
}
6870

6971
// Peize Lin test for bsse 2021.04.07
7072
const std::string bsse_label = "empty";
7173
ucell.atoms[i].flag_empty_element =
72-
(search( ucell.atom_label[i].begin(), ucell.atom_label[i].end(), bsse_label.begin(), bsse_label.end() ) != ucell.atom_label[i].end())
74+
(search( ucell.atom_label[i].begin(), ucell.atom_label[i].end(),
75+
bsse_label.begin(), bsse_label.end() ) != ucell.atom_label[i].end())
7376
? true : false;
7477
}
7578
}
@@ -80,7 +83,7 @@ bool read_atom_species(std::ifstream& ifa,
8083
||((PARAM.inp.basis_type == "pw")&&(PARAM.inp.init_wfc.substr(0, 3) == "nao"))
8184
|| PARAM.inp.onsite_radius > 0.0)
8285
{
83-
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "NUMERICAL_ORBITAL") )
86+
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "NUMERICAL_ORBITAL") )
8487
{
8588
for(int i=0; i<ntype; i++)
8689
{
@@ -90,7 +93,7 @@ bool read_atom_species(std::ifstream& ifa,
9093
// caoyu add 2021-03-16
9194
if(PARAM.globalv.deepks_setorb)
9295
{
93-
if (ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "NUMERICAL_DESCRIPTOR")) {
96+
if (ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "NUMERICAL_DESCRIPTOR")) {
9497
ifa >> ucell.descriptor_file;
9598
}
9699
}
@@ -105,7 +108,7 @@ bool read_atom_species(std::ifstream& ifa,
105108
#ifdef __EXX
106109
if( GlobalC::exx_info.info_global.cal_exx || PARAM.inp.rpa )
107110
{
108-
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "ABFS_ORBITAL") )
111+
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "ABFS_ORBITAL") )
109112
{
110113
for(int i=0; i<ntype; i++)
111114
{
@@ -133,7 +136,7 @@ bool read_lattice_constant(std::ifstream& ifa,
133136
double& lat0_angstrom =lat.lat0_angstrom;
134137
std::string& latName = lat.latName;
135138
ModuleBase::Matrix3& latvec = lat.latvec;
136-
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_CONSTANT") )
139+
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_CONSTANT") )
137140
{
138141
ModuleBase::GlobalFunc::READ_VALUE(ifa, lat0);
139142
if(lat0<=0.0)
@@ -154,7 +157,7 @@ bool read_lattice_constant(std::ifstream& ifa,
154157
if(latName=="none")
155158
{
156159
// check the existence of keyword "LATTICE_PARAMETERS"
157-
if (ModuleBase::GlobalFunc::SCAN_BEGIN(ifa,
160+
if (ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa,
158161
"LATTICE_PARAMETERS",
159162
true,
160163
false))
@@ -164,12 +167,12 @@ bool read_lattice_constant(std::ifstream& ifa,
164167
}
165168

166169
// check the existence of keyword "LATTICE_VECTORS"
167-
if( !ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_VECTORS") )
170+
if( !ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_VECTORS") )
168171
{
169172
ModuleBase::WARNING_QUIT("unitcell::read_lattice_constant",
170173
"Please set LATTICE_VECTORS in STRU file");
171174
}
172-
else if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_VECTORS") )
175+
else if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_VECTORS") )
173176
{
174177
// Reading lattice vectors. notice
175178
// here that only one cpu read these
@@ -184,7 +187,7 @@ bool read_lattice_constant(std::ifstream& ifa,
184187
}//supply lattice vectors
185188
else
186189
{
187-
if (ModuleBase::GlobalFunc::SCAN_BEGIN(ifa,
190+
if (ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa,
188191
"LATTICE_VECTORS",
189192
true,
190193
false))
@@ -216,7 +219,7 @@ bool read_lattice_constant(std::ifstream& ifa,
216219
latvec.e11 = 1.0; latvec.e12 = 0.0; latvec.e13 = 0.0;
217220
latvec.e21 =-0.5; latvec.e22 = e22; latvec.e23 = 0.0;
218221
latvec.e31 = 0.0; latvec.e32 = 0.0; latvec.e33 = 0.0;
219-
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_PARAMETERS") )
222+
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_PARAMETERS") )
220223
{
221224
ModuleBase::GlobalFunc::READ_VALUE(ifa, latvec.e33);
222225
}
@@ -225,7 +228,7 @@ bool read_lattice_constant(std::ifstream& ifa,
225228
{//trigonal, ibrav = 5
226229
double t1 = 0.0;
227230
double t2 = 0.0;
228-
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_PARAMETERS") )
231+
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_PARAMETERS") )
229232
{
230233
double cosab=0.0;
231234
ModuleBase::GlobalFunc::READ_VALUE(ifa, cosab);
@@ -245,15 +248,15 @@ bool read_lattice_constant(std::ifstream& ifa,
245248
latvec.e11 = 1.0; latvec.e12 = 0.0; latvec.e13 = 0.0;
246249
latvec.e21 = 0.0; latvec.e22 = 1.0; latvec.e23 = 0.0;
247250
latvec.e31 = 0.0; latvec.e32 = 0.0; latvec.e33 = 0.0;
248-
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_PARAMETERS") )
251+
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_PARAMETERS") )
249252
{
250253
ModuleBase::GlobalFunc::READ_VALUE(ifa, latvec.e33);
251254
}
252255
}
253256
else if(latName=="bct")
254257
{//body-centered tetragonal, ibrav = 7
255258
double cba = 0.0;
256-
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_PARAMETERS") )
259+
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_PARAMETERS") )
257260
{
258261
ModuleBase::GlobalFunc::READ_VALUE(ifa, cba);
259262
cba = cba / 2.0;
@@ -267,7 +270,7 @@ bool read_lattice_constant(std::ifstream& ifa,
267270
latvec.e11 = 1.0; latvec.e12 = 0.0; latvec.e13 = 0.0;
268271
latvec.e21 = 0.0; latvec.e22 = 0.0; latvec.e23 = 0.0;
269272
latvec.e31 = 0.0; latvec.e32 = 0.0; latvec.e33 = 0.0;
270-
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_PARAMETERS") )
273+
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_PARAMETERS") )
271274
{
272275
ifa >> latvec.e22;
273276
ModuleBase::GlobalFunc::READ_VALUE(ifa, latvec.e33);
@@ -278,7 +281,7 @@ bool read_lattice_constant(std::ifstream& ifa,
278281
latvec.e11 = 0.5; latvec.e12 = 0.0; latvec.e13 = 0.0;
279282
latvec.e21 =-0.5; latvec.e22 = 0.0; latvec.e23 = 0.0;
280283
latvec.e31 = 0.0; latvec.e32 = 0.0; latvec.e33 = 0.0;
281-
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_PARAMETERS") )
284+
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_PARAMETERS") )
282285
{
283286
ifa >> latvec.e12;
284287
latvec.e12 = latvec.e12 / 2.0;
@@ -289,7 +292,7 @@ bool read_lattice_constant(std::ifstream& ifa,
289292
else if(latName=="fco")
290293
{//face-centered orthorhombic, ibrav = 10
291294
double bba = 0.0; double cba = 0.0;
292-
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_PARAMETERS") )
295+
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_PARAMETERS") )
293296
{
294297
ifa >> bba;
295298
ModuleBase::GlobalFunc::READ_VALUE(ifa, cba);
@@ -302,7 +305,7 @@ bool read_lattice_constant(std::ifstream& ifa,
302305
else if(latName=="bco")
303306
{//body-centered orthorhombic, ibrav = 11
304307
double bba = 0.0; double cba = 0.0;
305-
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_PARAMETERS") )
308+
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_PARAMETERS") )
306309
{
307310
ifa >> bba;
308311
ModuleBase::GlobalFunc::READ_VALUE(ifa, cba);
@@ -317,7 +320,7 @@ bool read_lattice_constant(std::ifstream& ifa,
317320
double bba = 0.0; double cba = 0.0;
318321
double cosab = 0.0;
319322
double e21 = 0.0; double e22 = 0.0;
320-
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_PARAMETERS") )
323+
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_PARAMETERS") )
321324
{
322325
ifa >> bba >> cba;
323326
ModuleBase::GlobalFunc::READ_VALUE(ifa, cosab);
@@ -333,7 +336,7 @@ bool read_lattice_constant(std::ifstream& ifa,
333336
double bba = 0.0; double cba = 0.0;
334337
double cosab = 0.0;
335338
double e21 = 0.0; double e22 = 0.0;
336-
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_PARAMETERS") )
339+
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_PARAMETERS") )
337340
{
338341
ifa >> bba >> cba;
339342
ModuleBase::GlobalFunc::READ_VALUE(ifa, cosab);
@@ -354,7 +357,7 @@ bool read_lattice_constant(std::ifstream& ifa,
354357
double cosbc = 0.0;
355358
double sinab = 0.0;
356359
double term = 0.0;
357-
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_PARAMETERS") )
360+
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_PARAMETERS") )
358361
{
359362
ifa >> bba >> cba >> cosab >> cosac;
360363
ModuleBase::GlobalFunc::READ_VALUE(ifa, cosbc);

source/module_cell/read_atoms.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ bool unitcell::read_atom_positions(UnitCell& ucell,
2828
std::string& Coordinate = ucell.Coordinate;
2929
const int ntype = ucell.ntype;
3030

31-
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifpos, "ATOMIC_POSITIONS"))
31+
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifpos, "ATOMIC_POSITIONS"))
3232
{
3333
ModuleBase::GlobalFunc::READ_VALUE(ifpos, Coordinate);
3434

source/module_cell/test/unitcell_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ TEST_F(UcellTestReadStru, ReadAtomSpecies)
11711171
PARAM.input.basis_type = "lcao";
11721172
PARAM.sys.deepks_setorb = true;
11731173
EXPECT_NO_THROW(unitcell::read_atom_species(ifa, ofs_running,*ucell));
1174-
EXPECT_NO_THROW(unitcell::read_lattice_constant(ifa, ofs_running,ucell->lat));
1174+
EXPECT_NO_THROW(unitcell::read_lattice_constant(ifa, ofs_running, ucell->lat));
11751175
EXPECT_DOUBLE_EQ(ucell->latvec.e11, 4.27957);
11761176
EXPECT_DOUBLE_EQ(ucell->latvec.e22, 4.27957);
11771177
EXPECT_DOUBLE_EQ(ucell->latvec.e33, 4.27957);
@@ -1185,7 +1185,7 @@ TEST_F(UcellTestReadStru, ReadAtomSpeciesWarning1)
11851185
std::string fn = "./support/STRU_MgO_Warning1";
11861186
std::ifstream ifa(fn.c_str());
11871187
std::ofstream ofs_running;
1188-
ofs_running.open("read_atom_species.tmp");
1188+
ofs_running.open("read_atom_species.txt");
11891189
ucell->ntype = 2;
11901190
ucell->atoms = new Atom[ucell->ntype];
11911191
ucell->set_atom_flag = true;
@@ -1195,7 +1195,7 @@ TEST_F(UcellTestReadStru, ReadAtomSpeciesWarning1)
11951195
EXPECT_THAT(output, testing::HasSubstr("unrecongnized pseudo type."));
11961196
ofs_running.close();
11971197
ifa.close();
1198-
remove("read_atom_species.tmp");
1198+
//remove("read_atom_species.txt");
11991199
}
12001200

12011201
TEST_F(UcellTestReadStru, ReadLatticeConstantWarning1)

0 commit comments

Comments
 (0)