Fill one water column’s reference concentration from hTr/h,
falling back to the nearest massive layer (h > H_VANISHED) for
any vanished layer — bed-up pass first, then a surface-down pass
to backfill any vanished layers below the first massive one.
Plain host loop (called from a host do i,j loop, never do
concurrent — this is configure-time setup, not a per-step kernel).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(out) | :: | conc(nz) | |||
| real(kind=wp), | intent(in) | :: | hTr_col(nz) | |||
| real(kind=wp), | intent(in) | :: | h_col(nz) | |||
| integer, | intent(in) | :: | nz |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| logical, | private | :: | have_valid | ||||
| integer, | private | :: | k | ||||
| real(kind=wp), | private | :: | last_valid |
pure subroutine snapshot_column_concentration(conc, hTr_col, h_col, nz) !! Fill one water column's reference concentration from `hTr/h`, !! falling back to the nearest massive layer (`h > H_VANISHED`) for !! any vanished layer — bed-up pass first, then a surface-down pass !! to backfill any vanished layers below the first massive one. !! Plain host loop (called from a host `do i,j` loop, never `do !! concurrent` — this is configure-time setup, not a per-step kernel). integer, intent(in) :: nz real(wp), intent(out) :: conc(nz) real(wp), intent(in) :: hTr_col(nz), h_col(nz) integer :: k real(wp) :: last_valid logical :: have_valid have_valid = .false. last_valid = 0.0_wp do k = 1, nz if (h_col(k) > H_VANISHED) then conc(k) = hTr_col(k)/max(h_col(k), H_DIV_EPS) last_valid = conc(k) have_valid = .true. else if (have_valid) then conc(k) = last_valid else conc(k) = 0.0_wp ! filled by the backward pass below, if ever massive end if end do if (.not. have_valid) return last_valid = conc(nz) do k = nz, 1, -1 if (h_col(k) > H_VANISHED) then last_valid = conc(k) else conc(k) = last_valid end if end do end subroutine snapshot_column_concentration