cavity_mask_impl Subroutine

public pure subroutine cavity_mask_impl(src, active, buf)

Copy a 2-D cavity field into the diag buffer, writing IEEE NaN wherever the column was not solved. Every cavity fill that is a plain read of a slot array routes through here, so the missing-value convention cannot drift between them.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: src(:,:)
real(kind=wp), intent(in) :: active(:,:)
real(kind=wp), intent(inout) :: buf(:,:,:)

Called by

proc~~cavity_mask_impl~~CalledByGraph proc~cavity_mask_impl cavity_mask_impl proc~fill_exch_vel_s fill_exch_vel_s proc~fill_exch_vel_s->proc~cavity_mask_impl proc~fill_exch_vel_t fill_exch_vel_t proc~fill_exch_vel_t->proc~cavity_mask_impl proc~fill_melt fill_melt proc~fill_melt->proc~cavity_mask_impl proc~fill_sbdry fill_sbdry proc~fill_sbdry->proc~cavity_mask_impl proc~fill_tbdry fill_tbdry proc~fill_tbdry->proc~cavity_mask_impl proc~fill_ustar_shelf fill_ustar_shelf proc~fill_ustar_shelf->proc~cavity_mask_impl proc~fill_z_draft fill_z_draft proc~fill_z_draft->proc~cavity_mask_impl

Variables

Type Visibility Attributes Name Initial
integer, private :: i
integer, private :: j
integer, private :: nx
integer, private :: ny
real(kind=wp), private :: qnan

Source Code

   pure subroutine cavity_mask_impl(src, active, buf)
      !! Copy a 2-D cavity field into the diag buffer, writing IEEE NaN
      !! wherever the column was not solved.  Every cavity fill that is
      !! a plain read of a slot array routes through here, so the
      !! missing-value convention cannot drift between them.
      ! assumed-shape-ok: diag fill — fires once per output frame (cadence-bounded).
      real(wp), intent(in)    :: src(:, :)  ! assumed-shape-ok: diag fill — cadence-bounded
      real(wp), intent(in)    :: active(:, :)  ! assumed-shape-ok: diag fill — cadence-bounded
      real(wp), intent(inout) :: buf(:, :, :)  ! assumed-shape-ok: diag fill — cadence-bounded
      integer :: i, j, nx, ny
      real(wp) :: qnan
      nx = min(size(buf, 1), size(src, 1), size(active, 1))
      ny = min(size(buf, 2), size(src, 2), size(active, 2))
      ! Sentinel computed once on the HOST before the device loop —
      ! `ieee_value` is a host intrinsic (the `fill_tracer_impl` pattern).
      qnan = ieee_value(0.0_wp, ieee_quiet_nan)
      do concurrent(j=1:ny, i=1:nx)
         if (active(i, j) > 0.5_wp) then
            buf(i, j, 1) = src(i, j)
         else
            buf(i, j, 1) = qnan
         end if
      end do
   end subroutine cavity_mask_impl