pure function findFirstSwitch(iI, iJ, start, semi) result(orb)
! write a scratch implementation to find the first change in
! stepvector for two given CSFs. do it inefficiently for now
! improve later on
integer(n_int), intent(in) :: iI(0:GugaBits%len_tot), iJ(0:GugaBits%len_tot)
integer, intent(in) :: start, semi
integer :: orb, a, b
integer :: i
! with the fortran 2008 intrinsic funcitons it would be easy...
! for now just do a loop over double overlap region and compare
! stepvalues
! i could also use the quantity here.. or?
! if it is always called for the current looked at ilut..
! i guess it does..
! implement this with the new f2008 routines..
! i need to find the first spin-change between start and semi-1
if (start >= semi) then
orb = -1
return
end if
! make the spin_change bit-rep
! todo check if this change worked!
! ok... i have two different goals here..
! before i wanted to check for any switches.. now i only want
! spin-changes.. to i ever need anything else then spin-changes?
! ok i really only need spin-changes.. so change the testsuite
orb = -1
do i = start, semi - 1
a = getStepvalue(iI, i)
b = getStepvalue(iJ, i)
if (a /= b) then
orb = i
return
end if
end do
end function findFirstSwitch