Sample the three-region layer KE and print the attribution row. Call AFTER the segment being attributed; the printed dKE is “this sample minus the previous one” — i.e. the segment’s energy contribution. Drains all device queues first so the async velocity-apply chain (queue 1) has landed.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(hgrid_t), | intent(in) | :: | grid | |||
| type(multilayer_state_t), | intent(in) | :: | ms | |||
| type(ke_probe_t), | intent(inout) | :: | probe | |||
| character(len=*), | intent(in) | :: | label |
Segment tag, e.g. “coriolis_adv”, “bt_correction”. |
||
| integer, | intent(in) | :: | stage | |||
| integer, | intent(in) | :: | step |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=wp), | private | :: | d_east | ||||
| real(kind=wp), | private | :: | d_full | ||||
| real(kind=wp), | private | :: | d_rim | ||||
| real(kind=wp), | private | :: | ke_east | ||||
| real(kind=wp), | private | :: | ke_full | ||||
| real(kind=wp), | private | :: | ke_rim |
subroutine ke_probe_sample(grid, ms, probe, label, stage, step) !! Sample the three-region layer KE and print the attribution row. !! Call AFTER the segment being attributed; the printed dKE is !! "this sample minus the previous one" — i.e. the segment's !! energy contribution. Drains all device queues first so the !! async velocity-apply chain (queue 1) has landed. type(hgrid_t), intent(in) :: grid type(multilayer_state_t), intent(in) :: ms type(ke_probe_t), intent(inout) :: probe character(len=*), intent(in) :: label !! Segment tag, e.g. "coriolis_adv", "bt_correction". integer, intent(in) :: stage, step real(wp) :: ke_full, ke_rim, ke_east real(wp) :: d_full, d_rim, d_east if (.not. ke_probe_active(probe, step)) return !$acc wait call ke_regions_impl(ms%h_layer, ms%u_face_x_layer, ms%v_face_y_layer, & grid%nx_total, grid%ny_total, ms%nz_ml, & grid%nghost, grid%nx_phys, grid%ny_phys, & probe%rim_band, probe%east_band, & ke_full, ke_rim, ke_east) if (probe%have_prev) then d_full = ke_full - probe%prev_full d_rim = ke_rim - probe%prev_rim d_east = ke_east - probe%prev_east else d_full = ke_full d_rim = ke_rim d_east = ke_east end if if (.not. probe%header_done) then write (*, "(a)") "# KE_ATTR columns: step stage segment "// & "dKE_full KE_full dKE_rim KE_rim dKE_east KE_east [m3/s2]" write (*, "(a)") "# dKE = energy injected (+) / removed (-) by the segment just run" probe%header_done = .true. end if write (*, "(a,1x,i6,1x,a,i1,1x,a16,6(1x,es13.5))") & "KE_ATTR", step, "s", stage, adjustl(label), & d_full, ke_full, d_rim, ke_rim, d_east, ke_east probe%prev_full = ke_full probe%prev_rim = ke_rim probe%prev_east = ke_east probe%have_prev = .true. end subroutine ke_probe_sample