File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed
module_basis/module_pw/test Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 11#include " tool_quit.h"
22#ifdef __MPI
33#include " mpi.h"
4+ #include " module_base/parallel_global.h"
5+ #include " module_base/parallel_comm.h"
46#endif
57
68#ifdef __NORMAL
@@ -62,6 +64,20 @@ void QUIT(int ret)
6264void WARNING_QUIT (const std::string &file,const std::string &description)
6365{
6466 WARNING_QUIT (file, description, 1 );
67+
68+ #ifdef __MPI /* if it is MPI run, finalize first, then exit */
69+ std::cout << " Detecting if MPI has been initialized..."
70+ int is_initialized;
71+ MPI_Initialized (&is_initialized);
72+ if (is_initialized) {
73+ std::cout << " Terminating ABACUS with multiprocessing environment." << std::endl;
74+ Parallel_Global::finalize_mpi ();
75+ }
76+ else {
77+ std::cout << " MPI has not been initialized. Quit normally."
78+ }
79+ /* but seems this is the only correct way to terminate the MPI */
80+ #endif
6581}
6682
6783void WARNING_QUIT (const std::string &file,const std::string &description,int ret)
Original file line number Diff line number Diff line change 55 SOURCES ../../../module_base/matrix.cpp ../../../module_base/complexmatrix.cpp ../../../module_base/matrix3.cpp ../../../module_base/tool_quit.cpp
66 ../../../module_base/mymath.cpp ../../../module_base/timer.cpp ../../../module_base/memory.cpp ../../../module_base/blas_connector.cpp
77 ../../../module_base/libm/branred.cpp ../../../module_base/libm/sincos.cpp
8- # ../../../module_psi/kernels/psi_memory_op .cpp
8+ ../../../module_base/parallel_global .cpp ../../../module_base/parallel_comm.cpp
99 ../../../module_base/module_device/memory_op.cpp
1010 depend_mock.cpp pw_test.cpp test1-1-1.cpp test1-1-2.cpp test1-2.cpp test1-3.cpp test1-4.cpp test1-5.cpp
1111 test2-1-1.cpp test2-1-2.cpp test2-2.cpp test2-3.cpp
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ namespace GlobalV
88 std::ofstream ofs_running;
99}
1010#ifdef __MPI
11- MPI_Comm POOL_WORLD;
11+ // MPI_Comm POOL_WORLD;
1212namespace Parallel_Reduce
1313{
1414 template <typename T> void reduce_all (T& object) { return ; };
You can’t perform that action at this time.
0 commit comments