real *w_rls = nullptr;
int m, i, d, frame, outframe, natoms, nout, ncent, newstep = 0, model_nr;
#define SKIP 10
- t_topology top;
+ t_topology *top = nullptr;
gmx_mtop_t *mtop = nullptr;
gmx_conect gc = nullptr;
int ePBC = -1;
if (bTPS)
{
- read_tps_conf(top_file, &top, &ePBC, &xp, nullptr, top_box,
+ snew(top, 1);
+ read_tps_conf(top_file, top, &ePBC, &xp, nullptr, top_box,
bReset || bPBCcomRes);
- std::strncpy(top_title, *top.name, 255);
+ std::strncpy(top_title, *top->name, 255);
top_title[255] = '\0';
- atoms = &top.atoms;
+ atoms = &top->atoms;
- if (0 == top.mols.nr && (bCluster || bPBCcomMol))
+ if (0 == top->mols.nr && (bCluster || bPBCcomMol))
{
gmx_fatal(FARGS, "Option -pbc %s requires a .tpr file for the -s option", pbc_opt[pbc_enum]);
}
if (bCONECT)
{
- gc = gmx_conect_generate(&top);
+ gc = gmx_conect_generate(top);
}
if (bRmPBC)
{
- gpbc = gmx_rmpbc_init(&top.idef, ePBC, top.atoms.nr);
+ gpbc = gmx_rmpbc_init(&top->idef, ePBC, top->atoms.nr);
}
}
store original location (to put structure back) */
if (bRmPBC)
{
- gmx_rmpbc(gpbc, top.atoms.nr, top_box, xp);
+ gmx_rmpbc(gpbc, top->atoms.nr, top_box, xp);
}
copy_rvec(xp[index[0]], x_shift);
reset_x_ndim(nfitdim, ifit, ind_fit, atoms->nr, nullptr, xp, w_rls);
}
else if (bCluster)
{
- calc_pbc_cluster(ecenter, ifit, &top, ePBC, fr.x, ind_fit, fr.box);
+ calc_pbc_cluster(ecenter, ifit, top, ePBC, fr.x, ind_fit, fr.box);
}
if (bPFit)
if (bPBCcomMol)
{
put_molecule_com_in_box(unitcell_enum, ecenter,
- &top.mols,
+ &top->mols,
natoms, atoms->atom, ePBC, fr.box, fr.x);
}
/* Copy the input trxframe struct to the output trxframe struct */
}
sfree(mtop);
- done_top(&top);
+ if (top)
+ {
+ done_top(top);
+ sfree(top);
+ }
sfree(xp);
sfree(xmem);
sfree(vmem);
TrjconvWithIndexGroupSubset,
::testing::ValuesIn(trajectoryFileNames));
+class TrjconvWithoutTopologyFile : public gmx::test::CommandLineTestBase,
+ public ::testing::WithParamInterface<const char *>
+{
+ public:
+ void runTest(const char *fileName)
+ {
+ auto &cmdline = commandLine();
+
+ setInputFile("-f", fileName);
+ setInputFile("-n", "spc2.ndx");
+ setOutputFile("-o", "spc-traj.trr", gmx::test::NoTextMatch());
+
+ gmx::test::StdioTestHelper stdioHelper(&fileManager());
+ stdioHelper.redirectStringToStdin("SecondWaterMolecule\n");
+
+ /* As mentioned above, the tests don't check much besides
+ * that trjconv does not crash.
+ */
+ ASSERT_EQ(0, gmx_trjconv(cmdline.argc(), cmdline.argv()));
+ }
+};
+
+TEST_P(TrjconvWithoutTopologyFile, WithDifferentInputFormats)
+{
+ runTest(GetParam());
+}
+
+INSTANTIATE_TEST_CASE_P(NoFatalErrorWhenWritingFrom,
+ TrjconvWithoutTopologyFile,
+ ::testing::ValuesIn(trajectoryFileNames));
} // namespace