diff --git a/src/COMPRESS/dump_xyz_gz.cpp b/src/COMPRESS/dump_xyz_gz.cpp index cec32090cb..9b8fa16339 100644 --- a/src/COMPRESS/dump_xyz_gz.cpp +++ b/src/COMPRESS/dump_xyz_gz.cpp @@ -93,12 +93,11 @@ void DumpXYZGZ::openfile() void DumpXYZGZ::write_header(bigint ndump) { if (me == 0) { - std::string header = fmt::format("{}\n", ndump); - if (time_flag) - header += fmt::format("Atoms. Timestep: {} Time: {:.6f}\n", - update->ntimestep, update->atime); - else - header += fmt::format("Atoms. Timestep: {}\n", update->ntimestep); + auto header = fmt::format("{}\n", ndump); + if (time_flag) { + double tcurrent = update->atime + (update->ntimestep-update->atimestep) + update->dt; + header += fmt::format("Atoms. Timestep: {} Time: {:.6f}\n", update->ntimestep, tcurrent); + } else header += fmt::format("Atoms. Timestep: {}\n", update->ntimestep); writer.write(header.c_str(), header.length()); } } diff --git a/src/COMPRESS/dump_xyz_zstd.cpp b/src/COMPRESS/dump_xyz_zstd.cpp index 24d31fe671..0138e89e01 100644 --- a/src/COMPRESS/dump_xyz_zstd.cpp +++ b/src/COMPRESS/dump_xyz_zstd.cpp @@ -96,15 +96,16 @@ void DumpXYZZstd::openfile() if (multifile) delete[] filecurrent; } +/* ---------------------------------------------------------------------- */ + void DumpXYZZstd::write_header(bigint ndump) { if (me == 0) { - std::string header = fmt::format("{}\n", ndump); - if (time_flag) - header += fmt::format("Atoms. Timestep: {} Time: {:.6f}\n", - update->ntimestep, update->atime); - else - header += fmt::format("Atoms. Timestep: {}\n", update->ntimestep); + auto header = fmt::format("{}\n", ndump); + if (time_flag && (update->whichflag == 1)) { + double tcurrent = update->atime + (update->ntimestep-update->atimestep) + update->dt; + header += fmt::format("Atoms. Timestep: {} Time: {:.6f}\n", update->ntimestep, tcurrent); + } else header += fmt::format("Atoms. Timestep: {}\n", update->ntimestep); writer.write(header.c_str(), header.length()); } } diff --git a/src/dump_xyz.cpp b/src/dump_xyz.cpp index cb0a73eb81..c554593b69 100644 --- a/src/dump_xyz.cpp +++ b/src/dump_xyz.cpp @@ -130,10 +130,10 @@ int DumpXYZ::modify_param(int narg, char **arg) void DumpXYZ::write_header(bigint n) { if (me == 0) { - if (time_flag && (update->whichflag == 1)) - fmt::print(fp,"{}\n Atoms. Timestep: {} Time: {:.6f}\n", update->ntimestep, update->atime); - else - fmt::print(fp,"{}\n Atoms. Timestep: {}\n", update->ntimestep); + if (time_flag && (update->whichflag == 1)) { + double tcurrent = update->atime + (update->ntimestep-update->atimestep) + update->dt; + fmt::print(fp,"{}\n Atoms. Timestep: {} Time: {:.6f}\n", n, update->ntimestep, tcurrent); + } else fmt::print(fp,"{}\n Atoms. Timestep: {}\n", n, update->ntimestep); } }