SPEED
binarysearch Module Reference

Functions/Subroutines

pure recursive integer function, public binarysearch_real (vec, scal, min, max)
 

Function/Subroutine Documentation

◆ binarysearch_real()

pure recursive integer function, public binarysearch::binarysearch_real ( real*8, dimension(:), intent(in)  vec,
real*8, intent(in)  scal,
integer, intent(in), optional  min,
integer, intent(in), optional  max 
)

Definition at line 678 of file MODULES.f90.

679 ! input parameters
680 real*8, intent(in) :: vec(:)
681 real*8, intent(in) :: scal
682 integer, optional, intent(in) :: min
683 integer, optional, intent(in) :: max
684
685 ! result
686 integer :: idx
687
688 !locals
689 integer :: i
690
691 ! logic
692 if(.not.present(min)) then
693 idx = binarysearch_real(vec,scal, 1, size(vec))
694 else
695
696 i = ishft(min+max, -1)
697
698 !write(*,*) i, scal
699 !read(*,*)
700 !write(*,*) vec
701 !read(*,*)
702
703
704 if(scal >= vec(i) .and. scal < vec(i+1)) then
705 idx = i
706
707 else if( scal < vec(i) ) then
708 idx = binarysearch_real(vec,scal, min, ishft(min+max, -1) - 1)
709
710 elseif(scal > vec(i)) then
711 idx = binarysearch_real(vec,scal, ishft(min+max, -1) + 1, max)
712 end if
713 end if

References binarysearch_real().

Referenced by binarysearch_real(), and get_func_value().

Here is the call graph for this function:
Here is the caller graph for this function: