ocean_halo_exchange_ice_fluxes Subroutine

public subroutine ocean_halo_exchange_ice_fluxes(ice, grid, bc, device_resident)

Seam ghosts of the three per-cell ice->ocean flux diagnostics the couplers hand to the ocean — salt_flux_diag, heat_flux_diag, sw_thru_diag — one two-pass centre exchange each.

Why. The column driver, frazil uptake and snowfall share write them on PHYSICAL cells only, but the brine / heat / shortwave couplers copy them over the FULL array into Q_salt / Q_heat / q_sw (or their components), and the ocean’s surface-flux application reads a seam ghost before its next exchange. A stale ghost there is the neighbour’s flux replaced by this tile’s old one (measured: the first decomposed run diverged from the serial one in the outer step after the first thermo block). Call after the last contributor and before the couplers. Single-rank non-periodic: a no-op; requires ocean_halo_init. Also carries the tripolar north fold of the same three fields (plain-copy scalar contract) — the fold-seam fix’s third exchange site.

Arguments

Type IntentOptional Attributes Name
type(ocean_sea_ice_t), intent(inout) :: ice

Live sea-ice slot (ice%is_init); a no-op otherwise.

type(hgrid_t), intent(in) :: grid
type(ocean_bc_state_t), intent(in) :: bc

Supplies north_fold + the grid metrics the fold kernels need.

logical, intent(in), optional :: device_resident

Forwarded to the halo primitives.


Calls

proc~~ocean_halo_exchange_ice_fluxes~~CallsGraph proc~ocean_halo_exchange_ice_fluxes ocean_halo_exchange_ice_fluxes interface~ocean_halo_centre ocean_halo_centre proc~ocean_halo_exchange_ice_fluxes->interface~ocean_halo_centre proc~ocean_fold_wrap_centre_flat ocean_fold_wrap_centre_flat proc~ocean_halo_exchange_ice_fluxes->proc~ocean_fold_wrap_centre_flat proc~oh_count_suppress_off oh_count_suppress_off proc~ocean_halo_exchange_ice_fluxes->proc~oh_count_suppress_off proc~oh_count_suppress_on oh_count_suppress_on proc~ocean_halo_exchange_ice_fluxes->proc~oh_count_suppress_on proc~profiler_start profiler_start proc~ocean_halo_exchange_ice_fluxes->proc~profiler_start proc~profiler_stop profiler_stop proc~ocean_halo_exchange_ice_fluxes->proc~profiler_stop proc~ocean_halo_centre_2d ocean_halo_centre_2d interface~ocean_halo_centre->proc~ocean_halo_centre_2d proc~ocean_halo_centre_3d ocean_halo_centre_3d interface~ocean_halo_centre->proc~ocean_halo_centre_3d interface~fold_north_centre fold_north_centre proc~ocean_fold_wrap_centre_flat->interface~fold_north_centre interface~ocean_fold_pack ocean_fold_pack proc~ocean_fold_wrap_centre_flat->interface~ocean_fold_pack interface~ocean_fold_unpack ocean_fold_unpack proc~ocean_fold_wrap_centre_flat->interface~ocean_fold_unpack proc~ocean_fold_begin ocean_fold_begin proc~ocean_fold_wrap_centre_flat->proc~ocean_fold_begin proc~ocean_fold_end ocean_fold_end proc~ocean_fold_wrap_centre_flat->proc~ocean_fold_end proc~ocean_fold_exchange ocean_fold_exchange proc~ocean_fold_wrap_centre_flat->proc~ocean_fold_exchange proc~ocean_fold_is_distributed ocean_fold_is_distributed proc~ocean_fold_wrap_centre_flat->proc~ocean_fold_is_distributed proc~find_or_create_region find_or_create_region proc~profiler_start->proc~find_or_create_region proc~get_wall_time get_wall_time proc~profiler_start->proc~get_wall_time proc~nvtx_range_push nvtx_range_push proc~profiler_start->proc~nvtx_range_push proc~profiler_stop->proc~get_wall_time proc~nvtx_range_pop nvtx_range_pop proc~profiler_stop->proc~nvtx_range_pop proc~fold_north_centre_2d fold_north_centre_2d interface~fold_north_centre->proc~fold_north_centre_2d proc~fold_north_centre_3d fold_north_centre_3d interface~fold_north_centre->proc~fold_north_centre_3d proc~ocean_fold_pack_2d ocean_fold_pack_2d interface~ocean_fold_pack->proc~ocean_fold_pack_2d proc~ocean_fold_pack_3d ocean_fold_pack_3d interface~ocean_fold_pack->proc~ocean_fold_pack_3d proc~ocean_fold_unpack_2d ocean_fold_unpack_2d interface~ocean_fold_unpack->proc~ocean_fold_unpack_2d proc~ocean_fold_unpack_3d ocean_fold_unpack_3d interface~ocean_fold_unpack->proc~ocean_fold_unpack_3d proc~grow_buffers grow_buffers proc~ocean_fold_begin->proc~grow_buffers to_string to_string proc~ocean_fold_begin->to_string warning warning proc~ocean_fold_begin->warning comm_irecv_real_sp_array_n comm_irecv_real_sp_array_n proc~ocean_fold_exchange->comm_irecv_real_sp_array_n comm_isend_real_sp_array_n comm_isend_real_sp_array_n proc~ocean_fold_exchange->comm_isend_real_sp_array_n proc~comm_env_compute_comm comm_env_compute_comm proc~ocean_fold_exchange->proc~comm_env_compute_comm waitall waitall proc~ocean_fold_exchange->waitall proc~ocean_halo_centre_2d_impl ocean_halo_centre_2d_impl proc~ocean_halo_centre_2d->proc~ocean_halo_centre_2d_impl proc~oh_count_centre_2d oh_count_centre_2d proc~ocean_halo_centre_2d->proc~oh_count_centre_2d proc~ocean_halo_centre_3d->comm_irecv_real_sp_array_n proc~ocean_halo_centre_3d->comm_isend_real_sp_array_n proc~ocean_halo_centre_3d->proc~comm_env_compute_comm proc~ew_rank_east ew_rank_east proc~ocean_halo_centre_3d->proc~ew_rank_east proc~ew_rank_west ew_rank_west proc~ocean_halo_centre_3d->proc~ew_rank_west proc~needs_flags needs_flags proc~ocean_halo_centre_3d->proc~needs_flags proc~ns_rank_north ns_rank_north proc~ocean_halo_centre_3d->proc~ns_rank_north proc~ns_rank_south ns_rank_south proc~ocean_halo_centre_3d->proc~ns_rank_south proc~ocean_halo_buffers_ensure_nz ocean_halo_buffers_ensure_nz proc~ocean_halo_centre_3d->proc~ocean_halo_buffers_ensure_nz proc~ocean_periodic_wrap_centre_3d ocean_periodic_wrap_centre_3d proc~ocean_halo_centre_3d->proc~ocean_periodic_wrap_centre_3d proc~oh_count_centre_3d oh_count_centre_3d proc~ocean_halo_centre_3d->proc~oh_count_centre_3d proc~oh_count_msgs oh_count_msgs proc~ocean_halo_centre_3d->proc~oh_count_msgs proc~ocean_halo_centre_3d->waitall comm_world comm_world proc~comm_env_compute_comm->comm_world proc~decomp_rank_from_coords decomp_rank_from_coords proc~ew_rank_east->proc~decomp_rank_from_coords proc~ew_rank_west->proc~decomp_rank_from_coords proc~ns_rank_north->proc~decomp_rank_from_coords proc~ns_rank_south->proc~decomp_rank_from_coords proc~ocean_fold_pack_2d->proc~ocean_fold_pack_3d proc~fold_stagger_family fold_stagger_family proc~ocean_fold_pack_3d->proc~fold_stagger_family proc~fold_stagger_nrows fold_stagger_nrows proc~ocean_fold_pack_3d->proc~fold_stagger_nrows proc~ocean_fold_unpack_2d->proc~ocean_fold_unpack_3d proc~ocean_fold_unpack_3d->proc~fold_stagger_family proc~ocean_fold_unpack_3d->proc~fold_stagger_nrows proc~ocean_halo_buffers_ensure_nz->to_string proc~ocean_halo_buffers_ensure_nz->warning proc~ocean_halo_centre_2d_impl->comm_irecv_real_sp_array_n proc~ocean_halo_centre_2d_impl->comm_isend_real_sp_array_n proc~ocean_halo_centre_2d_impl->proc~comm_env_compute_comm proc~ocean_halo_centre_2d_impl->proc~ew_rank_east proc~ocean_halo_centre_2d_impl->proc~ew_rank_west proc~ocean_halo_centre_2d_impl->proc~needs_flags proc~ocean_halo_centre_2d_impl->proc~ns_rank_north proc~ocean_halo_centre_2d_impl->proc~ns_rank_south proc~ocean_halo_centre_2d_impl->proc~oh_count_msgs proc~ocean_halo_centre_2d_impl->waitall proc~ocean_periodic_wrap_centre_2d ocean_periodic_wrap_centre_2d proc~ocean_halo_centre_2d_impl->proc~ocean_periodic_wrap_centre_2d

Called by

proc~~ocean_halo_exchange_ice_fluxes~~CalledByGraph proc~ocean_halo_exchange_ice_fluxes ocean_halo_exchange_ice_fluxes proc~engine_step_ice engine_step_ice proc~engine_step_ice->proc~ocean_halo_exchange_ice_fluxes proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_step_ice proc~rdb_ocean_step rdb_ocean_step proc~rdb_ocean_step->proc~engine_step_ice proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean

Source Code

   subroutine ocean_halo_exchange_ice_fluxes(ice, grid, bc, device_resident)
      !! Seam ghosts of the three per-cell ice->ocean flux diagnostics the
      !! couplers hand to the ocean — `salt_flux_diag`, `heat_flux_diag`,
      !! `sw_thru_diag` — one two-pass centre exchange each.
      !!
      !! **Why.**  The column driver, frazil uptake and snowfall share write
      !! them on PHYSICAL cells only, but the brine / heat / shortwave
      !! couplers copy them over the FULL array into `Q_salt` / `Q_heat` /
      !! `q_sw` (or their components), and the ocean's surface-flux
      !! application reads a seam ghost before its next exchange.  A stale
      !! ghost there is the neighbour's flux replaced by this tile's old
      !! one (measured: the first decomposed run diverged from the serial
      !! one in the outer step after the first thermo block).  Call after
      !! the last contributor and before the couplers.  Single-rank
      !! non-periodic: a no-op; requires `ocean_halo_init`.  Also carries
      !! the tripolar north fold of the same three fields (plain-copy
      !! scalar contract) — the fold-seam fix's third exchange site.
      type(ocean_sea_ice_t), intent(inout) :: ice
         !! Live sea-ice slot (`ice%is_init`); a no-op otherwise.
      type(hgrid_t), intent(in) :: grid
      type(ocean_bc_state_t), intent(in) :: bc
         !! Supplies `north_fold` + the grid metrics the fold kernels need.
      logical, intent(in), optional :: device_resident
         !! Forwarded to the halo primitives.

      if (.not. ice%is_init) return
      call profiler_start("ice_comms_fluxes")
      call oh_count_suppress_on()
      call ocean_halo_centre(ice%salt_flux_diag, device_resident)
      call ocean_halo_centre(ice%heat_flux_diag, device_resident)
      call ocean_halo_centre(ice%sw_thru_diag, device_resident)
      call oh_count_suppress_off()
      call profiler_stop("ice_comms_fluxes")

      if (bc%north_fold) then
         call ocean_fold_wrap_centre_flat(grid, bc, ice%salt_flux_diag, &
                                          size(ice%salt_flux_diag, 1), &
                                          size(ice%salt_flux_diag, 2), 1, device_resident)
         call ocean_fold_wrap_centre_flat(grid, bc, ice%heat_flux_diag, &
                                          size(ice%heat_flux_diag, 1), &
                                          size(ice%heat_flux_diag, 2), 1, device_resident)
         call ocean_fold_wrap_centre_flat(grid, bc, ice%sw_thru_diag, &
                                          size(ice%sw_thru_diag, 1), &
                                          size(ice%sw_thru_diag, 2), 1, device_resident)
      end if
   end subroutine ocean_halo_exchange_ice_fluxes