Skip to content

Commit 918d11b

Browse files
authored
Fix calculation type inconsistency across MPI ranks (#6356)
1 parent f5e43ab commit 918d11b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

source/source_io/read_set_globalv.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,22 @@ void ReadInput::set_global_dir(const Input_para& inp, System_para& sys)
126126

127127
// set the global log file
128128
bool out_alllog = inp.out_alllog;
129+
// set the global calculation type
130+
std::string cal_type = inp.calculation;
129131
#ifdef __MPI
130132
// because log_file is different for each rank, so we need to bcast the out_alllog
131133
Parallel_Common::bcast_bool(out_alllog);
134+
// In `ReadInput::read_parameters`, `bcastfunc(param)` is after `set_global_dir`,
135+
// so `cal_type` must be synchronized here manually
136+
Parallel_Common::bcast_string(cal_type);
132137
#endif
133138
if (out_alllog)
134139
{
135-
PARAM.sys.log_file = "running_" + PARAM.inp.calculation + "_" + std::to_string(PARAM.sys.myrank + 1) + ".log";
140+
PARAM.sys.log_file = "running_" + cal_type + "_" + std::to_string(PARAM.sys.myrank + 1) + ".log";
136141
}
137142
else
138143
{
139-
PARAM.sys.log_file = "running_" + PARAM.inp.calculation + ".log";
144+
PARAM.sys.log_file = "running_" + cal_type + ".log";
140145
}
141146
#ifdef __MPI
142147
Parallel_Common::bcast_string(sys.global_in_card);

0 commit comments

Comments
 (0)