Skip to content

Commit 7e42ed7

Browse files
authored
Merge pull request #862 from sunliang98/debug
Fix: remove invalid warning in `Pseudopot_upf::read_pseudo_upf201`.
2 parents 864fcb7 + a24108c commit 7e42ed7

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

source/module_base/global_function.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ void TEST_LEVEL(const std::string &name)
150150
return;
151151
}
152152

153-
bool SCAN_BEGIN(std::ifstream &ifs, const std::string &TargetName, const bool restart)
153+
bool SCAN_BEGIN(std::ifstream &ifs, const std::string &TargetName, const bool restart, const bool ifwarn)
154154
{
155155
std::string SearchName;
156156
bool find = false;
@@ -169,18 +169,18 @@ bool SCAN_BEGIN(std::ifstream &ifs, const std::string &TargetName, const bool re
169169
break;
170170
}
171171
}
172-
if (!find)
172+
if (!find && ifwarn)
173173
{
174174
GlobalV::ofs_warning << " In SCAN_BEGIN, can't find: " << TargetName << " block." << std::endl;
175175
}
176176
return find;
177177
}
178178

179-
void SCAN_END(std::ifstream &ifs, const std::string &TargetName)
179+
void SCAN_END(std::ifstream &ifs, const std::string &TargetName, const bool ifwarn)
180180
{
181181
std::string SearchName;
182182
ifs >> SearchName;
183-
if (SearchName != TargetName)
183+
if (SearchName != TargetName && ifwarn)
184184
{
185185
GlobalV::ofs_warning << " In SCAN_END, can't find: " << TargetName << " block." << std::endl;
186186
}

source/module_base/global_function.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,13 @@ static void READ_VALUE(std::ifstream &ifs, T &v)
153153
return;
154154
}
155155

156-
bool SCAN_BEGIN(std::ifstream &ifs, const std::string &TargetName, const bool restart=1);
156+
bool SCAN_BEGIN(std::ifstream &ifs, const std::string &TargetName, const bool restart=1, const bool ifwarn=true);
157+
// ifwarn: whether to call GlobalV::ofs_warning when the TargetName is not found, used to avoid invalid warning.
157158
// Mohan warning : the last term can't be written as const bool &restart,
158159
// I don't know why.
159160

160-
void SCAN_END(std::ifstream &ifs, const std::string &TargetName);
161+
void SCAN_END(std::ifstream &ifs, const std::string &TargetName, const bool ifwarn=true);
162+
// ifwarn: whether to call GlobalV::ofs_warning when the TargetName is not found, used to avoid invalid warning.
161163

162164
template<class T>
163165
static inline void DCOPY( const T &a, T &b, const int &dim)

source/module_cell/read_pp_upf201.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ int Pseudopot_upf::read_pseudo_upf201(std::ifstream &ifs)
126126
ModuleBase::GlobalFunc::SCAN_BEGIN(ifs, "<PP_MESH>");
127127
}
128128

129-
if (ModuleBase::GlobalFunc::SCAN_BEGIN(ifs, "<PP_R"))
129+
if (ModuleBase::GlobalFunc::SCAN_BEGIN(ifs, "<PP_R", true, false))
130130
{
131131
ModuleBase::GlobalFunc::READ_VALUE(ifs, word); // type size columns
132132
this->read_pseudo_upf201_r(ifs);
@@ -137,7 +137,7 @@ int Pseudopot_upf::read_pseudo_upf201(std::ifstream &ifs)
137137
}
138138
ModuleBase::GlobalFunc::SCAN_END(ifs, "</PP_R>");
139139

140-
if (ModuleBase::GlobalFunc::SCAN_BEGIN(ifs, "<PP_RAB"))
140+
if (ModuleBase::GlobalFunc::SCAN_BEGIN(ifs, "<PP_RAB", true, false))
141141
{
142142
ModuleBase::GlobalFunc::READ_VALUE(ifs, word); // type size columns
143143
this->read_pseudo_upf201_rab(ifs);
@@ -222,7 +222,7 @@ int Pseudopot_upf::read_pseudo_upf201(std::ifstream &ifs)
222222
ifs >> word; //number of beta
223223
}
224224

225-
if (ModuleBase::GlobalFunc::SCAN_BEGIN(ifs, "<PP_DIJ"))
225+
if (ModuleBase::GlobalFunc::SCAN_BEGIN(ifs, "<PP_DIJ", true, false))
226226
{
227227
ModuleBase::GlobalFunc::READ_VALUE(ifs, word); // type size columns
228228
this->read_pseudo_upf201_dij(ifs);
@@ -287,7 +287,7 @@ int Pseudopot_upf::read_pseudo_upf201(std::ifstream &ifs)
287287
//--------------------------------------
288288
//- PP_RHOATOM -
289289
//--------------------------------------
290-
if (ModuleBase::GlobalFunc::SCAN_BEGIN(ifs, "<PP_RHOATOM"))
290+
if (ModuleBase::GlobalFunc::SCAN_BEGIN(ifs, "<PP_RHOATOM", true, false))
291291
{
292292
ModuleBase::GlobalFunc::READ_VALUE(ifs, word); // type size columns
293293
this->read_pseudo_upf201_rhoatom(ifs);
@@ -301,7 +301,7 @@ int Pseudopot_upf::read_pseudo_upf201(std::ifstream &ifs)
301301
//--------------------------------------
302302
//- PP_SPIN_ORB -
303303
//--------------------------------------
304-
ModuleBase::GlobalFunc::SCAN_BEGIN(ifs, "<PP_SPIN_ORB>");
304+
ModuleBase::GlobalFunc::SCAN_BEGIN(ifs, "<PP_SPIN_ORB>", true, false);
305305
//added by zhengdy-soc
306306
delete[] this->jchi;
307307
delete[] this->jjj;
@@ -378,13 +378,13 @@ int Pseudopot_upf::read_pseudo_upf201(std::ifstream &ifs)
378378
break;
379379
}
380380
}
381-
ModuleBase::GlobalFunc::SCAN_END(ifs, "</PP_SPIN_ORB>");
381+
ModuleBase::GlobalFunc::SCAN_END(ifs, "</PP_SPIN_ORB>", false);
382382
if (mesh%2 == 0)
383383
{
384384
mesh -= 1;
385385
}
386386

387-
ModuleBase::GlobalFunc::SCAN_END(ifs, "</UPF>");
387+
ModuleBase::GlobalFunc::SCAN_END(ifs, "</UPF>", false);
388388
delete []name;
389389
delete []val;
390390

0 commit comments

Comments
 (0)