proc_id_gf Function

private elemental function proc_id_gf(lo, i)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
type(gf_layout_type), intent(in) :: lo
integer, intent(in) :: i

Return Value integer


Contents

Source Code


Source Code

  elemental function proc_id_gf (lo, i)
    implicit none
    integer :: proc_id_gf
    type (gf_layout_type), intent (in) :: lo
    integer, intent (in) :: i

! For this scenario we have more blocks than processes so each process has multiple blocks, but the number of blocks
! does not exactly divide by the number of processes, so some have larger blocks than others.
    if(lo%largeblocksize .gt. 1) then
       if(i .gt. lo%largeregionlimit) then
           proc_id_gf = (((i - (lo%largeblocksize * lo%largeblocklimit) - lo%llim_world)/lo%smallblocksize) + lo%largeblocklimit)
       else
           proc_id_gf = (i - lo%llim_world) / lo%largeblocksize
       end if
! For this scenario we have less blocks than processes so we try to spread the blocks between processes.
    else if(lo%largeblocksize .eq. 1) then
       if(i .gt. lo%largeblocklimit) then
          proc_id_gf = lo%largeregionlimit + ((i - lo%largeblocklimit - lo%llim_world)*lo%smallgapsize)
       else
          proc_id_gf = (i - lo%llim_world) * lo%largegapsize
       end if
! For this scenario we either have exactly the same number of blocks as processes, or the number of blocks divides exactly
! by the number of processes so each process has the same size blocks of the domain.
! It is also used by the "simple_gf_decomposition" functionality for the scenario where we have less blocks than processes and we 
! are not trying to distributed those blocks through the whole process space, just assigning them to the first n processes 
! (where n is the number of xypoints we have in the gf_lo domain).
    else
       proc_id_gf = (i - lo%llim_world) / lo%smallblocksize
    end if

  end function proc_id_gf