File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
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
@@ -55,6 +57,20 @@ void QUIT(int ret)
5557 std::cout<<" See output information in : " <<PARAM.globalv .global_out_dir <<std::endl;
5658#endif
5759
60+ #ifdef _OPENMP // merge all threads of one process into one thread
61+ if (omp_in_parallel ())
62+ {
63+ omp_set_num_threads (1 );
64+ std::cout << " Terminating ABACUS with multithreading environment." << std::endl;
65+ }
66+ assert (!omp_in_parallel ()); /* avoid the case that death thread calls fork() */
67+ #endif
68+
69+ #ifdef __MPI /* if it is MPI run, finalize first, then exit */
70+ std::cout << " Terminating ABACUS with multiprocessing environment." << std::endl;
71+ Parallel_Global::finalize_mpi ();
72+ /* but seems this is the only correct way to terminate the MPI */
73+ #endif
5874 exit (ret);
5975}
6076
You can’t perform that action at this time.
0 commit comments