search by bisection for 1D array
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | array(:,:) |
2D array to search. Only searches 1st column |
||
integer(kind=int64), | intent(out) | :: | nlow |
Index of found index |
||
real(kind=wp), | intent(in) | :: | value |
Value to find in the array. |
subroutine search_2D(array, nlow, value) !! search by bisection for 1D array !> 2D array to search. Only searches 1st column real(kind=wp), intent(in) :: array(:, :) !> Index of found index integer(kind=int64), intent(out) :: nlow !> Value to find in the array. real(kind=wp), intent(in) :: value integer :: nup, middle nup = size(array, 1) nlow = 1 middle = int((nup+nlow)/2.) do while((nup - nlow) > 1) middle = int((nup + nlow)/2.) if(value > array(middle, 1))then nlow = middle else nup = middle end if end do end subroutine search_2D