Adaptive search (combination of linear and binary search) of sorted list for the smallest ix such that list(ix) >= val. On failure, returns size(list)+1
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | list(:) |
Sorted list |
||
| real(kind=dp), | intent(in) | :: | val |
Value to search for |
pure function find_index_adaptive(list, val) result(ix) real(dp), intent(in) :: list(:) !< Sorted list real(dp), intent(in) :: val !< Value to search for integer :: ix integer, parameter :: binary_search_limit = 40 if (size(list) < binary_search_limit) then ix = find_index_linear(list, val) else ix = find_index_bsearch(list, val) end if end function find_index_adaptive