Clamp/Limit the value of x to the range of [xmin, xmax], where x, xmin, and xmax are all integers.
No check is performed to ensure xmin < xmax.
(KCW, 2025-07-16)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int32), | intent(in) | :: | x | |||
| integer(kind=int32), | intent(in) | :: | xmin | |||
| integer(kind=int32), | intent(in) | :: | xmax |
pure elemental function clamp_int32(x, xmin, xmax) result(clamp) use, intrinsic :: iso_fortran_env, only: int32 integer(int32), intent(in) :: x, xmin, xmax integer(int32) :: clamp clamp = max(min(x, xmax), xmin) end function clamp_int32