From: Roland Schulz Date: Sat, 14 Jun 2014 01:07:43 +0000 (-0400) Subject: Fix that seeking was wrong if frame time was modified X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=81d10b25fc5a4cf2c84b7975e492e2284e392b17;p=alexxy%2Fgromacs.git Fix that seeking was wrong if frame time was modified The trjconv -t0 option causes fr->time to be modified and this then causes the skipping to be incorrect. Alternative we could document that fr->time shouldn't be modified and change that trjconv makes a copy of fr before changing time. This change has the advantage it is less likely to reintroduce the problem. Fixes #1405, #1406 Change-Id: Ibd692dfecdf175450fc43f7f35b774bf4446b316 --- diff --git a/include/types/trx.h b/include/types/trx.h index 481aaffb14..82e36c908d 100644 --- a/include/types/trx.h +++ b/include/types/trx.h @@ -60,6 +60,7 @@ typedef struct trxframe int natoms; /* number of atoms (atoms, x, v, f) */ 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 */ diff --git a/src/gmxlib/trxio.c b/src/gmxlib/trxio.c index 5822627fba..e56f383cac 100644 --- a/src/gmxlib/trxio.c +++ b/src/gmxlib/trxio.c @@ -180,6 +180,7 @@ void clear_trxframe(t_trxframe *fr, gmx_bool bFirst) fr->bDouble = FALSE; fr->natoms = -1; fr->t0 = 0; + fr->tf = 0; fr->tpf = 0; fr->tppf = 0; fr->title = NULL; @@ -805,13 +806,13 @@ gmx_bool read_next_frame(const output_env_t oenv, t_trxstatus *status, t_trxfram int dummy = 0; bRet = FALSE; - pt = fr->time; + pt = fr->tf; do { clear_trxframe(fr, FALSE); fr->tppf = fr->tpf; - fr->tpf = fr->time; + fr->tpf = fr->tf; switch (gmx_fio_getftp(status->fio)) { @@ -842,7 +843,7 @@ gmx_bool read_next_frame(const output_env_t oenv, t_trxstatus *status, t_trxfram /* 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->time < rTimeValue(TBEGIN))) + if (bTimeSet(TBEGIN) && (fr->tf < rTimeValue(TBEGIN))) { if (xtc_seek_time(status->fio, rTimeValue(TBEGIN), fr->natoms, TRUE)) { @@ -880,6 +881,7 @@ gmx_bool read_next_frame(const output_env_t oenv, t_trxstatus *status, t_trxfram gmx_fio_getname(status->fio)); #endif } + fr->tf = fr->time; if (bRet) { @@ -1043,6 +1045,7 @@ int read_first_frame(const output_env_t oenv, t_trxstatus **status, #endif break; } + fr->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))