fold_receiver_entries Subroutine

public pure subroutine fold_receiver_entries(ni, px, ng, fam, rx, ncol, own, src, cls)

Every destination column i = 1..ncol of tile rx’s window for a column family: the owning tile own(i) of its mirror, the owner’s local storage column src(i) to read, and the fold-row class cls(i). ncol = w+2ng (T) or w+2ng+1 (U); the arrays must hold at least that many entries.

Arguments

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

Global physical width of the fold row (cells).

integer, intent(in) :: px

Tiles along the fold row.

integer, intent(in) :: ng

Ghost width.

integer, intent(in) :: fam

Column family (FOLD_FAM_T or FOLD_FAM_U).

integer, intent(in) :: rx

Receiving tile x-coordinate (0-based).

integer, intent(out) :: ncol

Destination columns filled (w+2ng for T, w+2ng+1 for U).

integer, intent(out) :: own(:)

Owning tile x-coordinate (0-based) of each column’s mirror.

integer, intent(out) :: src(:)

Owner’s local storage column to read (1-based, ghosts included).

integer, intent(out) :: cls(:)

Fold-row class of each column (FOLD_ROW_*).


Calls

proc~~fold_receiver_entries~~CallsGraph proc~fold_receiver_entries fold_receiver_entries proc~fold_tile_extent fold_tile_extent proc~fold_receiver_entries->proc~fold_tile_extent proc~fold_tile_owner fold_tile_owner proc~fold_receiver_entries->proc~fold_tile_owner

Called by

proc~~fold_receiver_entries~~CalledByGraph proc~fold_receiver_entries fold_receiver_entries proc~fold_plan_build fold_plan_build proc~fold_plan_build->proc~fold_receiver_entries proc~ocean_fold_exchange_init ocean_fold_exchange_init proc~ocean_fold_exchange_init->proc~fold_plan_build proc~engine_setup engine_setup proc~engine_setup->proc~ocean_fold_exchange_init 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
integer, private :: a
integer, private :: a_o
integer, private :: c
integer, private :: g
integer, private :: i
integer, private :: m
integer, private :: p
integer, private :: pm
integer, private :: w
integer, private :: w_o

Source Code

   pure subroutine fold_receiver_entries(ni, px, ng, fam, rx, ncol, own, src, cls)
      !! Every destination column `i = 1..ncol` of tile `rx`'s window for a
      !! column family: the owning tile `own(i)` of its mirror, the owner's
      !! local storage column `src(i)` to read, and the fold-row class
      !! `cls(i)`.  `ncol` = `w+2ng` (T) or `w+2ng+1` (U); the arrays must
      !! hold at least that many entries.
      integer, intent(in) :: ni
         !! Global physical width of the fold row (cells).
      integer, intent(in) :: px
         !! Tiles along the fold row.
      integer, intent(in) :: ng
         !! Ghost width.
      integer, intent(in) :: fam
         !! Column family (`FOLD_FAM_T` or `FOLD_FAM_U`).
      integer, intent(in) :: rx
         !! Receiving tile x-coordinate (0-based).
      integer, intent(out) :: ncol
         !! Destination columns filled (`w+2ng` for T, `w+2ng+1` for U).
      integer, intent(out) :: own(:)
         !! Owning tile x-coordinate (0-based) of each column's mirror.
      integer, intent(out) :: src(:)
         !! Owner's local storage column to read (1-based, ghosts included).
      integer, intent(out) :: cls(:)
         !! Fold-row class of each column (`FOLD_ROW_*`).

      integer :: a, w, a_o, w_o, i, g, c, m, p, pm

      call fold_tile_extent(ni, px, rx, a, w)
      if (fam == FOLD_FAM_U) then
         ncol = w + 2*ng + 1
      else
         ncol = w + 2*ng
      end if

      do i = 1, ncol
         ! Global column of storage slot i, reduced into 1..ni.
         g = a + i - ng - 1
         c = modulo(g - 1, ni) + 1
         if (fam == FOLD_FAM_U) then
            ! Face c (west face of cell c, c = 1 ≡ ni+1) mirrors to face
            ! m = ni+2-c in 2..ni+1: the EAST face of cell m-1, owned (D1)
            ! by the tile holding that cell.
            m = ni + 2 - c
            own(i) = fold_tile_owner(ni, px, m - 1)
            call fold_tile_extent(ni, px, own(i), a_o, w_o)
            src(i) = ng + m - a_o + 1
            ! Corner projection rule (`fold_north_corner_2d`).
            p = c
            pm = modulo(ni + 1 - p, ni) + 1
         else
            m = ni + 1 - c
            own(i) = fold_tile_owner(ni, px, m)
            call fold_tile_extent(ni, px, own(i), a_o, w_o)
            src(i) = ng + m - a_o + 1
            ! v projection rule (`fold_north_v_face_*`).
            p = c
            pm = ni + 1 - p
         end if
         if (p < pm) then
            cls(i) = FOLD_ROW_WEST
         else if (p == pm) then
            cls(i) = FOLD_ROW_SELF
         else
            cls(i) = FOLD_ROW_EAST
         end if
      end do
   end subroutine fold_receiver_entries