btree_node_find_ge_pos_i8_sp2d Subroutine

private subroutine btree_node_find_ge_pos_i8_sp2d(keys, key, position, filled)

Arguments

TypeIntentOptionalAttributesName
integer(kind=keyt), DIMENSION(:):: keys
integer(kind=keyt), intent(in) :: key
integer, intent(out) :: position
integer, intent(in) :: filled

Contents


Source Code

      SUBROUTINE btree_node_find_ge_pos_i8_sp2d (keys, key, position, filled)
         INTEGER(KIND=keyt), DIMENSION(:) :: keys
         INTEGER(KIND=keyt), INTENT(IN) :: key
         INTEGER, INTENT(OUT) :: position
         INTEGER, INTENT(IN) :: filled
         INTEGER :: left, right
         !
         IF (keys(1) .GE. key) THEN
            position = 1
            RETURN
         END IF
         IF (keys(filled) .LT. key) THEN
            position = filled + 1
            RETURN
         END IF
         left = 2
         right = filled
         position = MAX(ISHFT(left + right, -1), left)
         DO WHILE (left .LE. right)
            IF (keys(position) .GE. key .AND. keys(position - 1) .LT. key) THEN
               RETURN
            END IF
            IF (keys(position) .GE. key) right = MIN(position, right - 1)
            IF (keys(position) .LT. key) left = MAX(position, left + 1)
            position = MAX(ISHFT(left + right, -1), left)
         END DO
      END SUBROUTINE btree_node_find_ge_pos_i8_sp2d