44#endif
55
66#ifdef __NORMAL
7-
87#else
98#include " global_variable.h"
109#include " module_parameter/parameter.h"
@@ -20,17 +19,14 @@ namespace ModuleBase
2019// NAME : WARNING( write information into GlobalV::ofs_warning)
2120// NAME : QUIT( exit the running program)
2221// NAME : WARNING_QUIT( write information into
23- // GlobalV::ofs_warning , and then quit)
22+ // GlobalV::ofs_warning , and then quit)
2423// ==========================================================
2524void WARNING (const std::string &file,const std::string &description)
2625{
27- #ifdef __NORMAL
28-
26+ #ifdef __NORMAL /* what is this??? */
2927#else
30-
3128 if (GlobalV::MY_RANK==0 )
3229 {
33- // std::cout << "\n "<<file<<" Warning : "<<description<<std::endl;
3430 GlobalV::ofs_warning << " " << file <<" warning : " << description<<std::endl;
3531 }
3632#endif
@@ -39,69 +35,65 @@ void WARNING(const std::string &file,const std::string &description)
3935
4036void QUIT ()
4137{
42- QUIT (0 );
38+ /* it is quite strange to exit with code 0 by default... */
39+ QUIT (0 );
4340}
4441
45- void QUIT (int ret)
42+ void QUIT (const int ret)
4643{
47-
48- #ifdef __NORMAL
49-
44+ #ifdef __NORMAL /* what is this??? */
5045#else
5146 ModuleBase::timer::finish (GlobalV::ofs_running , !GlobalV::MY_RANK);
52-
5347 ModuleBase::Global_File::close_all_log (GlobalV::MY_RANK);
54-
5548 std::cout<<" See output information in : " <<PARAM.globalv .global_out_dir <<std::endl;
5649#endif
57-
50+ #ifdef __MPI /* if it is MPI run, finalize first, then exit */
51+ MPI_Finalize ();
52+ #endif
5853 exit (ret);
5954}
6055
61-
62- void WARNING_QUIT (const std::string &file,const std::string &description)
56+ void WARNING_QUIT (const std::string &file, const std::string &description)
6357{
64- WARNING_QUIT (file, description, 0 );
58+ WARNING_QUIT (file, description, 0 );
59+ /* really? we return with 0? it is something like "we exit the program normally" */
6560}
6661
67- void WARNING_QUIT (const std::string &file,const std::string &description,int ret)
62+ void WARNING_QUIT (const std::string &file, const std::string &description, int ret)
6863{
69- #ifdef __NORMAL
70-
71- std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
72- std::cout << " NOTICE " << std::endl;
73- std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
74-
64+ #ifdef __NORMAL /* what is this??? */
65+ std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
66+ std::cout << " NOTICE " << std::endl;
67+ std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
7568#else
76- std::cout << " " << std::endl;
77- std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
78- std::cout << " NOTICE " << std::endl;
79- std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
80- std::cout << " " << std::endl;
81- std::cout << " " << description << std::endl;
82- std::cout << " CHECK IN FILE : " << PARAM.globalv .global_out_dir << " warning.log" << std::endl;
83- std::cout << " " << std::endl;
84- std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
85- std::cout << " NOTICE " << std::endl;
86- std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
87-
88-
89- GlobalV::ofs_running << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
90- GlobalV::ofs_running << " NOTICE " << std::endl;
91- GlobalV::ofs_running << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
92- GlobalV::ofs_running << std::endl;
93- GlobalV::ofs_running << " " << description << std::endl;
94- GlobalV::ofs_running << " CHECK IN FILE : " << PARAM.globalv .global_out_dir << " warning.log" << std::endl;
95- GlobalV::ofs_running << std::endl;
96- GlobalV::ofs_running << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
97- GlobalV::ofs_running << " NOTICE " << std::endl;
98- GlobalV::ofs_running << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
99-
100- WARNING (file,description);
69+ std::cout << " " << std::endl;
70+ std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
71+ std::cout << " NOTICE " << std::endl;
72+ std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
73+ std::cout << " " << std::endl;
74+ std::cout << " " << description << std::endl;
75+ std::cout << " CHECK IN FILE : " << PARAM.globalv .global_out_dir << " warning.log" << std::endl;
76+ std::cout << " " << std::endl;
77+ std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
78+ std::cout << " NOTICE " << std::endl;
79+ std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
80+
81+
82+ GlobalV::ofs_running << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
83+ GlobalV::ofs_running << " NOTICE " << std::endl;
84+ GlobalV::ofs_running << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
85+ GlobalV::ofs_running << std::endl;
86+ GlobalV::ofs_running << " " << description << std::endl;
87+ GlobalV::ofs_running << " CHECK IN FILE : " << PARAM.globalv .global_out_dir << " warning.log" << std::endl;
88+ GlobalV::ofs_running << std::endl;
89+ GlobalV::ofs_running << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
90+ GlobalV::ofs_running << " NOTICE " << std::endl;
91+ GlobalV::ofs_running << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
92+
93+ WARNING (file,description);
10194 GlobalV::ofs_running<<" Check in file : " <<PARAM.globalv .global_out_dir <<" warning.log" <<std::endl;
10295
10396#endif
104-
10597 QUIT (ret);
10698}
10799
@@ -112,34 +104,34 @@ void CHECK_WARNING_QUIT(const bool error_in, const std::string &file,const std::
112104#ifdef __NORMAL
113105// only for UT, do nothing here
114106#else
115- if (error_in)
116- {
117- // All cores will print inforamtion
118- std::cout.clear ();
119- if (!GlobalV::ofs_running.is_open ())
120- {
121- std::string logfile = PARAM.globalv .global_out_dir + " running_" + calculation + " .log" ;
122- GlobalV::ofs_running.open ( logfile.c_str (), std::ios::app );
123- }
124- if (!GlobalV::ofs_warning.is_open ())
125- {
126- std::string warningfile = PARAM.globalv .global_out_dir + " warning.log" ;
127- GlobalV::ofs_warning.open ( warningfile.c_str (), std::ios::app );
128- }
129-
130- // print error information
131- std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
132- std::cout << " ERROR! " << description << std::endl;
133- std::cout << " CHECK IN FILE : " << PARAM.globalv .global_out_dir << " warning.log" << std::endl;
134- std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
135- GlobalV::ofs_running << " ERROR! CHECK IN FILE : " << PARAM.globalv .global_out_dir << " warning.log" << std::endl;
136- GlobalV::ofs_warning << std::endl;
137- GlobalV::ofs_warning << " ERROR! " << file << " , core " << GlobalV::MY_RANK+1 << " : " << description << std::endl;
138- GlobalV::ofs_warning << std::endl;
139- exit (1 );
140- }
107+ if (error_in)
108+ {
109+ // All cores will print inforamtion
110+ std::cout.clear ();
111+ if (!GlobalV::ofs_running.is_open ())
112+ {
113+ std::string logfile = PARAM.globalv .global_out_dir + " running_" + calculation + " .log" ;
114+ GlobalV::ofs_running.open ( logfile.c_str (), std::ios::app );
115+ }
116+ if (!GlobalV::ofs_warning.is_open ())
117+ {
118+ std::string warningfile = PARAM.globalv .global_out_dir + " warning.log" ;
119+ GlobalV::ofs_warning.open ( warningfile.c_str (), std::ios::app );
120+ }
121+
122+ // print error information
123+ std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
124+ std::cout << " ERROR! " << description << std::endl;
125+ std::cout << " CHECK IN FILE : " << PARAM.globalv .global_out_dir << " warning.log" << std::endl;
126+ std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
127+ GlobalV::ofs_running << " ERROR! CHECK IN FILE : " << PARAM.globalv .global_out_dir << " warning.log" << std::endl;
128+ GlobalV::ofs_warning << std::endl;
129+ GlobalV::ofs_warning << " ERROR! " << file << " , core " << GlobalV::MY_RANK+1 << " : " << description << std::endl;
130+ GlobalV::ofs_warning << std::endl;
131+ exit (1 );
132+ }
141133#endif
142- return ;
134+ return ;
143135}
144136
145137}
0 commit comments