anchor.diff:     end do
      end do
      detEq = .true.
  +end function
  +
  +logical function isInCassd(a,Nint)
  +  use bitmasks
  +  implicit none
  +  integer, intent(in) :: Nint
  +  integer(bit_kind), intent(in) :: a(Nint,2)
  +  integer(bit_kind) :: inac, virt
  +  integer :: ni, i, deg
  +
  +  
  +  isInCassd = .false.
  +  
  +   
  +  deg = 0
  +  do i=1,2
  +    do ni=1,Nint
  +      virt = iand(not(HF_bitmask(ni,i)), not(active_sorb(ni,i)))
  +      deg += popcnt(iand(virt, a(ni,i)))
  +      if(deg > 2) return
  +    end do
  +  end do
  +  
  +  deg = 0
  +  do i=1,2
  +    do ni=1,Nint
  +      inac = iand(HF_bitmask(ni,i), not(active_sorb(ni,i)))
  +      deg += popcnt(xor(iand(inac,a(ni,i)), inac))
  +      if(deg > 2) return
  +    end do
  +  end do
  +  
  +  isInCassd = .true.
   end function
   
   integer function detCmp(a,b,Nint)
  
positive.code:       end do
      end do
      !$OMP END PARALLEL DO
      
      do i=1,N_det_ref
      do j=1,i
          delta_cas(j,i,i_state) = delta_cas(i,j,i_state)
  
negative.code:     !$OMP END PARALLEL DO 
    end do
    deallocate(idx_sorted_bit)
  !   call wall_time(wall)
  !   print *, "old ", wall
  END_PROVIDER
  
  
  