From 2a1052e2c66dcd3540fb56b573fc6eb0f7e01042 Mon Sep 17 00:00:00 2001 From: David van der Spoel Date: Fri, 8 Jul 2016 14:12:27 +0200 Subject: [PATCH] Introduce fatal error for too few frames in gmx dos. To prevent gmx dos from crashing with an incomprehensible error message when there are too few frames, test for this. Part of #1813 Change-Id: Ie2f23d68cb3d4570944c4ade5ced49873dc98a29 --- src/gromacs/gmxana/gmx_dos.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/gromacs/gmxana/gmx_dos.c b/src/gromacs/gmxana/gmx_dos.c index d67ac344f1..3db2d450ff 100644 --- a/src/gromacs/gmxana/gmx_dos.c +++ b/src/gromacs/gmxana/gmx_dos.c @@ -288,9 +288,10 @@ int gmx_dos(int argc, char *argv[]) double invNormalize; gmx_bool normalizeAutocorrelation; - static gmx_bool bVerbose = TRUE, bAbsolute = FALSE, bNormalizeDos = FALSE; - static gmx_bool bRecip = FALSE; - static real Temp = 298.15, toler = 1e-6; + static gmx_bool bVerbose = TRUE, bAbsolute = FALSE, bNormalizeDos = FALSE; + static gmx_bool bRecip = FALSE; + static real Temp = 298.15, toler = 1e-6; + int min_frames = 100; t_pargs pa[] = { { "-v", FALSE, etBOOL, {&bVerbose}, @@ -401,6 +402,10 @@ int gmx_dos(int argc, char *argv[]) close_trj(status); + if (nframes < min_frames) + { + gmx_fatal(FARGS, "You need at least %d frames in the trajectory and you only have %d.", min_frames, nframes); + } dt = (t1-t0)/(nframes-1); if (nV > 0) { -- 2.11.4.GIT