|
9 | 9 | #include <mpi.h> |
10 | 10 | #endif |
11 | 11 | #include <unistd.h> |
| 12 | +#include <sys/stat.h> |
| 13 | +#include <sys/types.h> |
| 14 | +#include <cerrno> |
12 | 15 | #include <sstream> |
13 | 16 | #include "global_function.h" |
14 | 17 | #include "source_io/module_parameter/parameter.h" |
@@ -40,14 +43,15 @@ void ModuleBase::Global_File::make_dir_out( |
40 | 43 | #endif |
41 | 44 | int make_dir = 0; |
42 | 45 | // mohan update 2011-05-03 |
43 | | - std::string command0 = "test -d " + PARAM.globalv.global_out_dir + " || mkdir " + PARAM.globalv.global_out_dir; |
| 46 | + //std::string command0 = "test -d " + PARAM.globalv.global_out_dir + " || mkdir " + PARAM.globalv.global_out_dir; |
44 | 47 |
|
45 | 48 | int times = 0; |
46 | 49 | while(times<GlobalV::NPROC) |
47 | 50 | { |
48 | 51 | if(rank==times) |
49 | 52 | { |
50 | | - if ( system( command0.c_str() ) == 0 ) |
| 53 | + int ret = mkdir(PARAM.globalv.global_out_dir.c_str(), 0755); |
| 54 | + if ( ret == 0 || errno == EEXIST ) |
51 | 55 | { |
52 | 56 | std::cout << " MAKE THE DIR : " << PARAM.globalv.global_out_dir << std::endl; |
53 | 57 | make_dir = 1; |
@@ -78,14 +82,15 @@ void ModuleBase::Global_File::make_dir_out( |
78 | 82 | if(calculation == "md") |
79 | 83 | { |
80 | 84 | int make_dir_stru = 0; |
81 | | - std::string command1 = "test -d " + PARAM.globalv.global_stru_dir + " || mkdir " + PARAM.globalv.global_stru_dir; |
| 85 | + //std::string command1 = "test -d " + PARAM.globalv.global_stru_dir + " || mkdir " + PARAM.globalv.global_stru_dir; |
82 | 86 |
|
83 | 87 | times = 0; |
84 | 88 | while(times<GlobalV::NPROC) |
85 | 89 | { |
86 | 90 | if(rank==times) |
87 | 91 | { |
88 | | - if ( system( command1.c_str() ) == 0 ) |
| 92 | + int ret = mkdir(PARAM.globalv.global_stru_dir.c_str(), 0755); |
| 93 | + if ( ret == 0 || errno == EEXIST ) |
89 | 94 | { |
90 | 95 | std::cout << " MAKE THE STRU DIR : " << PARAM.globalv.global_stru_dir << std::endl; |
91 | 96 | make_dir_stru = 1; |
@@ -118,16 +123,17 @@ void ModuleBase::Global_File::make_dir_out( |
118 | 123 | if((out_dir) && calculation == "md") |
119 | 124 | { |
120 | 125 | int make_dir_matrix = 0; |
121 | | - std::string command1 = "test -d " + PARAM.globalv.global_matrix_dir + " || mkdir " + PARAM.globalv.global_matrix_dir; |
| 126 | + //std::string command1 = "test -d " + PARAM.globalv.global_matrix_dir + " || mkdir " + PARAM.globalv.global_matrix_dir; |
122 | 127 |
|
123 | 128 | times = 0; |
124 | 129 | while(times<GlobalV::NPROC) |
125 | 130 | { |
126 | 131 | if(rank==times) |
127 | 132 | { |
128 | | - if ( system( command1.c_str() ) == 0 ) |
| 133 | + int ret = mkdir(PARAM.globalv.global_matrix_dir.c_str(), 0755); |
| 134 | + if ( ret == 0 || errno == EEXIST ) |
129 | 135 | { |
130 | | - std::cout << " MAKE THE MATRIX DIR : " << PARAM.globalv.global_stru_dir << std::endl; |
| 136 | + std::cout << " MAKE THE MATRIX DIR : " << PARAM.globalv.global_matrix_dir << std::endl; |
131 | 137 | make_dir_matrix = 1; |
132 | 138 | } |
133 | 139 | else |
@@ -157,14 +163,15 @@ void ModuleBase::Global_File::make_dir_out( |
157 | 163 | if(out_wfc_dir) |
158 | 164 | { |
159 | 165 | int make_dir_wfc = 0; |
160 | | - std::string command1 = "test -d " + PARAM.globalv.global_wfc_dir + " || mkdir " + PARAM.globalv.global_wfc_dir; |
| 166 | + //std::string command1 = "test -d " + PARAM.globalv.global_wfc_dir + " || mkdir " + PARAM.globalv.global_wfc_dir; |
161 | 167 |
|
162 | 168 | times = 0; |
163 | 169 | while(times<GlobalV::NPROC) |
164 | 170 | { |
165 | 171 | if(rank==times) |
166 | 172 | { |
167 | | - if ( system( command1.c_str() ) == 0 ) |
| 173 | + int ret = mkdir(PARAM.globalv.global_wfc_dir.c_str(), 0755); |
| 174 | + if ( ret == 0 || errno == EEXIST ) |
168 | 175 | { |
169 | 176 | std::cout << " MAKE THE WFC DIR : " << PARAM.globalv.global_wfc_dir << std::endl; |
170 | 177 | make_dir_wfc = 1; |
@@ -196,14 +203,15 @@ void ModuleBase::Global_File::make_dir_out( |
196 | 203 | if(PARAM.inp.of_ml_gene_data == 1) |
197 | 204 | { |
198 | 205 | int make_dir_descrip = 0; |
199 | | - std::string command1 = "test -d " + PARAM.globalv.global_mlkedf_descriptor_dir + " || mkdir " + PARAM.globalv.global_mlkedf_descriptor_dir; |
| 206 | + //std::string command1 = "test -d " + PARAM.globalv.global_mlkedf_descriptor_dir + " || mkdir " + PARAM.globalv.global_mlkedf_descriptor_dir; |
200 | 207 |
|
201 | 208 | times = 0; |
202 | 209 | while(times<GlobalV::NPROC) |
203 | 210 | { |
204 | 211 | if(rank==times) |
205 | 212 | { |
206 | | - if ( system( command1.c_str() ) == 0 ) |
| 213 | + int ret = mkdir(PARAM.globalv.global_mlkedf_descriptor_dir.c_str(), 0755); |
| 214 | + if ( ret == 0 || errno == EEXIST ) |
207 | 215 | { |
208 | 216 | std::cout << " MAKE THE MLKEDF DESCRIPTOR DIR : " << PARAM.globalv.global_mlkedf_descriptor_dir << std::endl; |
209 | 217 | make_dir_descrip = 1; |
@@ -237,14 +245,15 @@ void ModuleBase::Global_File::make_dir_out( |
237 | 245 | if(PARAM.inp.deepks_out_freq_elec > 0) |
238 | 246 | { |
239 | 247 | int make_dir_deepks_elec = 0; |
240 | | - std::string command1 = "test -d " + PARAM.globalv.global_deepks_label_elec_dir + " || mkdir " + PARAM.globalv.global_deepks_label_elec_dir; |
| 248 | + //std::string command1 = "test -d " + PARAM.globalv.global_deepks_label_elec_dir + " || mkdir " + PARAM.globalv.global_deepks_label_elec_dir; |
241 | 249 |
|
242 | 250 | times = 0; |
243 | 251 | while(times<GlobalV::NPROC) |
244 | 252 | { |
245 | 253 | if(rank==times) |
246 | 254 | { |
247 | | - if ( system( command1.c_str() ) == 0 ) |
| 255 | + int ret = mkdir(PARAM.globalv.global_deepks_label_elec_dir.c_str(), 0755); |
| 256 | + if ( ret == 0 || errno == EEXIST ) |
248 | 257 | { |
249 | 258 | std::cout << " MAKE THE DEEPKS LABELS (ELEC) DIR : " << PARAM.globalv.global_deepks_label_elec_dir << std::endl; |
250 | 259 | make_dir_deepks_elec = 1; |
|
0 commit comments