anchor.diff:        n = n - 1
         if(n /= 0) then
           call mrcc_part_dress(delta_ij_mrcc_sto, delta_ii_mrcc_sto, delta_ij_s2_mrcc_sto, &
  -            delta_ii_s2_mrcc_sto, gen,n,buf,N_int,omask,myCoef)
  +            delta_ii_s2_mrcc_sto, gen,n,buf,N_int,omask,myCoef,contrib)
         endif
       end do
       deallocate(buf)
  
positive.code:   integer, external :: omp_get_thread_num
    double precision :: coefs(N_det_non_ref), myCoef
    integer :: n_in_teeth
    double precision :: curn, in_teeth_step, curlim, curnorm
  
    read(*,*) n_in_teeth
    !n_in_teeth = 2
    in_teeth_step = 1d0 / dfloat(n_in_teeth)
  
negative.code:         enddo
        enddo
        do i_state=1,N_states
          if(dabs(psi_ref_coef(1,i_state)).ge.1.d-3)then
            do l_sd=1,idx_alpha(0)
              k_sd = idx_alpha(l_sd)
              p1 = 1
              hdress = dIa_hla(i_state,k_sd) * psi_ref_coef(i_I,i_state) / psi_ref_coef(p1,i_state)
              sdress = dIa_sla(i_state,k_sd) * psi_ref_coef(i_I,i_state) / psi_ref_coef(p1,i_state)
              !$OMP ATOMIC
              contrib(i_state) += hdress * psi_ref_coef(p1, i_state) * psi_non_ref_coef(k_sd, i_state)
              !$OMP ATOMIC
              delta_ij_(i_state,k_sd,p1) += hdress
              !$OMP ATOMIC
              !delta_ii_(i_state,i_I) = delta_ii_(i_state,i_I) - dIa_hla(i_state,k_sd) * ci_inv(i_state) * psi_non_ref_coef_transp(i_state,k_sd)
              delta_ii_(i_state,p1) -= hdress / psi_ref_coef(p1,i_state) * psi_non_ref_coef_transp(i_state,k_sd)
              !$OMP ATOMIC
              delta_ij_s2_(i_state,k_sd,p1) += sdress
              !$OMP ATOMIC
              !delta_ii_s2_(i_state,i_I) = delta_ii_s2_(i_state,i_I) - dIa_sla(i_state,k_sd) * ci_inv(i_state) * psi_non_ref_coef_transp(i_state,k_sd)
              delta_ii_s2_(i_state,p1) -= sdress / psi_ref_coef(p1,i_state) * psi_non_ref_coef_transp(i_state,k_sd)
            enddo
          else
            !stop "dress with coef < 1d-3"
            delta_ii_(i_state,1)  = 0.d0
            do l_sd=1,idx_alpha(0)
              k_sd = idx_alpha(l_sd)
              p1 = 1
              hdress = dIa_hla(i_state,k_sd) * psi_ref_coef(i_I,i_state) / psi_ref_coef(p1,i_state)
              sdress = dIa_sla(i_state,k_sd) * psi_ref_coef(i_I,i_state) / psi_ref_coef(p1,i_state)
              !$OMP ATOMIC
              delta_ij_(i_state,k_sd,p1) = delta_ij_(i_state,k_sd,p1) + 0.5d0*hdress
              !$OMP ATOMIC
              delta_ij_s2_(i_state,k_sd,p1) = delta_ij_s2_(i_state,k_sd,p1) + 0.5d0*sdress
            enddo
          endif
        enddo
  