From 6a442e1df43f1f029ae0387b6b4e3330e62f6719 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Tue, 21 Dec 2021 14:05:16 -0700 Subject: [PATCH] use compute_time() func in xyz output --- src/COMPRESS/dump_xyz_gz.cpp | 9 +++------ src/COMPRESS/dump_xyz_zstd.cpp | 9 +++------ src/dump.cpp | 1 + src/dump_xyz.cpp | 10 ++++------ 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/COMPRESS/dump_xyz_gz.cpp b/src/COMPRESS/dump_xyz_gz.cpp index a43a27ca7d..f017cb3b3e 100644 --- a/src/COMPRESS/dump_xyz_gz.cpp +++ b/src/COMPRESS/dump_xyz_gz.cpp @@ -94,14 +94,11 @@ void DumpXYZGZ::write_header(bigint ndump) { if (me == 0) { std::string header = fmt::format("{}\n", ndump); - if (time_flag) { - double tcurrent = update->atime + - (update->ntimestep-update->atimestep) + update->dt; + if (time_flag) fprintf(fp,"Atoms. Timestep: " BIGINT_FORMAT " Time: %f\n", - update->ntimestep, tcurrent); - } else { + update->ntimestep, compute_time()); + 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 e955a0e3ba..46833f3c74 100644 --- a/src/COMPRESS/dump_xyz_zstd.cpp +++ b/src/COMPRESS/dump_xyz_zstd.cpp @@ -102,14 +102,11 @@ void DumpXYZZstd::write_header(bigint ndump) { if (me == 0) { std::string header = fmt::format("{}\n", ndump); - if (time_flag) { - double tcurrent = update->atime + - (update->ntimestep-update->atimestep) + update->dt; + if (time_flag) fprintf(fp,"Atoms. Timestep: " BIGINT_FORMAT " Time: %f\n", - update->ntimestep, tcurrent); - } else { + update->ntimestep, compute_time()); + else fprintf(fp,"Atoms. Timestep: " BIGINT_FORMAT "\n",update->ntimestep); - } writer.write(header.c_str(), header.length()); } } diff --git a/src/dump.cpp b/src/dump.cpp index df39f3738d..0f338e99b5 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -1132,6 +1132,7 @@ double Dump::compute_time() { return update->atime + (update->ntimestep - update->atimestep)*update->dt; } + /* ---------------------------------------------------------------------- return # of bytes of allocated memory ------------------------------------------------------------------------- */ diff --git a/src/dump_xyz.cpp b/src/dump_xyz.cpp index 26e84d145d..9943dd57a6 100644 --- a/src/dump_xyz.cpp +++ b/src/dump_xyz.cpp @@ -131,14 +131,12 @@ void DumpXYZ::write_header(bigint n) { if (me == 0) { fprintf(fp,BIGINT_FORMAT "\n",n); - if (time_flag) { - double tcurrent = update->atime + - (update->ntimestep-update->atimestep) + update->dt; + if (time_flag) fprintf(fp,"Atoms. Timestep: " BIGINT_FORMAT " Time: %f\n", - update->ntimestep, tcurrent); - } else { + update->ntimestep, compute_time()); + else fprintf(fp,"Atoms. Timestep: " BIGINT_FORMAT "\n",update->ntimestep); - } + } } }