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