mapping_domain Subroutine

subroutine mapping_domain(map_proc, map_domainX, map_domainY, points_per_procX, points_per_procY, NX, NY, proc_id, global_indexX, global_indexY)

mapping_domain – Determime the indices of the local domain corners with respect to the global domain.

Arguments

Type IntentOptional Attributes Name
integer, intent(out) :: map_proc(0:NX-1,0:NY-1)

mapping procs to subdomains

integer, intent(out) :: map_domainX(0:NX-1,0:NY-1,2)

sub-domain x-corners

integer, intent(out) :: map_domainY(0:NX-1,0:NY-1,2)

sub-domain y-corners

integer, intent(in) :: points_per_procX(0:NX-1)

num of grid points/proc along x-axis

integer, intent(in) :: points_per_procY(0:NY-1)

num of grid points/proc along y-axis

integer, intent(in) :: NX

num of procs along x-axis

integer, intent(in) :: NY

num of procs along y-axis

integer, intent(in) :: proc_id
integer, intent(out) :: global_indexX(2)

Global sub-domain x-corners for proc_id

integer, intent(out) :: global_indexY(2)

Global sub-domain y-corners for proc_id


Called by

proc~~mapping_domain~~CalledByGraph proc~mapping_domain mapping_domain proc~perform_domain_deposition perform_domain_deposition proc~perform_domain_deposition->proc~mapping_domain program~main~8 main program~main~8->proc~perform_domain_deposition

Source Code

   subroutine mapping_domain(map_proc, map_domainX, map_domainY, &
                        points_per_procX, points_per_procY, NX, NY, &
                        proc_id, global_indexX, global_indexY)

      integer, intent(in)  :: proc_id
      integer, intent(in)  :: NX                       !! num of procs along x-axis
      integer, intent(in)  :: NY                       !! num of procs along y-axis
      integer, intent(in)  :: points_per_procX(0:NX-1) !! num of grid points/proc along x-axis
      integer, intent(in)  :: points_per_procY(0:NY-1) !! num of grid points/proc along y-axis
!
      integer, intent(out) :: map_proc(0:NX-1, 0:NY-1)       !! mapping procs to subdomains
      integer, intent(out) :: map_domainX(0:NX-1, 0:NY-1, 2) !! sub-domain x-corners
      integer, intent(out) :: map_domainY(0:NX-1, 0:NY-1, 2) !! sub-domain y-corners
      integer, intent(out) :: global_indexX(2)               !! Global sub-domain x-corners for proc_id
      integer, intent(out) :: global_indexY(2)               !! Global sub-domain y-corners for proc_id
!
      integer ::  ix, iy, prevX, prevY, lastY
      logical :: firstX, firstY
!------------------------------------------------------------------------------
      firstX = .TRUE.
      firstY = .TRUE.
      do iy = 0, NY-1
         if (firstY) then
            prevY = 1
            firstY = .FALSE.
         else
            prevY = lastY
         endif
         do ix = 0, NX-1
            map_proc(ix,iy) = ix + iy*NX

            if (firstX) then
               prevX = 1
               firstX = .FALSE.
            endif
            map_domainX(ix,iy, 1) = prevX
            map_domainX(ix,iy, 2) = prevX + points_per_procX(ix) - 1
            prevX = map_domainX(ix,iy, 2) + 1

            map_domainY(ix,iy, 1) = prevY
            map_domainY(ix,iy, 2) = prevY + points_per_procY(iy) - 1
            lastY = map_domainY(ix,iy, 2) + 1

            if ( map_proc(ix,iy) == proc_id ) then
               global_indexX(1) = map_domainX(ix,iy, 1)
               global_indexX(2) = map_domainX(ix,iy, 2)
               global_indexY(1) = map_domainY(ix,iy, 1)
               global_indexY(2) = map_domainY(ix,iy, 2)
            endif
         enddo
         firstX = .TRUE.
      enddo
   end subroutine mapping_domain