anchor.diff:    double precision               :: ihpsi_current(N_states)
     integer :: i_pert_count
     double precision :: hii, lambda_pert
  -  integer                        :: N_lambda_mrcc_pt2
  +  integer                        :: N_lambda_mrcc_pt2, N_lambda_mrcc_pt3
     double precision, parameter :: x = 2.d0
  -  
  +  double precision :: nurm 
     i_pert_count = 0
     lambda_mrcc_old = 0.d0
     N_lambda_mrcc_pt2 = 0
  +  N_lambda_mrcc_pt3 = 0
     lambda_mrcc_pt2_old(0) = 0
  -  
  +  lambda_mrcc_pt3_old(0) = 0
  +  if(N_states > 1) stop "old lambda N_states == 1"
  +  nurm = 0d0
  +  do i=1,N_det_ref
  +    nurm += psi_ref_coef(i,1)**2
  +  end do
  +
      do i=1,N_det_non_ref
        call i_h_psi(psi_non_ref(1,1,i), psi_ref, psi_ref_coef, N_int, N_det_ref, &
                     size(psi_ref_coef,1), N_states,ihpsi_current)
  
positive.code:          ihpsi_current(k) = 1.d-32
         endif
         lambda_mrcc_old(k,i) = psi_non_ref_coef(i,k)/ihpsi_current(k) 
        if ( dabs(psi_non_ref_coef(i,k)*ihpsi_current(k)) < 1.d-5 ) then
          i_pert_count += 1
          lambda_mrcc_old(k,i) = 0.d0
          if (lambda_mrcc_pt2_old(N_lambda_mrcc_pt2) /= i) then
             N_lambda_mrcc_pt2 += 1
             lambda_mrcc_pt2_old(N_lambda_mrcc_pt2) = i
          endif
  !         lambda_pert = 1.d0 / (psi_ref_energy_diagonalized(k)-hii)
  !         if((ihpsi_current(k) * lambda_pert) < 0.5d0 * psi_non_ref_coef_restart(i,k) ) then
  !            lambda_mrcc_old(k,i) = 0.d0
  !         endif
        endif
        
        if (lambda_mrcc_old(k,i) > x) then
          lambda_mrcc_old(k,i) = x
  
negative.code:      enddo
    enddo
    lambda_mrcc_pt2_old(0) = N_lambda_mrcc_pt2
    lambda_mrcc_pt3_old(0) = N_lambda_mrcc_pt3
    
    print*,'N_det_non_ref = ',N_det_non_ref
    print*,'Number of ignored determinants = ',i_pert_count
  