diff --git a/src/tools/Grid.cpp b/src/tools/Grid.cpp index aa3e00e35325f5b16ee75e8df784ff94c416049f..45bf2950ce7448205ba1b175d2708316342cc4b9 100644 --- a/src/tools/Grid.cpp +++ b/src/tools/Grid.cpp @@ -167,7 +167,11 @@ unsigned Grid::getDimension() const { // we are flattening arrays using a column-major order unsigned Grid::getIndex(const vector<unsigned> & indices) const { plumed_assert(indices.size()==dimension_); - for(unsigned int i=0;i<dimension_;i++) plumed_assert(indices[i]>=0 && indices[i]<nbin_[i]); + for(unsigned int i=0;i<dimension_;i++) + if(indices[i]<0 || indices[i]>=nbin_[i]) { + std::string msg="ERROR: the system is looking for a value outside the grid along the " + i; + plumed_merror(msg+" index!"); + } unsigned index=indices[dimension_-1]; for(unsigned int i=dimension_-1;i>0;--i){ index=index*nbin_[i-1]+indices[i-1];