cavity_flux_fill_impl Subroutine

public pure subroutine cavity_flux_fill_impl(nx, ny, s_ice, active, melt, q_ocean, s_far, heat_cavity, salt_cavity)

Fill the two OWNED surface-flux components from the solved interface. FULL OVERWRITE of the whole plane, never += — the same rule the sea-ice coupler’s fillers follow, and for the same reason (a += ratchets across outer steps with no bound).

See the module docstring for the sign derivation. In one line: the ocean loses the heat the interface takes (-q_ocean), and the dilution by meltwater of salinity s_ice is emulated at fixed column mass by -m_mass*(S_far - s_ice).

No wet-mask factor here: active already carries it (the sampler composes it), and the assembler multiplies Q_heat / Q_salt by ms%wet_mask again.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nx

First dimension (ghosts included).

integer, intent(in) :: ny

Second dimension.

real(kind=wp), intent(in) :: s_ice

Ice salinity (g/kg).

real(kind=wp), intent(in) :: active(nx,ny)

Composed solve mask.

real(kind=wp), intent(in) :: melt(nx,ny)

Melt mass flux (kg/m^2/s), > 0 melting.

real(kind=wp), intent(in) :: q_ocean(nx,ny)

Ocean → interface heat flux (W/m^2).

real(kind=wp), intent(in) :: s_far(nx,ny)

Far-field salinity the solve used (g/kg).

real(kind=wp), intent(out) :: heat_cavity(nx,ny)

Heat component (W/m^2), positive down into the ocean.

real(kind=wp), intent(out) :: salt_cavity(nx,ny)

Virtual salt component, positive salinifies.


Called by

proc~~cavity_flux_fill_impl~~CalledByGraph proc~cavity_flux_fill_impl cavity_flux_fill_impl proc~ocean_cavity_flux_step ocean_cavity_flux_step proc~ocean_cavity_flux_step->proc~cavity_flux_fill_impl proc~engine_step_finalize engine_step_finalize proc~engine_step_finalize->proc~ocean_cavity_flux_step proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_step_finalize proc~rdb_ocean_step rdb_ocean_step proc~rdb_ocean_step->proc~engine_step_finalize proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean

Variables

Type Visibility Attributes Name Initial
integer, private :: i
integer, private :: j

Source Code

   pure subroutine cavity_flux_fill_impl(nx, ny, s_ice, active, melt, q_ocean, s_far, &
                                         heat_cavity, salt_cavity)
      !! Fill the two OWNED surface-flux components from the solved
      !! interface.  FULL OVERWRITE of the whole plane, never `+=` —
      !! the same rule the sea-ice coupler's fillers follow, and for the
      !! same reason (a `+=` ratchets across outer steps with no bound).
      !!
      !! See the module docstring for the sign derivation.  In one line:
      !! the ocean loses the heat the interface takes (`-q_ocean`), and
      !! the dilution by meltwater of salinity `s_ice` is emulated at
      !! fixed column mass by `-m_mass*(S_far - s_ice)`.
      !!
      !! No wet-mask factor here: `active` already carries it (the
      !! sampler composes it), and the assembler multiplies `Q_heat` /
      !! `Q_salt` by `ms%wet_mask` again.
      integer, intent(in) :: nx
         !! First dimension (ghosts included).
      integer, intent(in) :: ny
         !! Second dimension.
      real(wp), intent(in) :: s_ice
         !! Ice salinity (g/kg).
      real(wp), intent(in) :: active(nx, ny)
         !! Composed solve mask.
      real(wp), intent(in) :: melt(nx, ny)
         !! Melt mass flux (kg/m^2/s), > 0 melting.
      real(wp), intent(in) :: q_ocean(nx, ny)
         !! Ocean → interface heat flux (W/m^2).
      real(wp), intent(in) :: s_far(nx, ny)
         !! Far-field salinity the solve used (g/kg).
      real(wp), intent(out) :: heat_cavity(nx, ny)
         !! Heat component (W/m^2), positive down into the ocean.
      real(wp), intent(out) :: salt_cavity(nx, ny)
         !! Virtual salt component, positive salinifies.
      integer :: i, j

      do concurrent(j=1:ny, i=1:nx)
         if (active(i, j) > 0.5_wp) then
            heat_cavity(i, j) = -q_ocean(i, j)
            salt_cavity(i, j) = -melt(i, j)*(s_far(i, j) - s_ice)
         else
            heat_cavity(i, j) = 0.0_wp
            salt_cavity(i, j) = 0.0_wp
         end if
      end do
   end subroutine cavity_flux_fill_impl