subroutine chksum_hotface(grid, ms, visc_rem_u, visc_rem_v, probe, label, stage, step)
!! Hot-face anatomy at a phase seam: interior argmax |u| and |v|
!! with the local thickness pair (donor/receiver cells), the
!! per-face viscous remnant, and the column context (thickness of
!! the layer below/above at the max face). The forensic question
!! this answers: WHICH face takes the explicit dt·F kick, is it an
!! outcrop edge (massive|vanished thickness pair), and is visc_rem
!! actually small there (i.e. would MOM6's attenuation have caught
!! it)? Row format (grep "HOTFACE"):
!! HOTFACE <step> s<stage> <label> u|v (i,j,k) val hL hR rem h_dn h_up
!! Debug-window only (chksum_active gate); D→H of the two face
!! fields per sample — affordable at window cadence, not at
!! production cadence.
type(hgrid_t), intent(in) :: grid
type(multilayer_state_t), intent(inout) :: ms
real(wp), intent(in) :: visc_rem_u(:, :, :), visc_rem_v(:, :, :)
! assumed-shape-ok: host-side debug probe, no device loops here.
type(chksum_probe_t), intent(inout) :: probe
character(len=*), intent(in) :: label
integer, intent(in) :: stage, step
integer :: ig, i0, i1, j0, j1, im, jm, km
real(wp) :: amax
if (.not. chksum_active(probe, step)) return
!$acc wait
!$acc update self(ms%u_face_x_layer, ms%v_face_y_layer, ms%h_layer)
!$acc update self(visc_rem_u, visc_rem_v)
ig = grid%nghost
i0 = ig + 1
i1 = grid%nx_total - ig
j0 = ig + 1
j1 = grid%ny_total - ig
! ---- u argmax over interior u-faces ----
call chksum_argmax(ms%u_face_x_layer, grid%nx_total + 1, grid%ny_total, &
ms%nz_ml, i0, i1 + 1, j0, j1, im, jm, km, amax)
call hotface_row(label, stage, step, "u", im, jm, km, &
ms%u_face_x_layer(im, jm, km), &
ms%h_layer(im - 1, jm, km), ms%h_layer(im, jm, km), &
visc_rem_u(im, jm, km), &
ms%h_layer(im - 1, jm, max(km - 1, 1)), &
ms%h_layer(im - 1, jm, min(km + 1, ms%nz_ml)))
! ---- v argmax over interior v-faces ----
call chksum_argmax(ms%v_face_y_layer, grid%nx_total, grid%ny_total + 1, &
ms%nz_ml, i0, i1, j0, j1 + 1, im, jm, km, amax)
call hotface_row(label, stage, step, "v", im, jm, km, &
ms%v_face_y_layer(im, jm, km), &
ms%h_layer(im, jm - 1, km), ms%h_layer(im, jm, km), &
visc_rem_v(im, jm, km), &
ms%h_layer(im, jm - 1, max(km - 1, 1)), &
ms%h_layer(im, jm - 1, min(km + 1, ms%nz_ml)))
end subroutine chksum_hotface