Non-integer exponent only. For integer exponents
(a**2, a**3, …), write the multiplication out — the
compiler unrolls those and they’re already deterministic.
Plain elemental inline around the intrinsic; see safe_exp
and the module docstring.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | base | |||
| real(kind=wp), | intent(in) | :: | exponent |
elemental function safe_pow(base, exponent) result(y) !! Non-integer exponent only. For integer exponents !! (`a**2`, `a**3`, ...), write the multiplication out — the !! compiler unrolls those and they're already deterministic. !! Plain elemental inline around the intrinsic; see `safe_exp` !! and the module docstring. real(wp), intent(in) :: base real(wp), intent(in) :: exponent real(wp) :: y y = base**exponent end function safe_pow