get_parity_conn Subroutine

private subroutine get_parity_conn(iglo, iglo_conn, iproc_conn)

Return the iglo corresponding to the part of the domain given by iglo reflected in theta=theta0

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: iglo
integer, intent(out) :: iglo_conn
integer, intent(out) :: iproc_conn

Contents

Source Code


Source Code

  subroutine get_parity_conn(iglo,iglo_conn,iproc_conn)
    use gs2_layouts, only: ik_idx,it_idx,proc_id,g_lo
    implicit none
    integer, intent(in) :: iglo
    integer, intent(out) :: iglo_conn, iproc_conn
    integer :: it, ik, it_conn, link, tmp

    !Get indices
    it=it_idx(g_lo,iglo)
    ik=ik_idx(g_lo,iglo)

    !Initialise to this cell
    tmp=iglo
    
    !Now check number of links
    if(l_links(it, ik).eq.r_links(it, ik))then
       !If in the middle of the domain then iglo doesn't change
       !Just get the proc id
       iproc_conn=proc_id(g_lo,iglo)
       iglo_conn=tmp
    elseif(l_links(it, ik).gt.r_links(it, ik))then
       !If we're on the right then look left
       do link=1,l_links(it, ik)
          !Get the next connected domain
          call get_left_connection(tmp,iglo_conn,iproc_conn)

          !What is the it index here?
          it_conn=it_idx(g_lo,iglo_conn)

          !Update current iglo
          tmp=iglo_conn

          !If the number of right links now matches the left then we've got the match
          if(r_links(it_conn, ik).eq.l_links(it, ik)) exit
       enddo
    else
       !If we're on the left then look right
       do link=1,r_links(it, ik)
          !Get the next connected domain
          call get_right_connection(tmp,iglo_conn,iproc_conn)

          !What is the it index here?
          it_conn=it_idx(g_lo,iglo_conn)

          !Update current iglo
          tmp=iglo_conn

          !If the number of left links now matches the right then we've got the match
          if(l_links(it_conn, ik).eq.r_links(it, ik)) exit
       enddo
    endif
  end subroutine get_parity_conn