| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | index | |||
| integer, | intent(out) | :: | igrid_particle | |||
| integer, | intent(out) | :: | ipe_particle |
subroutine locate_particle(index,igrid_particle,ipe_particle) ! given the particles unique index, tell me on which cpu and igrid it is ! returns -1,-1 if particle was not found use mod_global_parameters integer, intent(in) :: index integer, intent(out) :: igrid_particle,& ipe_particle integer :: iipart,ipart,& ipe_has_particle,ipe logical :: has_particle(0:npe-1) integer,dimension(0:1) :: buff has_particle(:) = .false. do iipart=1,nparticles_on_mype;ipart=particles_on_mype(iipart); if (particle(ipart)%self%index == index) then has_particle(mype) = .true. exit end if end do if (has_particle(mype)) then buff(0) = particle(ipart)%igrid buff(1) = mype end if if (npe>0) call MPI_ALLGATHER(has_particle(mype),1,MPI_LOGICAL,& has_particle,1,MPI_LOGICAL,icomm,ierrmpi) ipe_has_particle = -1 do ipe=0,npe-1 if (has_particle(ipe) .eqv. .true.) then ipe_has_particle = ipe exit end if end do if (ipe_has_particle .ne. -1) then if (npe>0) call MPI_BCAST(buff,2,MPI_INTEGER,ipe_has_particle,icomm,& ierrmpi) igrid_particle=buff(0) ipe_particle = buff(1) else igrid_particle=-1 ipe_particle = -1 end if end subroutine locate_particle