diff --git a/src/gridtools/GridVessel.cpp b/src/gridtools/GridVessel.cpp index e83b371d6e6af5f03b39712f714ca927a36af950..37c550d7dfef77e635deb14fae703cf765b0bb82 100644 --- a/src/gridtools/GridVessel.cpp +++ b/src/gridtools/GridVessel.cpp @@ -95,10 +95,12 @@ void GridVessel::setBounds( const std::vector<std::string>& smin, const std::vec Tools::convert( str_min[i], min[i] ); Tools::convert( str_max[i], max[i] ); if( spacing.size()==dimension && binsin.size()==dimension ) { - double range = max[i] - min[i]; unsigned spc = std::floor( range / spacing[i]); - // This check ensures that nbins is set correctly if spacing is set the same as the number of bins - if( fabs( binsin[i]*spacing[i]-range )>epsilon ) spc += 1; - if( spc>binsin[i] ) nbin[i]=spc; else nbin[i]=binsin[i]; + if( spacing[i]==0 ) nbin[i] = binsin[i]; + else { + double range = max[i] - min[i]; nbin[i] = std::ceil( range / spacing[i]); + // This check ensures that nbins is set correctly if spacing is set the same as the number of bins + if( nbin[i]!=binsin[i] ) plumed_merror("mismatch between input spacing and input number of bins"); + } } else if( binsin.size()==dimension ) nbin[i]=binsin[i]; else if( spacing.size()==dimension ) nbin[i] = std::floor(( max[i] - min[i] ) / spacing[i]) + 1; else plumed_error();