snapshot_column_concentration Subroutine

private 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).

Arguments

Type IntentOptional 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

Called by

proc~~snapshot_column_concentration~~CalledByGraph proc~snapshot_column_concentration snapshot_column_concentration proc~ocean_sponge_snapshot_reference ocean_sponge_snapshot_reference proc~ocean_sponge_snapshot_reference->proc~snapshot_column_concentration proc~engine_setup engine_setup proc~engine_setup->proc~ocean_sponge_snapshot_reference proc~complete_ocean_create complete_ocean_create proc~complete_ocean_create->proc~engine_setup proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_setup proc~driver_validate driver_validate proc~driver_validate->proc~engine_setup proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean proc~rdb_ocean_create_finalize rdb_ocean_create_finalize proc~rdb_ocean_create_finalize->proc~complete_ocean_create proc~rdb_ocean_create_from_string rdb_ocean_create_from_string proc~rdb_ocean_create_from_string->proc~complete_ocean_create

Variables

Type Visibility Attributes Name Initial
logical, private :: have_valid
integer, private :: k
real(kind=wp), private :: last_valid

Source Code

   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