From dc102ab09741698e002c93970c789363836fbcbc Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Mon, 21 May 2018 17:13:56 +0200
Subject: [PATCH] Added error when using xdr/xtc files without xdrfile library

---
 src/generic/DumpAtoms.cpp | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/generic/DumpAtoms.cpp b/src/generic/DumpAtoms.cpp
index 83da27d1e..866d8b06b 100644
--- a/src/generic/DumpAtoms.cpp
+++ b/src/generic/DumpAtoms.cpp
@@ -153,11 +153,7 @@ DumpAtoms::DumpAtoms(const ActionOptions&ao):
   if(file.length()==0) error("name out output file was not specified");
   type=Tools::extension(file);
   log<<"  file name "<<file<<"\n";
-  if(type=="gro" || type=="xyz"
-#ifdef __PLUMED_HAS_XDRFILE
-      || type=="xtc" || type=="trr"
-#endif
-    ) {
+  if(type=="gro" || type=="xyz" || type=="xtc" || type=="trr") {
     log<<"  file extension indicates a "<<type<<" file\n";
   } else {
     log<<"  file extension not detected, assuming xyz\n";
@@ -166,14 +162,14 @@ DumpAtoms::DumpAtoms(const ActionOptions&ao):
   string ntype;
   parse("TYPE",ntype);
   if(ntype.length()>0) {
-    if(ntype!="xyz" && ntype!="gro"
-#ifdef __PLUMED_HAS_XDRFILE
-        && ntype!="xtc" && ntype!="trr"
-#endif
+    if(ntype!="xyz" && ntype!="gro" && ntype!="xtc" && ntype!="trr"
       ) error("TYPE cannot be understood");
     log<<"  file type enforced to be "<<ntype<<"\n";
     type=ntype;
   }
+#ifndef __PLUMED_HAS_XDRFILE
+  if(type=="xtc" || type=="trr") error("types xtc and trr require PLUMED to be linked with the xdrfile library. Please install it and recompile PLUMED.");
+#endif
 
   fmt_gro_pos="%8.3f";
   fmt_gro_box="%12.7f";
-- 
GitLab