subroutine find_switches_stepvector(csf_i, ind, lower, upper)
! same as above but using the already calculated stepvector
type(CSF_Info_t), intent(in) :: csf_i
integer, intent(in) :: ind
integer, intent(out) :: lower, upper
character(*), parameter :: this_routine = "find_switches_stepvector"
integer :: switch, i
! set defaults
lower = 1
upper = nSpatOrbs
if (csf_i%stepvector(ind) == 1) then
switch = 2
else if (csf_i%stepvector(ind) == 2) then
switch = 1
else
! wrong input!
call stop_all(this_routine, "wrong input! stepvalue /= {1,2}!")
end if
do i = ind - 1, 2, -1
if (csf_i%stepvector(i) == switch) then
lower = i
exit
end if
end do
do i = ind + 1, nSpatOrbs - 1
if (csf_i%stepvector(i) == switch) then
upper = i
exit
end if
end do
end subroutine find_switches_stepvector