module validation implicit none private public :: checkRange !genric verify range interface checkRange module procedure checkRangeReal module procedure checkRangeInteger end interface contains function checkRangeReal(n, minin, maxin, minex, maxex) result(result) real, intent(in) :: n logical :: result real, intent(in), optional :: minin, maxin, minex, maxex !inclusive min if(present(minin)) then if(n .lt. minin) then result = .false. return end if end if !exclusive min if(present(minex)) then if(n .le. minex) then result = .false. return end if end if !inclusive max if(present(maxin)) then if(n .gt. maxin) then result = .false. return end if end if !exclusive max if(present(maxex)) then if(n .ge. maxex) then result = .false. return end if end if !fall back to true result = .true. return end function function checkRangeInteger(n, minin, maxin, minex, maxex) result(result) integer, intent(in) :: n logical :: result integer, intent(in), optional :: minin, maxin, minex, maxex !inclusive min if(present(minin)) then if(n .lt. minin) then result = .false. return end if end if !exclusive min if(present(minex)) then if(n .le. minex) then result = .false. return end if end if !inclusive max if(present(maxin)) then if(n .gt. maxin) then result = .false. return end if end if !exclusive max if(present(maxex)) then if(n .ge. maxex) then result = .false. return end if end if !fall back to true result = .true. return end function end module