diff --git a/.gitignore b/.gitignore index 319d66928..9f36e853c 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ src/exp src/user/CylindricalDisk.cc src/user/EllipsoidForce.cc src/user/SLSphere.cc +_codeql_detected_source_root diff --git a/src/OutHDF5.cc b/src/OutHDF5.cc index 9c28459ed..b60db5583 100644 --- a/src/OutHDF5.cc +++ b/src/OutHDF5.cc @@ -175,8 +175,13 @@ void OutHDF5::initialize() // if (directory) { std::ostringstream dname; - dname << outdir - << filename << "_" << setw(5) << setfill('0') << nbeg; + + if (chkpt) + dname << outdir + << "checkpoint_" << runtag; + else + dname << outdir + << filename << "_" << setw(5) << setfill('0') << nbeg; std::filesystem::path dir_path = dname.str(); @@ -187,9 +192,16 @@ void OutHDF5::initialize() } else { std::ostringstream fname; - fname << outdir - << filename << "_" << setw(5) << setfill('0') << nbeg - << ".1"; + + if (chkpt) { + fname << outdir + << "checkpoint_" << runtag; + if (numprocs>1) fname << ".1"; + } else { + fname << outdir + << filename << "_" << setw(5) << setfill('0') << nbeg + << ".1"; + } std::filesystem::path file_path = fname.str(); @@ -200,31 +212,35 @@ void OutHDF5::initialize() // Find starting index // - for (; nbeg<100000; nbeg++) { - // Path name - // - std::ostringstream fname; - fname << outdir - << filename << "_" << setw(5) << setfill('0') << nbeg; - - if (not directory) fname << ".1"; - - std::filesystem::path path = fname.str(); - - // See if we can open the directory or file - // - if (directory) { - if (not std::filesystem::is_directory(path)) break; - } else - if (not std::filesystem::is_regular_file(path)) break; + if (not chkpt) { + for (; nbeg<100000; nbeg++) { + // Path name + // + std::ostringstream fname; + fname << outdir + << filename << "_" << setw(5) << setfill('0') << nbeg; + + if (not directory) fname << ".1"; + + std::filesystem::path path = fname.str(); + + // See if we can open the directory or file + // + if (directory) { + if (not std::filesystem::is_directory(path)) break; + } else + if (not std::filesystem::is_regular_file(path)) break; + } + + std::cout << "---- OutHDF5: found last file <" << nbeg << ">" << std::endl; } - - std::cout << "---- OutHDF5: found last file <" << nbeg << ">" << std::endl; + // END: snapshot mode loop } + // END: root node read - // Communicate starting file index to all nodes + // Communicate starting file index to all nodes for snapshot mode // - MPI_Bcast(&nbeg, 1, MPI_INT, 0, MPI_COMM_WORLD); + if (not chkpt) MPI_Bcast(&nbeg, 1, MPI_INT, 0, MPI_COMM_WORLD); } return;