1414#include < cerrno>
1515#include < sstream>
1616#include " global_function.h"
17+ #include " source_io/module_parameter/parameter.h"
1718#include " global_variable.h"
1819#include " source_base/parallel_common.h"
1920#include " source_base/parallel_reduce.h"
@@ -30,16 +31,7 @@ void ModuleBase::Global_File::make_dir_out(
3031 const bool &out_wfc_dir,
3132 const int rank,
3233 const bool &restart,
33- const bool out_alllog,
34- const std::string &global_out_dir,
35- const std::string &global_stru_dir,
36- const std::string &global_matrix_dir,
37- const std::string &global_wfc_dir,
38- const std::string &global_mlkedf_descriptor_dir,
39- const std::string &global_deepks_label_elec_dir,
40- const std::string &log_file,
41- const bool of_ml_gene_data,
42- const bool deepks_out_freq_elec)
34+ const bool out_alllog)
4335{
4436// ----------------------------------------------------------
4537// USE STL FUNCTION
@@ -51,16 +43,17 @@ void ModuleBase::Global_File::make_dir_out(
5143#endif
5244 int make_dir = 0 ;
5345 // mohan update 2011-05-03
46+ // std::string command0 = "test -d " + PARAM.globalv.global_out_dir + " || mkdir " + PARAM.globalv.global_out_dir;
5447
5548 int times = 0 ;
5649 while (times<GlobalV::NPROC )
5750 {
5851 if (rank==times)
5952 {
60- int ret = mkdir (global_out_dir.c_str (), 0755 );
53+ int ret = mkdir (PARAM . globalv . global_out_dir .c_str (), 0755 );
6154 if ( ret == 0 || errno == EEXIST )
6255 {
63- std::cout << " MAKE THE DIR : " << global_out_dir << std::endl;
56+ std::cout << " MAKE THE DIR : " << PARAM . globalv . global_out_dir << std::endl;
6457 make_dir = 1 ;
6558 }
6659 else
@@ -89,16 +82,17 @@ void ModuleBase::Global_File::make_dir_out(
8982 if (calculation == " md" )
9083 {
9184 int make_dir_stru = 0 ;
85+ // std::string command1 = "test -d " + PARAM.globalv.global_stru_dir + " || mkdir " + PARAM.globalv.global_stru_dir;
9286
9387 times = 0 ;
9488 while (times<GlobalV::NPROC )
9589 {
9690 if (rank==times)
9791 {
98- int ret = mkdir (global_stru_dir.c_str (), 0755 );
92+ int ret = mkdir (PARAM . globalv . global_stru_dir .c_str (), 0755 );
9993 if ( ret == 0 || errno == EEXIST )
10094 {
101- std::cout << " MAKE THE STRU DIR : " << global_stru_dir << std::endl;
95+ std::cout << " MAKE THE STRU DIR : " << PARAM . globalv . global_stru_dir << std::endl;
10296 make_dir_stru = 1 ;
10397 }
10498 else
@@ -129,16 +123,17 @@ void ModuleBase::Global_File::make_dir_out(
129123 if ((out_dir) && calculation == " md" )
130124 {
131125 int make_dir_matrix = 0 ;
126+ // std::string command1 = "test -d " + PARAM.globalv.global_matrix_dir + " || mkdir " + PARAM.globalv.global_matrix_dir;
132127
133128 times = 0 ;
134129 while (times<GlobalV::NPROC )
135130 {
136131 if (rank==times)
137132 {
138- int ret = mkdir (global_matrix_dir.c_str (), 0755 );
133+ int ret = mkdir (PARAM . globalv . global_matrix_dir .c_str (), 0755 );
139134 if ( ret == 0 || errno == EEXIST )
140135 {
141- std::cout << " MAKE THE MATRIX DIR : " << global_matrix_dir << std::endl;
136+ std::cout << " MAKE THE MATRIX DIR : " << PARAM . globalv . global_matrix_dir << std::endl;
142137 make_dir_matrix = 1 ;
143138 }
144139 else
@@ -168,16 +163,17 @@ void ModuleBase::Global_File::make_dir_out(
168163 if (out_wfc_dir)
169164 {
170165 int make_dir_wfc = 0 ;
166+ // std::string command1 = "test -d " + PARAM.globalv.global_wfc_dir + " || mkdir " + PARAM.globalv.global_wfc_dir;
171167
172168 times = 0 ;
173169 while (times<GlobalV::NPROC )
174170 {
175171 if (rank==times)
176172 {
177- int ret = mkdir (global_wfc_dir.c_str (), 0755 );
173+ int ret = mkdir (PARAM . globalv . global_wfc_dir .c_str (), 0755 );
178174 if ( ret == 0 || errno == EEXIST )
179175 {
180- std::cout << " MAKE THE WFC DIR : " << global_wfc_dir << std::endl;
176+ std::cout << " MAKE THE WFC DIR : " << PARAM . globalv . global_wfc_dir << std::endl;
181177 make_dir_wfc = 1 ;
182178 }
183179 else
@@ -204,19 +200,20 @@ void ModuleBase::Global_File::make_dir_out(
204200#endif
205201 }
206202
207- if (of_ml_gene_data)
203+ if (PARAM . inp . of_ml_gene_data == 1 )
208204 {
209205 int make_dir_descrip = 0 ;
206+ // std::string command1 = "test -d " + PARAM.globalv.global_mlkedf_descriptor_dir + " || mkdir " + PARAM.globalv.global_mlkedf_descriptor_dir;
210207
211208 times = 0 ;
212209 while (times<GlobalV::NPROC )
213210 {
214211 if (rank==times)
215212 {
216- int ret = mkdir (global_mlkedf_descriptor_dir.c_str (), 0755 );
213+ int ret = mkdir (PARAM . globalv . global_mlkedf_descriptor_dir .c_str (), 0755 );
217214 if ( ret == 0 || errno == EEXIST )
218215 {
219- std::cout << " MAKE THE MLKEDF DESCRIPTOR DIR : " << global_mlkedf_descriptor_dir << std::endl;
216+ std::cout << " MAKE THE MLKEDF DESCRIPTOR DIR : " << PARAM . globalv . global_mlkedf_descriptor_dir << std::endl;
220217 make_dir_descrip = 1 ;
221218 }
222219 else
@@ -229,7 +226,7 @@ void ModuleBase::Global_File::make_dir_out(
229226 Parallel_Reduce::reduce_all (make_dir_descrip);
230227#endif
231228 if (make_dir_descrip > 0 )
232- {
229+ {
233230 break ;
234231 }
235232 ++times;
@@ -245,19 +242,20 @@ void ModuleBase::Global_File::make_dir_out(
245242#endif
246243 }
247244
248- if (deepks_out_freq_elec)
245+ if (PARAM . inp . deepks_out_freq_elec > 0 )
249246 {
250247 int make_dir_deepks_elec = 0 ;
248+ // std::string command1 = "test -d " + PARAM.globalv.global_deepks_label_elec_dir + " || mkdir " + PARAM.globalv.global_deepks_label_elec_dir;
251249
252250 times = 0 ;
253251 while (times<GlobalV::NPROC )
254252 {
255253 if (rank==times)
256254 {
257- int ret = mkdir (global_deepks_label_elec_dir.c_str (), 0755 );
255+ int ret = mkdir (PARAM . globalv . global_deepks_label_elec_dir .c_str (), 0755 );
258256 if ( ret == 0 || errno == EEXIST )
259257 {
260- std::cout << " MAKE THE DEEPKS LABELS (ELEC) DIR : " << global_deepks_label_elec_dir << std::endl;
258+ std::cout << " MAKE THE DEEPKS LABELS (ELEC) DIR : " << PARAM . globalv . global_deepks_label_elec_dir << std::endl;
261259 make_dir_deepks_elec = 1 ;
262260 }
263261 else
@@ -270,7 +268,7 @@ void ModuleBase::Global_File::make_dir_out(
270268 Parallel_Reduce::reduce_all (make_dir_deepks_elec);
271269#endif
272270 if (make_dir_deepks_elec > 0 )
273- {
271+ {
274272 break ;
275273 }
276274 ++times;
@@ -289,53 +287,53 @@ void ModuleBase::Global_File::make_dir_out(
289287 // mohan add 2010-09-12
290288 if (out_alllog)
291289 {
292- open_log (GlobalV::ofs_running, log_file, calculation, restart, global_out_dir );
290+ open_log (GlobalV::ofs_running, PARAM . globalv . log_file , calculation, restart);
293291 #if defined(__CUDA) || defined(__ROCM)
294- open_log (GlobalV::ofs_device, " device" + std::to_string (rank) + " .log" , calculation, restart, global_out_dir );
292+ open_log (GlobalV::ofs_device, " device" + std::to_string (rank) + " .log" , calculation, restart);
295293 #endif
296294 }
297295 else
298296 {
299297 if (rank==0 )
300298 {
301- open_log (GlobalV::ofs_running, log_file, calculation, restart, global_out_dir );
299+ open_log (GlobalV::ofs_running, PARAM . globalv . log_file , calculation, restart);
302300 #if defined(__CUDA) || defined(__ROCM)
303- open_log (GlobalV::ofs_device, " device.log" , calculation, restart, global_out_dir );
301+ open_log (GlobalV::ofs_device, " device.log" , calculation, restart);
304302 #endif
305303 }
306304 }
307305
308306 if (rank==0 )
309307 {
310- open_log (GlobalV::ofs_warning, " warning.log" , calculation, restart, global_out_dir );
308+ open_log (GlobalV::ofs_warning, " warning.log" , calculation, restart);
311309 }
312310
313311#ifdef GATHER_INFO
314- open_log (GlobalV::ofs_info, " math_info_" + std::to_string (rank) + " .log" , calculation, restart, global_out_dir );
312+ open_log (GlobalV::ofs_info, " math_info_" + std::to_string (rank) + " .log" , calculation, restart);
315313#endif
316314
317315 return ;
318316}
319317
320- void ModuleBase::Global_File::make_dir_atom (const std::string &label, const std::string &global_out_dir )
318+ void ModuleBase::Global_File::make_dir_atom (const std::string &label)
321319{
322320// ----------------------------------------------------------
323321// EXPLAIN : generate atom dir for each type of atom
324322// ----------------------------------------------------------
325323 std::stringstream ss;
326- ss << global_out_dir << label << " /" ;
324+ ss << PARAM . globalv . global_out_dir << label << " /" ;
327325 ModuleBase::GlobalFunc::MAKE_DIR (ss.str ());
328326 return ;
329327}
330328
331- void ModuleBase::Global_File::open_log (std::ofstream &ofs, const std::string &fn, const std::string &calculation, const bool &restart, const std::string &global_out_dir )
329+ void ModuleBase::Global_File::open_log (std::ofstream &ofs, const std::string &fn, const std::string &calculation, const bool &restart)
332330{
333331// ----------------------------------------------------------
334332// USE GLOBAL VARIABLE :
335- // global_out_dir : (default dir to store "*.log" file)
333+ // PARAM.globalv. global_out_dir : (default dir to store "*.log" file)
336334// ----------------------------------------------------------
337335 std::stringstream ss;
338- ss << global_out_dir << fn;
336+ ss << PARAM . globalv . global_out_dir << fn;
339337
340338 if (calculation == " md" && restart)
341339 {
0 commit comments