*
* 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) 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.
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "gmxpre.h"
-#include <string.h>
#include <math.h>
-#include "macros.h"
-#include "sysstuff.h"
-#include "smalloc.h"
-#include "typedefs.h"
+#include <stdlib.h>
+#include <string.h>
+
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/utility/smalloc.h"
+#include "gromacs/legacyheaders/typedefs.h"
#include "gromacs/fileio/gmxfio.h"
#include "gromacs/fileio/tpxio.h"
#include "gromacs/fileio/trxio.h"
#include "gromacs/fileio/trnio.h"
+#include "gromacs/fileio/tngio.h"
+#include "gromacs/fileio/tngio_for_tools.h"
#include "gromacs/commandline/pargs.h"
-#include "gromacs/fileio/futil.h"
+#include "gromacs/utility/futil.h"
#include "gromacs/fileio/pdbio.h"
#include "gromacs/fileio/confio.h"
-#include "names.h"
-#include "index.h"
-#include "vec.h"
+#include "gromacs/legacyheaders/names.h"
+#include "gromacs/topology/index.h"
+#include "gromacs/math/vec.h"
#include "gromacs/fileio/xtcio.h"
-#include "do_fit.h"
-#include "rmpbc.h"
-#include "gromacs/fileio/g87io.h"
-#include "pbc.h"
-#include "xvgr.h"
-#include "gromacs/fileio/xdrf.h"
+#include "gromacs/fileio/xvgr.h"
#include "gmx_ana.h"
+#include "gromacs/utility/fatalerror.h"
+
#define TIME_EXPLICIT 0
#define TIME_CONTINUE 1
#define TIME_LAST 2
};
#define npargs asize(pa)
int ftpin, i, frame, frame_out, step = 0, trjout = 0;
- t_trxstatus *status;
+ t_trxstatus *status, *trxout = NULL;
rvec *x, *v;
real t_corr;
t_trxframe fr, frout;
char **fnms, **fnms_out, *in_file, *out_file;
int n_append;
- t_trxstatus *trxout = NULL;
gmx_bool bNewFile, bIndex, bWrite;
int earliersteps, nfile_in, nfile_out, *cont_type, last_ok_step;
real *readtime, *timest, *settime;
atom_id *index = NULL, imax;
char *grpname;
real **val = NULL, *t = NULL, dt_remd;
- int n, nset;
+ int n, nset, ftpout = -1, prevEndStep = 0, filetype;
gmx_bool bOK;
gmx_off_t fpos;
output_env_t oenv;
#define NFILE asize(fnm)
- if (!parse_common_args(&argc, argv, PCA_BE_NICE | PCA_TIME_UNIT, NFILE, fnm,
+ if (!parse_common_args(&argc, argv, PCA_TIME_UNIT, NFILE, fnm,
asize(pa), pa, asize(desc), desc, 0, NULL, &oenv))
{
return 0;
gmx_fatal(FARGS, "You have specified %d files and %d entries in the demux table", nfile_in, nset);
}
+ ftpin = fn2ftp(fnms[0]);
+
+ for (i = 1; i < nfile_in; i++)
+ {
+ if (ftpin != fn2ftp(fnms[i]))
+ {
+ gmx_fatal(FARGS, "All input files must be of the same format");
+ }
+ }
+
nfile_out = opt2fns(&fnms_out, "-o", NFILE, fnm);
if (!nfile_out)
{
{
if (nfile_out != nset)
{
- char *buf = strdup(fnms_out[0]);
+ char *buf = gmx_strdup(fnms_out[0]);
snew(fnms_out, nset);
for (i = 0; (i < nset); i++)
{
* This has to be done after sorting etc.
*/
out_file = fnms_out[0];
+ ftpout = fn2ftp(out_file);
n_append = -1;
for (i = 0; ((i < nfile_in) && (n_append == -1)); i++)
{
if (n_append == -1)
{
- trxout = open_trx(out_file, "w");
+ if (ftpout == efTNG)
+ {
+ if (bIndex)
+ {
+ trjtools_gmx_prepare_tng_writing(out_file, 'w', NULL, &trxout,
+ fnms[0], isize, NULL, index, grpname);
+ }
+ else
+ {
+ trjtools_gmx_prepare_tng_writing(out_file, 'w', NULL, &trxout,
+ fnms[0], -1, NULL, NULL, NULL);
+ }
+ }
+ else
+ {
+ trxout = open_trx(out_file, "w");
+ }
memset(&frout, 0, sizeof(frout));
}
else
"If the trajectories have an overlap and have not been written binary \n"
"reproducible this will produce an incorrect trajectory!\n\n");
+ filetype = gmx_fio_getftp(stfio);
/* Fails if last frame is incomplete
* We can't do anything about it without overwriting
* */
- if (gmx_fio_getftp(stfio) == 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." );
- }
+ 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)
/* set the next time from the last frame in previous file */
if (i > 0)
{
+ /* When writing TNG the step determine which frame to write. Use an
+ * offset to be able to increase steps properly when changing files. */
+ if (ftpout == efTNG)
+ {
+ prevEndStep = frout.step;
+ }
+
if (frame_out >= 0)
{
if (cont_type[i] == TIME_CONTINUE)
frout = fr;
/* set the new time by adding the correct calculated above */
frout.time += t_corr;
+ if (ftpout == efTNG)
+ {
+ frout.step += prevEndStep;
+ }
/* quit if we have reached the end of what should be written */
if ((end > 0) && (frout.time > end+GMX_REAL_EPS))
{