-int xdr_xtc_seek_time(real time, FILE *fp, XDR *xdrs, int natoms)
+int xdr_xtc_seek_time(real time, FILE *fp, XDR *xdrs, int natoms,gmx_bool bSeekForwardOnly)
{
float t;
float dt;
int res;
int dt_sign = 0;
+ if (bSeekForwardOnly)
+ {
+ low = gmx_ftell(fp);
+ }
if (gmx_fseek(fp,0,SEEK_END))
{
return -1;
/* round to int */
high /= XDR_INT_SIZE;
high *= XDR_INT_SIZE;
- offset = ((high / 2) / XDR_INT_SIZE) * XDR_INT_SIZE;
+ offset = (((high-low) / 2) / XDR_INT_SIZE) * XDR_INT_SIZE;
if (gmx_fseek(fp,offset,SEEK_SET))
{