41 integer :: iigrid, igrid
61 integer :: iigrid, igrid, i^
d, my_neighbor_type
62 integer :: iside, idim, ic^
d, inc^
d, ih^
d, icdim
64 logical,
dimension(^ND) :: pole
67 integer :: idir,pi^
d, mi^
d, ph^
d, mh^
d, ipe_neighbor
68 integer :: nrecvs,nsends
71 integer :: nbuff_bc_recv_srl, nbuff_bc_send_srl, nbuff_bc_recv_r, nbuff_bc_send_r, nbuff_bc_recv_p, nbuff_bc_send_p
76 nrecv_fc=0; nsend_fc=0
77 nbuff_bc_recv_srl=0; nbuff_bc_send_srl=0
78 nbuff_bc_recv_r=0; nbuff_bc_send_r=0
79 nbuff_bc_recv_p=0; nbuff_bc_send_p=0
82 do iigrid=1,igridstail; igrid=igrids(iigrid);
87 if (i^
d==0|.and.)
then
88 neighbor_type(0^
d&,igrid)=0
89 neighbor(1,0^
d&,igrid)=igrid
90 neighbor(2,0^
d&,igrid)=
mype
95 select case (my_neighbor_type)
97 case (neighbor_boundary)
98 neighbor(1,i^
d,igrid)=0
99 neighbor(2,i^
d,igrid)=-1
101 case (neighbor_coarse)
102 neighbor(1,i^
d,igrid)=my_neighbor%node%igrid
103 neighbor(2,i^
d,igrid)=my_neighbor%node%ipe
104 if (my_neighbor%node%ipe/=
mype)
then
105 ic^
d=1+modulo(tree%node%ig^
d-1,2);
106 if ({(i^
d==0.or.i^
d==2*ic^
d-3)|.and.})
then
116 case (neighbor_sibling)
117 neighbor(1,i^
d,igrid)=my_neighbor%node%igrid
118 neighbor(2,i^
d,igrid)=my_neighbor%node%ipe
119 if (my_neighbor%node%ipe/=
mype)
then
127 neighbor(1,i^
d,igrid)=0
128 neighbor(2,i^
d,igrid)=-1
131 {
do ic^db=1+int((1-i^db)/2),2-int((1+i^db)/2)
138 child%node => my_neighbor%node%child(ih^d)%node
139 neighbor_child(1,inc^d,igrid)=child%node%igrid
140 neighbor_child(2,inc^d,igrid)=child%node%ipe
141 if (child%node%ipe/=mype)
then
142 nrecv_bc_r=nrecv_bc_r+1
143 nsend_bc_p=nsend_bc_p+1
144 nbuff_bc_send_p=nbuff_bc_send_p+sizes_p_send_total(inc^d)
145 nbuff_bc_recv_r=nbuff_bc_recv_r+sizes_r_recv_total(inc^d)
151 if ({abs(i^d)+}==1)
then
156 select case (my_neighbor_type)
158 case (neighbor_coarse)
159 if (my_neighbor%node%ipe/=mype)
then
160 if (.not.pole(idim)) nsend_fc(idim)=nsend_fc(idim)+1
170 {
do ic^d=icdim,icdim^d%do ic^dd=1,2\}
171 child%node => my_neighbor%node%child(ic^dd)%node
172 if (child%node%ipe/=mype)
then
173 if (.not.pole(^d)) nrecv_fc(^d)=nrecv_fc(^d)+1
181 neighbor_pole(i^d,igrid)=0
182 if (my_neighbor_type>1)
then
185 neighbor_pole(i^d,igrid)=idim
191 neighbor_type(i^d,igrid)=my_neighbor_type
196 if(stagger_grid)
then
201 if ({abs(i^d)+}==1)
then
202 if (neighbor_pole(i^d,igrid)/=0) cycle
209 if (neighbor_type(i^d,igrid)==2)
then
211 pi^d=i^d+kr(idir,^d);
212 mi^d=i^d-kr(idir,^d);
213 ph^d=pi^d-kr(idim,^d)*(2*iside-3);
214 mh^d=mi^d-kr(idim,^d)*(2*iside-3);
216 if (neighbor_type(pi^d,igrid)==2.and.&
217 neighbor_type(ph^d,igrid)==2.and.&
218 mype/=neighbor(2,pi^d,igrid).and.&
219 neighbor_pole(pi^d,igrid)==0)
then
220 nsend_cc(idim) = nsend_cc(idim) + 1
223 if (neighbor_type(mi^d,igrid)==2.and.&
224 neighbor_type(mh^d,igrid)==2.and.&
225 mype/=neighbor(2,mi^d,igrid).and.&
226 neighbor_pole(mi^d,igrid)==0)
then
227 nsend_cc(idim) = nsend_cc(idim) + 1
232 if (neighbor_type(i^d,igrid)==3)
then
234 pi^d=i^d+kr(idir,^d);
235 mi^d=i^d-kr(idir,^d);
236 ph^d=pi^d-kr(idim,^d)*(2*iside-3);
237 mh^d=mi^d-kr(idim,^d)*(2*iside-3);
239 if (neighbor_type(pi^d,igrid)==4.and.&
240 neighbor_type(ph^d,igrid)==3.and.&
241 neighbor_pole(pi^d,igrid)==0)
then
243 {
do ic^db=1+int((1-pi^db)/2),2-int((1+pi^db)/2)
244 inc^db=2*pi^db+ic^db\}
245 if (mype.ne.neighbor_child(2,inc^d,igrid))
then
246 nrecv_cc(idim) = nrecv_cc(idim) + 1
251 if (neighbor_type(mi^d,igrid)==4.and.&
252 neighbor_type(mh^d,igrid)==3.and.&
253 neighbor_pole(mi^d,igrid)==0)
then
255 {
do ic^db=1+int((1-mi^db)/2),2-int((1+mi^db)/2)
256 inc^db=2*mi^db+ic^db\}
257 if (mype.ne.neighbor_child(2,inc^d,igrid))
then
258 nrecv_cc(idim) = nrecv_cc(idim) + 1
271 nrecvs=nrecv_bc_srl+nrecv_bc_r
272 if (
allocated(recvstatus_c_sr))
then
273 deallocate(recvstatus_c_sr,recvrequest_c_sr)
274 allocate(recvstatus_c_sr(mpi_status_size,nrecvs),recvrequest_c_sr(nrecvs))
276 allocate(recvstatus_c_sr(mpi_status_size,nrecvs),recvrequest_c_sr(nrecvs))
278 recvrequest_c_sr=mpi_request_null
281 nsends=nsend_bc_srl+nsend_bc_r
282 if (
allocated(sendstatus_c_sr))
then
283 deallocate(sendstatus_c_sr,sendrequest_c_sr)
284 allocate(sendstatus_c_sr(mpi_status_size,nsends),sendrequest_c_sr(nsends))
286 allocate(sendstatus_c_sr(mpi_status_size,nsends),sendrequest_c_sr(nsends))
288 sendrequest_c_sr=mpi_request_null
291 if (
allocated(recvstatus_c_p))
then
292 deallocate(recvstatus_c_p,recvrequest_c_p)
293 allocate(recvstatus_c_p(mpi_status_size,nrecv_bc_p),recvrequest_c_p(nrecv_bc_p))
295 allocate(recvstatus_c_p(mpi_status_size,nrecv_bc_p),recvrequest_c_p(nrecv_bc_p))
297 recvrequest_c_p=mpi_request_null
300 if (
allocated(sendstatus_c_p))
then
301 deallocate(sendstatus_c_p,sendrequest_c_p)
302 allocate(sendstatus_c_p(mpi_status_size,nsend_bc_p),sendrequest_c_p(nsend_bc_p))
304 allocate(sendstatus_c_p(mpi_status_size,nsend_bc_p),sendrequest_c_p(nsend_bc_p))
306 sendrequest_c_p=mpi_request_null
308 if(stagger_grid)
then
310 if (
allocated(recvbuffer_srl))
then
311 if (nbuff_bc_recv_srl /=
size(recvbuffer_srl))
then
312 deallocate(recvbuffer_srl)
313 allocate(recvbuffer_srl(nbuff_bc_recv_srl))
316 allocate(recvbuffer_srl(nbuff_bc_recv_srl))
318 if (
allocated(recvstatus_srl))
then
319 deallocate(recvstatus_srl,recvrequest_srl)
320 allocate(recvstatus_srl(mpi_status_size,nrecv_bc_srl),recvrequest_srl(nrecv_bc_srl))
322 allocate(recvstatus_srl(mpi_status_size,nrecv_bc_srl),recvrequest_srl(nrecv_bc_srl))
324 recvrequest_srl=mpi_request_null
327 if (
allocated(sendbuffer_srl))
then
328 if (nbuff_bc_send_srl /=
size(sendbuffer_srl))
then
329 deallocate(sendbuffer_srl)
330 allocate(sendbuffer_srl(nbuff_bc_send_srl))
333 allocate(sendbuffer_srl(nbuff_bc_send_srl))
335 if (
allocated(sendstatus_srl))
then
336 deallocate(sendstatus_srl,sendrequest_srl)
337 allocate(sendstatus_srl(mpi_status_size,nsend_bc_srl),sendrequest_srl(nsend_bc_srl))
339 allocate(sendstatus_srl(mpi_status_size,nsend_bc_srl),sendrequest_srl(nsend_bc_srl))
341 sendrequest_srl=mpi_request_null
344 if (
allocated(recvbuffer_r))
then
345 if (nbuff_bc_recv_r /=
size(recvbuffer_r))
then
346 deallocate(recvbuffer_r)
347 allocate(recvbuffer_r(nbuff_bc_recv_r))
350 allocate(recvbuffer_r(nbuff_bc_recv_r))
352 if (
allocated(recvstatus_r))
then
353 deallocate(recvstatus_r,recvrequest_r)
354 allocate(recvstatus_r(mpi_status_size,nrecv_bc_r),recvrequest_r(nrecv_bc_r))
356 allocate(recvstatus_r(mpi_status_size,nrecv_bc_r),recvrequest_r(nrecv_bc_r))
358 recvrequest_r=mpi_request_null
361 if (
allocated(sendbuffer_r))
then
362 if (nbuff_bc_send_r /=
size(sendbuffer_r))
then
363 deallocate(sendbuffer_r)
364 allocate(sendbuffer_r(nbuff_bc_send_r))
367 allocate(sendbuffer_r(nbuff_bc_send_r))
369 if (
allocated(sendstatus_r))
then
370 deallocate(sendstatus_r,sendrequest_r)
371 allocate(sendstatus_r(mpi_status_size,nsend_bc_r),sendrequest_r(nsend_bc_r))
373 allocate(sendstatus_r(mpi_status_size,nsend_bc_r),sendrequest_r(nsend_bc_r))
375 sendrequest_r=mpi_request_null
378 if (
allocated(recvbuffer_p))
then
379 if (nbuff_bc_recv_p /=
size(recvbuffer_p))
then
380 deallocate(recvbuffer_p)
381 allocate(recvbuffer_p(nbuff_bc_recv_p))
384 allocate(recvbuffer_p(nbuff_bc_recv_p))
386 if (
allocated(recvstatus_p))
then
387 deallocate(recvstatus_p,recvrequest_p)
388 allocate(recvstatus_p(mpi_status_size,nrecv_bc_p),recvrequest_p(nrecv_bc_p))
390 allocate(recvstatus_p(mpi_status_size,nrecv_bc_p),recvrequest_p(nrecv_bc_p))
392 recvrequest_p=mpi_request_null
395 if (
allocated(sendbuffer_p))
then
396 if (nbuff_bc_send_p /=
size(sendbuffer_p))
then
397 deallocate(sendbuffer_p)
398 allocate(sendbuffer_p(nbuff_bc_send_p))
401 allocate(sendbuffer_p(nbuff_bc_send_p))
403 if (
allocated(sendstatus_p))
then
404 deallocate(sendstatus_p,sendrequest_p)
405 allocate(sendstatus_p(mpi_status_size,nsend_bc_p),sendrequest_p(nsend_bc_p))
407 allocate(sendstatus_p(mpi_status_size,nsend_bc_p),sendrequest_p(nsend_bc_p))
409 sendrequest_p=mpi_request_null
subroutine, public find_neighbor(my_neighbor, my_neighbor_type, tree, iD, pole)
find neighors of all blocks
Module with basic grid data structures.
logical, dimension(:,:), allocatable, save igrid_inuse
type(tree_node_ptr), dimension(:), allocatable, save level_tail
The tail pointer of the linked list per refinement level.
type(tree_node_ptr), dimension(:,:), allocatable, save igrid_to_node
Array to go from an [igrid, ipe] index to a node pointer.
subroutine, public get_level_range
subroutine, public build_connectivity
subroutine, public getigrids
update ghost cells of all blocks including physical boundaries
integer, dimension(-1:1^d &) sizes_r_send_total
integer, dimension(-1:1^d &) sizes_srl_send_total
integer, dimension(0:3^d &) sizes_p_recv_total
integer, dimension(-1:1^d &) sizes_srl_recv_total
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, dimension(:), allocatable, parameter d
integer refine_max_level
Maximal number of AMR levels.
integer max_blocks
The maximum number of grid blocks in a processor.