From 88763daec29c86112922b1ddc89801c6b77c2568 Mon Sep 17 00:00:00 2001
From: Gareth Tribello <gareth.tribello@gmail.com>
Date: Tue, 26 Mar 2013 10:00:38 +0000
Subject: [PATCH] Fixed a number of bugs that appear when the code is compiled
 without -DNDEBUG

---
 src/multicolvar/MultiColvar.h     | 2 --
 src/tools/DynamicList.h           | 7 +++++++
 src/vesselbase/ActionWithVessel.h | 4 ----
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/multicolvar/MultiColvar.h b/src/multicolvar/MultiColvar.h
index 7f2e94449..a76f3b610 100644
--- a/src/multicolvar/MultiColvar.h
+++ b/src/multicolvar/MultiColvar.h
@@ -180,7 +180,6 @@ public:
 inline
 unsigned MultiColvar::getFirstDerivativeToMerge(){
   imerge_deriv=0; imerge_natoms=atoms_with_derivatives.getNumberActive();
-  plumed_dbg_assert( colvar_atoms[current].isActive( atoms_with_derivatives[imerge_deriv] ) );
   return 3*getAtomIndex( atoms_with_derivatives[imerge_deriv] ); 
 }
 
@@ -189,7 +188,6 @@ unsigned MultiColvar::getNextDerivativeToMerge( const unsigned& j){
   imerge_deriv++; 
   if( imerge_deriv>=3*imerge_natoms ) return 3*getNumberOfAtoms() - 3*imerge_natoms + imerge_deriv;
   unsigned imerge_atom=std::floor( imerge_deriv / 3 );
-  plumed_dbg_assert( colvar_atoms[current].isActive( atoms_with_derivatives[imerge_atom] ) ); 
   return 3*getAtomIndex( imerge_atom ) + imerge_deriv%3;
 }
 
diff --git a/src/tools/DynamicList.h b/src/tools/DynamicList.h
index a31ddc406..bc4626f58 100644
--- a/src/tools/DynamicList.h
+++ b/src/tools/DynamicList.h
@@ -163,6 +163,8 @@ public:
   unsigned fullSize() const;
 /// Return the number of elements that are currently active
   unsigned getNumberActive() const;
+/// Find out if a member is active
+  bool isActive(const unsigned& ) const;
 /// Add something to the active list
   void addIndexToList( const T & ii );
 /// Make a particular element inactive
@@ -194,6 +196,11 @@ void DynamicList<T>::clear() {
   onoff.resize(0); active.resize(0);
 }
 
+template <typename T>
+bool DynamicList<T>::isActive( const unsigned& i ) const {
+  return (onoff[i]>0);
+}
+
 template <typename T>
 unsigned DynamicList<T>::fullSize() const {
   return all.size();
diff --git a/src/vesselbase/ActionWithVessel.h b/src/vesselbase/ActionWithVessel.h
index 662a21d91..0cc19c55b 100644
--- a/src/vesselbase/ActionWithVessel.h
+++ b/src/vesselbase/ActionWithVessel.h
@@ -207,10 +207,6 @@ void ActionWithVessel::addElementDerivative( const unsigned& ider, const double&
 
 inline
 void ActionWithVessel::setElementDerivative( const unsigned& ider, const double& der ){
-#ifndef NDEBUG
-  unsigned ndertmp=getNumberOfDerivatives();
-  if( ider>=ndertmp && ider<2*ndertmp ) plumed_dbg_massert( weightHasDerivatives, "In " + getLabel() );
-#endif
   plumed_dbg_assert( ider<derivatives.size() );
   derivatives[ider] = der;
 }
-- 
GitLab