候補 hit が現在の best より優先されるかを deterministic に判定する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | t | |||
| integer(kind=i32), | intent(in) | :: | elem_idx | |||
| integer(kind=i32), | intent(in) | :: | image_shift(2) | |||
| type(hit_info), | intent(in) | :: | best_hit |
pure logical function prefer_periodic_candidate(t, elem_idx, image_shift, best_hit) real(dp), intent(in) :: t integer(i32), intent(in) :: elem_idx, image_shift(2) type(hit_info), intent(in) :: best_hit real(dp) :: tol if (.not. best_hit%has_hit) then prefer_periodic_candidate = .true. return end if tol = 1.0d-12*max(1.0d0, abs(t), abs(best_hit%t)) if (t < best_hit%t - tol) then prefer_periodic_candidate = .true. return end if if (t > best_hit%t + tol) then prefer_periodic_candidate = .false. return end if if (elem_idx < best_hit%elem_idx) then prefer_periodic_candidate = .true. return end if if (elem_idx > best_hit%elem_idx) then prefer_periodic_candidate = .false. return end if if (image_shift(1) < best_hit%image_shift(1)) then prefer_periodic_candidate = .true. else if (image_shift(1) > best_hit%image_shift(1)) then prefer_periodic_candidate = .false. else prefer_periodic_candidate = image_shift(2) < best_hit%image_shift(2) end if end function prefer_periodic_candidate