Returns block ID and rank of the block where the point is located using a binary search alogirthm. Note that this function assumes that the point is within the domain, i.e., (pmin <= p <= pmax) and that any treatment for periodicity has been previously applied.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(block_obj), | intent(in) | :: | this |
A block object |
||
| real(kind=wp), | intent(in) | :: | p(3) |
Position to locate |
MPI rank
impure function block_obj_Locate(this,p) result (rank) !> Returns block ID and rank of the block ! where the point is located using a binary search ! alogirthm. Note that this function assumes that ! the point is within the domain, i.e., (pmin <= p <= pmax) ! and that any treatment for periodicity has been ! previously applied. use mpi_f08 implicit none class(block_obj), intent(in) :: this !! A block object real(wp), intent(in) :: p(3) !! Position to locate integer :: rank !! MPI rank ! Work variables integer :: dir integer :: ind(3) integer :: i_lo integer :: i_hi integer :: ierr associate(axis_p => this%axis_partition, np => this%parallel%np) do dir=1,3 ! Find block index using binary search i_lo = axis_p(dir)%lo i_hi = axis_p(dir)%hi + 1 do while (i_hi-i_lo.ge.2) ind(dir) = (i_hi+i_lo)/2 if (p(dir).ge.axis_p(dir)%x( ind(dir) )) then i_lo = ind(dir) else i_hi = ind(dir) end if end do ind(dir) = i_lo end do ! Get rank from the MPI cartesian topology call MPI_CART_RANK(this%parallel%comm%g,ind-1,rank,ierr) ! Adjust rank to be 1-based (instead of 0-based ranks returned by MPI) rank = rank + 1 end associate return end function block_obj_Locate