seed_wet_mask_impl Subroutine

private pure subroutine seed_wet_mask_impl(wet_mask, b, land_cutoff)

1.0 where b >= cutoff (ocean), 0.0 elsewhere (land). Default (absent land_cutoff): cutoff = LAND_DEPTH_THRESHOLD (byte-identical to the pre-v2 path). When land_cutoff is present, a column is land iff b < land_cutoff; the wetdry-aware seed passes land_cutoff = -land_margin so intertidal columns (bed above rest MSL but below the flood headroom) stay wet_mask=1 and the dynamic wd_wet_dyn gate handles their wetting/drying.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(inout) :: wet_mask(:,:)
real(kind=wp), intent(in) :: b(:,:)
real(kind=wp), intent(in), optional :: land_cutoff

When present, a column is land iff b < land_cutoff (used by the wetdry-aware seed: land_cutoff = -land_margin lets intertidal columns near/above rest MSL stay wet_mask=1). Absent ⇒ the default b >= LAND_DEPTH_THRESHOLD ocean test (byte-identical).


Called by

proc~~seed_wet_mask_impl~~CalledByGraph proc~seed_wet_mask_impl seed_wet_mask_impl proc~ocean_state_seed_from_cfg ocean_state_seed_from_cfg proc~ocean_state_seed_from_cfg->proc~seed_wet_mask_impl proc~engine_setup engine_setup proc~engine_setup->proc~ocean_state_seed_from_cfg 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
real(kind=wp), private :: cutoff
integer, private :: i
integer, private :: j
integer, private :: nx
integer, private :: ny

Source Code

   pure subroutine seed_wet_mask_impl(wet_mask, b, land_cutoff)
      !! 1.0 where `b >= cutoff` (ocean), 0.0 elsewhere (land).
      !! Default (absent `land_cutoff`): `cutoff = LAND_DEPTH_THRESHOLD`
      !! (byte-identical to the pre-v2 path).  When `land_cutoff` is
      !! present, a column is land iff `b < land_cutoff`; the wetdry-aware
      !! seed passes `land_cutoff = -land_margin` so intertidal columns
      !! (bed above rest MSL but below the flood headroom) stay wet_mask=1
      !! and the dynamic wd_wet_dyn gate handles their wetting/drying.
      ! assumed-shape-ok: init routine called once at startup; size(b,1/2) used
      ! to derive loop bounds.
      real(wp), intent(inout) :: wet_mask(:, :)
      real(wp), intent(in)    :: b(:, :)  ! assumed-shape-ok: init routine; size(b,1/2) derives loop bounds
      real(wp), intent(in), optional :: land_cutoff
         !! When present, a column is land iff `b < land_cutoff` (used by
         !! the wetdry-aware seed: land_cutoff = -land_margin lets intertidal
         !! columns near/above rest MSL stay wet_mask=1). Absent ⇒ the default
         !! `b >= LAND_DEPTH_THRESHOLD` ocean test (byte-identical).
      integer :: i, j, nx, ny
      real(wp) :: cutoff
      nx = size(b, 1)
      ny = size(b, 2)
      cutoff = LAND_DEPTH_THRESHOLD
      if (present(land_cutoff)) cutoff = land_cutoff
      ! Plain host loop ON PURPOSE: this runs BEFORE enter_data, so a
      ! do concurrent here makes -stdpar=gpu implicitly round-trip the
      ! (unmapped) arrays through the device per loop — measured 36.9 s
      ! of ic_seed at 5.3M cells.  Setup-only code seeds on the host;
      ! enter_data then maps the seeded values once.
      do j = 1, ny
         do i = 1, nx
            if (b(i, j) >= cutoff) then
               wet_mask(i, j) = 1.0_wp
            else
               wet_mask(i, j) = 0.0_wp
            end if
         end do
      end do
   end subroutine seed_wet_mask_impl