added check to prevent indices greater than mxdtopo or mydtopo in the event of eps rounding error