From 13c01cf49ca0147637d4d8a7f926a8db31bb3cdc Mon Sep 17 00:00:00 2001 From: Teemu Murtola Date: Fri, 8 Jan 2016 20:47:00 +0200 Subject: [PATCH] Remove historical times from t_trxframe The fields t0 and tf were used for internal bookkeeping for trajectory reading, so moved them there. They do not provide useful information about the current trajectory frame. Similarly, gmx check will no longer repeatedly compare the t0 values for each frame. Values stored to tpf and tppf were never read, so removed the fields. Change-Id: I1554a3b64da84efba44f685cbf8eb6cffd9fac19 --- src/gromacs/fileio/trxio.cpp | 32 ++++++++++++-------------------- src/gromacs/tools/compare.cpp | 1 - src/gromacs/trajectory/trajectoryframe.h | 16 ++++------------ 3 files changed, 16 insertions(+), 33 deletions(-) diff --git a/src/gromacs/fileio/trxio.cpp b/src/gromacs/fileio/trxio.cpp index 7800431c9b..a98031cbbc 100644 --- a/src/gromacs/fileio/trxio.cpp +++ b/src/gromacs/fileio/trxio.cpp @@ -83,6 +83,9 @@ struct t_trxstatus { int __frame; + real t0; /* time of the first frame, needed * + * for skipping frames with -dt */ + real tf; /* internal frame time */ t_trxframe *xframe; int nxframe; t_fileio *fio; @@ -169,6 +172,8 @@ static void status_init(t_trxstatus *status) status->xframe = NULL; status->fio = NULL; status->__frame = -1; + status->t0 = 0; + status->tf = 0; status->persistent_line = NULL; status->tng = NULL; } @@ -291,10 +296,6 @@ void clear_trxframe(t_trxframe *fr, gmx_bool bFirst) fr->flags = 0; fr->bDouble = FALSE; fr->natoms = -1; - fr->t0 = 0; - fr->tf = 0; - fr->tpf = 0; - fr->tppf = 0; fr->title = NULL; fr->step = 0; fr->time = 0; @@ -805,13 +806,11 @@ gmx_bool read_next_frame(const gmx_output_env_t *oenv, t_trxstatus *status, t_tr int ftp; bRet = FALSE; - pt = fr->tf; + pt = status->tf; do { clear_trxframe(fr, FALSE); - fr->tppf = fr->tpf; - fr->tpf = fr->tf; if (status->tng) { @@ -842,14 +841,7 @@ gmx_bool read_next_frame(const gmx_output_env_t *oenv, t_trxstatus *status, t_tr break; } case efXTC: - /* B. Hess 2005-4-20 - * Sometimes is off by one frame - * and sometimes reports frame not present/file not seekable - */ - /* DvdS 2005-05-31: this has been fixed along with the increased - * accuracy of the control over -b and -e options. - */ - if (bTimeSet(TBEGIN) && (fr->tf < rTimeValue(TBEGIN))) + if (bTimeSet(TBEGIN) && (status->tf < rTimeValue(TBEGIN))) { if (xtc_seek_time(status->fio, rTimeValue(TBEGIN), fr->natoms, TRUE)) { @@ -890,7 +882,7 @@ gmx_bool read_next_frame(const gmx_output_env_t *oenv, t_trxstatus *status, t_tr gmx_fio_getname(status->fio)); #endif } - fr->tf = fr->time; + status->tf = fr->time; if (bRet) { @@ -900,7 +892,7 @@ gmx_bool read_next_frame(const gmx_output_env_t *oenv, t_trxstatus *status, t_tr bSkip = FALSE; if (!bMissingData) { - ct = check_times2(fr->time, fr->t0, fr->bDouble); + ct = check_times2(fr->time, status->t0, fr->bDouble); if (ct == 0 || ((fr->flags & TRX_DONT_SKIP) && ct < 0)) { printcount(status, oenv, fr->time, FALSE); @@ -1063,12 +1055,12 @@ int read_first_frame(const gmx_output_env_t *oenv, t_trxstatus **status, #endif break; } - fr->tf = fr->time; + (*status)->tf = fr->time; /* Return FALSE if we read a frame that's past the set ending time. */ if (!bFirst && (!(fr->flags & TRX_DONT_SKIP) && check_times(fr->time) > 0)) { - fr->t0 = fr->time; + (*status)->t0 = fr->time; return FALSE; } @@ -1081,7 +1073,7 @@ int read_first_frame(const gmx_output_env_t *oenv, t_trxstatus **status, return FALSE; } } - fr->t0 = fr->time; + (*status)->t0 = fr->time; /* We need the number of atoms for random-access XTC searching, even when * we don't have access to the actual frame data. diff --git a/src/gromacs/tools/compare.cpp b/src/gromacs/tools/compare.cpp index 4b3add204c..c0cb9aaad2 100644 --- a/src/gromacs/tools/compare.cpp +++ b/src/gromacs/tools/compare.cpp @@ -996,7 +996,6 @@ void comp_frame(FILE *fp, t_trxframe *fr1, t_trxframe *fr2, cmp_int(fp, "flags", -1, fr1->flags, fr2->flags); cmp_int(fp, "not_ok", -1, fr1->not_ok, fr2->not_ok); cmp_int(fp, "natoms", -1, fr1->natoms, fr2->natoms); - cmp_real(fp, "t0", -1, fr1->t0, fr2->t0, ftol, abstol); if (cmp_bool(fp, "bTitle", -1, fr1->bTitle, fr2->bTitle)) { cmp_str(fp, "title", -1, fr1->title, fr2->title); diff --git a/src/gromacs/trajectory/trajectoryframe.h b/src/gromacs/trajectory/trajectoryframe.h index 05c2b4f763..4ab75836ed 100644 --- a/src/gromacs/trajectory/trajectoryframe.h +++ b/src/gromacs/trajectory/trajectoryframe.h @@ -51,18 +51,10 @@ struct t_atoms; typedef struct t_trxframe { - int flags; /* flags for read_first/next_frame */ - int not_ok; /* integrity flags */ - gmx_bool bDouble; /* Double precision? */ - int natoms; /* number of atoms (atoms, x, v, f, index) */ - real t0; /* time of the first frame, needed * - * for skipping frames with -dt */ - real tf; /* internal frame time - DO NOT CHANGE */ - real tpf; /* time of the previous frame, not */ - /* the read, but real file frames */ - real tppf; /* time of two frames ago */ - /* tpf and tppf are needed to */ - /* correct rounding errors for -e */ + int flags; /* flags for read_first/next_frame */ + int not_ok; /* integrity flags */ + gmx_bool bDouble; /* Double precision? */ + int natoms; /* number of atoms (atoms, x, v, f, index) */ gmx_bool bTitle; const char *title; /* title of the frame */ gmx_bool bStep; -- 2.11.4.GIT