#include "pdbio.h"
#include "confio.h"
#include "checkpoint.h"
+#include "xdrf.h"
#include "gromacs/fileio/timecontrol.h"
return status->fio;
}
-tng_trajectory_t trx_get_tng(t_trxstatus *status)
+float trx_get_time_of_final_frame(t_trxstatus *status)
{
- return status->tng;
+ t_fileio *stfio = trx_get_fileio(status);
+ int filetype = gmx_fio_getftp(stfio);
+ int bOK;
+ float lasttime = -1;
+
+ if (filetype == efXTC)
+ {
+ lasttime =
+ xdr_xtc_get_last_frame_time(gmx_fio_getfp(stfio),
+ gmx_fio_getxdr(stfio),
+ status->xframe->natoms, &bOK);
+ if (!bOK)
+ {
+ gmx_fatal(FARGS, "Error reading last frame. Maybe seek not supported." );
+ }
+ }
+ else if (filetype == efTNG)
+ {
+ tng_trajectory_t tng = status->tng;
+ if (!tng)
+ {
+ gmx_fatal(FARGS, "Error opening TNG file.");
+ }
+ lasttime = gmx_tng_get_time_of_final_frame(tng);
+ }
+ else
+ {
+ gmx_incons("Only supported for TNG and XTC");
+ }
+ return lasttime;
}
void clear_trxframe(t_trxframe *fr, gmx_bool bFirst)
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2001-2004, The GROMACS development team.
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "pdbio.h"
#include "../legacyheaders/oenv.h"
#include "gmxfio.h"
-#include "../../external/tng_io/include/tng_io_fwd.h"
#ifdef __cplusplus
extern "C" {
t_fileio *trx_get_fileio(t_trxstatus *status);
/* get a fileio from a trxstatus */
-tng_trajectory_t trx_get_tng(t_trxstatus *status);
-/* get a tng trajectory container from a trxstatus */
+float trx_get_time_of_final_frame(t_trxstatus *status);
+/* get time of final frame. Only supported for TNG and XTC */
gmx_bool bRmod_fd(double a, double b, double c, gmx_bool bDouble);
/* Returns TRUE when (a - b) MOD c = 0, using a margin which is slightly
#include "rmpbc.h"
#include "pbc.h"
#include "xvgr.h"
-#include "gromacs/fileio/xdrf.h"
#include "gmx_ana.h"
#define TIME_EXPLICIT 0
/* Fails if last frame is incomplete
* We can't do anything about it without overwriting
* */
- if (filetype == efXTC)
+ if (filetype == efXTC || filetype == efTNG)
{
- lasttime =
- xdr_xtc_get_last_frame_time(gmx_fio_getfp(stfio),
- gmx_fio_getxdr(stfio),
- fr.natoms, &bOK);
- fr.time = lasttime;
- if (!bOK)
- {
- gmx_fatal(FARGS, "Error reading last frame. Maybe seek not supported." );
- }
- }
- else if (filetype == efTNG)
- {
- tng_trajectory_t tng = trx_get_tng(status);
- if (!tng)
- {
- gmx_fatal(FARGS, "Error opening TNG file.");
- }
- lasttime = gmx_tng_get_time_of_final_frame(tng);
+ lasttime = trx_get_time_of_final_frame(status);
fr.time = lasttime;
}
else
{
gmx_fatal(FARGS, "Overwrite only supported for XTC." );
}
- last_frame_time =
- xdr_xtc_get_last_frame_time(gmx_fio_getfp(stfio),
- gmx_fio_getxdr(stfio),
- fr.natoms, &bOK);
- if (!bOK)
- {
- gmx_fatal(FARGS, "Error reading last frame. Maybe seek not supported." );
- }
+ last_frame_time = trx_get_time_of_final_frame(status);
+
/* xtc_seek_time broken for trajectories containing only 1 or 2 frames
* or when seek time = 0 */
if (nfile_in > 1 && settime[1] < last_frame_time+timest[0]*0.5)