subroutine chksum_row(probe, label, stage, step, field, stats)
!! Emit one CHKSUM row (write(*,...) like the KE_ATTR probe —
!! probe output bypasses the logger by design: greppable, no
!! prefix, survives logger-level filtering).
type(chksum_probe_t), intent(inout) :: probe
character(len=*), intent(in) :: label, field
integer, intent(in) :: stage, step
type(chksum_stats_t), intent(in) :: stats
integer(int64) :: bits_global
if (.not. probe%header_done) then
write (*, "(a)") "# CHKSUM columns: step stage phase field "// &
"sum min max nonfin bits"
write (*, "(a)") "# nonfin > 0 = the phase just run minted non-finite values"
write (*, "(a)") "# bits = decomposition-invariant POPCNT reduction "// &
"(sum/min/max are per-rank)"
probe%header_done = .true.
end if
! `bits` is the ONLY column reduced across ranks — its whole purpose
! is being identical on 1 rank vs N. sum/min/max stay per-rank
! (documented). Single-rank ⇒ the facade wrapper is an identity copy.
call halo_allreduce_sum_i8(stats%bits, bits_global)
write (*, "(a,1x,i6,1x,a,i1,1x,a16,1x,a12,3(1x,es20.12),1x,i9,1x,i20)") &
"CHKSUM", step, "s", stage, adjustl(label), adjustl(field), &
stats%total, stats%minv, stats%maxv, stats%nonfin, bits_global
end subroutine chksum_row