* 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 "config.h"
+#include <assert.h>
+#include <math.h>
#include <stdio.h>
#include <string.h>
-#include <math.h>
-#include <assert.h>
-#include "main.h"
-#include "macros.h"
-#include "gromacs/commandline/pargs.h"
-#include "sysstuff.h"
-#include "txtdump.h"
-#include "gmx_fatal.h"
-#include "smalloc.h"
-#include "names.h"
-#include "txtdump.h"
-#include "gromacs/gmxpreprocess/gmxcpp.h"
-#include "checkpoint.h"
-#include "mtop_util.h"
+
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/legacyheaders/txtdump.h"
+#include "gromacs/legacyheaders/names.h"
+#include "gromacs/legacyheaders/txtdump.h"
+#include "gromacs/legacyheaders/checkpoint.h"
+#include "gromacs/topology/mtop_util.h"
#include "gromacs/fileio/xtcio.h"
#include "gromacs/fileio/enxio.h"
#include "gromacs/fileio/gmxfio.h"
#include "gromacs/fileio/tpxio.h"
#include "gromacs/fileio/trnio.h"
-#include "gromacs/fileio/futil.h"
+#include "gromacs/utility/futil.h"
+#include "gromacs/fileio/tngio.h"
#include "gromacs/fileio/tngio_for_tools.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
-#include "gromacs/linearalgebra/mtxio.h"
+#include "gromacs/commandline/pargs.h"
+#include "gromacs/fileio/mtxio.h"
+#include "gromacs/gmxpreprocess/gmxcpp.h"
#include "gromacs/linearalgebra/sparsematrix.h"
-
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/smalloc.h"
static void list_tpx(const char *fn, gmx_bool bShowNumbers, const char *mdpfn,
gmx_bool bSysTop)
close_trn(fpread);
}
-void list_xtc(const char *fn, gmx_bool bXVG)
+void list_xtc(const char *fn)
{
t_fileio *xd;
int indent;
nframe = 0;
do
{
- if (bXVG)
- {
- int i, d;
-
- fprintf(stdout, "%g", time);
- for (i = 0; i < natoms; i++)
- {
- for (d = 0; d < DIM; d++)
- {
- fprintf(stdout, " %g", x[i][d]);
- }
- }
- fprintf(stdout, "\n");
- }
- else
- {
- sprintf(buf, "%s frame %d", fn, nframe);
- indent = 0;
- indent = pr_title(stdout, indent, buf);
- pr_indent(stdout, indent);
- fprintf(stdout, "natoms=%10d step=%10d time=%12.7e prec=%10g\n",
- natoms, step, time, prec);
- pr_rvecs(stdout, indent, "box", box, DIM);
- pr_rvecs(stdout, indent, "x", x, natoms);
- }
+ sprintf(buf, "%s frame %d", fn, nframe);
+ indent = 0;
+ indent = pr_title(stdout, indent, buf);
+ pr_indent(stdout, indent);
+ fprintf(stdout, "natoms=%10d step=%10d time=%12.7e prec=%10g\n",
+ natoms, step, time, prec);
+ pr_rvecs(stdout, indent, "box", box, DIM);
+ pr_rvecs(stdout, indent, "x", x, natoms);
nframe++;
}
while (read_next_xtc(xd, natoms, &step, &time, box, x, &prec, &bOK));
close_xtc(xd);
}
-/* Callback used by list_tng_for_gmx_dump. */
-void list_tng_inner(const char *fn,
- gmx_bool bFirstFrame,
- gmx_bool bXVG,
- real *values,
- gmx_int64_t step,
- double frame_time,
- gmx_int64_t n_values_per_frame,
- gmx_int64_t n_atoms,
- real prec,
- gmx_int64_t nframe,
- char *block_name)
+/*! \brief Callback used by list_tng_for_gmx_dump. */
+static void list_tng_inner(const char *fn,
+ gmx_bool bFirstFrame,
+ real *values,
+ gmx_int64_t step,
+ double frame_time,
+ gmx_int64_t n_values_per_frame,
+ gmx_int64_t n_atoms,
+ real prec,
+ gmx_int64_t nframe,
+ char *block_name)
{
char buf[256];
int indent = 0;
- if (bXVG)
+ if (bFirstFrame)
{
- gmx_int64_t j;
- int d;
-
- if (bFirstFrame)
+ sprintf(buf, "%s frame %" GMX_PRId64, fn, nframe);
+ indent = 0;
+ indent = pr_title(stdout, indent, buf);
+ pr_indent(stdout, indent);
+ fprintf(stdout, "natoms=%10" GMX_PRId64 " step=%10" GMX_PRId64 " time=%12.7e",
+ n_atoms, step, frame_time);
+ if (prec > 0)
{
- fprintf(stdout, "%g", (real)frame_time);
- }
- for (j = 0; j < n_atoms; j++)
- {
- for (d = 0; d < DIM; d++)
- {
- fprintf(stdout, " %g", values[j * DIM + d]);
- }
+ fprintf(stdout, " prec=%10g", prec);
}
fprintf(stdout, "\n");
}
- else
+ pr_reals_of_dim(stdout, indent, block_name, values, n_atoms, n_values_per_frame);
+}
+
+static void list_tng(const char gmx_unused *fn)
+{
+#ifdef GMX_USE_TNG
+ tng_trajectory_t tng;
+ gmx_int64_t nframe = 0;
+ gmx_int64_t i, *block_ids = NULL, step, ndatablocks;
+ gmx_bool bOK;
+
+ gmx_tng_open(fn, 'r', &tng);
+ gmx_print_tng_molecule_system(tng, stdout);
+
+ bOK = gmx_get_tng_data_block_types_of_next_frame(tng, -1,
+ 0,
+ NULL,
+ &step, &ndatablocks,
+ &block_ids);
+ do
{
- if (bFirstFrame)
+ for (i = 0; i < ndatablocks; i++)
{
- sprintf(buf, "%s frame %" GMX_PRId64, fn, nframe);
- indent = 0;
- indent = pr_title(stdout, indent, buf);
- pr_indent(stdout, indent);
- fprintf(stdout, "natoms=%10" GMX_PRId64 " step=%10" GMX_PRId64 " time=%12.7e",
- n_atoms, step, frame_time);
- if (prec > 0)
+ double frame_time;
+ real prec, *values = NULL;
+ gmx_int64_t n_values_per_frame, n_atoms;
+ char block_name[STRLEN];
+
+ gmx_get_tng_data_next_frame_of_block_type(tng, block_ids[i], &values,
+ &step, &frame_time,
+ &n_values_per_frame, &n_atoms,
+ &prec,
+ block_name, STRLEN, &bOK);
+ if (!bOK)
+ {
+ /* Can't write any output because we don't know what
+ arrays are valid. */
+ fprintf(stderr, "\nWARNING: Incomplete frame at time %g, will not write output\n", frame_time);
+ }
+ else
{
- fprintf(stdout, " prec=%10g", prec);
+ list_tng_inner(fn, (0 == i), values, step, frame_time,
+ n_values_per_frame, n_atoms, prec, nframe, block_name);
}
- fprintf(stdout, "\n");
}
- pr_reals_of_dim(stdout, indent, block_name, values, n_atoms, n_values_per_frame);
+ nframe++;
+ }
+ while (gmx_get_tng_data_block_types_of_next_frame(tng, step,
+ 0,
+ NULL,
+ &step,
+ &ndatablocks,
+ &block_ids));
+
+ if (block_ids)
+ {
+ sfree(block_ids);
}
+
+ gmx_tng_close(&tng);
+#endif
}
-void list_trx(const char *fn, gmx_bool bXVG)
+void list_trx(const char *fn)
{
- int ftp;
-
- ftp = fn2ftp(fn);
- if (ftp == efXTC)
- {
- list_xtc(fn, bXVG);
- }
- else if ((ftp == efTRR) || (ftp == efTRJ))
- {
- list_trn(fn);
- }
- else if (ftp == efTNG)
- {
- list_tng_for_gmx_dump(fn, bXVG);
- }
- else
+ switch (fn2ftp(fn))
{
- fprintf(stderr, "File %s is of an unsupported type. Try using the command\n 'less %s'\n",
- fn, fn);
+ case efXTC:
+ list_xtc(fn);
+ break;
+ case efTRR:
+ list_trn(fn);
+ break;
+ case efTNG:
+ list_tng(fn);
+ break;
+ default:
+ fprintf(stderr, "File %s is of an unsupported type. Try using the command\n 'less %s'\n",
+ fn, fn);
}
}
int gmx_dump(int argc, char *argv[])
{
const char *desc[] = {
- "[THISMODULE] reads a run input file ([TT].tpa[tt]/[TT].tpr[tt]/[TT].tpb[tt]),",
- "a trajectory ([TT].trj[tt]/[TT].trr[tt]/[TT].xtc[tt]), an energy",
- "file ([TT].ene[tt]/[TT].edr[tt]), or a checkpoint file ([TT].cpt[tt])",
+ "[THISMODULE] reads a run input file ([TT].tpr[tt]),",
+ "a trajectory ([TT].trr[tt]/[TT].xtc[tt]/[TT]/tng[tt]), an energy",
+ "file ([TT].edr[tt]) or a checkpoint file ([TT].cpt[tt])",
"and prints that to standard output in a readable format.",
"This program is essential for checking your run input file in case of",
"problems.[PAR]",
"Position restraint output from -sys -s is broken"
};
t_filenm fnm[] = {
- { efTPX, "-s", NULL, ffOPTRD },
+ { efTPR, "-s", NULL, ffOPTRD },
{ efTRX, "-f", NULL, ffOPTRD },
{ efEDR, "-e", NULL, ffOPTRD },
{ efCPT, NULL, NULL, ffOPTRD },
output_env_t oenv;
/* Command line options */
- static gmx_bool bXVG = FALSE;
static gmx_bool bShowNumbers = TRUE;
static gmx_bool bSysTop = FALSE;
t_pargs pa[] = {
- { "-xvg", FALSE, etBOOL, {&bXVG}, "HIDDENXVG layout for xtc" },
{ "-nr", FALSE, etBOOL, {&bShowNumbers}, "Show index numbers in output (leaving them out makes comparison easier, but creates a useless topology)" },
{ "-sys", FALSE, etBOOL, {&bSysTop}, "List the atoms and bonded interactions for the whole system instead of for each molecule type" }
};
}
- if (ftp2bSet(efTPX, NFILE, fnm))
+ if (ftp2bSet(efTPR, NFILE, fnm))
{
- list_tpx(ftp2fn(efTPX, NFILE, fnm), bShowNumbers,
+ list_tpx(ftp2fn(efTPR, NFILE, fnm), bShowNumbers,
ftp2fn_null(efMDP, NFILE, fnm), bSysTop);
}
else if (ftp2bSet(efTRX, NFILE, fnm))
{
- list_trx(ftp2fn(efTRX, NFILE, fnm), bXVG);
+ list_trx(ftp2fn(efTRX, NFILE, fnm));
}
else if (ftp2bSet(efEDR, NFILE, fnm))
{