anchor.diff:  
     call connect_to_taskserver(zmq_to_qp_run_socket,worker_id,thread)
   
  -  allocate (dleat(N_states, N_det_non_ref, 2), delta(N_states,0:N_det_non_ref, 2))
  -  allocate (dleat_s2(N_states, N_det_non_ref, 2), delta_s2(N_states,0:N_det_non_ref, 2))
  +  allocate (delta(N_states,0:N_det_non_ref, 2))
  +  allocate (delta_s2(N_states,0:N_det_non_ref, 2))
     allocate(komon(0:N_det_non_ref))
   
     allocate(hp(2,N_det_non_ref))
  
positive.code:         call apply_excitation(psi_non_ref(1,1,i),exc_Ik,det_tmp,ok,N_int)
          if(.not. ok) cycle
          if(HP(1,i) + HP(1,k) <= 2 .and. HP(2,i) + HP(2,k) <= 2) then
            cycle
          end if
          
          !if(isInCassd(det_tmp, N_int)) cycle
            
          do i_state = 1, N_states 
            !if(lambda_mrcc(i_state, i) == 0d0) cycle
            
  
            !contrib = h_cache(i_I,k) * lambda_mrcc(i_state, k) * dleat(i_state, m, 2)! * phase_al
            contrib =  dij(i_I, k, i_state) * dleat(i_state, m, 2)
            contrib_s2 =  dij(i_I, k, i_state) * dleat_s2(i_state, m, 2)
            delta(i_state,ll,1) += contrib
            delta_s2(i_state,ll,1) += contrib_s2
            if(dabs(psi_ref_coef(i_I,i_state)).ge.5.d-5) then
  
negative.code:           
            if(h_cache(J,i) == 0.d0) cycle
            if(h_cache(i_I,i) == 0.d0) cycle
           
            komon(0) += 1
            kn = komon(0)
            komon(kn) = i
          end do
            
          komoned = .true.
  