Skip to content

Commit 2c2ed13

Browse files
authored
Fix: Fix the warning triggered in error of SCAN_END. (#5576)
1 parent ed2fecf commit 2c2ed13

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

source/module_cell/read_pp.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,4 +478,13 @@ void Pseudopot_upf::setqfnew(const int& nqf,
478478
}
479479
rho[ir] *= pow(r[ir], l + n);
480480
}
481+
}
482+
483+
void Pseudopot_upf::skip_number(std::ifstream& ifs, bool mesh_changed)
484+
{
485+
if (mesh_changed)
486+
{
487+
double temp = 0.;
488+
ifs >> temp;
489+
}
481490
}

source/module_cell/read_pp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class Pseudopot_upf
7373

7474
private:
7575
bool mesh_changed = false; // if the mesh is even, it will be changed to odd
76+
void skip_number(std::ifstream& ifs, bool mesh_changed); // skip the last number if the mesh is even
7677

7778
int set_pseudo_type(const std::string& fn, std::string& type);
7879
std::string& trim(std::string& in_str);

source/module_cell/read_pp_upf100.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ void Pseudopot_upf::read_pseudo_mesh(std::ifstream &ifs, Atom_pseudo& pp)
236236
{
237237
ifs >> pp.r[ir];
238238
}
239+
this->skip_number(ifs, this->mesh_changed);
239240
ModuleBase::GlobalFunc::SCAN_END(ifs, "</PP_R>");
240241
}
241242

@@ -245,6 +246,7 @@ void Pseudopot_upf::read_pseudo_mesh(std::ifstream &ifs, Atom_pseudo& pp)
245246
{
246247
ifs >> pp.rab[ir];
247248
}
249+
this->skip_number(ifs, this->mesh_changed);
248250
ModuleBase::GlobalFunc::SCAN_END(ifs, "</PP_RAB>");
249251
}
250252
return;
@@ -258,6 +260,7 @@ void Pseudopot_upf::read_pseudo_nlcc(std::ifstream &ifs, Atom_pseudo& pp)
258260
{
259261
ifs >> pp.rho_atc[ir];
260262
}
263+
this->skip_number(ifs, this->mesh_changed);
261264
return;
262265
}
263266

@@ -270,7 +273,7 @@ void Pseudopot_upf::read_pseudo_local(std::ifstream &ifs, Atom_pseudo& pp)
270273
{
271274
ifs >> pp.vloc_at[ir];
272275
}
273-
276+
this->skip_number(ifs, this->mesh_changed);
274277
return;
275278
}
276279

@@ -406,6 +409,7 @@ void Pseudopot_upf::read_pseudo_nl(std::ifstream &ifs, Atom_pseudo& pp)
406409
ifs >> qfunc(nmb, ir);
407410
}
408411
}
412+
this->skip_number(ifs, this->mesh_changed);
409413

410414
if (this->nqf > 0)
411415
{
@@ -445,11 +449,7 @@ void Pseudopot_upf::read_pseudo_pswfc(std::ifstream &ifs, Atom_pseudo& pp)
445449
{
446450
ifs >> pp.chi(i, ir);
447451
}
448-
if (this->mesh_changed)
449-
{
450-
double temp = 0.0;
451-
ifs >> temp;
452-
}
452+
this->skip_number(ifs, this->mesh_changed);
453453
}
454454
return;
455455
}
@@ -461,6 +461,7 @@ void Pseudopot_upf::read_pseudo_rhoatom(std::ifstream &ifs, Atom_pseudo& pp)
461461
{
462462
ifs >> pp.rho_at[ir];
463463
}
464+
this->skip_number(ifs, this->mesh_changed);
464465
return;
465466
}
466467

source/module_cell/read_pp_upf201.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ int Pseudopot_upf::read_pseudo_upf201(std::ifstream &ifs, Atom_pseudo& pp)
3232
{
3333
ifs >> pp.rho_atc[ir];
3434
}
35+
this->skip_number(ifs, this->mesh_changed);
3536
ModuleBase::GlobalFunc::SCAN_END(ifs, "</PP_NLCC>");
3637
}
3738

@@ -53,6 +54,7 @@ int Pseudopot_upf::read_pseudo_upf201(std::ifstream &ifs, Atom_pseudo& pp)
5354
{
5455
ifs >> pp.vloc_at[ir];
5556
}
57+
this->skip_number(ifs, this->mesh_changed);
5658
ModuleBase::GlobalFunc::SCAN_END(ifs, "</PP_LOCAL>");
5759
}
5860

@@ -90,6 +92,7 @@ int Pseudopot_upf::read_pseudo_upf201(std::ifstream &ifs, Atom_pseudo& pp)
9092
{
9193
ifs >> pp.rho_at[ir];
9294
}
95+
this->skip_number(ifs, this->mesh_changed);
9396
ModuleBase::GlobalFunc::SCAN_END(ifs, "</PP_RHOATOM>");
9497

9598
//--------------------------------------
@@ -406,6 +409,7 @@ void Pseudopot_upf::read_pseudo_upf201_mesh(std::ifstream& ifs, Atom_pseudo& pp)
406409
{
407410
ifs >> pp.r[ir];
408411
}
412+
this->skip_number(ifs, this->mesh_changed);
409413
ModuleBase::GlobalFunc::SCAN_END(ifs, "</PP_R>");
410414

411415
if (ModuleBase::GlobalFunc::SCAN_BEGIN(ifs, "<PP_RAB", true, false))
@@ -420,6 +424,7 @@ void Pseudopot_upf::read_pseudo_upf201_mesh(std::ifstream& ifs, Atom_pseudo& pp)
420424
{
421425
ifs >> pp.rab[ir];
422426
}
427+
this->skip_number(ifs, this->mesh_changed);
423428
ModuleBase::GlobalFunc::SCAN_END(ifs, "</PP_RAB>");
424429
ModuleBase::GlobalFunc::SCAN_END(ifs, "</PP_MESH>");
425430
}
@@ -497,6 +502,7 @@ void Pseudopot_upf::read_pseudo_upf201_nonlocal(std::ifstream& ifs, Atom_pseudo&
497502
{
498503
ifs >> pp.betar(ib, ir);
499504
}
505+
this->skip_number(ifs, this->mesh_changed);
500506
word = "</PP_BETA." + std::to_string(ib + 1) + ">";
501507
ModuleBase::GlobalFunc::SCAN_END(ifs, word);
502508
}
@@ -639,6 +645,7 @@ void Pseudopot_upf::read_pseudo_upf201_nonlocal(std::ifstream& ifs, Atom_pseudo&
639645
{
640646
ifs >> pp.qfuncl(l, nmb, ir);
641647
}
648+
this->skip_number(ifs, this->mesh_changed);
642649
word = "</PP_QIJL." + std::to_string(nb + 1) + "." + std::to_string(mb + 1) + "."
643650
+ std::to_string(l) + ">";
644651
ModuleBase::GlobalFunc::SCAN_END(ifs, word);
@@ -653,6 +660,7 @@ void Pseudopot_upf::read_pseudo_upf201_nonlocal(std::ifstream& ifs, Atom_pseudo&
653660
{
654661
ifs >> this->qfunc(nmb, ir);
655662
}
663+
this->skip_number(ifs, this->mesh_changed);
656664
word = "</PP_QIJ." + std::to_string(nb + 1) + "." + std::to_string(mb + 1) + ">";
657665
ModuleBase::GlobalFunc::SCAN_END(ifs, word);
658666
}
@@ -757,6 +765,7 @@ void Pseudopot_upf::read_pseudo_upf201_pswfc(std::ifstream& ifs, Atom_pseudo& pp
757765
{
758766
assert(pp.chi.c[iw * pp.mesh + ir] == pp.chi(iw, ir));
759767
}
768+
this->skip_number(ifs, this->mesh_changed);
760769
word = "</PP_CHI." + std::to_string(iw + 1) + ">";
761770
ModuleBase::GlobalFunc::SCAN_END(ifs, word);
762771
}

0 commit comments

Comments
 (0)