--- trunk/OOPSE/libmdtools/ZConstraint.cpp 2003/07/31 15:35:07 658 +++ trunk/OOPSE/libmdtools/ZConstraint.cpp 2003/07/31 19:59:34 660 @@ -33,7 +33,29 @@ template ZConstraint::ZConstraint(SimIn } else{ + indexOfAllZConsMols = index->getIndexData(); + + //the maximum value of index is the last one(we sorted the index data in SimSetup.cpp) + int maxIndex; + int totalNumMol; + + maxIndex = indexOfAllZConsMols[indexOfAllZConsMols.size() - 1]; + +#ifndef IS_MPI + totalNumMol = nMols; +#else + totalNumMol = mpiSim->getTotNmol(); +#endif + + if(maxIndex > totalNumMol - 1){ + sprintf( painCave.errMsg, + "ZConstraint error: index is out of range\n"); + painCave.isFatal = 1; + simError(); + + } + } }