Compute y - x. x and y must both lie in [-180, 180]. The result is equivalent to computing the difference exactly, reducing it to (-180, 180] and rounding the result. Note that this prescription allows -180 to be returned (e.g., if x is tiny and negative and y = 180). The error in the difference is returned in e
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x | |||
real(kind=wp), | intent(in) | :: | y | |||
real(kind=wp), | intent(out) | :: | e |
real(wp) function AngDiff(x, y, e) real(wp),intent(in) :: x, y real(wp),intent(out) :: e real(wp) d, t d = sumx(remx(-x, 360.0_wp), remx(y, 360.0_wp), t) d = sumx(remx(d, 360.0_wp), t, e) if (d == 0 .or. abs(d) == 180) then if (e == 0) then d = sign(d, y - x) else d = sign(d, -e) end if end if AngDiff = d end function AngDiff