@@ -129,24 +129,41 @@ void WARNING_QUIT(const std::string &file,const std::string &description)
129129}
130130
131131
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)
132+ // Check and print warning information for all cores.
133+ // Maybe in the future warning.log should be replaced by error.log.
134+ void CHECK_WARNING_QUIT (const bool error_in, const std::string &file,const std::string &description)
134135{
135- int error = (int )error_in;
136136#ifdef __NORMAL
137137// only for UT, do nothing here
138138#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)
139+ if (error_in)
147140 {
148- WARNING_QUIT (file, description);
141+ // All cores will print inforamtion
142+ std::cout.clear ();
143+ if (!GlobalV::ofs_running.is_open ())
144+ {
145+ std::string logfile = GlobalV::global_out_dir + " running_" + GlobalV::CALCULATION + " .log" ;
146+ GlobalV::ofs_running.open ( logfile.c_str (), std::ios::app );
147+ }
148+ if (!GlobalV::ofs_warning.is_open ())
149+ {
150+ std::string warningfile = GlobalV::global_out_dir + " warning.log" ;
151+ GlobalV::ofs_warning.open ( warningfile.c_str (), std::ios::app );
152+ }
153+
154+ // print error information
155+ std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
156+ std::cout << " ERROR! " << description << std::endl;
157+ std::cout << " CHECK IN FILE : " << GlobalV::global_out_dir << " warning.log" << std::endl;
158+ std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
159+ GlobalV::ofs_running << " ERROR! CHECK IN FILE : " << GlobalV::global_out_dir << " warning.log" << std::endl;
160+ GlobalV::ofs_warning << std::endl;
161+ GlobalV::ofs_warning << " ERROR! " << file << " , core " << GlobalV::MY_RANK+1 << " : " << description << std::endl;
162+ GlobalV::ofs_warning << std::endl;
163+ exit (0 );
149164 }
165+ #endif
166+ return ;
150167}
151168
152169}
0 commit comments