anchor.diff:  !   !    -459.6346665282306
   ! 
   !   call wall_time(iwall)
  -!   allocate(linked(N_det_non_ref, N_det_ref), blokMwen(N_det_non_ref, N_det_ref), nlink(N_det_ref))
  +!   !allocate(linked(N_det_non_ref, N_det_ref), blokMwen(N_det_non_ref, N_det_ref), nlink(N_det_ref))
   !   
   ! 
   !   delta_ii_old(:,:) = 0d0
   !   delta_ij_old(:,:,:) = 0d0
   ! 
  -!   searchance = 0d0
  -!   do J = 1, N_det_ref
  -!     nlink(J) = 0
  -!     do blok=1,cepa0_shortcut(0)
  -!     do k=cepa0_shortcut(blok), cepa0_shortcut(blok+1)-1
  -!       call get_excitation_degree(psi_ref(1,1,J),det_cepa0(1,1,k),degree,N_int)
  -!       if(degree <= 2) then
  -!         nlink(J) += 1
  -!         linked(nlink(J),J) = k
  -!         blokMwen(nlink(J),J) = blok
  -!         searchance(J) += log(dfloat(cepa0_shortcut(blok+1) - cepa0_shortcut(blok)))
  -!       end if
  -!     end do
  -!     end do
  -!   end do
  +! !   searchance = 0d0
  +! !   do J = 1, N_det_ref
  +! !     nlink(J) = 0
  +! !     do blok=1,cepa0_shortcut(0)
  +! !     do k=cepa0_shortcut(blok), cepa0_shortcut(blok+1)-1
  +! !       call get_excitation_degree(psi_ref(1,1,J),det_cepa0(1,1,k),degree,N_int)
  +! !       if(degree <= 2) then
  +! !         nlink(J) += 1
  +! !         linked(nlink(J),J) = k
  +! !         blokMwen(nlink(J),J) = blok
  +! !         searchance(J) += log(dfloat(cepa0_shortcut(blok+1) - cepa0_shortcut(blok)))
  +! !       end if
  +! !     end do
  +! !     end do
  +! !   end do
   ! 
   !      
   ! 
  
positive.code:   
    integer                         :: i_state, i, i_I, J, k, kk, degree, degree2, m, l, deg, ni
    integer                         :: p1,p2,h1,h2,s1,s2, blok, I_s, J_s
    integer, allocatable            :: linked(:,:), blokMwen(:, :), nlink(:)
    logical                         :: ok
    double precision                :: phase_iI, phase_Ik, phase_Jl, phase_Ji, phase_al, diI, hIi, hJi, delta_JI, dkI(N_states), HkI, ci_inv(N_states), dia_hla(N_states)
    double precision                :: contrib, wall, iwall, searchance(N_det_ref)
    double precision, allocatable   :: deltaMwen(:,:,:), deltaIImwen(:,:)
    integer, dimension(0:2,2,2)     :: exc_iI, exc_Ik, exc_IJ
    integer(bit_kind)               :: det_tmp(N_int, 2), det_tmp2(N_int, 2), inac, virt
  
negative.code:       stop "invalid mrmode"
      end if
    end do
  !   do i=1,N_det_ref
  !     print *, delta_ii(1,i)
  !   end do
  !   do i=1,min(N_det_non_ref,100)
  !     print *, delta_ij(1,i,:)
  !   end do
  !   stop
    
  
  