SideExchange_MappedScalar2D_t Subroutine

public subroutine SideExchange_MappedScalar2D_t(this, mesh)

Arguments

TypeIntentOptionalAttributesName
class(MappedScalar2D_t), intent(inout) :: this
type(Mesh2D), intent(inout) :: mesh

Contents


Source Code

  subroutine SideExchange_MappedScalar2D_t(this,mesh)
    implicit none
    class(MappedScalar2D_t),intent(inout) :: this
    type(Mesh2D),intent(inout) :: mesh
    ! Local
    integer :: e1,e2,s1,s2,e2Global
    integer :: flip
    integer :: i1,i2,ivar
    integer :: r2
    integer :: rankId,offset,N
    integer,pointer :: elemtorank(:)

    ! This mapping is needed to resolve a build error with
    ! amdflang that appears to be caused by referencing
    ! the elemToRank attribute within the do concurrent
    ! https://github.com/FluidNumerics/SELF/issues/54
    elemtorank => mesh%decomp%elemToRank(:)
    rankId = mesh%decomp%rankId
    offset = mesh%decomp%offsetElem(rankId+1)
    N = this%interp%N

    if(mesh%decomp%mpiEnabled) then
      call this%MPIExchangeAsync(mesh)
    endif

    do concurrent(s1=1:4,e1=1:mesh%nElem,ivar=1:this%nvar)

      e2Global = mesh%sideInfo(3,s1,e1)
      e2 = e2Global-offset
      s2 = mesh%sideInfo(4,s1,e1)/10
      flip = mesh%sideInfo(4,s1,e1)-s2*10

      if(e2Global > 0) then

        r2 = elemToRank(e2Global)
        if(r2 == rankId) then

          if(flip == 0) then
            do i1 = 1,N+1
              this%extBoundary(i1,s1,e1,ivar) = &
                this%boundary(i1,s2,e2,ivar)
            enddo

          elseif(flip == 1) then
            do i1 = 1,N+1
              i2 = N+2-i1
              this%extBoundary(i1,s1,e1,ivar) = &
                this%boundary(i2,s2,e2,ivar)
            enddo

          endif
        endif
      endif
    enddo

    if(mesh%decomp%mpiEnabled) then
      call mesh%decomp%FinalizeMPIExchangeAsync()
      ! Apply side flips for data exchanged with MPI
      call this%ApplyFlip(mesh)
    endif

  endsubroutine SideExchange_MappedScalar2D_t