Skip to content

Commit fcc8e8d

Browse files
committed
Fix: add CHECK_WARNING_QUIT function for reporting no plane wave error
1 parent f08c638 commit fcc8e8d

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

source/module_base/tool_quit.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,25 @@ void WARNING_QUIT(const std::string &file,const std::string &description)
128128
QUIT();
129129
}
130130

131+
132+
//Input judgement and communicate , if any judgement is true, do WARNING_QUIT
133+
void CHECK_WARNING_QUIT(bool error_in, const std::string &file,const std::string &description)
134+
{
135+
int error = (int)error_in;
136+
#ifdef __NORMAL
137+
// only for UT, do nothing here
138+
#else
139+
#ifdef __MPI
140+
int error_max = error;
141+
MPI_Reduce(&error, &error_max, 1, MPI_INT, MPI_MAX, 0, MPI_COMM_WORLD);
142+
MPI_Bcast(&error_max, 1, MPI_INT, 0, MPI_COMM_WORLD);
143+
error = error_max;
144+
#endif
145+
#endif
146+
if(error)
147+
{
148+
WARNING_QUIT(file, description);
149+
}
150+
}
151+
131152
}

source/module_base/tool_quit.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ void QUIT(void);
4343
*/
4444
void WARNING_QUIT(const std::string &file, const std::string &description);
4545

46+
/**
47+
* @brief Check, if true, WARNING_QUIT
48+
*
49+
* @param file The file where warning happens
50+
* @param description The warning information
51+
*/
52+
void CHECK_WARNING_QUIT(bool error, const std::string &file,const std::string &description);
53+
4654
} // namespace ModuleBase
4755

4856
#endif

source/module_pw/pw_basis_k.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ void PW_Basis_K::setupIndGk()
8080
++ng;
8181
}
8282
}
83+
ModuleBase::CHECK_WARNING_QUIT((ng==0), "PW_Basis_K::setupIndGk", "some cores have no plane waves!");
8384
this->npwk[ik] = ng;
8485
if(ng == 0)
8586
{

0 commit comments

Comments
 (0)