forked from abacusmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 230
Optimize WARNING_QUIT fatal-exit output #7413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| #include "tool_quit.h" | ||
| #include <cstdlib> | ||
| #ifdef __MPI | ||
| #include "mpi.h" | ||
| #endif | ||
|
|
@@ -18,6 +19,22 @@ namespace | |
| { | ||
| std::string g_quit_out_dir; | ||
| std::string g_quit_calculation; | ||
|
|
||
| [[noreturn]] void quit_impl(const int ret, const bool print_timer) | ||
| { | ||
| #ifdef __NORMAL | ||
| (void)print_timer; | ||
| #else | ||
| if (print_timer) | ||
| { | ||
| ModuleBase::timer::finish(GlobalV::ofs_running, GlobalV::MY_RANK == 0, false); | ||
| std::cout << " See output information in : " << g_quit_out_dir << std::endl; | ||
| } | ||
| ModuleBase::Global_File::close_all_log(GlobalV::MY_RANK); | ||
| #endif | ||
|
|
||
| std::exit(ret); | ||
| } | ||
| } | ||
|
|
||
| void set_quit_out_dir(const std::string& dir) | ||
|
|
@@ -64,43 +81,21 @@ void QUIT() | |
|
|
||
| void QUIT(int ret) | ||
| { | ||
|
|
||
| #ifdef __NORMAL | ||
| #else | ||
| ModuleBase::timer::finish(GlobalV::ofs_running , !GlobalV::MY_RANK, false); | ||
| ModuleBase::Global_File::close_all_log(GlobalV::MY_RANK); | ||
| std::cout<<" See output information in : "<<g_quit_out_dir<<std::endl; | ||
| #endif | ||
|
|
||
| exit(ret); | ||
| quit_impl(ret, true); | ||
| } | ||
|
|
||
|
|
||
| void WARNING_QUIT(const std::string &file,const std::string &description) | ||
| { | ||
| WARNING_QUIT(file, description, 1); | ||
|
|
||
| #ifdef __MPI /* if it is MPI run, finalize first, then exit */ | ||
| std::cout << "Detecting if MPI has been initialized..." << std::endl; | ||
| int is_initialized = 0; | ||
| MPI_Initialized(&is_initialized); | ||
| if (is_initialized) { | ||
| std::cout << "Terminating ABACUS with multiprocessing environment." << std::endl; | ||
| MPI_Finalize(); | ||
| } | ||
| else{ | ||
| std::cout << "MPI has not been initialized. Quit normally." << std::endl; | ||
| } | ||
| /* but seems this is the only correct way to terminate the MPI */ | ||
| #endif | ||
| WARNING_QUIT(file, description, 1); | ||
| } | ||
|
|
||
| void WARNING_QUIT(const std::string &file,const std::string &description,int ret) | ||
| { | ||
| #ifdef __NORMAL | ||
|
|
||
| std::cout << " ---------------------------------------------------------" << std::endl; | ||
| std::cout << " !NOTICE! " << std::endl; | ||
| std::cout << " !ERROR! " << std::endl; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not always an error. We intentionally set the log level to NOTICE. |
||
| std::cout << " ---------------------------------------------------------" << std::endl; | ||
| std::cout << " For detailed manual of ABACUS, please see the website" << std::endl; | ||
| std::cout << " https://abacus.deepmodeling.com" << std::endl; | ||
|
|
@@ -110,42 +105,44 @@ void WARNING_QUIT(const std::string &file,const std::string &description,int ret | |
| #else | ||
| std::cout << " " << std::endl; | ||
| std::cout << " ---------------------------------------------------------" << std::endl; | ||
| std::cout << " !NOTICE! " << std::endl; | ||
| std::cout << " !ERROR! " << std::endl; | ||
| std::cout << " ---------------------------------------------------------" << std::endl; | ||
| std::cout << " " << std::endl; | ||
| std::cout << " " << description << std::endl; | ||
| std::cout << " " << std::endl; | ||
| std::cout << " CHECK IN FILE : " << g_quit_out_dir << "warning.log" << std::endl; | ||
| std::cout << " " << std::endl; | ||
| std::cout << " For detailed manual of ABACUS, please see the website" << std::endl; | ||
| std::cout << " https://abacus.deepmodeling.com" << std::endl; | ||
| std::cout << " For any questions, propose issues on the website" << std::endl; | ||
| std::cout << " https://github.com/deepmodeling/abacus-develop/issues" << std::endl; | ||
| std::cout << " ---------------------------------------------------------" << std::endl; | ||
| std::cout << " !NOTICE! " << std::endl; | ||
| std::cout << " !ERROR! " << std::endl; | ||
| std::cout << " ---------------------------------------------------------" << std::endl; | ||
|
|
||
|
|
||
| GlobalV::ofs_running << " ---------------------------------------------------------" << std::endl; | ||
| GlobalV::ofs_running << " !NOTICE! " << std::endl; | ||
| GlobalV::ofs_running << " !ERROR! " << std::endl; | ||
| GlobalV::ofs_running << " ---------------------------------------------------------" << std::endl; | ||
| GlobalV::ofs_running << std::endl; | ||
| GlobalV::ofs_running << " " << description << std::endl; | ||
| GlobalV::ofs_running << std::endl; | ||
| GlobalV::ofs_running << " CHECK IN FILE : " << g_quit_out_dir << "warning.log" << std::endl; | ||
| GlobalV::ofs_running << std::endl; | ||
| GlobalV::ofs_running << " For detailed manual of ABACUS, please see the website" << std::endl; | ||
| GlobalV::ofs_running << " https://abacus.deepmodeling.com" << std::endl; | ||
| GlobalV::ofs_running << " For any questions, propose issues on the website" << std::endl; | ||
| GlobalV::ofs_running << " https://github.com/deepmodeling/abacus-develop/issues" << std::endl; | ||
| GlobalV::ofs_running << " ---------------------------------------------------------" << std::endl; | ||
| GlobalV::ofs_running << " NOTICE " << std::endl; | ||
| GlobalV::ofs_running << " !ERROR! " << std::endl; | ||
| GlobalV::ofs_running << " ---------------------------------------------------------" << std::endl; | ||
|
|
||
| WARNING(file,description); | ||
| GlobalV::ofs_running<<" Check in file : "<<g_quit_out_dir<<"warning.log"<<std::endl; | ||
|
|
||
| #endif | ||
|
|
||
| QUIT(ret); | ||
| quit_impl(ret, false); | ||
| } | ||
|
|
||
| //Check and print warning information for all cores. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We recommend keeping the C++ syntax simple: just use void and avoid adding new syntax elements.