real(wp) function LatFix(x) real(wp),intent(in) :: x LatFix = x if (abs(x) > 90.0_wp) then ! concoct a NaN LatFix = sqrt(90.0_wp - abs(x)) end if end function LatFix