Skip to content

Commit 2efe796

Browse files
authored
Fix calculation type inconsistency across MPI ranks (#6437)
1 parent 8a3ea2a commit 2efe796

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

source/source_io/read_set_globalv.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
#include "read_input.h"
2+
#include "read_input_tool.h"
13
#include "source_base/global_variable.h"
24
#include "source_base/tool_quit.h"
35
#include "source_io/module_parameter/parameter.h"
4-
#include "read_input.h"
5-
#include "read_input_tool.h"
66
namespace ModuleIO
77
{
88
/// @note Here para.inp has been synchronized of all ranks.
@@ -101,7 +101,7 @@ void ReadInput::set_global_dir(const Input_para& inp, System_para& sys)
101101
sys.global_mlkedf_descriptor_dir = sys.global_out_dir + "MLKEDF_Descriptors/";
102102
sys.global_mlkedf_descriptor_dir = to_dir(sys.global_mlkedf_descriptor_dir);
103103

104-
/// get the global directory for DeePKS labels during electronic steps
104+
/// get the global directory for DeePKS labels during electronic steps
105105
sys.global_deepks_label_elec_dir = sys.global_out_dir + "DeePKS_Labels_Elec/";
106106
sys.global_deepks_label_elec_dir = to_dir(sys.global_deepks_label_elec_dir);
107107

@@ -130,17 +130,22 @@ void ReadInput::set_global_dir(const Input_para& inp, System_para& sys)
130130

131131
// set the global log file
132132
bool out_alllog = inp.out_alllog;
133+
// set the global calculation type
134+
std::string cal_type = inp.calculation;
133135
#ifdef __MPI
134136
// because log_file is different for each rank, so we need to bcast the out_alllog
135137
Parallel_Common::bcast_bool(out_alllog);
138+
// In `ReadInput::read_parameters`, `bcastfunc(param)` is after `set_global_dir`,
139+
// so `cal_type` must be synchronized here manually
140+
Parallel_Common::bcast_string(cal_type);
136141
#endif
137142
if (out_alllog)
138143
{
139-
PARAM.sys.log_file = "running_" + PARAM.inp.calculation + "_" + std::to_string(PARAM.sys.myrank + 1) + ".log";
144+
PARAM.sys.log_file = "running_" + cal_type + "_" + std::to_string(PARAM.sys.myrank + 1) + ".log";
140145
}
141146
else
142147
{
143-
PARAM.sys.log_file = "running_" + PARAM.inp.calculation + ".log";
148+
PARAM.sys.log_file = "running_" + cal_type + ".log";
144149
}
145150
#ifdef __MPI
146151
Parallel_Common::bcast_string(sys.global_in_card);

0 commit comments

Comments
 (0)