find neighors of level-one root blocks
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(tree_node_ptr) | :: | tree_neighbor | ||||
| type(tree_node_ptr) | :: | tree | ||||
| integer, | intent(in) | :: | i1 | |||
| integer, | intent(in) | :: | i2 | |||
| integer, | intent(in) | :: | i3 |
subroutine find_root_neighbor(tree_neighbor,tree,i1,i2,i3) use mod_forest use mod_global_parameters use mod_geometry type(tree_node_ptr) :: tree_neighbor, tree integer, intent(in) :: i1,i2,i3 integer :: jg1,jg2,jg3 jg1=tree%node%ig1+i1;jg2=tree%node%ig2+i2;jg3=tree%node%ig3+i3; ! find the periodic grid indices, modulo(-1,10)=9 if (periodB(1)) jg1=1+modulo(jg1-1,ng1(1)) if (periodB(2)) jg2=1+modulo(jg2-1,ng2(1)) if (periodB(3)) jg3=1+modulo(jg3-1,ng3(1)) ! pi-periodicity at pole select case (coordinate) case (spherical) if (poleB(1,2).and.jg2==0) then ! northpole (theta=0) jg2=1; jg3=1+modulo(jg3+ng3(1)/2-1,ng3(1)) end if if (poleB(2,2).and.jg2==ng2(1)+1) then ! southpole (theta=pi) jg2=ng2(1); jg3=1+modulo(jg3+ng3(1)/2-1,ng3(1)) end if case (cylindrical) if (poleB(1,1).and.jg1==0) then ! cylindrical axis jg1=1 if (1==phi_) jg1=1+modulo(jg1+ng1(1)/2-1,ng1(1)) if (2==phi_) jg2=1+modulo(jg2+ng2(1)/2-1,ng2(1)) if (3==phi_) jg3=1+modulo(jg3+ng3(1)/2-1,ng3(1)) end if end select if (jg1>=1.and.jg1<=ng1(1).and.jg2>=1.and.jg2<=ng2(1).and.jg3>=& 1.and.jg3<=ng3(1)) then tree_neighbor%node => tree_root(jg1,jg2,jg3)%node else nullify(tree_neighbor%node) end if end subroutine find_root_neighbor