#include "gromacs/commandline/pargs.h"
#include "gromacs/commandline/viewit.h"
+#include "gromacs/compat/make_unique.h"
#include "gromacs/fileio/confio.h"
#include "gromacs/fileio/g96io.h"
#include "gromacs/fileio/gmxfio.h"
* molecule information will generally be present if the input TNG
* file was written by a GROMACS tool, this seems like reasonable
* behaviour. */
-static gmx_mtop_t *read_mtop_for_tng(const char *tps_file,
- const char *input_file,
- const char *output_file)
+static std::unique_ptr<gmx_mtop_t>
+read_mtop_for_tng(const char *tps_file,
+ const char *input_file,
+ const char *output_file)
{
- gmx_mtop_t *mtop = nullptr;
+ std::unique_ptr<gmx_mtop_t> mtop;
if (fn2bTPX(tps_file) &&
efTNG != fn2ftp(input_file) &&
efTNG == fn2ftp(output_file))
{
int temp_natoms = -1;
- snew(mtop, 1);
+ mtop = gmx::compat::make_unique<gmx_mtop_t>();
read_tpx(tps_file, nullptr, nullptr, &temp_natoms,
- nullptr, nullptr, mtop);
+ nullptr, nullptr, mtop.get());
}
return mtop;
int m, i, d, frame, outframe, natoms, nout, ncent, newstep = 0, model_nr;
#define SKIP 10
t_topology top;
- gmx_mtop_t *mtop = nullptr;
gmx_conect gc = nullptr;
int ePBC = -1;
t_atoms *atoms = nullptr, useatoms;
/* skipping */
if (skip_nr <= 0)
{
+ gmx_fatal(FARGS, "Argument for -skip (%d) needs to be greater or equal to 1.", skip_nr);
}
- mtop = read_mtop_for_tng(top_file, in_file, out_file);
+ std::unique_ptr<gmx_mtop_t> mtop = read_mtop_for_tng(top_file, in_file, out_file);
/* Determine whether to read a topology */
bTPS = (ftp2bSet(efTPS, NFILE, fnm) ||
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.get(),
+ index,
+ grpnm);
break;
case efXTC:
case efTRR:
}
}
- sfree(mtop);
- done_top(&top);
+ if (bTPS)
+ {
+ done_top(&top);
+ }
sfree(xp);
sfree(xmem);
sfree(vmem);
sfree(grpnm);
sfree(index);
sfree(cindex);
- done_filenms(NFILE, fnm);
done_frame(&fr);
do_view(oenv, out_file, nullptr);