Skip to content

Commit 3c73446

Browse files
committed
<fix>
Add a parameter "ifwarn" to the SCAN_BEGIN and SCAN_END in global_function.h to switch the warning. Fix a output bug in Pseudopot_upf::read_pseudo_upf201, which may out invalid warning. For example, if the key word in pseudopotential is <PP_R>, ABACUS will look for <PP_R first and output the warning that the <PP_R> isn't found, next it will find <PP_R>, but <PP_R and <PP_R> are equivalent, so the warning is invalid. As a result, I turn off the warning in the functions that look for <PP_R, <PP_RAB, <PP_DIJ, <PP_RHOATOM. Besides, many pseudopotentials do not have block <PP_SPIN_ORB>, the warning seems needless, so I turn off the warning of looking for <PP_SPIN_ORB> and </PP_SPIN_ORB>. The warning of </UPF> is turned off for the same reason. The problems of <PP_SPIN_ORB> and </UPF> are mentioned in issue#128 in abacusmodeling/abacus-develop.
1 parent 835a190 commit 3c73446

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ 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);
157157
// Mohan warning : the last term can't be written as const bool &restart,
158158
// I don't know why.
159159

160-
void SCAN_END(std::ifstream &ifs, const std::string &TargetName);
160+
void SCAN_END(std::ifstream &ifs, const std::string &TargetName, const bool ifwarn=true);
161161

162162
template<class T>
163163
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)