Fold an angle in degrees to the canonical residue [0,360).
(Fortran mod returns the sign of the argument, so a negative
polynomial value needs the +360 canonicalisation.)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | x |
pure function wrap360(x) result(y) !! Fold an angle in degrees to the canonical residue [0,360). !! (Fortran `mod` returns the sign of the argument, so a negative !! polynomial value needs the +360 canonicalisation.) real(wp), intent(in) :: x real(wp) :: y y = mod(x, 360.0_wp) if (y < 0.0_wp) y = y + 360.0_wp end function wrap360