Update gridding.f90

added extra error check