Disallow extracting V/F from XTC files in g_traj
authorErik Lindahl <erik@kth.se>
Fri, 20 Jun 2014 15:52:51 +0000 (17:52 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Mon, 23 Jun 2014 11:50:09 +0000 (13:50 +0200)
We now issue a fatal error if the user asks for velocities or
forces to be written to as output from g_traj when the input
XTC file does not contain these quantities.

Fixes #1298.

Change-Id: I45a12fb1e5db5b2b2e1b072444e5430373fbaaa3

src/gromacs/gmxana/gmx_traj.c

index 29f1bd49c329cd940e231d8f4181ddc5ae78e680..6f26469d7c45b8ede4fb2de984b86cea0c4b7c4f 100644 (file)
@@ -904,6 +904,12 @@ int gmx_traj(int argc, char *argv[])
 
     read_first_frame(oenv, &status, ftp2fn(efTRX, NFILE, fnm), &fr, flags);
 
+
+    if ((bOV || bOF) && fn2ftp(ftp2fn(efTRX, NFILE, fnm)) == efXTC)
+    {
+        gmx_fatal(FARGS, "Cannot extract velocities or forces since your input XTC file does not contain them.");
+    }
+
     if (bCV || bCF)
     {
         snew(sumx, fr.natoms);