#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"
static void calc_pbc_cluster(int ecenter, int nrefat, t_topology *top, int ePBC,
- rvec x[], int index[], matrix box)
+ rvec x[], const int index[], matrix box)
{
int m, i, j, j0, j1, jj, ai, aj;
int imin, jmin;
break;
}
rvec_sub(newCom, com, shift);
- if (norm2(shift))
+ if (norm2(shift) != 0.0f)
{
if (debug)
{
}
}
-static void center_x(int ecenter, rvec x[], matrix box, int n, int nc, int ci[])
+static void center_x(int ecenter, rvec x[], matrix box, int n, int nc, const int ci[])
{
int i, m, ai;
rvec cmin, cmax, box_center, dx;
{
fprintf(stderr, "Do you REALLY want to truncate this trajectory (%s) at:\n"
"frame %d, time %g, bytes %ld ??? (type YES if so)\n",
- fn, j, t, (long int)fpos);
+ fn, j, t, static_cast<long int>(fpos));
if (1 != scanf("%s", yesno))
{
gmx_fatal(FARGS, "Error reading user input");
* 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 = nullptr;
- gmx_mtop_t *mtop = nullptr;
gmx_conect gc = nullptr;
int ePBC = -1;
t_atoms *atoms = nullptr, useatoms;
/* Check for number of files disabled, as FOPEN_MAX is not the correct
* number to check for. In my linux box it is only 16.
*/
- if (0 && (clust->clust->nr > FOPEN_MAX-4))
+ if (/* DISABLES CODE */ (false))
+ //if (clust->clust->nr > FOPEN_MAX-4)
{
gmx_fatal(FARGS, "Can not open enough (%d) files to write all the"
" trajectories.\ntry splitting the index file in %d parts.\n"
/* 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) ||
if (opt2bSet("-fr", NFILE, fnm))
{
printf("Select groups of frame number indices:\n");
- rd_index(opt2fn("-fr", NFILE, fnm), 1, &nrfri, (int **)&frindex, &frname);
+ rd_index(opt2fn("-fr", NFILE, fnm), 1, &nrfri, &frindex, &frname);
if (debug)
{
for (i = 0; i < nrfri; i++)
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:
if (bSetBox)
{
/* generate new box */
- if (fr.bBox == FALSE)
+ if (!fr.bBox)
{
clear_mat(fr.box);
}
}
else
{
- if (fr.bBox == FALSE)
+ if (!fr.bBox)
{
gmx_fatal(FARGS, "Cannot preserve a box that does not exist.\n");
}
}
bWriteFrame =
- ( ( !bTDump && !frindex && frame % skip_nr == 0 ) || bDumpFrame );
+ ( ( !bTDump && (frindex == nullptr) && frame % skip_nr == 0 ) || bDumpFrame );
if (bWriteFrame && (bDropUnder || bDropOver))
{
{
frout_time = tzero + frame*timestep;
}
- else
- if (bSetTime)
+ else if (bSetTime)
{
frout_time += tshift;
}
}
if (frout.bStep)
{
- sprintf(stepstr, " step= %" GMX_PRId64, frout.step);
+ sprintf(stepstr, " step= %" PRId64, frout.step);
}
else
{
}
}
- sfree(mtop);
- if (top)
+ if (bTPS)
{
done_top(top);
sfree(top);
sfree(grpnm);
sfree(index);
sfree(cindex);
- done_filenms(NFILE, fnm);
done_frame(&fr);
do_view(oenv, out_file, nullptr);