Skip to content

Commit c302eac

Browse files
committed
recover the tool_quit
1 parent b350111 commit c302eac

File tree

2 files changed

+78
-70
lines changed

2 files changed

+78
-70
lines changed

source/module_base/tool_quit.cpp

Lines changed: 77 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#endif
55

66
#ifdef __NORMAL
7+
78
#else
89
#include "global_variable.h"
910
#include "module_parameter/parameter.h"
@@ -19,14 +20,17 @@ namespace ModuleBase
1920
// NAME : WARNING( write information into GlobalV::ofs_warning)
2021
// NAME : QUIT( exit the running program)
2122
// NAME : WARNING_QUIT( write information into
22-
// GlobalV::ofs_warning , and then quit)
23+
// GlobalV::ofs_warning , and then quit)
2324
//==========================================================
2425
void WARNING(const std::string &file,const std::string &description)
2526
{
26-
#ifdef __NORMAL /* what is this??? */
27+
#ifdef __NORMAL
28+
2729
#else
30+
2831
if (GlobalV::MY_RANK==0)
2932
{
33+
// std::cout << "\n "<<file<<" Warning : "<<description<<std::endl;
3034
GlobalV::ofs_warning << " " << file <<" warning : "<< description<<std::endl;
3135
}
3236
#endif
@@ -35,65 +39,69 @@ void WARNING(const std::string &file,const std::string &description)
3539

3640
void QUIT()
3741
{
38-
/* it is quite strange to exit with code 0 by default... */
39-
QUIT(0);
42+
QUIT(0);
4043
}
4144

42-
void QUIT(const int ret)
45+
void QUIT(int ret)
4346
{
44-
#ifdef __NORMAL /* what is this??? */
47+
48+
#ifdef __NORMAL
49+
4550
#else
4651
ModuleBase::timer::finish(GlobalV::ofs_running , !GlobalV::MY_RANK);
52+
4753
ModuleBase::Global_File::close_all_log(GlobalV::MY_RANK);
54+
4855
std::cout<<" See output information in : "<<PARAM.globalv.global_out_dir<<std::endl;
4956
#endif
50-
#ifdef __MPI /* if it is MPI run, finalize first, then exit */
51-
MPI_Finalize();
52-
#endif
57+
5358
exit(ret);
5459
}
5560

56-
void WARNING_QUIT(const std::string &file, const std::string &description)
61+
62+
void WARNING_QUIT(const std::string &file,const std::string &description)
5763
{
58-
WARNING_QUIT(file, description, 0);
59-
/* really? we return with 0? it is something like "we exit the program normally" */
64+
WARNING_QUIT(file, description, 0);
6065
}
6166

62-
void WARNING_QUIT(const std::string &file, const std::string &description, int ret)
67+
void WARNING_QUIT(const std::string &file,const std::string &description,int ret)
6368
{
64-
#ifdef __NORMAL /* what is this??? */
65-
std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
66-
std::cout << " NOTICE " << std::endl;
67-
std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
69+
#ifdef __NORMAL
70+
71+
std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
72+
std::cout << " NOTICE " << std::endl;
73+
std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
74+
6875
#else
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);
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);
94101
GlobalV::ofs_running<<" Check in file : "<<PARAM.globalv.global_out_dir<<"warning.log"<<std::endl;
95102

96103
#endif
104+
97105
QUIT(ret);
98106
}
99107

@@ -104,34 +112,34 @@ void CHECK_WARNING_QUIT(const bool error_in, const std::string &file,const std::
104112
#ifdef __NORMAL
105113
// only for UT, do nothing here
106114
#else
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-
}
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+
}
133141
#endif
134-
return;
142+
return;
135143
}
136144

137145
}

source/module_base/tool_quit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void WARNING(const std::string &file, const std::string &description);
3838
* @brief Close .log files and exit
3939
*
4040
*/
41-
[[noreturn]] void QUIT(const int ret);
41+
[[noreturn]] void QUIT(int ret);
4242

4343
/**
4444
* @brief Combine the functions of WARNING and QUIT

0 commit comments

Comments
 (0)