subroutine measure_local_spin(real_sgn, csf_i)
real(dp), intent(in) :: real_sgn(lenof_sign)
type(CSF_Info_t), intent(in) :: csf_i
real(dp) :: coeff, loc_spin(nSpatOrbs)
#if defined PROG_NUMRUNS_ || defined DOUBLERUN_
#ifdef CMPLX_
character(*), parameter :: this_routine = "measure_local_spin"
! i do not want to deal with complex runs for now..
call stop_all(this_routine, &
"complex double occupancy measurement not yet implemented!")
unused_var(real_sgn)
#else
coeff = real_sgn(1) * real_sgn(2)
#endif
#else
coeff = abs(real_sgn(1))**2
#endif
! the current b vector should be fine to get the total spin
loc_spin = csf_i%B_real / 2.0_dp * (csf_i%B_real / 2.0_dp + 1.0_dp)
inst_local_spin = inst_local_spin + coeff * loc_spin
end subroutine measure_local_spin