@@ -175,8 +175,13 @@ void OutHDF5::initialize()
175175 //
176176 if (directory) {
177177 std::ostringstream dname;
178- dname << outdir
179- << filename << " _" << setw (5 ) << setfill (' 0' ) << nbeg;
178+
179+ if (chkpt)
180+ dname << outdir
181+ << " checkpoint_" << runtag;
182+ else
183+ dname << outdir
184+ << filename << " _" << setw (5 ) << setfill (' 0' ) << nbeg;
180185
181186 std::filesystem::path dir_path = dname.str ();
182187
@@ -187,9 +192,14 @@ void OutHDF5::initialize()
187192 }
188193 else {
189194 std::ostringstream fname;
190- fname << outdir
191- << filename << " _" << setw (5 ) << setfill (' 0' ) << nbeg
192- << " .1" ;
195+
196+ if (chkpt)
197+ fname << outdir
198+ << " checkpoint_" << runtag << " .1" ;
199+ else
200+ fname << outdir
201+ << filename << " _" << setw (5 ) << setfill (' 0' ) << nbeg
202+ << " .1" ;
193203
194204 std::filesystem::path file_path = fname.str ();
195205
@@ -200,31 +210,37 @@ void OutHDF5::initialize()
200210
201211 // Find starting index
202212 //
203- for (; nbeg<100000 ; nbeg++) {
204- // Path name
205- //
206- std::ostringstream fname;
207- fname << outdir
208- << filename << " _" << setw (5 ) << setfill (' 0' ) << nbeg;
209-
210- if (not directory) fname << " .1" ;
211-
212- std::filesystem::path path = fname.str ();
213-
214- // See if we can open the directory or file
215- //
216- if (directory) {
217- if (not std::filesystem::is_directory (path)) break ;
218- } else
219- if (not std::filesystem::is_regular_file (path)) break ;
213+ if (not chkpt) {
214+ for (; nbeg<100000 ; nbeg++) {
215+ // Path name
216+ //
217+ std::ostringstream fname;
218+ if (chkpt)
219+ fname << outdir
220+ << " checkpoint_" << runtag;
221+ else
222+ fname << outdir
223+ << filename << " _" << setw (5 ) << setfill (' 0' ) << nbeg;
224+
225+ if (not directory) fname << " .1" ;
226+
227+ std::filesystem::path path = fname.str ();
228+
229+ // See if we can open the directory or file
230+ //
231+ if (directory) {
232+ if (not std::filesystem::is_directory (path)) break ;
233+ } else
234+ if (not std::filesystem::is_regular_file (path)) break ;
235+ }
236+
237+ std::cout << " ---- OutHDF5: found last file <" << nbeg << " >" << std::endl;
220238 }
221239
222- std::cout << " ---- OutHDF5: found last file <" << nbeg << " >" << std::endl;
240+ // Communicate starting file index to all nodes
241+ //
242+ MPI_Bcast (&nbeg, 1 , MPI_INT, 0 , MPI_COMM_WORLD);
223243 }
224-
225- // Communicate starting file index to all nodes
226- //
227- MPI_Bcast (&nbeg, 1 , MPI_INT, 0 , MPI_COMM_WORLD);
228244 }
229245
230246 return ;
0 commit comments