13 integer :: Morton_no, recv_igrid, recv_ipe, send_igrid, send_ipe, igrid, ipe
15 integer :: itag, irecv, isend
16 integer,
dimension(:),
allocatable :: recvrequest, sendrequest
17 integer,
dimension(:,:),
allocatable :: recvstatus, sendstatus
20 integer,
dimension(:),
allocatable :: recvrequest_stg, sendrequest_stg
21 integer,
dimension(:,:),
allocatable :: recvstatus_stg, sendstatus_stg
36 recvrequest=mpi_request_null
37 sendrequest=mpi_request_null
42 recvrequest_stg=mpi_request_null
43 sendrequest_stg=mpi_request_null
49 send_igrid=
sfc(1,morton_no)
50 send_ipe=
sfc(2,morton_no)
52 if (recv_ipe/=send_ipe)
then
62 if (recv_ipe==
mype)
then
63 if (recv_ipe==send_ipe)
then
72 call mpi_waitall(irecv,recvrequest,recvstatus,ierrmpi)
73 if(stagger_grid)
call mpi_waitall(irecv,recvrequest_stg,recvstatus_stg,ierrmpi)
76 call mpi_waitall(isend,sendrequest,sendstatus,ierrmpi)
77 if(stagger_grid)
call mpi_waitall(isend,sendrequest_stg,sendstatus_stg,ierrmpi)
80 deallocate(recvstatus,recvrequest,sendstatus,sendrequest)
81 if(stagger_grid)
deallocate(recvstatus_stg,recvrequest_stg,sendstatus_stg,sendrequest_stg)
84 do ipe=0,npe-1;
do morton_no=morton_start(ipe),morton_stop(ipe)
87 send_igrid=sfc(1,morton_no)
88 send_ipe=sfc(2,morton_no)
90 if (recv_ipe/=send_ipe)
then
92 call putnode(send_igrid,send_ipe)
95 {
#IFDEF EVOLVINGBOUNDARY
97 do morton_no=morton_start(mype),morton_stop(mype)
98 igrid=sfc_to_igrid(morton_no)
99 if (phyboundblock(igrid)) sfc_phybound(morton_no)=1
101 call mpi_allreduce(mpi_in_place,sfc_phybound,nleafs,mpi_integer,&
102 mpi_sum,icomm,ierrmpi)
106 call amr_morton_order()
117 {
#IFDEF EVOLVINGBOUNDARY
118 if (phyboundblock(recv_igrid))
then
119 call mpi_irecv(ps(recv_igrid)%w,1,type_block,send_ipe,itag, &
120 icomm,recvrequest(irecv),ierrmpi)
122 call mpi_irecv(ps(recv_igrid)%w,1,type_block_io,send_ipe,itag, &
123 icomm,recvrequest(irecv),ierrmpi)
125 }{
#IFNDEF EVOLVINGBOUNDARY
126 call mpi_irecv(ps(recv_igrid)%w,1,type_block_io,send_ipe,itag, &
127 icomm,recvrequest(irecv),ierrmpi)
129 if(stagger_grid)
then
130 itag=recv_igrid+max_blocks
131 call mpi_irecv(ps(recv_igrid)%ws,1,type_block_io_stg,send_ipe,itag, &
132 icomm,recvrequest_stg(irecv),ierrmpi)
141 {
#IFDEF EVOLVINGBOUNDARY
142 if (phyboundblock(send_igrid))
then
143 call mpi_isend(ps(send_igrid)%w,1,type_block,recv_ipe,itag, &
144 icomm,sendrequest(isend),ierrmpi)
146 call mpi_isend(ps(send_igrid)%w,1,type_block_io,recv_ipe,itag, &
147 icomm,sendrequest(isend),ierrmpi)
149 }{
#IFNDEF EVOLVINGBOUNDARY
150 call mpi_isend(ps(send_igrid)%w,1,type_block_io,recv_ipe,itag, &
151 icomm,sendrequest(isend),ierrmpi)
153 if(stagger_grid)
then
154 itag=recv_igrid+max_blocks
155 call mpi_isend(ps(send_igrid)%ws,1,type_block_io_stg,recv_ipe,itag, &
156 icomm,sendrequest_stg(isend),ierrmpi)
subroutine, public putnode(igrid, ipe)
subroutine, public alloc_node(igrid)
allocate arrays on igrid node
integer function, public getnode(ipe)
Get first available igrid on processor ipe.
Module with basic grid data structures.
integer, dimension(:), allocatable, save sfc_to_igrid
Go from a Morton number to an igrid index (for a single processor)
integer, dimension(:), allocatable, save morton_start
First Morton number per processor.
integer, dimension(:), allocatable, save morton_stop
Last Morton number per processor.
integer, dimension(:,:), allocatable, save sfc
Array to go from a Morton number to an igrid and processor index. Sfc(1:3, MN) contains [igrid,...
subroutine, public change_ipe_tree_leaf(recv_igrid, recv_ipe, send_igrid, send_ipe)
This module contains definitions of global parameters and variables and some generic functions/subrou...
logical stagger_grid
True for using stagger grid.
integer mype
The rank of the current MPI task.
integer npe
The number of MPI tasks.
integer max_blocks
The maximum number of grid blocks in a processor.
subroutine load_balance
reallocate blocks into processors for load balance
subroutine get_morton_range
Set the Morton range for each processor.