return 0;
}
-void trjtools_gmx_prepare_tng_writing(const char *filename,
- char filemode,
- t_trxstatus *in,
- t_trxstatus **out,
- const char *infile,
- const int natoms,
- const gmx_mtop_t *mtop,
- const int *index,
- const char *index_group_name)
+t_trxstatus *
+trjtools_gmx_prepare_tng_writing(const char *filename,
+ char filemode,
+ t_trxstatus *in,
+ const char *infile,
+ const int natoms,
+ const gmx_mtop_t *mtop,
+ const int *index,
+ const char *index_group_name)
{
if (filemode != 'w' && filemode != 'a')
{
gmx_incons("Sorry, can only prepare for TNG output.");
}
-
- if (*out == nullptr)
- {
- snew((*out), 1);
- }
- status_init(*out);
+ t_trxstatus *out;
+ snew(out, 1);
+ status_init(out);
if (in != nullptr)
{
gmx_prepare_tng_writing(filename,
filemode,
&in->tng,
- &(*out)->tng,
+ &out->tng,
natoms,
mtop,
index,
index_group_name);
}
- else if (efTNG == fn2ftp(infile))
+ else if ((infile) && (efTNG == fn2ftp(infile)))
{
gmx_tng_trajectory_t tng_in;
gmx_tng_open(infile, 'r', &tng_in);
gmx_prepare_tng_writing(filename,
filemode,
&tng_in,
- &(*out)->tng,
+ &out->tng,
+ natoms,
+ mtop,
+ index,
+ index_group_name);
+ }
+ else
+ {
+ // we start from a file that is not a tng file or have been unable to load the
+ // input file, so we need to populate the fields independently of it
+ gmx_prepare_tng_writing(filename,
+ filemode,
+ nullptr,
+ &out->tng,
natoms,
mtop,
index,
index_group_name);
}
+ return out;
}
void write_tng_frame(t_trxstatus *status,
* v can be NULL.
* atoms can be NULL for file types which don't need atom names.
*/
-
-void trjtools_gmx_prepare_tng_writing(const char *filename,
- char filemode,
- t_trxstatus *in,
- t_trxstatus **out,
- const char *infile,
- const int natoms,
- const struct gmx_mtop_t *mtop,
- const int *index,
- const char *index_group_name);
+t_trxstatus *
+trjtools_gmx_prepare_tng_writing(const char *filename,
+ char filemode,
+ t_trxstatus *in,
+ const char *infile,
+ const int natoms,
+ const struct gmx_mtop_t *mtop,
+ const int *index,
+ const char *index_group_name);
/* Sets up *out for writing TNG. If *in != NULL and contains a TNG trajectory
- * some data, e.g. molecule system, will be copied over from *in to *out.
+ * some data, e.g. molecule system, will be copied over from *in to the return value.
* If *in == NULL a file name (infile) of a TNG file can be provided instead
- * and used for copying data to *out.
+ * and used for copying data to the return value.
* If there is no TNG input natoms is used to create "implicit atoms" (no atom
* or molecular data present). If natoms == -1 the number of atoms are
* not known (or there is already a TNG molecule system to copy, in which case
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018, 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.
}
if (bIndex)
{
- trjtools_gmx_prepare_tng_writing(out_file, 'w', nullptr, &trxout,
- fnms[0], isize, nullptr, index, grpname);
+ trxout = trjtools_gmx_prepare_tng_writing(out_file, 'w', nullptr,
+ fnms[0], isize, nullptr, index, grpname);
}
else
{
- trjtools_gmx_prepare_tng_writing(out_file, 'w', nullptr, &trxout,
- fnms[0], -1, nullptr, nullptr, nullptr);
+ trxout = trjtools_gmx_prepare_tng_writing(out_file, 'w', nullptr,
+ fnms[0], -1, nullptr, nullptr, nullptr);
}
}
else
switch (ftp)
{
case efTNG:
- trjtools_gmx_prepare_tng_writing(out_file,
- filemode[0],
- trxin,
- &trxout,
- nullptr,
- nout,
- mtop,
- index,
- grpnm);
+ trxout = trjtools_gmx_prepare_tng_writing(out_file,
+ filemode[0],
+ trxin,
+ nullptr,
+ nout,
+ mtop,
+ index,
+ grpnm);
break;
case efXTC:
case efTRR: