28 integer,
intent(in) :: global_indices(:)
29 integer,
intent(in) :: ndivs
30 integer,
intent(out) :: layout(:)
32 integer :: isg, ieg, jsg, jeg, isz, jsz, idiv, jdiv
34 if(
size(global_indices(:)) .NE. 4)
call mpp_error(fatal,
"mpp_define_layout2D: size of global_indices should be 4")
35 if(
size(layout(:)) .NE. 2)
call mpp_error(fatal,
"mpp_define_layout2D: size of layout should be 2")
37 isg = global_indices(1)
38 ieg = global_indices(2)
39 jsg = global_indices(3)
40 jeg = global_indices(4)
45 idiv = nint( sqrt(float(ndivs*isz)/jsz) )
47 do while( mod(ndivs,idiv).NE.0 )
52 layout = (/ idiv, jdiv /)
63 integer,
dimension(:),
intent(in) :: sizes
64 integer,
dimension(:),
intent(inout) :: pe_start, pe_end
65 integer,
dimension(:),
intent(in),
optional :: pelist, costpertile
66 integer,
dimension(size(sizes(:))) :: costs
67 integer,
dimension(:),
allocatable :: pes
68 integer :: ntiles, npes, totcosts, avgcost
69 integer :: ntiles_left, npes_left, pos, n, tile
70 integer :: cost_on_tile, cost_on_pe, npes_used, errunit
72 ntiles =
size(sizes(:))
73 if(
size(pe_start(:)) .NE. ntiles .OR.
size(pe_end(:)) .NE. ntiles )
then
74 call mpp_error(fatal,
"mpp_define_mosaic_pelist: size mismatch between pe_start/pe_end and sizes")
77 if(
present(costpertile))
then
78 if(
size(costpertile(:)) .NE. ntiles )
then
79 call mpp_error(fatal,
"mpp_define_mosaic_pelist: size mismatch between costpertile and sizes")
81 costs = sizes*costpertile
86 if(
PRESENT(pelist) )
then
87 if( .NOT.any(pelist.EQ.
mpp_pe()) )
then
89 write( errunit,* )
'pe=',
mpp_pe(),
' pelist=', pelist
90 call mpp_error( fatal,
'mpp_define_mosaic_pelist: pe must be in pelist.' )
92 npes =
size(pelist(:))
93 allocate( pes(0:npes-1) )
97 allocate( pes(0:npes-1) )
98 call mpp_get_current_pelist(pes)
105 do while( ntiles_left > 0 )
106 if( npes_left == 1 )
then
108 if(costs(n) > 0)
then
117 totcosts = sum(costs)
118 avgcost = ceiling(real(totcosts)/npes_left )
119 tile = minval(maxloc(costs))
120 cost_on_tile = costs(tile)
122 ntiles_left = ntiles_left - 1
124 totcosts = totcosts - cost_on_tile
125 if(cost_on_tile .GE. avgcost )
then
126 npes_used = min(ceiling(real(cost_on_tile)/avgcost), npes_left)
127 if( ntiles_left > 0 .AND. npes_used == npes_left ) npes_used = npes_used - 1
128 pe_end(tile) = pos + npes_used - 1
129 npes_left = npes_left - npes_used
130 pos = pos + npes_used
134 cost_on_pe = cost_on_tile
135 do while(ntiles_left>npes_left)
136 tile = minval(minloc(costs, costs> 0 ))
137 cost_on_tile = costs(tile)
138 cost_on_pe = cost_on_pe + cost_on_tile
139 if(cost_on_pe > avgcost )
exit
142 ntiles_left = ntiles_left - 1
144 totcosts = totcosts - cost_on_tile
146 npes_left = npes_left - 1
152 if(npes_left .NE. 0 )
call mpp_error(fatal,
"mpp_define_mosaic_pelist: the left npes should be zero")
162 integer,
intent(in) :: isg, ieg, ndivs
163 integer,
dimension(:),
intent(out) :: ibegin, iend
171 is = ie - ceiling( real(ie-isg+1)/ndiv ) + 1
175 if( ie.LT.is )
call mpp_error( fatal, &
176 'MPP_DEFINE_DOMAINS(mpp_compute_block_extent): domain extents must be positive definite.' )
177 if( ndiv.EQ.1 .AND. ibegin(ndiv) .NE. isg ) &
178 call mpp_error( fatal,
'mpp_compute_block_extent: domain extents do not span space completely.' )
188 integer,
intent(in) :: isg, ieg, ndivs
189 integer,
dimension(0:),
intent(out) :: ibegin, iend
190 integer,
dimension(0:),
intent(in),
optional :: extent
192 integer :: ndiv, imax, ndmax, ndmirror
194 logical :: symmetrize, use_extent
197 even(n) = (mod(n,2).EQ.0)
198 odd(n) = (mod(n,2).EQ.1)
201 if(
PRESENT(extent))
then
202 if(
size(extent(:)).NE.ndivs ) &
203 call mpp_error( fatal,
'mpp_compute_extent: extent array size must equal number of domain divisions.' )
205 if(all(extent ==0)) use_extent = .false.
212 if(extent(ndiv) .LE. 0)
call mpp_error( fatal, &
213 &
'mpp_compute_extent: domain extents must be positive definite.' )
214 iend(ndiv) = ibegin(ndiv) + extent(ndiv) - 1
215 ibegin(ndiv+1) = iend(ndiv) + 1
217 iend(ndivs-1) = ibegin(ndivs-1) + extent(ndivs-1) - 1
218 if(iend(ndivs-1) .NE. ieg)
call mpp_error(fatal, &
219 &
'mpp_compute_extent: extent array limits do not match global domain.' )
233 symmetrize = ( even(ndivs) .AND. even(ieg-isg+1) ) .OR. &
234 ( odd(ndivs) .AND. odd(ieg-isg+1) ) .OR. &
235 ( odd(ndivs) .AND. even(ieg-isg+1) .AND. ndivs.LT.(ieg-isg+1)/2 )
244 if( ndiv.LT.(ndivs-1)/2+1 )
then
246 ie = is + ceiling( real(imax-is+1)/(ndmax-ndiv) ) - 1
247 ndmirror = (ndivs-1) - ndiv
248 if( ndmirror.GT.ndiv .AND. symmetrize )
then
250 ibegin(ndmirror) = max( isg+ieg-ie, ie+1 )
251 iend(ndmirror) = max( isg+ieg-is, ie+1 )
252 imax = ibegin(ndmirror) - 1
261 ie = is + ceiling( real(imax-is+1)/(ndmax-ndiv) ) - 1
266 if( ie.LT.is )
call mpp_error( fatal, &
267 'MPP_DEFINE_DOMAINS(mpp_compute_extent): domain extents must be positive definite.' )
268 if( ndiv.EQ.ndivs-1 .AND. iend(ndiv).NE.ieg ) &
269 call mpp_error( fatal,
'mpp_compute_extent: domain extents do not span space completely.' )
282 memory_size, begin_halo, end_halo )
283 integer,
intent(in) :: global_indices(:)
284 integer,
intent(in) :: ndivs
285 type(domain1d),
intent(inout) :: domain
287 integer,
intent(in),
optional :: pelist(0:)
290 integer,
intent(in),
optional :: flags, halo
294 integer,
intent(in),
optional :: extent(0:)
296 logical,
intent(in),
optional :: maskmap(0:)
301 integer,
intent(in),
optional :: memory_size
302 integer,
intent(in),
optional :: begin_halo, end_halo
304 logical :: compute_domain_is_global, data_domain_is_global
305 integer :: ndiv, n, isg, ieg
306 integer,
allocatable :: pes(:)
307 integer :: ibegin(0:ndivs-1), iend(0:ndivs-1)
308 logical :: mask(0:ndivs-1)
309 integer :: halosz, halobegin, haloend
312 if( .NOT.module_is_initialized )
call mpp_error( fatal, &
313 &
'MPP_DEFINE_DOMAINS1D: You must first call mpp_domains_init.' )
314 if(
size(global_indices(:)) .NE. 2)
call mpp_error(fatal,
"mpp_define_domains1D: size of global_indices should be 2")
316 isg = global_indices(1)
317 ieg = global_indices(2)
318 if( ndivs.GT.ieg-isg+1 )
call mpp_error( fatal, &
319 &
'MPP_DEFINE_DOMAINS1D: more divisions requested than rows available.' )
321 if(
PRESENT(pelist) )
then
322 if( .NOT.any(pelist.EQ.
mpp_pe()) )
then
324 write( errunit,* )
'pe=',
mpp_pe(),
' pelist=', pelist
325 call mpp_error( fatal,
'MPP_DEFINE_DOMAINS1D: pe must be in pelist.' )
327 allocate( pes(0:
size(pelist(:))-1) )
331 call mpp_get_current_pelist(pes)
337 if(
PRESENT(maskmap) )
then
338 if(
size(maskmap(:)).NE.ndivs ) &
339 call mpp_error( fatal,
'MPP_DEFINE_DOMAINS1D: maskmap array size must equal number of domain divisions.' )
342 if( count(mask).NE.
size(pes(:)) ) &
343 call mpp_error( fatal,
'MPP_DEFINE_DOMAINS1D: number of TRUEs in maskmap array must match PE count.' )
347 if(
PRESENT(halo) )
then
350 if(
present(begin_halo) .OR.
present(end_halo) )
call mpp_error(fatal, &
351 "mpp_domains_define.inc: when halo is present, begin_halo and end_halo should not present")
353 halobegin = halosz; haloend = halosz
354 if(
present(begin_halo)) halobegin = begin_halo
355 if(
present(end_halo)) haloend = end_halo
356 halosz = max(halobegin, haloend)
358 compute_domain_is_global = .false.
359 data_domain_is_global = .false.
360 domain%cyclic = .false.
363 if(
PRESENT(flags) )
then
366 compute_domain_is_global = ndivs.EQ.1
368 data_domain_is_global = btest(flags,global) .OR. compute_domain_is_global
369 domain%cyclic = btest(flags,cyclic) .AND. halosz.NE.0
370 if(btest(flags,cyclic)) domain%goffset = 0
374 allocate( domain%list(0:ndivs-1) )
377 domain%list(:)%global%begin = isg
378 domain%list(:)%global%end = ieg
379 domain%list(:)%global%size = ieg-isg+1
380 domain%list(:)%global%max_size = ieg-isg+1
381 domain%list(:)%global%is_global = .true.
384 if( compute_domain_is_global )
then
385 domain%list(:)%compute%begin = isg
386 domain%list(:)%compute%end = ieg
387 domain%list(:)%compute%is_global = .true.
388 domain%list(:)%pe = pes(:)
391 domain%list(:)%compute%is_global = .false.
395 domain%list(ndiv)%compute%begin = ibegin(ndiv)
396 domain%list(ndiv)%compute%end = iend(ndiv)
398 domain%list(ndiv)%pe = pes(n)
399 if(
mpp_pe().EQ.pes(n) )domain%pos = ndiv
402 domain%list(ndiv)%pe = null_pe
407 domain%list(:)%compute%size = domain%list(:)%compute%end - domain%list(:)%compute%begin + 1
411 domain%list(:)%domain_data%begin = domain%list(:)%compute%begin
412 domain%list(:)%domain_data%end = domain%list(:)%compute%end
413 domain%list(:)%domain_data%is_global = .false.
415 if( data_domain_is_global )
then
416 domain%list(:)%domain_data%begin = isg
417 domain%list(:)%domain_data%end = ieg
418 domain%list(:)%domain_data%is_global = .true.
421 domain%list(:)%domain_data%begin = domain%list(:)%domain_data%begin - halobegin
422 domain%list(:)%domain_data%end = domain%list(:)%domain_data%end + haloend
423 domain%list(:)%domain_data%size = domain%list(:)%domain_data%end - domain%list(:)%domain_data%begin + 1
428 domain%list(:)%memory%begin = domain%list(:)%domain_data%begin
429 domain%list(:)%memory%end = domain%list(:)%domain_data%end
430 if(
present(memory_size) )
then
431 if(memory_size > 0)
then
432 if( domain%list(domain%pos)%domain_data%size > memory_size )
call mpp_error(fatal, &
433 "mpp_domains_define.inc: data domain size is larger than memory domain size on this pe")
434 domain%list(:)%memory%end = domain%list(:)%memory%begin + memory_size - 1
437 domain%list(:)%memory%size = domain%list(:)%memory%end - domain%list(:)%memory%begin + 1
438 domain%list(:)%memory%is_global = domain%list(:)%domain_data%is_global
440 domain%compute = domain%list(domain%pos)%compute
441 domain%domain_data = domain%list(domain%pos)%domain_data
442 domain%global = domain%list(domain%pos)%global
443 domain%memory = domain%list(domain%pos)%memory
444 domain%compute%max_size = maxval( domain%list(:)%compute%size )
445 domain%domain_data%max_size = maxval( domain%list(:)%domain_data%size )
446 domain%global%max_size = domain%global%size
447 domain%memory%max_size = domain%memory%size
458 type(domain2d),
intent(inout) :: domain
459 integer,
intent(in ) :: io_layout(2)
461 integer :: npes_in_group
462 type(domain2d),
pointer :: io_domain=>null()
463 integer :: i, j, n, m
464 integer :: ipos, jpos, igroup, jgroup
465 integer :: ipos_beg, ipos_end, jpos_beg, jpos_end
466 integer :: whalo, ehalo, shalo, nhalo
467 integer :: npes_x, npes_y, ndivx, ndivy
468 integer,
allocatable :: posarray(:,:)
470 if(io_layout(1) * io_layout(2) .LE. 0)
then
471 call mpp_error(note, &
472 "mpp_domains_define.inc(mpp_define_io_domain): io domain will not be defined for "//trim(domain%name)// &
473 " when one or both entry of io_layout is not positive")
477 layout(1) =
size(domain%x(1)%list(:))
478 layout(2) =
size(domain%y(1)%list(:))
480 if(
ASSOCIATED(domain%io_domain))
call mpp_error(fatal, &
481 "mpp_domains_define.inc(mpp_define_io_domain): io_domain is already defined")
483 if(mod(layout(1), io_layout(1)) .NE. 0)
call mpp_error(fatal, &
484 "mpp_domains_define.inc(mpp_define_io_domain): "//trim(domain%name)// &
485 &
" domain layout(1) must be divided by io_layout(1)")
486 if(mod(layout(2), io_layout(2)) .NE. 0)
call mpp_error(fatal, &
487 "mpp_domains_define.inc(mpp_define_io_domain): "//trim(domain%name)// &
488 &
" domain layout(2) must be divided by io_layout(2)")
489 if(
size(domain%x(:)) > 1)
call mpp_error(fatal, &
490 "mpp_domains_define.inc(mpp_define_io_domain): "//trim(domain%name)// &
491 ": multiple tile per pe is not supported yet for this routine")
493 if (
associated(domain%io_domain))
deallocate(domain%io_domain)
494 allocate(domain%io_domain)
495 domain%io_layout = io_layout
496 io_domain => domain%io_domain
498 npes_x = layout(1)/io_layout(1)
499 npes_y = layout(2)/io_layout(2)
500 ipos = mod(domain%x(1)%pos, npes_x)
501 jpos = mod(domain%y(1)%pos, npes_y)
502 igroup = domain%x(1)%pos/npes_x
503 jgroup = domain%y(1)%pos/npes_y
504 ipos_beg = igroup*npes_x; ipos_end = ipos_beg + npes_x - 1
505 jpos_beg = jgroup*npes_y; jpos_end = jpos_beg + npes_y - 1
507 do j = jpos_beg, jpos_end
508 do i = ipos_beg, ipos_end
509 if(domain%pearray(i,j) .NE. null_pe) npes_in_group = npes_in_group+1
513 io_domain%whalo = domain%whalo
514 io_domain%ehalo = domain%ehalo
515 io_domain%shalo = domain%shalo
516 io_domain%nhalo = domain%nhalo
518 io_domain%pe = domain%pe
519 io_domain%symmetry = domain%symmetry
520 if (
associated(io_domain%list))
deallocate(io_domain%list)
521 allocate(io_domain%list(0:npes_in_group-1))
522 do i = 0, npes_in_group-1
523 allocate( io_domain%list(i)%x(1), io_domain%list(i)%y(1), io_domain%list(i)%tile_id(1) )
526 ndivx =
size(domain%pearray,1)
527 ndivy =
size(domain%pearray,2)
528 allocate(posarray(0:ndivx-1, 0:ndivy-1))
529 n = domain%tile_root_pe - mpp_root_pe()
533 if( domain%pearray(i,j) == null_pe) cycle
540 do j = jpos_beg, jpos_end
541 do i = ipos_beg, ipos_end
542 if( domain%pearray(i,j) == null_pe) cycle
543 io_domain%list(n)%pe = domain%pearray(i,j)
545 io_domain%list(n)%x(1)%compute = domain%list(m)%x(1)%compute
546 io_domain%list(n)%y(1)%compute = domain%list(m)%y(1)%compute
547 igroup = domain%list(m)%x(1)%pos/npes_x
548 jgroup = domain%list(m)%y(1)%pos/npes_y
549 io_domain%list(n)%tile_id(1) = jgroup*io_layout(1) + igroup
555 if (
associated(io_domain%x))
deallocate(io_domain%x)
556 if (
associated(io_domain%y))
deallocate(io_domain%y)
557 if (
associated(io_domain%tile_id))
deallocate(io_domain%tile_id)
558 allocate(io_domain%x(1), io_domain%y(1), io_domain%tile_id(1) )
559 allocate(io_domain%x(1)%list(0:npes_x-1), io_domain%y(1)%list(0:npes_y-1) )
561 do j = jpos_beg, jpos_beg+jpos
562 do i = ipos_beg, ipos_beg+ipos
563 if(domain%pearray(i,j) .NE. null_pe) n = n + 1
567 io_domain%x(1)%compute = domain%x(1)%compute
568 io_domain%x(1)%domain_data = domain%x(1)%domain_data
569 io_domain%x(1)%memory = domain%x(1)%memory
570 io_domain%y(1)%compute = domain%y(1)%compute
571 io_domain%y(1)%domain_data = domain%y(1)%domain_data
572 io_domain%y(1)%memory = domain%y(1)%memory
573 io_domain%x(1)%global%begin = domain%x(1)%list(ipos_beg)%compute%begin
574 io_domain%x(1)%global%end = domain%x(1)%list(ipos_end)%compute%end
575 io_domain%x(1)%global%size = io_domain%x(1)%global%end - io_domain%x(1)%global%begin + 1
576 io_domain%x(1)%global%max_size = io_domain%x(1)%global%size
577 io_domain%y(1)%global%begin = domain%y(1)%list(jpos_beg)%compute%begin
578 io_domain%y(1)%global%end = domain%y(1)%list(jpos_end)%compute%end
579 io_domain%y(1)%global%size = io_domain%y(1)%global%end - io_domain%y(1)%global%begin + 1
580 io_domain%y(1)%global%max_size = io_domain%y(1)%global%size
581 io_domain%x(1)%pos = ipos
582 io_domain%y(1)%pos = jpos
583 io_domain%tile_id(1) = io_domain%list(n)%tile_id(1)
584 io_domain%tile_root_pe = io_domain%list(0)%pe
609 xhalo, yhalo, xextent, yextent, maskmap, name, symmetry, memory_size, &
610 whalo, ehalo, shalo, nhalo, is_mosaic, tile_count, tile_id, complete, x_cyclic_offset, y_cyclic_offset )
611 integer,
intent(in) :: global_indices(:)
612 integer,
intent(in) :: layout(:)
613 type(domain2d),
intent(inout) :: domain
614 integer,
intent(in),
optional :: pelist(0:)
615 integer,
intent(in),
optional :: xflags, yflags
616 integer,
intent(in),
optional :: xhalo, yhalo
617 integer,
intent(in),
optional :: xextent(0:), yextent(0:)
618 logical,
intent(in),
optional :: maskmap(0:,0:)
619 character(len=*),
intent(in),
optional :: name
620 logical,
intent(in),
optional :: symmetry
621 logical,
intent(in),
optional :: is_mosaic
623 integer,
intent(in),
optional :: memory_size(:)
624 integer,
intent(in),
optional :: whalo, ehalo, shalo, nhalo
630 integer,
intent(in),
optional :: tile_count
634 integer,
intent(in),
optional :: tile_id
635 logical,
intent(in),
optional :: complete
637 integer,
intent(in),
optional :: x_cyclic_offset
640 integer,
intent(in),
optional :: y_cyclic_offset
645 integer :: i, j, m, n, xhalosz, yhalosz, memory_xsize, memory_ysize
646 integer :: whalosz, ehalosz, shalosz, nhalosz
647 integer :: ipos, jpos, pos, tile, nlist, cur_tile_id, cur_comm_id
648 integer :: ndivx, ndivy, isg, ieg, jsg, jeg, ishift, jshift, errunit, logunit
649 integer :: x_offset, y_offset, start_pos, nfold
650 logical :: from_mosaic, is_complete
651 logical :: mask(0:layout(1)-1,0:layout(2)-1)
652 integer,
allocatable :: pes(:), pesall(:)
653 integer :: pearray(0:layout(1)-1,0:layout(2)-1)
654 integer :: ibegin(0:layout(1)-1), iend(0:layout(1)-1)
655 integer :: jbegin(0:layout(2)-1), jend(0:layout(2)-1)
656 character(len=8) :: text
657 type(overlapspec),
pointer :: check_T => null()
659 logical :: send(8), recv(8)
662 if( .NOT.module_is_initialized )
call mpp_error( fatal, &
663 &
'MPP_DEFINE_DOMAINS2D: You must first call mpp_domains_init.' )
664 if(
PRESENT(name))
then
665 if(len_trim(name) > name_length)
call mpp_error(fatal, &
666 "mpp_domains_define.inc(mpp_define_domains2D): the len_trim of optional argument name ="//trim(name)// &
667 " is greater than NAME_LENGTH, change the argument name or increase NAME_LENGTH")
670 if(
size(global_indices(:)) .NE. 4)
call mpp_error(fatal, &
671 "mpp_define_domains2D: size of global_indices should be 4 for "//trim(domain%name) )
672 if(
size(layout(:)) .NE. 2)
call mpp_error(fatal,
"mpp_define_domains2D: size of layout should be 2 for "// &
673 & trim(domain%name) )
675 ndivx = layout(1); ndivy = layout(2)
676 isg = global_indices(1); ieg = global_indices(2); jsg = global_indices(3); jeg = global_indices(4)
678 from_mosaic = .false.
679 if(
present(is_mosaic)) from_mosaic = is_mosaic
681 if(
present(complete)) is_complete = complete
683 if(
present(tile_count)) tile = tile_count
685 if(
present(tile_id)) cur_tile_id = tile_id
688 if(
PRESENT(pelist) )
then
689 allocate( pes(0:
size(pelist(:))-1) )
693 call mpp_get_current_pelist(pesall, commid=cur_comm_id)
695 allocate( pesall(0:
size(pes(:))-1) )
697 call mpp_get_current_pelist(pesall, commid=cur_comm_id)
702 call mpp_get_current_pelist(pes, commid=cur_comm_id)
709 x_offset = 0; y_offset = 0
710 if(
PRESENT(x_cyclic_offset)) x_offset = x_cyclic_offset
711 if(
PRESENT(y_cyclic_offset)) y_offset = y_cyclic_offset
712 if(x_offset*y_offset .NE. 0)
call mpp_error(fatal, &
713 'MPP_DEFINE_DOMAINS2D: At least one of x_cyclic_offset and y_cyclic_offset must be zero for '// &
717 if(abs(x_offset) > jeg-jsg+1)
call mpp_error(fatal, &
718 'MPP_DEFINE_DOMAINS2D: absolute value of x_cyclic_offset is greater than jeg-jsg+1 for '//trim(domain%name))
719 if(abs(y_offset) > ieg-isg+1)
call mpp_error(fatal, &
720 'MPP_DEFINE_DOMAINS2D: absolute value of y_cyclic_offset is greater than ieg-isg+1 for '//trim(domain%name))
723 if( tile > 1 .AND.
size(pes(:)) > 1)
call mpp_error(fatal, &
724 'MPP_DEFINE_DOMAINS2D: there are more than one tile on this pe, '// &
725 'all the tile should be limited on this pe for '//trim(domain%name))
731 do n = 0,
size(pesall(:))-1
732 if(pesall(n) ==
mpp_pe() )
then
737 if(pos<0)
call mpp_error(fatal,
'MPP_DEFINE_DOMAINS2D: mpp_pe() is not in the pesall list')
739 domain%symmetry = .false.
740 if(
present(symmetry)) domain%symmetry = symmetry
741 if(domain%symmetry)
then
742 ishift = 1; jshift = 1
744 ishift = 0; jshift = 0
751 xhalosz = 0; yhalosz = 0
752 if(
present(xhalo)) xhalosz = xhalo
753 if(
present(yhalo)) yhalosz = yhalo
754 whalosz = xhalosz; ehalosz = xhalosz
755 shalosz = yhalosz; nhalosz = yhalosz
756 if(
present(whalo)) whalosz = whalo
757 if(
present(ehalo)) ehalosz = ehalo
758 if(
present(shalo)) shalosz = shalo
759 if(
present(nhalo)) nhalosz = nhalo
763 if(
PRESENT(maskmap) )
then
764 if(
size(maskmap,1).NE.ndivx .OR.
size(maskmap,2).NE.ndivy ) &
765 call mpp_error( fatal,
'MPP_DEFINE_DOMAINS2D: maskmap array does not match layout for '// &
766 & trim(domain%name) )
767 mask(:,:) = maskmap(:,:)
771 if( n.NE.
size(pes(:)) )
then
772 write( text,
'(i8)' )n
773 call mpp_error( fatal,
'MPP_DEFINE_DOMAINS2D: incorrect number of PEs assigned for ' // &
774 'this layout and maskmap. Use '//text//
' PEs for this domain decomposition for '//trim(domain%name) )
777 memory_xsize = 0; memory_ysize = 0
778 if(
present(memory_size))
then
779 if(
size(memory_size(:)) .NE. 2)
call mpp_error(fatal, &
780 "mpp_define_domains2D: size of memory_size should be 2 for "//trim(domain%name))
781 memory_xsize = memory_size(1)
782 memory_ysize = memory_size(2)
788 nlist =
size(pesall(:))
789 if( .NOT.
Associated(domain%x) )
then
790 allocate(domain%tileList(1))
791 domain%tileList(1)%xbegin = global_indices(1)
792 domain%tileList(1)%xend = global_indices(2)
793 domain%tileList(1)%ybegin = global_indices(3)
794 domain%tileList(1)%yend = global_indices(4)
795 allocate(domain%x(1), domain%y(1) )
796 allocate(domain%tile_id(1))
797 allocate(domain%tile_id_all(1))
798 domain%tile_id = cur_tile_id
799 domain%tile_id_all = cur_tile_id
800 domain%tile_comm_id = cur_comm_id
802 domain%max_ntile_pe = 1
804 domain%rotated_ninety = .false.
805 allocate( domain%list(0:nlist-1) )
807 allocate( domain%list(i)%x(1), domain%list(i)%y(1), domain%list(i)%tile_id(1))
811 domain%initialized = .true.
815 if(pesall(n) == pes(0))
then
822 pearray(:,:) = null_pe
823 ipos = null_pe; jpos = null_pe
829 pearray(i,j) = pes(n)
830 domain%list(m)%x(tile)%compute%begin = ibegin(i)
831 domain%list(m)%x(tile)%compute%end = iend(i)
832 domain%list(m)%y(tile)%compute%begin = jbegin(j)
833 domain%list(m)%y(tile)%compute%end = jend(j)
834 domain%list(m)%x(tile)%compute%size = domain%list(m)%x(tile)%compute%end &
835 & - domain%list(m)%x(tile)%compute%begin + 1
836 domain%list(m)%y(tile)%compute%size = domain%list(m)%y(tile)%compute%end &
837 & - domain%list(m)%y(tile)%compute%begin + 1
838 domain%list(m)%tile_id(tile) = cur_tile_id
839 domain%list(m)%x(tile)%pos = i
840 domain%list(m)%y(tile)%pos = j
841 domain%list(m)%tile_root_pe = pes(0)
842 domain%list(m)%pe = pesall(m)
844 if( pes(n).EQ.
mpp_pe() )
then
856 if( any(pes ==
mpp_pe()) )
then
857 domain%io_layout = layout
858 domain%tile_root_pe = pes(0)
859 domain%comm_id = cur_comm_id
860 if( ipos.EQ.null_pe .OR. jpos.EQ.null_pe ) &
861 call mpp_error( fatal,
'MPP_DEFINE_DOMAINS2D: pelist must include this PE for '//trim(domain%name) )
864 write( errunit, * )
'pe, tile, ipos, jpos=',
mpp_pe(), tile, ipos, jpos,
' pearray(:,jpos)=', &
865 pearray(:,jpos),
' pearray(ipos,:)=', pearray(ipos,:)
870 if (
associated(domain%pearray))
deallocate(domain%pearray)
871 allocate( domain%pearray(0:ndivx-1,0:ndivy-1) )
872 domain%pearray = pearray
877 domain_cnt = domain_cnt + int(1,kind=i8_kind)
878 domain%id = domain_cnt*domain_id_base
881 call mpp_define_domains( global_indices(1:2), ndivx, domain%x(tile), &
882 pack(pearray(:,jpos),mask(:,jpos)), xflags, xhalo, xextent, mask(:,jpos), memory_xsize, whalo, ehalo )
883 call mpp_define_domains( global_indices(3:4), ndivy, domain%y(tile), &
884 pack(pearray(ipos,:),mask(ipos,:)), yflags, yhalo, yextent, mask(ipos,:), memory_ysize, shalo, nhalo )
885 if( domain%x(tile)%list(ipos)%pe.NE.domain%y(tile)%list(jpos)%pe ) &
886 call mpp_error( fatal, .NE.
'MPP_DEFINE_DOMAINS2D: domain%x%list(ipos)%pedomain%y%list(jpos)%pe.' )
889 if(x_offset .NE. 0 .OR. y_offset .NE. 0)
then
890 if(whalosz .GT. domain%x(tile)%compute%size .OR. ehalosz .GT. domain%x(tile)%compute%size ) &
891 call mpp_error(fatal,
"mpp_define_domains_2d: when x_cyclic_offset/y_cyclic_offset is set, "// &
892 "whalo and ehalo must be no larger than the x-direction computation domain size")
893 if(shalosz .GT. domain%y(tile)%compute%size .OR. nhalosz .GT. domain%y(tile)%compute%size ) &
894 call mpp_error(fatal,
"mpp_define_domains_2d: when x_cyclic_offset/y_cyclic_offset is set, "// &
895 "shalo and nhalo must be no larger than the y-direction computation domain size")
899 if(whalosz .GT. domain%x(tile)%global%size) &
900 call mpp_error(fatal,
"MPP_DEFINE_DOMAINS2D: whalo is greather global domain size")
901 if(ehalosz .GT. domain%x(tile)%global%size) &
902 call mpp_error(fatal,
"MPP_DEFINE_DOMAINS2D: ehalo is greather global domain size")
903 if(shalosz .GT. domain%x(tile)%global%size) &
904 call mpp_error(fatal,
"MPP_DEFINE_DOMAINS2D: shalo is greather global domain size")
905 if(nhalosz .GT. domain%x(tile)%global%size) &
906 call mpp_error(fatal,
"MPP_DEFINE_DOMAINS2D: nhalo is greather global domain size")
911 if(
PRESENT(xflags) )
then
912 if( btest(xflags,west) )
then
914 if(domain%x(tile)%domain_data%begin .LE. domain%x(tile)%global%begin .AND. &
915 domain%x(tile)%compute%begin > domain%x(tile)%global%begin )
then
916 call mpp_error(fatal, &
917 'MPP_DEFINE_DOMAINS: the domain could not be crossed when west is folded')
919 if( domain%x(tile)%cyclic )
call mpp_error( fatal, &
920 'MPP_DEFINE_DOMAINS: an axis cannot be both folded west and cyclic for '//trim(domain%name) )
921 domain%fold = domain%fold + fold_west_edge
924 if( btest(xflags,east) )
then
926 if(domain%x(tile)%domain_data%end .GE. domain%x(tile)%global%end .AND. &
927 domain%x(tile)%compute%end < domain%x(tile)%global%end )
then
928 call mpp_error(fatal, &
929 'MPP_DEFINE_DOMAINS: the domain could not be crossed when north is folded')
931 if( domain%x(tile)%cyclic )
call mpp_error( fatal, &
932 'MPP_DEFINE_DOMAINS: an axis cannot be both folded east and cyclic for '//trim(domain%name) )
933 domain%fold = domain%fold + fold_east_edge
937 if(
PRESENT(yflags) )
then
938 if( btest(yflags,south) )
then
940 if(domain%y(tile)%domain_data%begin .LE. domain%y(tile)%global%begin .AND. &
941 domain%y(tile)%compute%begin > domain%y(tile)%global%begin )
then
942 call mpp_error(fatal, &
943 'MPP_DEFINE_DOMAINS: the domain could not be crossed when south is folded')
945 if( domain%y(tile)%cyclic )
call mpp_error( fatal, &
946 'MPP_DEFINE_DOMAINS: an axis cannot be both folded north and cyclic for '//trim(domain%name))
947 domain%fold = domain%fold + fold_south_edge
950 if( btest(yflags,north) )
then
953 if(whalosz .GT. domain%x(tile)%compute%size .AND. whalosz .GE. domain%x(tile)%global%size/2 ) &
954 call mpp_error(fatal, .GT.
"MPP_DEFINE_DOMAINS2D: north is folded, whalo compute domain size "// &
955 .GE.
"and whalo half of global domain size")
956 if(ehalosz .GT. domain%x(tile)%compute%size .AND. ehalosz .GE. domain%x(tile)%global%size/2 ) &
957 call mpp_error(fatal, .GT.
"MPP_DEFINE_DOMAINS2D: north is folded, ehalo is compute domain size "// &
958 .GE.
"and ehalo half of global domain size")
959 if(shalosz .GT. domain%y(tile)%compute%size .AND. shalosz .GE. domain%x(tile)%global%size/2 ) &
960 call mpp_error(fatal, .GT.
"MPP_DEFINE_DOMAINS2D: north is folded, shalo compute domain size "// &
961 .GE.
"and shalo half of global domain size")
962 if(nhalosz .GT. domain%y(tile)%compute%size .AND. nhalosz .GE. domain%x(tile)%global%size/2 ) &
963 call mpp_error(fatal, .GT.
"MPP_DEFINE_DOMAINS2D: north is folded, nhalo compute domain size "// &
964 .GE.
"and nhalo half of global domain size")
967 if( domain%y(tile)%cyclic )
call mpp_error( fatal, &
968 'MPP_DEFINE_DOMAINS: an axis cannot be both folded south and cyclic for '//trim(domain%name) )
969 domain%fold = domain%fold + fold_north_edge
973 if(nfold > 1)
call mpp_error(fatal, &
974 'MPP_DEFINE_DOMAINS2D: number of folded edge is greater than 1 for '//trim(domain%name) )
977 if( x_offset .NE. 0 .OR. y_offset .NE. 0)
call mpp_error(fatal, &
978 'MPP_DEFINE_DOMAINS2D: For the foled_north/folded_south/fold_east/folded_west boundary condition, '//&
979 'x_cyclic_offset and y_cyclic_offset must be zero for '//trim(domain%name))
981 if( btest(domain%fold,south) .OR. btest(domain%fold,north) )
then
982 if( domain%y(tile)%cyclic )
call mpp_error( fatal, &
983 'MPP_DEFINE_DOMAINS: an axis cannot be both folded and cyclic for '//trim(domain%name) )
984 if( modulo(domain%x(tile)%global%size,2).NE.0 ) &
985 call mpp_error( fatal,
'MPP_DEFINE_DOMAINS: number of points in X must be even ' // &
986 'when there is a fold in Y for '//trim(domain%name) )
991 if( domain%x(tile)%list(i)%compute%size.NE.domain%x(tile)%list(n-i)%compute%size ) &
992 call mpp_error( fatal,
'MPP_DEFINE_DOMAINS: Folded domain boundaries ' // &
993 'must line up (mirror-symmetric extents) for '//trim(domain%name) )
996 if( btest(domain%fold,west) .OR. btest(domain%fold,east) )
then
997 if( domain%x(tile)%cyclic )
call mpp_error( fatal, &
998 'MPP_DEFINE_DOMAINS: an axis cannot be both folded and cyclic for '//trim(domain%name) )
999 if( modulo(domain%y(tile)%global%size,2).NE.0 ) &
1000 call mpp_error( fatal,
'MPP_DEFINE_DOMAINS: number of points in Y must be even '//&
1001 'when there is a fold in X for '//trim(domain%name) )
1006 if( domain%y(tile)%list(i)%compute%size.NE.domain%y(tile)%list(n-i)%compute%size ) &
1007 call mpp_error( fatal,
'MPP_DEFINE_DOMAINS: Folded domain boundaries must '//&
1008 'line up (mirror-symmetric extents) for '//trim(domain%name) )
1013 if(
mpp_pe().EQ.pes(0) .AND.
PRESENT(name) )
then
1015 write( logunit,
'(/a,i5,a,i5)' )trim(name)//
' domain decomposition: ', ndivx,
' X', ndivy
1016 write( logunit,
'(3x,a)' )
'pe, is, ie, js, je, isd, ied, jsd, jed'
1020 if(is_complete)
then
1021 domain%whalo = whalosz; domain%ehalo = ehalosz
1022 domain%shalo = shalosz; domain%nhalo = nhalosz
1023 if (
associated(domain%update_T))
deallocate(domain%update_T)
1024 if (
associated(domain%update_E))
deallocate(domain%update_E)
1025 if (
associated(domain%update_C))
deallocate(domain%update_C)
1026 if (
associated(domain%update_N))
deallocate(domain%update_N)
1027 allocate(domain%update_T, domain%update_E, domain%update_C, domain%update_N)
1028 domain%update_T%next => null()
1029 domain%update_E%next => null()
1030 domain%update_C%next => null()
1031 domain%update_N%next => null()
1032 if (
associated(domain%check_E))
deallocate(domain%check_E)
1033 if (
associated(domain%check_C))
deallocate(domain%check_C)
1034 if (
associated(domain%check_N))
deallocate(domain%check_N)
1035 allocate(domain%check_E, domain%check_C, domain%check_N )
1036 domain%update_T%nsend = 0
1037 domain%update_T%nrecv = 0
1038 domain%update_C%nsend = 0
1039 domain%update_C%nrecv = 0
1040 domain%update_E%nsend = 0
1041 domain%update_E%nrecv = 0
1042 domain%update_N%nsend = 0
1043 domain%update_N%nrecv = 0
1045 if( btest(domain%fold,south) )
then
1050 else if( btest(domain%fold,west) )
then
1055 else if( btest(domain%fold,east) )
then
1061 call compute_overlaps(domain, center, domain%update_T, check_t, 0, 0, x_offset, y_offset, &
1062 domain%whalo, domain%ehalo, domain%shalo, domain%nhalo)
1063 call compute_overlaps(domain, corner, domain%update_C, domain%check_C, ishift, jshift, x_offset, y_offset, &
1064 domain%whalo, domain%ehalo, domain%shalo, domain%nhalo)
1065 call compute_overlaps(domain, east, domain%update_E, domain%check_E, ishift, 0, x_offset, y_offset, &
1066 domain%whalo, domain%ehalo, domain%shalo, domain%nhalo)
1067 call compute_overlaps(domain, north, domain%update_N, domain%check_N, 0, jshift, x_offset, y_offset, &
1068 domain%whalo, domain%ehalo, domain%shalo, domain%nhalo)
1070 call check_overlap_pe_order(domain, domain%update_T, trim(domain%name)//
" update_T in mpp_define_domains")
1071 call check_overlap_pe_order(domain, domain%update_C, trim(domain%name)//
" update_C in mpp_define_domains")
1072 call check_overlap_pe_order(domain, domain%update_E, trim(domain%name)//
" update_E in mpp_define_domains")
1073 call check_overlap_pe_order(domain, domain%update_N, trim(domain%name)//
" update_N in mpp_define_domains")
1077 if(domain%symmetry .AND. (domain%ncontacts == 0 .OR. domain%ntiles == 1) )
then
1081 if (
associated(domain%bound_E))
deallocate(domain%bound_E)
1082 if (
associated(domain%bound_C))
deallocate(domain%bound_C)
1083 if (
associated(domain%bound_N))
deallocate(domain%bound_N)
1084 allocate(domain%bound_E, domain%bound_C, domain%bound_N )
1089 call set_domain_comm_inf(domain%update_T)
1090 call set_domain_comm_inf(domain%update_E)
1091 call set_domain_comm_inf(domain%update_C)
1092 call set_domain_comm_inf(domain%update_N)
1098 if(debug_message_passing .and. (domain%ncontacts == 0 .OR. domain%ntiles == 1) )
then
1101 call check_message_size(domain, domain%update_T, send, recv,
'T')
1102 call check_message_size(domain, domain%update_E, send, recv,
'E')
1103 call check_message_size(domain, domain%update_C, send, recv,
'C')
1104 call check_message_size(domain, domain%update_N, send, recv,
'N')
1109 if(
mpp_pe() .EQ. pes(0) .AND.
PRESENT(name) )
then
1110 write(*,*) trim(name)//
' domain decomposition'
1111 write(*,
'(a,i4,a,i4,a,i4,a,i4)')
'whalo = ', whalosz,
", ehalo = ", ehalosz,
", shalo = ", shalosz, &
1112 &
", nhalo = ", nhalosz
1113 write (*,110) (domain%x(1)%list(i)%compute%size, i= 0, layout(1)-1)
1114 write (*,120) (domain%y(1)%list(i)%compute%size, i= 0, layout(2)-1)
1115 110
format (
' X-AXIS = ',24i4,/,(11x,24i4))
1116 120
format (
' Y-AXIS = ',24i4,/,(11x,24i4))
1119 deallocate( pes, pesall)
1127 subroutine check_message_size(domain, update, send, recv, position)
1128 type(domain2d),
intent(in) :: domain
1129 type(overlapspec),
intent(in) :: update
1130 logical,
intent(in) :: send(:)
1131 logical,
intent(in) :: recv(:)
1132 character,
intent(in) :: position
1134 integer,
dimension(0:size(domain%list(:))-1) :: msg1, msg2, msg3
1135 integer :: m, n, l, dir, is, ie, js, je, from_pe, msgsize
1138 nlist =
size(domain%list(:))
1143 do m = 1, update%nrecv
1145 do n = 1, update%recv(m)%count
1146 dir = update%recv(m)%dir(n)
1147 if( recv(dir) )
then
1148 is = update%recv(m)%is(n); ie = update%recv(m)%ie(n)
1149 js = update%recv(m)%js(n); je = update%recv(m)%je(n)
1150 msgsize = msgsize + (ie-is+1)*(je-js+1)
1153 from_pe = update%recv(m)%pe
1154 l = from_pe-mpp_root_pe()
1155 call mpp_recv( msg1(l), glen=1, from_pe=from_pe, block=.false., tag=comm_tag_1)
1159 do m = 1, update%nsend
1161 do n = 1, update%send(m)%count
1162 dir = update%send(m)%dir(n)
1164 is = update%send(m)%is(n); ie = update%send(m)%ie(n)
1165 js = update%send(m)%js(n); je = update%send(m)%je(n)
1166 msgsize = msgsize + (ie-is+1)*(je-js+1)
1169 l = update%send(m)%pe-mpp_root_pe()
1171 call mpp_send( msg3(l), plen=1, to_pe=update%send(m)%pe, tag=comm_tag_1)
1176 if(msg1(m) .NE. msg2(m))
then
1177 print*,
"My pe = ",
mpp_pe(),
",domain name =", trim(domain%name),
",at position=",position,
",from pe=", &
1178 domain%list(m)%pe,
":send size = ", msg1(m),
", recv size = ", msg2(m)
1179 call mpp_error(fatal,
"mpp_define_domains2D: mismatch on send and recv size")
1185 end subroutine check_message_size
1201 subroutine mpp_define_mosaic( global_indices, layout, domain, num_tile, num_contact, tile1, tile2, &
1202 istart1, iend1, jstart1, jend1, istart2, iend2, jstart2, jend2, pe_start, &
1203 pe_end, pelist, whalo, ehalo, shalo, nhalo, xextent, yextent, &
1204 maskmap, name, memory_size, symmetry, xflags, yflags, tile_id )
1205 integer,
intent(in) :: global_indices(:,:)
1209 integer,
intent(in) :: layout(:,:)
1210 type(domain2d),
intent(inout) :: domain
1211 integer,
intent(in) :: num_tile
1212 integer,
intent(in) :: num_contact
1213 integer,
intent(in) :: tile1(:), tile2(:)
1214 integer,
intent(in) :: istart1(:), iend1(:)
1215 integer,
intent(in) :: jstart1(:), jend1(:)
1216 integer,
intent(in) :: istart2(:), iend2(:)
1217 integer,
intent(in) :: jstart2(:), jend2(:)
1218 integer,
intent(in) :: pe_start(:)
1219 integer,
intent(in) :: pe_end(:)
1220 integer,
intent(in),
optional :: pelist(:)
1221 integer,
intent(in),
optional :: whalo, ehalo, shalo, nhalo
1222 integer,
intent(in),
optional :: xextent(:,:), yextent(:,:)
1223 logical,
intent(in),
optional :: maskmap(:,:,:)
1224 character(len=*),
intent(in),
optional :: name
1225 integer,
intent(in),
optional :: memory_size(2)
1226 logical,
intent(in),
optional :: symmetry
1227 integer,
intent(in),
optional :: xflags, yflags
1228 integer,
intent(in),
optional :: tile_id(:)
1230 integer :: n, m, ndivx, ndivy, nc, nlist, nt, pos, n1, n2
1231 integer :: whalosz, ehalosz, shalosz, nhalosz, xhalosz, yhalosz, t1, t2, tile
1232 integer :: flags_x, flags_y
1233 logical,
allocatable :: mask(:,:)
1234 integer,
allocatable :: pes(:), xext(:), yext(:), pelist_tile(:), ntile_per_pe(:), tile_count(:)
1235 integer,
allocatable :: tile_id_local(:)
1236 logical :: is_symmetry
1237 integer,
allocatable :: align1(:), align2(:), is1(:), ie1(:), js1(:), je1(:), is2(:), ie2(:), js2(:), je2(:)
1238 integer,
allocatable :: isgList(:), iegList(:), jsgList(:), jegList(:)
1239 real,
allocatable :: refine1(:), refine2(:)
1241 logical :: send(8), recv(8)
1244 mosaic_defined = .true.
1246 if(
size(global_indices, 1) .NE. 4)
call mpp_error(fatal, &
1247 'mpp_domains_define.inc: The size of first dimension of global_indices is not 4')
1249 if(
size(global_indices, 2) .NE. num_tile)
call mpp_error(fatal, &
1250 'mpp_domains_define.inc: The size of second dimension of global_indices is not equal num_tile')
1252 if(
size(layout, 1) .NE. 2)
call mpp_error(fatal, &
1253 'mpp_domains_define.inc: The size of first dimension of layout is not 2')
1254 if(
size(layout,2) .NE. num_tile)
call mpp_error(fatal, &
1255 'mpp_domains_define.inc: The size of second dimension of layout is not equal num_tile')
1259 allocate(pes(0:nlist-1))
1260 if(
present(pelist))
then
1261 if( nlist .NE.
size(pelist(:)))
call mpp_error(fatal, &
1262 'mpp_domains_define.inc: size of pelist is not equal mpp_npes')
1265 call mpp_get_current_pelist(pes, commid=domain%comm_id)
1268 if(pes(n) - pes(n-1) .NE. 1)
call mpp_error(fatal, &
1269 'mpp_domains_define.inc: pelist is not monotonic increasing by 1')
1272 is_symmetry = .false.
1273 if(
present(symmetry)) is_symmetry = symmetry
1275 if(
size(pe_start(:)) .NE. num_tile .OR.
size(pe_end(:)) .NE. num_tile )
call mpp_error(fatal, &
1276 'mpp_domains_define.inc: size of pe_start and/or pe_end is not equal num_tile')
1278 if( any( pe_start < pes(0) ) )
call mpp_error(fatal, &
1279 &
'mpp_domains_define.inc: not all the pe_start are in the pelist')
1280 if( any( pe_end > pes(nlist-1)) )
call mpp_error(fatal, &
1281 &
'mpp_domains_define.inc: not all the pe_end are in the pelist')
1284 allocate( ntile_per_pe(0:nlist-1) )
1287 do m = pe_start(n) - mpp_root_pe(), pe_end(n) - mpp_root_pe()
1288 ntile_per_pe(m) = ntile_per_pe(m) + 1
1291 if(any(ntile_per_pe == 0))
call mpp_error(fatal, &
1292 'mpp_domains_define.inc: At least one pe in pelist is not used by any tile in the mosaic')
1295 if(
PRESENT(xextent) )
then
1296 if(
size(xextent,1) .GT. maxval(layout(1,:)) )
call mpp_error(fatal, &
1297 'mpp_domains_define.inc: size mismatch between xextent and layout')
1298 if(
size(xextent,2) .NE. num_tile)
call mpp_error(fatal, &
1299 'mpp_domains_define.inc: size of xextent is not eqaul num_tile')
1301 if(
PRESENT(yextent) )
then
1302 if(
size(yextent,1) .GT. maxval(layout(2,:)) )
call mpp_error(fatal, &
1303 'mpp_domains_define.inc: size mismatch between yextent and layout')
1304 if(
size(yextent,2) .NE. num_tile)
call mpp_error(fatal, &
1305 'mpp_domains_define.inc: size of yextent is not eqaul num_tile')
1312 if(
present(maskmap))
then
1313 if(
size(maskmap,1) .GT. maxval(layout(1,:)) .or.
size(maskmap,2) .GT. maxval(layout(2,:))) &
1314 call mpp_error(fatal,
'mpp_domains_define.inc: size mismatch between maskmap and layout')
1315 if(
size(maskmap,3) .NE. num_tile)
call mpp_error(fatal, &
1316 'mpp_domains_define.inc: the third dimension of maskmap is not equal num_tile')
1319 if (
associated(domain%tileList))
deallocate(domain%tileList)
1320 allocate(domain%tileList(num_tile))
1322 domain%tileList(n)%xbegin = global_indices(1,n)
1323 domain%tileList(n)%xend = global_indices(2,n)
1324 domain%tileList(n)%ybegin = global_indices(3,n)
1325 domain%tileList(n)%yend = global_indices(4,n)
1328 nt = ntile_per_pe(
mpp_pe()-mpp_root_pe())
1329 if (
associated(domain%tile_id))
deallocate(domain%tile_id)
1330 if (
associated(domain%x))
deallocate(domain%x)
1331 if (
associated(domain%y))
deallocate(domain%y)
1332 if (
associated(domain%list))
deallocate(domain%list)
1333 allocate(domain%tile_id(nt), domain%x(nt), domain%y(nt) )
1334 allocate(domain%list(0:nlist-1))
1337 nt = ntile_per_pe(n)
1338 allocate(domain%list(n)%x(nt), domain%list(n)%y(nt), domain%list(n)%tile_id(nt))
1343 if(
PRESENT(tile_id) )
then
1344 if(
size(tile_id(:)) .NE. num_tile)
then
1345 call mpp_error(fatal, .NE.
"mpp_domains_define.inc: size(tile_id) num_tile")
1348 allocate(tile_id_local(num_tile))
1356 if(
PRESENT(tile_id))
then
1357 tile_id_local(n) = tile_id(n)
1359 tile_id_local(n) = n
1365 if( pe .GE. pe_start(n) .AND. pe .LE. pe_end(n))
then
1367 domain%tile_id(pos) = tile_id_local(n)
1371 if (
associated(domain%tile_id_all))
deallocate(domain%tile_id_all)
1372 allocate(domain%tile_id_all(num_tile))
1373 domain%tile_id_all(:) = tile_id_local(:)
1375 domain%initialized = .true.
1376 domain%rotated_ninety = .false.
1377 domain%ntiles = num_tile
1378 domain%max_ntile_pe = maxval(ntile_per_pe)
1379 domain%ncontacts = num_contact
1381 deallocate(ntile_per_pe)
1383 allocate(tile_count(pes(0):pes(0)+nlist-1))
1386 domain%tile_comm_id=0
1388 allocate(mask(layout(1,n), layout(2,n)))
1389 allocate(pelist_tile(pe_start(n):pe_end(n)) )
1390 tile_count(pe_start(n)) = tile_count(pe_start(n)) + 1
1391 do m = pe_start(n), pe_end(n)
1395 if (any(pelist_tile == pe))
then
1399 if(
present(maskmap)) mask = maskmap(1:layout(1,n), 1:layout(2,n), n)
1400 ndivx = layout(1,n); ndivy = layout(2,n)
1401 allocate(xext(ndivx), yext(ndivy))
1403 if(
present(xextent)) xext = xextent(1:ndivx,n)
1404 if(
present(yextent)) yext = yextent(1:ndivy,n)
1407 if(num_tile == 1)
then
1410 if(
PRESENT(xflags)) flags_x = xflags
1411 if(
PRESENT(yflags)) flags_y = yflags
1412 do m = 1, num_contact
1413 if(istart1(m) == iend1(m) )
then
1414 if(istart2(m) .NE. iend2(m) )
call mpp_error(fatal, &
1415 "mpp_domains_define: for one tile mosaic, when istart1=iend1, istart2 must equal iend2")
1416 if(istart1(m) == istart2(m) )
then
1417 if(istart1(m) == global_indices(1,n) )
then
1418 if(.NOT. btest(flags_x,west) ) flags_x = flags_x + fold_west_edge
1419 else if(istart1(m) == global_indices(2,n) )
then
1420 if(.NOT. btest(flags_x,east) ) flags_x = flags_x + fold_east_edge
1422 call mpp_error(fatal,
"mpp_domains_define: when istart1=iend1,jstart1=jend1, "//&
1423 "istart1 should equal global_indices(1) or global_indices(2)")
1426 if(.NOT. btest(flags_x,cyclic)) flags_x = flags_x + cyclic_global_domain
1428 else if( jstart1(m) == jend1(m) )
then
1429 if(jstart2(m) .NE. jend2(m) )
call mpp_error(fatal, &
1430 "mpp_domains_define: for one tile mosaic, when jstart1=jend1, jstart2 must equal jend2")
1431 if(jstart1(m) == jstart2(m) )
then
1432 if(jstart1(m) == global_indices(3,n) )
then
1433 if(.NOT. btest(flags_y,south) ) flags_y = flags_y + fold_south_edge
1434 else if(jstart1(m) == global_indices(4,n) )
then
1435 if(.NOT. btest(flags_y,north) ) flags_y = flags_y + fold_north_edge
1437 call mpp_error(fatal,
"mpp_domains_define: when istart1=iend1,jstart1=jend1, "//&
1438 "istart1 should equal global_indices(1) or global_indices(2)")
1441 if(.NOT. btest(flags_y,cyclic)) flags_y = flags_y + cyclic_global_domain
1444 call mpp_error(fatal, &
1445 "mpp_domains_define: for one tile mosaic, invalid boundary contact")
1448 call mpp_define_domains(global_indices(:,n), layout(:,n), domain, pelist=pelist_tile, xflags = flags_x, &
1449 yflags = flags_y, whalo=whalo, ehalo=ehalo, shalo=shalo, nhalo=nhalo, &
1450 xextent=xext, yextent=yext, maskmap=mask, name=name, symmetry=is_symmetry, &
1451 memory_size = memory_size, is_mosaic = .true., tile_id=tile_id_local(n))
1453 call mpp_define_domains(global_indices(:,n), layout(:,n), domain, pelist=pelist_tile, &
1454 whalo=whalo, ehalo=ehalo, shalo=shalo, nhalo=nhalo, xextent=xext, yextent=yext, &
1455 maskmap=mask, name=name, symmetry=is_symmetry, memory_size = memory_size, &
1456 is_mosaic = .true., tile_count = tile_count(pe_start(n)), tile_id=tile_id_local(n), &
1457 complete = n==num_tile)
1459 deallocate(mask, xext, yext, pelist_tile)
1462 deallocate(pes, tile_count, tile_id_local)
1464 if(num_contact == 0 .OR. num_tile == 1)
return
1468 allocate(is1(num_contact), ie1(num_contact), js1(num_contact), je1(num_contact) )
1469 allocate(is2(num_contact), ie2(num_contact), js2(num_contact), je2(num_contact) )
1470 allocate(isglist(num_tile), ieglist(num_tile), jsglist(num_tile), jeglist(num_tile) )
1471 allocate(align1(num_contact), align2(num_contact), refine1(num_contact), refine2(num_contact))
1474 isglist(n) = domain%tileList(n)%xbegin; ieglist(n) = domain%tileList(n)%xend
1475 jsglist(n) = domain%tileList(n)%ybegin; jeglist(n) = domain%tileList(n)%yend
1480 do n = 1, num_contact
1483 is1(n) = istart1(n) + isglist(t1) - 1; ie1(n) = iend1(n) + isglist(t1) - 1
1484 js1(n) = jstart1(n) + jsglist(t1) - 1; je1(n) = jend1(n) + jsglist(t1) - 1
1485 is2(n) = istart2(n) + isglist(t2) - 1; ie2(n) = iend2(n) + isglist(t2) - 1
1486 js2(n) = jstart2(n) + jsglist(t2) - 1; je2(n) = jend2(n) + jsglist(t2) - 1
1487 call check_alignment( is1(n), ie1(n), js1(n), je1(n), isglist(t1), ieglist(t1), jsglist(t1), &
1488 & jeglist(t1), align1(n))
1489 call check_alignment( is2(n), ie2(n), js2(n), je2(n), isglist(t2), ieglist(t2), jsglist(t2), &
1490 & jeglist(t2), align2(n))
1491 if( (align1(n) == west .or. align1(n) == east ) .NEQV. (align2(n) == west .or. align2(n) == east ) )&
1492 domain%rotated_ninety=.true.
1496 do n = 1, num_contact
1497 n1 = max(abs(iend1(n) - istart1(n)), abs(jend1(n) - jstart1(n)) ) + 1
1498 n2 = max(abs(iend2(n) - istart2(n)), abs(jend2(n) - jstart2(n)) ) + 1
1499 refine1(n) = real(n2)/n1
1500 refine2(n) = real(n1)/n2
1503 whalosz = 0; ehalosz = 0; shalosz = 0; nhalosz = 0
1504 if(
present(whalo)) whalosz = whalo
1505 if(
present(ehalo)) ehalosz = ehalo
1506 if(
present(shalo)) shalosz = shalo
1507 if(
present(nhalo)) nhalosz = nhalo
1508 xhalosz = max(whalosz, ehalosz)
1509 yhalosz = max(shalosz, nhalosz)
1512 call define_contact_point( domain, center, num_contact, tile1, tile2, align1, align2, refine1, refine2, &
1513 is1, ie1, js1, je1, is2, ie2, js2, je2, isglist, ieglist, jsglist, jeglist )
1519 call set_domain_comm_inf(domain%update_T)
1520 call set_domain_comm_inf(domain%update_E)
1521 call set_domain_comm_inf(domain%update_C)
1522 call set_domain_comm_inf(domain%update_N)
1526 do m = 1,
size(domain%tile_id(:))
1527 tile = domain%tile_id(m)
1528 do n = 1, num_contact
1529 if( tile1(n) == tile )
then
1530 if(align1(n) == east ) domain%x(m)%goffset = 0
1531 if(align1(n) == north) domain%y(m)%goffset = 0
1533 if( tile2(n) == tile )
then
1534 if(align2(n) == east ) domain%x(m)%goffset = 0
1535 if(align2(n) == north) domain%y(m)%goffset = 0
1539 call check_overlap_pe_order(domain, domain%update_T, trim(domain%name)//
" update_T in mpp_define_mosaic")
1540 call check_overlap_pe_order(domain, domain%update_C, trim(domain%name)//
" update_C in mpp_define_mosaic")
1541 call check_overlap_pe_order(domain, domain%update_E, trim(domain%name)//
" update_E in mpp_define_mosaic")
1542 call check_overlap_pe_order(domain, domain%update_N, trim(domain%name)//
" update_N in mpp_define_mosaic")
1545 if(debug_update_level .NE. no_check)
then
1550 if(domain%symmetry)
then
1551 if (
associated(domain%bound_E))
deallocate(domain%bound_E)
1552 if (
associated(domain%bound_C))
deallocate(domain%bound_C)
1553 if (
associated(domain%bound_N))
deallocate(domain%bound_N)
1554 allocate(domain%bound_E, domain%bound_C, domain%bound_N )
1558 call check_overlap_pe_order(domain, domain%bound_C, trim(domain%name)//
" bound_C")
1559 call check_overlap_pe_order(domain, domain%bound_E, trim(domain%name)//
" bound_E")
1560 call check_overlap_pe_order(domain, domain%bound_N, trim(domain%name)//
" bound_N")
1566 if(debug_message_passing)
then
1569 call check_message_size(domain, domain%update_T, send, recv,
'T')
1570 call check_message_size(domain, domain%update_C, send, recv,
'C')
1571 call check_message_size(domain, domain%update_E, send, recv,
'E')
1572 call check_message_size(domain, domain%update_N, send, recv,
'N')
1577 deallocate(align1, align2, is1, ie1, js1, je1, is2, ie2, js2, je2 )
1578 deallocate(isglist, ieglist, jsglist, jeglist, refine1, refine2 )
1594 subroutine compute_overlaps( domain, position, update, check, ishift, jshift, x_cyclic_offset, y_cyclic_offset, &
1595 whalo, ehalo, shalo, nhalo )
1596 type(domain2d),
intent(inout) :: domain
1597 type(overlapspec),
intent(inout),
pointer :: update
1598 type(overlapspec),
intent(inout),
pointer :: check
1599 integer,
intent(in) :: position, ishift, jshift
1600 integer,
intent(in) :: x_cyclic_offset, y_cyclic_offset
1601 integer,
intent(in) :: whalo, ehalo, shalo, nhalo
1603 integer :: i, m, n, nlist, tMe, tNbr, dir
1604 integer :: is, ie, js, je, isc, iec, jsc, jec, isd, ied, jsd, jed
1605 integer :: isg, ieg, jsg, jeg, ioff, joff
1606 integer :: list, middle, ni, nj, isgd, iegd, jsgd, jegd
1607 integer :: ism, iem, jsm, jem
1608 integer :: is2, ie2, js2, je2
1609 integer :: is3, ie3, js3, je3
1610 integer :: isd3, ied3, jsd3, jed3
1611 integer :: isd2, ied2, jsd2, jed2
1612 logical :: folded, need_adjust_1, need_adjust_2, need_adjust_3, folded_north
1613 type(overlap_type) :: overlap
1614 type(overlap_type),
pointer :: overlapList(:)=>null()
1615 type(overlap_type),
pointer :: checkList(:)=>null()
1616 integer :: nsend, nrecv
1617 integer :: nsend_check, nrecv_check
1619 logical :: set_check
1624 if(
size(domain%x(:)) > 1)
return
1627 if(whalo==0 .AND. ehalo==0 .AND. shalo==0 .AND. nhalo==0)
return
1630 nlist =
size(domain%list(:))
1632 if(
ASSOCIATED(check)) set_check = .true.
1633 allocate(overlaplist(maxlist) )
1634 if(set_check)
allocate(checklist(maxlist) )
1637 call allocate_update_overlap( overlap, maxoverlap)
1639 call mpp_get_compute_domain( domain, isc, iec, jsc, jec, position=position )
1640 call mpp_get_global_domain ( domain, isg, ieg, jsg, jeg, xsize=ni, ysize=nj, position=position )
1641 call mpp_get_memory_domain ( domain, ism, iem, jsm, jem, position=position )
1643 update%xbegin = ism; update%xend = iem
1644 update%ybegin = jsm; update%yend = jem
1646 check%xbegin = ism; check%xend = iem
1647 check%ybegin = jsm; check%yend = jem
1649 update%whalo = whalo; update%ehalo = ehalo
1650 update%shalo = shalo; update%nhalo = nhalo
1654 middle = (isg+ieg)/2+1
1656 folded_north = btest(domain%fold,north)
1657 if( btest(domain%fold,south) .OR. btest(domain%fold,east) .OR. btest(domain%fold,west) )
then
1658 call mpp_error(fatal,
"mpp_domains_define.inc(compute_overlaps): folded south, east or west boundary condition "&
1659 &//
"is not supported, please use other version of compute_overlaps for "//trim(domain%name))
1666 m = mod( domain%pos+list, nlist )
1667 if(domain%list(m)%tile_id(tnbr) == domain%tile_id(tme) )
then
1670 is = domain%list(m)%x(tnbr)%compute%end+1+ishift; ie = domain%list(m)%x(tnbr)%compute%end+ehalo+ishift
1671 js = domain%list(m)%y(tnbr)%compute%begin; je = domain%list(m)%y(tnbr)%compute%end+jshift
1673 if( domain%symmetry .AND. (position == north .OR. position == corner ) &
1674 .AND. ( jsc == je .or. jec == js ) )
then
1679 if( je == jeg .AND. folded_north .AND. (position == corner .OR. position == north) )
then
1680 call fill_overlap_send_fold(overlap, domain, m, is, ie, js, je, isc, iec, jsc, jec, &
1681 isg, ieg, dir, ishift, position, ioff, middle)
1683 if(x_cyclic_offset ==0 .AND. y_cyclic_offset == 0)
then
1684 call fill_overlap_send_nofold(overlap, domain, m, is, ie, js, je, isc, iec, jsc, jec, &
1685 isg, ieg, dir, ioff, domain%x(tme)%cyclic, symmetry=domain%symmetry)
1687 if( ie.GT.ieg )
then
1688 if( domain%x(tme)%cyclic .AND. iec.LT.is )
then
1689 is = is-ioff; ie = ie-ioff
1693 call fill_overlap(overlap, domain, m, is, ie, js, je, isc, iec, jsc, jec, &
1694 isg, ieg, jsg, jeg, dir, symmetry=domain%symmetry)
1701 is = domain%list(m)%x(tnbr)%compute%end+1+ishift; ie = domain%list(m)%x(tnbr)%compute%end+ehalo+ishift
1702 js = domain%list(m)%y(tnbr)%compute%begin-shalo; je = domain%list(m)%y(tnbr)%compute%begin-1
1703 need_adjust_1 = .true.; need_adjust_2 = .true.; need_adjust_3 = .true.
1706 is2 = 0; ie2 = -1; js2 = 0; je2 = -1
1707 if(x_cyclic_offset == 0 .AND. y_cyclic_offset == 0)
then
1708 if(je .LT. jsg)
then
1709 if( domain%y(tme)%cyclic )
then
1710 js = js + joff; je = je + joff
1712 else if(js .Lt. jsg)
then
1713 if( domain%y(tme)%cyclic )
then
1714 js2 = js + joff; je2 = jsg-1+joff
1718 call fill_overlap_send_nofold(overlap, domain, m, is, ie, js, je, isc, iec, jsc, jec, &
1719 isg, ieg, dir, ioff, domain%x(tme)%cyclic)
1720 if(je2 .GE. js2)
call fill_overlap_send_nofold(overlap, domain, m, is, ie, js2, je2, isc, iec, jsc, jec, &
1721 isg, ieg, dir, ioff, domain%x(tme)%cyclic)
1724 if( domain%x(tme)%cyclic .AND. iec.LT.is )
then
1725 is = is-ioff; ie = ie-ioff
1726 need_adjust_1 = .false.
1727 if(jsg .GT. js)
then
1728 if( domain%y(tme)%cyclic .AND. je.LT.jsc )
then
1729 js = js+joff; je = je+joff
1730 need_adjust_2 = .false.
1731 if(x_cyclic_offset .NE. 0)
then
1733 else if(y_cyclic_offset .NE. 0)
then
1739 need_adjust_3 = .false.
1743 if( need_adjust_3 .AND. jsg.GT.js )
then
1744 if( need_adjust_2 .AND. domain%y(tme)%cyclic .AND. je.LT.jsc )
then
1745 js = js+joff; je = je+joff
1746 if(need_adjust_1 .AND. ie.LE.ieg)
then
1751 call fill_overlap(overlap, domain, m, is, ie, js, je, isc, iec, jsc, jec, isg, ieg, jsg, jeg, dir)
1756 is = domain%list(m)%x(tnbr)%compute%begin; ie = domain%list(m)%x(tnbr)%compute%end+ishift
1757 js = domain%list(m)%y(tnbr)%compute%begin-shalo; je = domain%list(m)%y(tnbr)%compute%begin-1
1760 if( domain%y(tme)%cyclic .AND. je.LT.jsc )
then
1761 js = js+joff; je = je+joff
1764 else if (jsg .GT. js)
then
1765 if( domain%y(tme)%cyclic)
then
1766 js2 = js + joff; je2 = jsg-1+joff
1771 call fill_overlap(overlap, domain, m, is, ie, js, je, isc, iec, jsc, jec, &
1772 isg, ieg, jsg, jeg, dir, symmetry=domain%symmetry)
1773 if(je2 .GE. js2)
call fill_overlap(overlap, domain, m, is, ie, js2, je2, isc, iec, jsc, jec, &
1774 isg, ieg, jsg, jeg, dir, symmetry=domain%symmetry)
1778 is = domain%list(m)%x(tnbr)%compute%begin-whalo; ie = domain%list(m)%x(tnbr)%compute%begin-1
1779 js = domain%list(m)%y(tnbr)%compute%begin-shalo; je = domain%list(m)%y(tnbr)%compute%begin-1
1780 need_adjust_1 = .true.; need_adjust_2 = .true.; need_adjust_3 = .true.
1781 is2 = 0; ie2 = -1; js2 = 0; je2 = -1
1782 if(x_cyclic_offset == 0 .AND. y_cyclic_offset == 0)
then
1783 if(je .LT. jsg)
then
1784 if( domain%y(tme)%cyclic )
then
1785 js = js + joff; je = je + joff
1787 else if(js .Lt. jsg)
then
1788 if( domain%y(tme)%cyclic )
then
1789 js2 = js + joff; je2 = jsg-1+joff
1793 call fill_overlap_send_nofold(overlap, domain, m, is, ie, js, je, isc, iec, jsc, jec, &
1794 isg, ieg, dir, ioff, domain%x(tme)%cyclic)
1795 if(je2 .GE. js2)
call fill_overlap_send_nofold(overlap, domain, m, is, ie, js2, je2, isc, iec, jsc, jec, &
1796 isg, ieg, dir, ioff, domain%x(tme)%cyclic)
1799 if( domain%x(tme)%cyclic .AND. ie.LT.isc )
then
1800 is = is+ioff; ie = ie+ioff
1801 need_adjust_1 = .false.
1802 if(jsg .GT. js)
then
1803 if( domain%y(tme)%cyclic .AND. je.LT.jsc )
then
1804 js = js+joff; je = je+joff
1805 need_adjust_2 = .false.
1806 if(x_cyclic_offset .NE. 0)
then
1808 else if(y_cyclic_offset .NE. 0)
then
1814 need_adjust_3 = .false.
1818 if( need_adjust_3 .AND. jsg.GT.js )
then
1819 if( need_adjust_2 .AND. domain%y(tme)%cyclic .AND. je.LT.jsc )
then
1820 js = js+joff; je = je+joff
1821 if(need_adjust_1 .AND. isg.LE.is )
then
1826 call fill_overlap(overlap, domain, m, is, ie, js, je, isc, iec, jsc, jec, isg, ieg, jsg, jeg, dir)
1831 is = domain%list(m)%x(tnbr)%compute%begin-whalo; ie = domain%list(m)%x(tnbr)%compute%begin-1
1832 js = domain%list(m)%y(tnbr)%compute%begin; je = domain%list(m)%y(tnbr)%compute%end+jshift
1836 if( je == jeg .AND. folded_north .AND. (position == corner .OR. position == north))
then
1837 call fill_overlap_send_fold(overlap, domain, m, is, ie, js, je, isc, iec, jsc, jec, &
1838 isg, ieg, dir, ishift, position, ioff, middle)
1840 if(x_cyclic_offset ==0 .AND. y_cyclic_offset == 0)
then
1841 call fill_overlap_send_nofold(overlap, domain, m, is, ie, js, je, isc, iec, jsc, jec, &
1842 isg, ieg, dir, ioff, domain%x(tme)%cyclic, symmetry=domain%symmetry)
1845 if( domain%x(tme)%cyclic .AND. ie.LT.isc )
then
1846 is = is+ioff; ie = ie+ioff
1850 call fill_overlap(overlap, domain, m, is, ie, js, je, isc, iec, jsc, jec, &
1851 isg, ieg, jsg, jeg, dir, symmetry=domain%symmetry)
1857 is = domain%list(m)%x(tnbr)%compute%begin-whalo; ie = domain%list(m)%x(tnbr)%compute%begin-1
1858 js = domain%list(m)%y(tnbr)%compute%end+1+jshift; je = domain%list(m)%y(tnbr)%compute%end+nhalo+jshift
1859 is2 = 0; ie2 = -1; js2 = 0; je2 = -1
1860 is3 = 0; ie3 = -1; js3 = 0; je3 = -1
1862 if(x_cyclic_offset == 0 .AND. y_cyclic_offset == 0)
then
1863 if(js .GT. jeg)
then
1864 if( domain%y(tme)%cyclic )
then
1865 js = js-joff; je = je-joff
1866 else if(folded_north )
then
1868 call get_fold_index_north(isg, ieg, jeg, ishift, position, is, ie, js, je)
1870 else if(je .GT. jeg)
then
1871 if( domain%y(tme)%cyclic )
then
1872 is2 = is; ie2 = ie; js2 = js; je2 = jeg
1873 js = jeg+1-joff; je = je -joff
1874 else if(folded_north)
then
1876 is2 = is; ie2 = ie; js2 = js; je2 = jeg
1878 call get_fold_index_north(isg, ieg, jeg, ishift, position, is, ie, js, je)
1879 if( is .GT. ieg)
then
1880 is = is - ioff; ie = ie - ioff
1881 else if( ie .GT. ieg )
then
1882 is3 = is; ie3 = ieg; js3 = js; je3 = je
1883 is = ieg+1-ioff; ie = ie - ioff
1888 if( je == jeg .AND. jec == jeg .AND. folded_north .AND. (position == corner .OR. position == north))
then
1889 call fill_overlap_send_fold(overlap, domain, m, is, ie, js, je, isc, iec, jsc, jec, &
1890 isg, ieg, dir, ishift, position, ioff, middle)
1892 call fill_overlap_send_nofold(overlap, domain, m, is, ie, js, je, isc, iec, jsc, jec, &
1893 isg, ieg, dir, ioff, domain%x(tme)%cyclic, folded)
1895 if(ie3 .GE. is3)
call fill_overlap_send_nofold(overlap, domain, m, is3, ie3, js3, je3, &
1896 isc, iec, jsc, jec, isg, ieg, dir, ioff, domain%x(tme)%cyclic, folded)
1897 if(ie2 .GE. is2)
then
1898 if(je2 == jeg .AND. jec == jeg .AND. folded_north.AND.(position == corner .OR. position == north))
then
1899 call fill_overlap_send_fold(overlap, domain, m, is2, ie2, js2, je2, isc, iec, jsc, jec, &
1900 isg, ieg, dir, ishift, position, ioff, middle)
1902 call fill_overlap_send_nofold(overlap, domain, m, is2, ie2, js2, je2, isc, iec, jsc, jec, &
1903 isg, ieg, dir, ioff, domain%x(tme)%cyclic)
1907 need_adjust_1 = .true.; need_adjust_2 = .true.; need_adjust_3 = .true.
1909 if( domain%x(tme)%cyclic .AND. ie.LT.isc )
then
1910 is = is+ioff; ie = ie+ioff
1911 need_adjust_1 = .false.
1912 if(je .GT. jeg)
then
1913 if( domain%y(tme)%cyclic .AND. jec.LT.js )
then
1914 js = js-joff; je = je-joff
1915 need_adjust_2 = .false.
1916 if(x_cyclic_offset .NE. 0)
then
1918 else if(y_cyclic_offset .NE. 0)
then
1924 need_adjust_3 = .false.
1929 if( need_adjust_3 .AND. je.GT.jeg )
then
1930 if( need_adjust_2 .AND. domain%y(tme)%cyclic .AND. jec.LT.js )
then
1931 js = js-joff; je = je-joff
1932 if( need_adjust_1 .AND. isg.LE.is)
then
1935 else if( folded_north )
then
1937 call get_fold_index_north(isg, ieg, jeg, ishift, position, is, ie, js, je)
1940 call fill_overlap(overlap, domain, m, is, ie, js, je, isc, iec, jsc, jec, &
1941 isg, ieg, jsg, jeg, dir)
1948 is = domain%list(m)%x(tnbr)%compute%begin; ie = domain%list(m)%x(tnbr)%compute%end+ishift
1949 js = domain%list(m)%y(tnbr)%compute%end+1+jshift; je = domain%list(m)%y(tnbr)%compute%end+nhalo+jshift
1954 if( domain%symmetry .AND. (position == east .OR. position == corner ) &
1955 .AND. ( isc == ie .or. iec == is ) .AND. (.not. folded_north) )
then
1959 if( js .GT. jeg)
then
1960 if( domain%y(tme)%cyclic .AND. jec.LT.js )
then
1961 js = js-joff; je = je-joff
1963 else if( folded_north )
then
1965 call get_fold_index_north(isg, ieg, jeg, ishift, position, is, ie, js, je)
1967 else if( je.GT.jeg )
then
1968 if( domain%y(tme)%cyclic)
then
1969 is2 = is; ie2 = ie; js2 = js; je2 = jeg
1970 js = jeg+1-joff; je = je - joff
1971 else if( folded_north )
then
1973 is2 = is; ie2 = ie; js2 = js; je2 = jeg
1975 call get_fold_index_north(isg, ieg, jeg, ishift, position, is, ie, js, je)
1978 if(x_cyclic_offset == 0 .AND. y_cyclic_offset == 0)
then
1979 if( je == jeg .AND. jec == jeg .AND. folded_north .AND.(position == corner .OR. position == north))
then
1980 call fill_overlap_send_fold(overlap, domain, m, is, ie, js, je, isc, iec, jsc, jec, &
1981 isg, ieg, dir, ishift, position, ioff, middle, domain%symmetry)
1983 call fill_overlap_send_nofold(overlap, domain, m, is, ie, js, je, isc, iec, jsc, jec, &
1984 isg, ieg, dir, ioff, domain%x(tme)%cyclic, folded, domain%symmetry)
1987 call fill_overlap(overlap, domain, m, is, ie, js, je, isc, iec, jsc, jec, &
1988 isg, ieg, jsg, jeg, dir, symmetry=domain%symmetry)
1991 if(ie2 .GE. is2)
then
1992 if(je2 == jeg .AND. jec == jeg .AND. folded_north .AND.(position == corner .OR. position == north))
then
1993 call fill_overlap_send_fold(overlap, domain, m, is2, ie2, js2, je2, isc, iec, jsc, jec, &
1994 isg, ieg, dir, ishift, position, ioff, middle, domain%symmetry)
1996 call fill_overlap_send_nofold(overlap, domain, m, is2, ie2, js2, je2, isc, iec, jsc, jec, &
1997 isg, ieg, dir, ioff, domain%x(tme)%cyclic, symmetry=domain%symmetry)
2003 if(is .LT. isg .AND. domain%x(tme)%cyclic)
then
2014 if( folded_north .AND. (position == north .OR. position == corner) &
2015 .AND. domain%x(tme)%pos .LT. (
size(domain%x(tme)%list(:))+1)/2 )
then
2016 if( domain%list(m)%y(tnbr)%compute%end+nhalo+jshift .GE. jeg .AND. isc .LE. middle)
then
2018 is = domain%list(m)%x(tnbr)%compute%begin; ie = domain%list(m)%x(tnbr)%compute%end+ishift
2019 is = max(is, middle)
2020 select case (position)
2022 i=is; is = isg+ieg-ie; ie = isg+ieg-i
2024 i=is; is = isg+ieg-ie-1+ishift; ie = isg+ieg-i-1+ishift
2026 call insert_update_overlap(overlap, domain%list(m)%pe, &
2027 is, ie, js, je, isc, iec, jsc, jec, dir, .true.)
2029 if(debug_update_level .NE. no_check .AND. set_check)
then
2030 je = domain%list(m)%y(tnbr)%compute%end+jshift;
2032 is = max(is, isc); ie = min(ie, iec)
2033 js = max(js, jsc); je = min(je, jec)
2034 if(ie.GE.is .AND. je.GE.js )
then
2035 nsend_check = nsend_check+1
2036 if(nsend_check >
size(checklist(:)) )
then
2037 call expand_check_overlap_list(checklist, nlist)
2039 call allocate_check_overlap(checklist(nsend_check), 1)
2040 call insert_check_overlap(checklist(nsend_check), domain%list(m)%pe, &
2041 tme, 4, one_hundred_eighty, is, ie, js, je)
2049 is = domain%list(m)%x(tnbr)%compute%end+1+ishift; ie = domain%list(m)%x(tnbr)%compute%end+ehalo+ishift
2050 js = domain%list(m)%y(tnbr)%compute%end+1+jshift; je = domain%list(m)%y(tnbr)%compute%end+nhalo+jshift
2051 is2 = 0; ie2=-1; js2=0; je2=-1
2052 is3 = 0; ie3 = -1; js3 = 0; je3 = -1
2053 if(x_cyclic_offset == 0 .AND. y_cyclic_offset == 0)
then
2055 if(js .GT. jeg)
then
2056 if( domain%y(tme)%cyclic )
then
2057 js = js-joff; je = je-joff
2058 else if(folded_north )
then
2060 call get_fold_index_north(isg, ieg, jeg, ishift, position, is, ie, js, je)
2062 else if(je .GT. jeg)
then
2063 if( domain%y(tme)%cyclic )
then
2064 is2 = is; ie2 = ie; js2 = js; je2 = jeg
2065 js = jeg+1-joff; je = je -joff
2066 else if(folded_north)
then
2068 is2 = is; ie2 = ie; js2 = js; je2 = jeg
2070 call get_fold_index_north(isg, ieg, jeg, ishift, position, is, ie, js, je)
2072 if( ie .LT. isg )
then
2073 is = is+ioff; ie = ie+ioff
2074 else if( is .LT. isg)
then
2075 is3 = isg; ie3 = ie; js3 = js; je3 = je
2076 is = is+ioff; ie = isg-1+ioff;
2080 if( je == jeg .AND. jec == jeg .AND. folded_north .AND. (position == corner .OR. position == north))
then
2081 call fill_overlap_send_fold(overlap, domain, m, is, ie, js, je, isc, iec, jsc, jec, &
2082 isg, ieg, dir, ishift, position, ioff, middle)
2084 call fill_overlap_send_nofold(overlap, domain, m, is, ie, js, je, isc, iec, jsc, jec, &
2085 isg, ieg, dir, ioff, domain%x(tme)%cyclic, folded)
2087 if(ie3 .GE. is3)
call fill_overlap_send_nofold(overlap, domain, m, is3, ie3, js3, je3, &
2088 isc, iec, jsc, jec, isg, ieg, dir, ioff, domain%x(tme)%cyclic, folded)
2089 if(ie2 .GE. is2)
then
2090 if(je2 == jeg .AND. jec == jeg .AND. folded_north .AND.(position == corner .OR. position == north))
then
2091 call fill_overlap_send_fold(overlap, domain, m, is2, ie2, js2, je2, isc, iec, jsc, jec, &
2092 isg, ieg, dir, ishift, position, ioff, middle)
2094 call fill_overlap_send_nofold(overlap, domain, m, is2, ie2, js2, je2, isc, iec, jsc, jec, &
2095 isg, ieg, dir, ioff, domain%x(tme)%cyclic)
2099 need_adjust_1 = .true.; need_adjust_2 = .true.; need_adjust_3 = .true.
2101 if( domain%x(tme)%cyclic .AND. iec.LT.is )
then
2102 is = is-ioff; ie = ie-ioff
2103 need_adjust_1 = .false.
2104 if(je .GT. jeg)
then
2105 if( domain%y(tme)%cyclic .AND. jec.LT.js )
then
2106 js = js-joff; je = je-joff
2107 need_adjust_2 = .false.
2108 if(x_cyclic_offset .NE. 0)
then
2110 else if(y_cyclic_offset .NE. 0)
then
2116 need_adjust_3 = .false.
2121 if( need_adjust_3 .AND. je.GT.jeg )
then
2122 if( need_adjust_2 .AND. domain%y(tme)%cyclic .AND. jec.LT.js )
then
2123 js = js-joff; je = je-joff
2124 if( need_adjust_1 .AND. ie.LE.ieg)
then
2127 else if( folded_north )
then
2129 call get_fold_index_north(isg, ieg, jeg, ishift, position, is, ie, js, je)
2132 call fill_overlap(overlap, domain, m, is, ie, js, je, isc, iec, jsc, jec, &
2133 isg, ieg, jsg, jeg, dir)
2138 if( overlap%count > 0)
then
2140 if(nsend >
size(overlaplist(:)) )
then
2141 call mpp_error(note,
'mpp_domains_define.inc(compute_overlaps): overlapList for send is expanded')
2142 call expand_update_overlap_list(overlaplist, nlist)
2144 call add_update_overlap( overlaplist(nsend), overlap)
2145 call init_overlap_type(overlap)
2149 if(debug_message_passing)
then
2153 write(iunit, *)
"********to_pe = " ,overlaplist(m)%pe,
" count = ",overlaplist(m)%count
2154 do n = 1, overlaplist(m)%count
2155 write(iunit, *) overlaplist(m)%is(n), overlaplist(m)%ie(n), overlaplist(m)%js(n), overlaplist(m)%je(n), &
2156 overlaplist(m)%dir(n), overlaplist(m)%rotation(n)
2159 if(nsend >0)
flush(iunit)
2164 if (
associated(update%send))
deallocate(update%send)
2165 allocate(update%send(nsend))
2166 update%nsend = nsend
2168 call add_update_overlap( update%send(m), overlaplist(m) )
2172 if(nsend_check>0)
then
2173 check%nsend = nsend_check
2174 if (
associated(check%send))
deallocate(check%send)
2175 allocate(check%send(nsend_check))
2176 do m = 1, nsend_check
2181 do m = 1,
size(overlaplist(:))
2182 call deallocate_overlap_type(overlaplist(m))
2185 if(debug_update_level .NE. no_check .AND. set_check)
then
2186 do m = 1,
size(checklist(:))
2187 call deallocate_overlap_type(checklist(m))
2191 isgd = isg - domain%whalo
2192 iegd = ieg + domain%ehalo
2193 jsgd = jsg - domain%shalo
2194 jegd = jeg + domain%nhalo
2200 m = mod( domain%pos+nlist-list, nlist )
2201 if(domain%list(m)%tile_id(tnbr) == domain%tile_id(tme) )
then
2202 isc = domain%list(m)%x(1)%compute%begin; iec = domain%list(m)%x(1)%compute%end+ishift
2203 jsc = domain%list(m)%y(1)%compute%begin; jec = domain%list(m)%y(1)%compute%end+jshift
2206 isd = domain%x(tme)%compute%end+1+ishift; ied = domain%x(tme)%compute%end+ehalo+ishift
2207 jsd = domain%y(tme)%compute%begin; jed = domain%y(tme)%compute%end+jshift
2208 is=isc; ie=iec; js=jsc; je=jec
2209 if( domain%symmetry .AND. (position == north .OR. position == corner ) &
2210 .AND. ( jsd == je .or. jed == js ) )
then
2215 if( jed == jeg .AND. folded_north .AND. (position == corner .OR. position == north) )
then
2216 call fill_overlap_recv_fold(overlap, domain, m, is, ie, js, je, isd, ied, jsd, jed, &
2217 isg, ieg, dir, ishift, position, ioff, middle)
2219 if(x_cyclic_offset == 0 .AND. y_cyclic_offset == 0)
then
2220 call fill_overlap_recv_nofold(overlap, domain, m, is, ie, js, je, isd, ied, jsd, jed, &
2221 isg, ieg, dir, ioff, domain%x(tme)%cyclic)
2223 if( ied.GT.ieg )
then
2224 if( domain%x(tme)%cyclic .AND. ie.LT.isd )
then
2225 is = is+ioff; ie = ie+ioff
2229 call fill_overlap(overlap, domain, m, is, ie, js, je, isd, ied, jsd, jed, &
2230 isg, ieg, jsg, jeg, dir, symmetry=domain%symmetry)
2237 isd = domain%x(tme)%compute%end+1+ishift; ied = domain%x(tme)%compute%end+ehalo+ishift
2238 jsd = domain%y(tme)%compute%begin-shalo; jed = domain%y(tme)%compute%begin-1
2239 is=isc; ie=iec; js=jsc; je=jec
2242 is2 = 0; ie2 = -1; js2 = 0; je2 = -1
2243 if(x_cyclic_offset == 0 .AND. y_cyclic_offset == 0)
then
2244 if(jed .LT. jsg)
then
2245 if( domain%y(tme)%cyclic )
then
2246 js = js-joff; je = je-joff
2248 else if(jsd .LT. jsg)
then
2249 if( domain%y(tme)%cyclic )
then
2250 js2 = js-joff; je2 = je-joff
2253 call fill_overlap_recv_nofold(overlap, domain, m, is, ie, js, je, isd, ied, jsd, jed, &
2254 isg, ieg, dir, ioff, domain%x(tme)%cyclic)
2255 if(je2 .GE. js2)
call fill_overlap_recv_nofold(overlap, domain, m, is, ie, js2, je2, isd, ied, jsd, jed, &
2256 isg, ieg, dir, ioff, domain%x(tme)%cyclic)
2258 need_adjust_1 = .true.; need_adjust_2 = .true.; need_adjust_3 = .true.
2259 if( jsd.LT.jsg )
then
2260 if( domain%y(tme)%cyclic .AND. js.GT.jed )
then
2261 js = js-joff; je = je-joff
2262 need_adjust_1 = .false.
2263 if( ied.GT.ieg )
then
2264 if( domain%x(tme)%cyclic .AND. ie.LT.isd )
then
2265 is = is+ioff; ie = ie+ioff
2266 need_adjust_2 = .false.
2267 if(x_cyclic_offset .NE. 0)
then
2269 else if(y_cyclic_offset .NE. 0)
then
2275 need_adjust_3 = .false.
2279 if( need_adjust_3 .AND. ied.GT.ieg )
then
2280 if( need_adjust_2 .AND. domain%x(tme)%cyclic .AND. ie.LT.isd )
then
2281 is = is+ioff; ie = ie+ioff
2282 if( need_adjust_1 .AND. jsd.GE.jsg )
then
2287 call fill_overlap(overlap, domain, m, is, ie, js, je, isd, ied, jsd, jed, &
2288 isg, ieg, jsg, jeg, dir)
2293 isd = domain%x(tme)%compute%begin; ied = domain%x(tme)%compute%end+ishift
2294 jsd = domain%y(tme)%compute%begin-shalo; jed = domain%y(tme)%compute%begin-1
2295 is=isc; ie=iec; js=jsc; je=jec
2297 if( jed .LT. jsg)
then
2298 if( domain%y(tme)%cyclic )
then
2299 js = js-joff; je = je-joff
2302 else if( jsd.LT.jsg )
then
2303 if( domain%y(tme)%cyclic)
then
2304 js2 = js-joff; je2 = je-joff
2307 call fill_overlap(overlap, domain, m, is, ie, js, je, isd, ied, jsd, jed, &
2308 isg, ieg, jsg, jeg, dir, symmetry=domain%symmetry)
2309 if(je2 .GE. js2)
call fill_overlap(overlap, domain, m, is, ie, js2, je2, isd, ied, jsd, jed, &
2310 isg, ieg, jsg, jeg, dir, symmetry=domain%symmetry)
2314 isd = domain%x(tme)%compute%begin-whalo; ied = domain%x(tme)%compute%begin-1
2315 jsd = domain%y(tme)%compute%begin-shalo; jed = domain%y(tme)%compute%begin-1
2316 is=isc; ie=iec; js=jsc; je=jec
2317 is2 = 0; ie2 = -1; js2 = 0; je2 = -1
2318 if(x_cyclic_offset == 0 .AND. y_cyclic_offset == 0)
then
2319 if( ied.LT.isg )
then
2320 if( domain%x(tme)%cyclic )
then
2321 is = is-ioff; ie = ie-ioff
2323 else if (isd.LT.isg )
then
2324 if( domain%x(tme)%cyclic )
then
2325 is2 = is-ioff; ie2 = ie-ioff
2328 if( jed.LT.jsg )
then
2329 if( domain%y(tme)%cyclic )
then
2330 js = js-joff; je = je-joff
2332 else if( jsd.LT.jsg )
then
2333 if( domain%y(tme)%cyclic )
then
2334 js2 = js-joff; je2 = je-joff
2338 need_adjust_1 = .true.; need_adjust_2 = .true.; need_adjust_3 = .true.
2339 if( jsd.LT.jsg )
then
2340 if( domain%y(tme)%cyclic .AND. js.GT.jed )
then
2341 js = js-joff; je = je-joff
2342 need_adjust_1 = .false.
2343 if( isd.LT.isg )
then
2344 if( domain%x(tme)%cyclic .AND. is.GT.ied )
then
2345 is = is-ioff; ie = ie-ioff
2346 need_adjust_2 = .false.
2347 if(x_cyclic_offset .NE. 0)
then
2349 else if(y_cyclic_offset .NE. 0)
then
2355 need_adjust_3 = .false.
2359 if( need_adjust_3 .AND. isd.LT.isg )
then
2360 if( need_adjust_2 .AND. domain%x(tme)%cyclic .AND. is.GT.ied )
then
2361 is = is-ioff; ie = ie-ioff
2362 if(need_adjust_1 .AND. jsd.GE.jsg)
then
2368 call fill_overlap(overlap, domain, m, is, ie, js, je, isd, ied, jsd, jed, &
2369 isg, ieg, jsg, jeg, dir)
2371 if(ie2 .GE. is2)
call fill_overlap(overlap, domain, m, is2, ie2, js, je, isd, ied, jsd, jed, &
2372 isg, ieg, jsg, jeg, dir)
2373 if(je2 .GE. js2)
call fill_overlap(overlap, domain, m, is, ie, js2, je2, isd, ied, jsd, jed, &
2374 isg, ieg, jsg, jeg, dir)
2376 if(ie2 .GE. is2 .AND. je2 .GE. js2)
call fill_overlap(overlap, domain, m, is2, ie2, js2, je2, isd, ied, jsd, &
2377 & jed, isg, ieg, jsg, jeg, dir)
2382 isd = domain%x(tme)%compute%begin-whalo; ied = domain%x(tme)%compute%begin-1
2383 jsd = domain%y(tme)%compute%begin; jed = domain%y(tme)%compute%end+jshift
2384 is=isc; ie=iec; js=jsc; je=jec
2388 if( jed == jeg .AND. folded_north .AND. (position == corner .OR. position == north) )
then
2389 call fill_overlap_recv_fold(overlap, domain, m, is, ie, js, je, isd, ied, jsd, jed, &
2390 isg, ieg, dir, ishift, position, ioff, middle)
2392 if(x_cyclic_offset == 0 .AND. y_cyclic_offset == 0)
then
2393 call fill_overlap_recv_nofold(overlap, domain, m, is, ie, js, je, isd, ied, jsd, jed, &
2394 isg, ieg, dir, ioff, domain%x(tme)%cyclic, symmetry=domain%symmetry)
2396 if( isd.LT.isg )
then
2397 if( domain%x(tme)%cyclic .AND. is.GT.ied )
then
2398 is = is-ioff; ie = ie-ioff
2402 call fill_overlap(overlap, domain, m, is, ie, js, je, isd, ied, jsd, jed, &
2403 isg, ieg, jsg, jeg, dir, symmetry=domain%symmetry)
2410 isd = domain%x(tme)%compute%begin-whalo; ied = domain%x(tme)%compute%begin-1
2411 jsd = domain%y(tme)%compute%end+1+jshift; jed = domain%y(tme)%compute%end+nhalo+jshift
2412 is=isc; ie=iec; js=jsc; je=jec
2413 is2 = 0; ie2 = -1; js2 = 0; je2 = -1
2414 is3 = 0; ie3 = -1; js3 = 0; je3 = -1
2415 if(x_cyclic_offset == 0 .AND. y_cyclic_offset == 0)
then
2417 if( jsd .GT. jeg )
then
2418 if( domain%y(tme)%cyclic .AND. je.LT.jsd )
then
2419 js = js+joff; je = je+joff
2421 else if( folded_north )
then
2423 call get_fold_index_north(isg, ieg, jeg, ishift, position, is, ie, js, je)
2425 else if( jed.GT.jeg )
then
2426 if( domain%y(tme)%cyclic)
then
2427 is2 = is; ie2 = ie; js2 = js; je2 = je
2428 isd2 = isd; ied2 = ied; jsd2 = jsd; jed2 = jeg
2429 js = js + joff; je = je + joff
2431 else if( folded_north )
then
2433 is2 = is; ie2 = ie; js2 = js; je2 = je
2434 isd2 = isd; ied2 = ied; jsd2 = jsd; jed2 = jeg
2436 call get_fold_index_north(isg, ieg, jeg, ishift, position, is, ie, js, je)
2437 if(isd < isg .and. ied .GE. isg .and. domain%symmetry)
then
2438 isd3 = isd; ied3 = isg-1
2439 jsd3 = jsd; jed3 = jed
2440 is3 = is-ioff; ie3=ie-ioff
2447 if( jeg .GE. js .AND. jeg .LE. je .AND. jed == jeg .AND. folded_north &
2448 .AND. (position == corner .OR. position == north))
then
2449 call fill_overlap_recv_fold(overlap, domain, m, is, ie, js, je, isd, ied, jsd, jed, &
2450 isg, ieg, dir, ishift, position, ioff, middle)
2452 call fill_overlap_recv_nofold(overlap, domain, m, is, ie, js, je, isd, ied, jsd, jed, &
2453 isg, ieg, dir, ioff, domain%x(tme)%cyclic, folded)
2456 if(ie3 .GE. is3)
call fill_overlap_recv_nofold(overlap, domain, m, is3, ie3, js3, je3, isd3, ied3, jsd3, &
2457 & jed3, isg, ieg, dir, ioff, domain%x(tme)%cyclic, folded)
2459 if(ie2 .GE. is2)
then
2460 if( jeg .GE. js2 .AND. jeg .LE. je2 .AND. jed2 == jeg .AND. folded_north &
2461 .AND. (position == corner .OR. position == north))
then
2462 call fill_overlap_recv_fold(overlap, domain, m, is2, ie2, js2, je2, isd2, ied2, jsd2, jed2, &
2463 isg, ieg, dir, ishift, position, ioff, middle)
2465 call fill_overlap_recv_nofold(overlap, domain, m, is2, ie2, js2, je2, isd2, ied2, jsd2, jed2, &
2466 isg, ieg, dir, ioff, domain%x(tme)%cyclic)
2470 need_adjust_1 = .true.; need_adjust_2 = .true.; need_adjust_3 = .true.
2471 if( jed.GT.jeg )
then
2472 if( domain%y(tme)%cyclic .AND. je.LT.jsd )
then
2473 js = js+joff; je = je+joff
2474 need_adjust_1 = .false.
2475 if( isd.LT.isg )
then
2476 if( domain%x(tme)%cyclic .AND. is.GE.ied )
then
2477 is = is-ioff; ie = ie-ioff
2478 need_adjust_2 = .false.
2479 if(x_cyclic_offset .NE. 0)
then
2481 else if(y_cyclic_offset .NE. 0)
then
2487 need_adjust_3 = .false.
2489 else if( folded_north )
then
2491 call get_fold_index_north(isg, ieg, jeg, ishift, position, is, ie, js, je)
2494 if( need_adjust_3 .AND. isd.LT.isg )
then
2495 if( need_adjust_2 .AND. domain%x(tme)%cyclic .AND. is.GE.ied )
then
2496 is = is-ioff; ie = ie-ioff
2497 if( need_adjust_1 .AND. jed.LE.jeg )
then
2502 call fill_overlap(overlap, domain, m, is, ie, js, je, isd, ied, jsd, jed, &
2503 isg, ieg, jsg, jeg, dir)
2507 if(is .LT. isg .AND. domain%x(tme)%cyclic)
then
2509 call insert_update_overlap(overlap, domain%list(m)%pe, &
2510 is, is, js, je, isd, ied, jsd, jed, dir, folded )
2516 isd = domain%x(tme)%compute%begin; ied = domain%x(tme)%compute%end+ishift
2517 jsd = domain%y(tme)%compute%end+1+jshift; jed = domain%y(tme)%compute%end+nhalo+jshift
2518 is=isc; ie=iec; js=jsc; je=jec
2522 if( domain%symmetry .AND. (position == east .OR. position == corner ) &
2523 .AND. (isd == ie .or. ied == is ) .AND. (.not. folded_north) )
then
2527 if( jsd .GT. jeg )
then
2528 if( domain%y(tme)%cyclic .AND. je.LT.jsd )
then
2529 js = js+joff; je = je+joff
2531 else if( folded_north )
then
2533 call get_fold_index_north(isg, ieg, jeg, ishift, position, is, ie, js, je)
2535 else if( jed.GT.jeg )
then
2536 if( domain%y(tme)%cyclic)
then
2537 is2 = is; ie2 = ie; js2 = js; je2 = je
2538 isd2 = isd; ied2 = ied; jsd2 = jsd; jed2 = jeg
2539 js = js + joff; je = je + joff
2541 else if( folded_north )
then
2543 is2 = is; ie2 = ie; js2 = js; je2 = je
2544 isd2 = isd; ied2 = ied; jsd2 = jsd; jed2 = jeg
2546 call get_fold_index_north(isg, ieg, jeg, ishift, position, is, ie, js, je)
2549 if(x_cyclic_offset == 0 .and. y_cyclic_offset == 0)
then
2550 if( jeg .GE. js .AND. jeg .LE. je .AND. jed == jeg .AND. folded_north &
2551 .AND. (position == corner .OR. position == north))
then
2552 call fill_overlap_recv_fold(overlap, domain, m, is, ie, js, je, isd, ied, jsd, jed, &
2553 isg, ieg, dir, ishift, position, ioff, middle, symmetry=domain%symmetry)
2555 call fill_overlap_recv_nofold(overlap, domain, m, is, ie, js, je, isd, ied, jsd, jed, &
2556 isg, ieg, dir, ioff, domain%x(tme)%cyclic, folded, symmetry=domain%symmetry)
2559 call fill_overlap(overlap, domain, m, is, ie, js, je, isd, ied, jsd, jed, &
2560 isg, ieg, jsg, jeg, dir, symmetry=domain%symmetry)
2562 if(ie2 .GE. is2)
then
2563 if(jeg .GE. js2 .AND. jeg .LE. je2 .AND. jed2 == jeg .AND. folded_north &
2564 .AND. (position == corner .OR. position == north))
then
2565 call fill_overlap_recv_fold(overlap, domain, m, is2, ie2, js2, je2, isd2, ied2, jsd2, jed2, &
2566 isg, ieg, dir, ishift, position, ioff, middle, symmetry=domain%symmetry)
2568 call fill_overlap_recv_nofold(overlap, domain, m, is2, ie2, js2, je2, isd2, ied2, jsd2, jed2, &
2569 isg, ieg, dir, ioff, domain%x(tme)%cyclic, folded, symmetry=domain%symmetry)
2575 if(is .LT. isg .AND. domain%x(tme)%cyclic)
then
2585 if( folded_north .AND. (position == north .OR. position == corner) &
2586 .AND. domain%x(tme)%pos .GE.
size(domain%x(tme)%list(:))/2)
then
2587 if( jed .GE. jeg .AND. ied .GE. middle)
then
2588 jsd = jeg; jed = jeg
2589 is=isc; ie=iec; js = jsc; je = jec
2590 isd = max(isd, middle)
2591 select case (position)
2593 i=is; is = isg+ieg-ie; ie = isg+ieg-i
2595 i=is; is = isg+ieg-ie-1+ishift; ie = isg+ieg-i-1+ishift
2597 call insert_update_overlap(overlap, domain%list(m)%pe, &
2598 is, ie, js, je, isd, ied, jsd, jed, dir, .true.)
2600 if(debug_update_level .NE. no_check .AND. set_check)
then
2601 jsd = domain%y(tme)%compute%end+jshift; jed = jsd
2603 is = max(is, isd); ie = min(ie, ied)
2604 js = max(js, jsd); je = min(je, jed)
2605 if(ie.GE.is .AND. je.GE.js )
then
2606 nrecv_check = nrecv_check+1
2607 if(nrecv_check >
size(checklist(:)) )
then
2608 call expand_check_overlap_list(checklist, nlist)
2610 call allocate_check_overlap(checklist(nrecv_check), 1)
2611 call insert_check_overlap(checklist(nrecv_check), domain%list(m)%pe, &
2612 tme, 4, one_hundred_eighty, is, ie, js, je)
2622 isd = domain%x(tme)%compute%end+1+ishift; ied = domain%x(tme)%compute%end+ehalo+ishift
2623 jsd = domain%y(tme)%compute%end+1+jshift; jed = domain%y(tme)%compute%end+nhalo+jshift
2624 is=isc; ie=iec; js=jsc; je=jec
2625 is2 = 0; ie2=-1; js2=0; je2=-1
2626 is3 = 0; ie3 = -1; js3 = 0; je3 = -1
2627 if(x_cyclic_offset == 0 .AND. y_cyclic_offset == 0)
then
2629 if( jsd .GT. jeg )
then
2630 if( domain%y(tme)%cyclic .AND. je.LT.jsd )
then
2631 js = js+joff; je = je+joff
2633 else if( folded_north )
then
2635 call get_fold_index_north(isg, ieg, jeg, ishift, position, is, ie, js, je)
2637 else if( jed.GT.jeg )
then
2638 if( domain%y(tme)%cyclic)
then
2639 is2 = is; ie2 = ie; js2 = js; je2 = je
2640 isd2 = isd; ied2 = ied; jsd2 = jsd; jed2 = jeg
2641 js = js + joff; je = je + joff
2643 else if( folded_north )
then
2645 is2 = is; ie2 = ie; js2 = js; je2 = je
2646 isd2 = isd; ied2 = ied; jsd2 = jsd; jed2 = jeg
2648 call get_fold_index_north(isg, ieg, jeg, ishift, position, is, ie, js, je)
2649 if(ied > ieg .and. isd .LE. ieg .and. domain%symmetry)
then
2650 isd3 = ieg+1; ied3 = ied
2651 jsd3 = jsd; jed3 = jed
2652 is3 = is+ioff; ie3=ie+ioff
2658 if( jeg .GE. js .AND. jeg .LE. je .AND. jed == jeg .AND. folded_north &
2659 .AND. (position == corner .OR. position == north))
then
2660 call fill_overlap_recv_fold(overlap, domain, m, is, ie, js, je, isd, ied, jsd, jed, &
2661 isg, ieg, dir, ishift, position, ioff, middle)
2663 call fill_overlap_recv_nofold(overlap, domain, m, is, ie, js, je, isd, ied, jsd, jed, &
2664 isg, ieg, dir, ioff, domain%x(tme)%cyclic, folded)
2666 if(ie3 .GE. is3)
call fill_overlap_recv_nofold(overlap, domain, m, is3, ie3, js3, je3, isd3, ied3, jsd3, &
2667 & jed3, isg, ieg, dir, ioff, domain%x(tme)%cyclic, folded)
2668 if(ie2 .GE. is2)
then
2669 if(jeg .GE. js2 .AND. jeg .LE. je2 .AND. jed2 == jeg .AND. folded_north &
2670 .AND. (position == corner .OR. position == north))
then
2671 call fill_overlap_recv_fold(overlap, domain, m, is2, ie2, js2, je2, isd2, ied2, jsd2, jed2, &
2672 isg, ieg, dir, ishift, position, ioff, middle)
2674 call fill_overlap_recv_nofold(overlap, domain, m, is2, ie2, js2, je2, isd2, ied2, jsd2, jed2, &
2675 isg, ieg, dir, ioff, domain%x(tme)%cyclic)
2679 need_adjust_1 = .true.; need_adjust_2 = .true.; need_adjust_3 = .true.
2680 if( jed.GT.jeg )
then
2681 if( domain%y(tme)%cyclic .AND. je.LT.jsd )
then
2682 js = js+joff; je = je+joff
2683 need_adjust_1 = .false.
2684 if( ied.GT.ieg )
then
2685 if( domain%x(tme)%cyclic .AND. ie.LT.isd )
then
2686 is = is+ioff; ie = ie+ioff
2687 need_adjust_2 = .false.
2688 if(x_cyclic_offset .NE. 0)
then
2690 else if(y_cyclic_offset .NE. 0)
then
2696 need_adjust_3 = .false.
2698 else if( folded_north )
then
2700 call get_fold_index_north(isg, ieg, jeg, ishift, position, is, ie, js, je)
2703 if( need_adjust_3 .AND. ied.GT.ieg )
then
2704 if( need_adjust_2 .AND. domain%x(tme)%cyclic .AND. ie.LT.isd )
then
2705 is = is+ioff; ie = ie+ioff
2706 if( need_adjust_1 .AND. jed.LE.jeg)
then
2711 call fill_overlap(overlap, domain, m, is, ie, js, je, isd, ied, jsd, jed, &
2712 isg, ieg, jsg, jeg, dir)
2717 if( overlap%count > 0)
then
2719 if(nrecv >
size(overlaplist(:)) )
then
2720 call mpp_error(note,
'mpp_domains_define.inc(compute_overlaps): overlapList for recv is expanded')
2721 call expand_update_overlap_list(overlaplist, nlist)
2723 call add_update_overlap( overlaplist(nrecv), overlap)
2724 call init_overlap_type(overlap)
2728 if(debug_message_passing)
then
2732 write(iunit, *)
"********from_pe = " ,overlaplist(m)%pe,
" count = ",overlaplist(m)%count
2733 do n = 1, overlaplist(m)%count
2734 write(iunit, *) overlaplist(m)%is(n), overlaplist(m)%ie(n), overlaplist(m)%js(n), overlaplist(m)%je(n), &
2735 overlaplist(m)%dir(n), overlaplist(m)%rotation(n)
2738 if(nrecv >0)
flush(iunit)
2743 if (
associated(update%recv))
deallocate(update%recv)
2744 allocate(update%recv(nrecv))
2745 update%nrecv = nrecv
2747 call add_update_overlap( update%recv(m), overlaplist(m) )
2748 do n = 1, update%recv(m)%count
2749 if(update%recv(m)%tileNbr(n) == domain%tile_id(tme))
then
2750 if(update%recv(m)%dir(n) == 1) domain%x(tme)%loffset = 0
2751 if(update%recv(m)%dir(n) == 7) domain%y(tme)%loffset = 0
2757 if(nrecv_check>0)
then
2758 check%nrecv = nrecv_check
2759 if (
associated(check%recv))
deallocate(check%recv)
2760 allocate(check%recv(nrecv_check))
2761 do m = 1, nrecv_check
2766 call deallocate_overlap_type(overlap)
2767 do m = 1,
size(overlaplist(:))
2768 call deallocate_overlap_type(overlaplist(m))
2771 if(debug_update_level .NE. no_check .AND. set_check)
then
2772 do m = 1,
size(checklist(:))
2773 call deallocate_overlap_type(checklist(m))
2777 deallocate(overlaplist)
2778 if(set_check)
deallocate(checklist)
2779 domain%initialized = .true.
2784 subroutine fill_overlap_send_nofold(overlap, domain, m, is, ie, js, je, isc, iec, jsc, jec, &
2785 isg, ieg, dir, ioff, is_cyclic, folded, symmetry)
2786 type(overlap_type),
intent(inout) :: overlap
2787 type(domain2d),
intent(inout) :: domain
2788 integer,
intent(in ) :: m, is, ie, js, je
2789 integer,
intent(in ) :: isc, iec, jsc, jec
2790 integer,
intent(in ) :: isg, ieg, dir, ioff
2791 logical,
intent(in ) :: is_cyclic
2792 logical,
optional,
intent(in ) :: folded, symmetry
2794 call insert_update_overlap( overlap, domain%list(m)%pe, &
2795 is, ie, js, je, isc, iec, jsc, jec, dir, reverse=folded, symmetry=symmetry)
2797 if(ie .GT. ieg)
then
2798 call insert_update_overlap( overlap, domain%list(m)%pe, &
2799 is-ioff, ie-ioff, js, je, isc, iec, jsc, jec, dir, reverse=folded, symmetry=symmetry)
2800 else if( is .LT. isg )
then
2801 call insert_update_overlap( overlap, domain%list(m)%pe, &
2802 is+ioff, ie+ioff, js, je, isc, iec, jsc, jec, dir, reverse=folded, symmetry=symmetry)
2806 end subroutine fill_overlap_send_nofold
2808 subroutine fill_overlap_send_fold(overlap, domain, m, is, ie, js, je, isc, iec, jsc, jec, &
2809 isg, ieg, dir, ishift, position, ioff, middle, symmetry)
2810 type(overlap_type),
intent(inout) :: overlap
2811 type(domain2d),
intent(inout) :: domain
2812 integer,
intent(in ) :: m, is, ie, js, je
2813 integer,
intent(in ) :: isc, iec, jsc, jec
2814 integer,
intent(in ) :: isg, ieg, dir, ishift, position, ioff, middle
2815 logical,
optional,
intent(in ) :: symmetry
2816 integer :: is1, ie1, is2, ie2, i
2820 if(position == corner .AND. .NOT. domain%symmetry .AND. is .LE. isg-1 .AND. ie .GE. isg-1)
then
2821 call insert_update_overlap(overlap, domain%list(m)%pe, &
2822 isg-1+ioff, isg-1+ioff, je, je, isc, iec, jsc, jec, dir, .true.)
2825 is1 = 0; ie1 = -1; is2 = 0; ie2 = -1
2828 is2 = is-ioff; ie2 = ie-ioff
2829 else if( ie > ieg )
then
2831 is2 = ieg+1-ioff; ie2 = ie-ioff
2832 else if( is .GE. middle )
then
2834 else if( ie .GE. middle )
then
2835 is1 = middle; ie1 = ie
2836 is2 = is; ie2 = middle-1
2837 else if( ie < isg )
then
2838 is1 = is+ieg-isg+1-ishift; ie1 = ie+ieg-isg+1-ishift
2839 else if( is < isg )
then
2840 is1 = is+ieg-isg+1-ishift; ie1 = isg-1+ieg-isg+1-ishift
2846 if( ie1 .GE. is1)
then
2847 call insert_update_overlap( overlap, domain%list(m)%pe, &
2848 is1, ie1, js, je-1, isc, iec, jsc, jec, dir, symmetry=symmetry)
2850 select case (position)
2852 i=is1; is1 = isg+ieg-ie1; ie1 = isg+ieg-i
2854 i=is1; is1 = isg+ieg-ie1-1+ishift; ie1 = isg+ieg-i-1+ishift
2856 call insert_update_overlap( overlap, domain%list(m)%pe, &
2857 is1, ie1, je, je, isc, iec, jsc, jec, dir, .true., symmetry=symmetry)
2860 if(ie2 .GE. is2)
then
2861 call insert_update_overlap( overlap, domain%list(m)%pe, &
2862 is2, ie2, js, je, isc, iec, jsc, jec, dir)
2865 end subroutine fill_overlap_send_fold
2869 subroutine fill_overlap_recv_nofold(overlap, domain, m, is, ie, js, je, isd, ied, jsd, jed, &
2870 isg, ieg, dir, ioff, is_cyclic, folded, symmetry)
2871 type(overlap_type),
intent(inout) :: overlap
2872 type(domain2d),
intent(inout) :: domain
2873 integer,
intent(in ) :: m, is, ie, js, je
2874 integer,
intent(in ) :: isd, ied, jsd, jed
2875 integer,
intent(in ) :: isg, ieg, dir, ioff
2876 logical,
intent(in ) :: is_cyclic
2877 logical,
optional,
intent(in ) :: folded, symmetry
2878 integer :: is1, ie1, is2, ie2
2879 integer :: isd1, ied1, isd2, ied2
2881 is1 = 0; ie1 = -1; is2 = 0; ie2 = -1
2885 call insert_update_overlap( overlap, domain%list(m)%pe, &
2886 is, ie, js, je, isd, ied, jsd, jed, dir, reverse=folded, symmetry=symmetry)
2888 if(ied .GT. ieg)
then
2889 call insert_update_overlap( overlap, domain%list(m)%pe, &
2890 is+ioff, ie+ioff, js, je, isd, ied, jsd, jed, dir, reverse=folded, symmetry=symmetry)
2891 else if( isd .LT. isg )
then
2892 call insert_update_overlap( overlap, domain%list(m)%pe, &
2893 is-ioff, ie-ioff, js, je, isd, ied, jsd, jed, dir, reverse=folded, symmetry=symmetry)
2894 else if ( is .LT. isg )
then
2895 call insert_update_overlap( overlap, domain%list(m)%pe, &
2896 is+ioff, ie+ioff, js, je, isd, ied, jsd, jed, dir, reverse=folded, symmetry=symmetry)
2897 else if ( ie .GT. ieg )
then
2898 call insert_update_overlap( overlap, domain%list(m)%pe, &
2899 is-ioff, ie-ioff, js, je, isd, ied, jsd, jed, dir, reverse=folded, symmetry=symmetry)
2903 end subroutine fill_overlap_recv_nofold
2905 subroutine fill_overlap_recv_fold(overlap, domain, m, is, ie, js, je, isd, ied, jsd, jed, &
2906 isg, ieg, dir, ishift, position, ioff, middle, symmetry)
2907 type(overlap_type),
intent(inout) :: overlap
2908 type(domain2d),
intent(inout) :: domain
2909 integer,
intent(in ) :: m, is, ie, js, je
2910 integer,
intent(in ) :: isd, ied, jsd, jed
2911 integer,
intent(in ) :: isg, ieg, dir, ishift, position, ioff, middle
2912 logical,
optional,
intent(in ) :: symmetry
2913 integer :: is1, ie1, is2, ie2, is3, ie3
2914 integer :: isd1, ied1, isd2, ied2
2918 if( position == corner .AND. .NOT. domain%symmetry .AND. isd .LE. isg-1 .AND. ied .GE. isg-1 )
then
2919 call insert_update_overlap( overlap, domain%list(m)%pe, &
2920 is-ioff, ie-ioff, js, je, isg-1, isg-1, jed, jed, dir, .true.)
2923 is1 = 0; ie1 = -1; is2 = 0; ie2 = -1
2926 select case (position)
2928 is3 = isg+ieg-ie; ie3 = isg+ieg-is
2930 is3 = isg+ieg-ie-1+ishift; ie3 = isg+ieg-is-1+ishift
2933 if(isd .GT. ieg)
then
2934 is2 = is + ioff; ie2 = ie + ioff;
2935 else if(ied .GT. ieg)
then
2937 isd1 = isd; ied1 = ieg;
2938 is2 = is + ioff; ie2 = ie + ioff
2939 isd2 = ieg + 1; ied2 = ied
2940 else if(isd .GE. middle)
then
2942 else if(ied .GE. middle)
then
2944 isd1 = middle; ied1 = ied
2946 isd2 = isd; ied2 = middle-1
2947 else if(ied .LT. isg)
then
2948 is1 = is - ioff; ie1 = ie - ioff;
2949 is3 = is3 - ioff; ie3 = ie3 - ioff;
2950 else if(isd .LT. isg)
then
2951 is1 = is - ioff; ie1 = ie - ioff;
2952 is3 = is3 - ioff; ie3 = ie3 - ioff;
2953 isd1 = isd; ied1 = isg-1
2955 isd2 = isg; ied2 = ied
2958 isd2 = isd; ied2 = ied
2961 if( ie1 .GE. is1)
then
2962 call insert_update_overlap( overlap, domain%list(m)%pe, &
2963 is1, ie1, js, je, isd1, ied1, jsd, jed-1, dir, symmetry=symmetry)
2965 call insert_update_overlap( overlap, domain%list(m)%pe, &
2966 is3, ie3, js, je, isd1, ied1, jed, jed, dir, .true., symmetry=symmetry)
2969 if(ie2 .GE. is2)
then
2970 call insert_update_overlap( overlap, domain%list(m)%pe, &
2971 is2, ie2, js, je, isd2, ied2, jsd, jed, dir)
2974 end subroutine fill_overlap_recv_fold
2977 subroutine fill_overlap(overlap, domain, m, is, ie, js, je, isc, iec, jsc, jec, &
2978 isg, ieg, jsg, jeg, dir, reverse, symmetry)
2979 type(overlap_type),
intent(inout) :: overlap
2980 type(domain2d),
intent(inout) :: domain
2981 integer,
intent(in ) :: m, is, ie, js, je
2982 integer,
intent(in ) :: isc, iec, jsc, jec
2983 integer,
intent(in ) :: isg, ieg, jsg, jeg
2984 integer,
intent(in ) :: dir
2985 logical,
optional,
intent(in ) :: reverse, symmetry
2989 call insert_update_overlap( overlap, domain%list(m)%pe, &
2990 is, ie, jsg, je, isc, iec, jsc, jec, dir, reverse, symmetry)
2991 call insert_update_overlap( overlap, domain%list(m)%pe, &
2992 is, ie, js, jeg, isc, iec, jsc, jec, dir, reverse, symmetry)
2993 else if(is > ie)
then
2995 call insert_update_overlap( overlap, domain%list(m)%pe, &
2996 is, ieg, js, je, isc, iec, jsc, jec, dir, reverse, symmetry)
2997 call insert_update_overlap( overlap, domain%list(m)%pe, &
2998 isg, ie, js, je, isc, iec, jsc, jec, dir, reverse, symmetry)
3000 call insert_update_overlap( overlap, domain%list(m)%pe, &
3001 is, ie, js, je, isc, iec, jsc, jec, dir, reverse, symmetry)
3005 end subroutine fill_overlap
3012 type(domain2d),
intent(inout) :: domain
3013 integer,
intent(in) :: position, ishift, jshift
3015 integer :: i, m, n, nlist, tMe, tNbr, dir
3016 integer :: is, ie, js, je, isc, iec, jsc, jec, isd, ied, jsd, jed
3017 integer :: isg, ieg, jsg, jeg, ioff, joff
3018 integer :: list, middle, ni, nj, isgd, iegd, jsgd, jegd
3019 integer :: ism, iem, jsm, jem, whalo, ehalo, shalo, nhalo
3021 type(overlap_type) :: overlap
3022 type(overlapspec),
pointer :: update=>null()
3023 type(overlap_type),
pointer :: overlapList(:)=>null()
3024 type(overlap_type),
pointer :: checkList(:)=>null()
3025 type(overlapspec),
pointer :: check =>null()
3026 integer :: nsend, nrecv
3027 integer :: nsend_check, nrecv_check
3033 if(
size(domain%x(:)) > 1)
return
3036 if(domain%whalo==0 .AND. domain%ehalo==0 .AND. domain%shalo==0 .AND. domain%nhalo==0)
return
3039 nlist =
size(domain%list(:))
3041 select case(position)
3043 update => domain%update_T
3046 update => domain%update_C
3047 check => domain%check_C
3049 update => domain%update_E
3050 check => domain%check_E
3052 update => domain%update_N
3053 check => domain%check_N
3055 call mpp_error(fatal, &
3056 "mpp_domains_define.inc(compute_overlaps_fold_south): the value of position should be CENTER, EAST, &
3060 allocate(overlaplist(maxlist) )
3061 allocate(checklist(maxlist) )
3064 call allocate_update_overlap( overlap, maxoverlap)
3067 call mpp_get_compute_domain( domain, isc, iec, jsc, jec, position=position )
3068 call mpp_get_global_domain ( domain, isg, ieg, jsg, jeg, xsize=ni, ysize=nj, position=position )
3069 call mpp_get_memory_domain ( domain, ism, iem, jsm, jem, position=position )
3070 update%xbegin = ism; update%xend = iem
3071 update%ybegin = jsm; update%yend = jem
3072 if(
ASSOCIATED(check))
then
3073 check%xbegin = ism; check%xend = iem
3074 check%ybegin = jsm; check%yend = jem
3076 update%whalo = domain%whalo; update%ehalo = domain%ehalo
3077 update%shalo = domain%shalo; update%nhalo = domain%nhalo
3078 whalo = domain%whalo; ehalo = domain%ehalo
3079 shalo = domain%shalo; nhalo = domain%nhalo
3084 middle = (isg+ieg)/2+1
3087 if(.NOT. btest(domain%fold,south))
then
3088 call mpp_error(fatal,
"mpp_domains_define.inc(compute_overlaps_fold_south): "//&
3089 "boundary condition in y-direction should be folded-south for "//trim(domain%name))
3091 if(.NOT. domain%x(tme)%cyclic)
then
3092 call mpp_error(fatal,
"mpp_domains_define.inc(compute_overlaps_fold_south): "//&
3093 "boundary condition in x-direction should be cyclic for "//trim(domain%name))
3096 if(.not. domain%symmetry)
then
3097 call mpp_error(fatal,
"mpp_domains_define.inc(compute_overlaps_fold_south): "//&
3098 "when south boundary is folded, the domain must be symmetry for "//trim(domain%name))
3104 m = mod( domain%pos+list, nlist )
3105 if(domain%list(m)%tile_id(tnbr) == domain%tile_id(tme) )
then
3108 is = domain%list(m)%x(tnbr)%compute%end+1+ishift; ie = domain%list(m)%x(tnbr)%compute%end+ehalo+ishift
3109 js = domain%list(m)%y(tnbr)%compute%begin; je = domain%list(m)%y(tnbr)%compute%end+jshift
3111 if( (position == north .OR. position == corner ) .AND. ( jsc == je .or. jec == js ) )
then
3114 if( ie.GT.ieg .AND. iec.LT.is )
then
3115 is = is-ioff; ie = ie-ioff
3119 if( js == jsg .AND. (position == corner .OR. position == north) &
3120 .AND. is .GE. middle .AND. domain%list(m)%x(tnbr)%compute%end+ehalo+jshift .LE. ieg )
then
3121 call insert_update_overlap( overlap, domain%list(m)%pe, &
3122 is, ie, js+1, je, isc, iec, jsc, jec, dir)
3123 is = domain%list(m)%x(tnbr)%compute%end+1+ishift; ie = domain%list(m)%x(tnbr)%compute%end+ehalo+ishift
3125 select case (position)
3127 i=is; is = isg+ieg-ie; ie = isg+ieg-i
3129 i=is; is = isg+ieg-ie-1+ishift; ie = isg+ieg-i-1+ishift
3131 call insert_update_overlap( overlap, domain%list(m)%pe, &
3132 is, ie, js, je, isc, iec, jsc, jec, dir, .true.)
3134 call insert_update_overlap( overlap, domain%list(m)%pe, &
3135 is, ie, js, je, isc, iec, jsc, jec, dir, symmetry=domain%symmetry)
3142 is = domain%list(m)%x(tnbr)%compute%end+1+ishift; ie = domain%list(m)%x(tnbr)%compute%end+ehalo+ishift
3143 js = domain%list(m)%y(tnbr)%compute%begin-shalo; je = domain%list(m)%y(tnbr)%compute%begin-1
3144 if( ie.GT.ieg .AND. iec.LT.is )
then
3145 is = is-ioff; ie = ie-ioff
3149 call get_fold_index_south(isg, ieg, jsg, ishift, position, is, ie, js, je)
3152 call insert_update_overlap( overlap, domain%list(m)%pe, &
3153 is, ie, js, je, isc, iec, jsc, jec, dir, folded)
3158 is = domain%list(m)%x(tnbr)%compute%begin; ie = domain%list(m)%x(tnbr)%compute%end+ishift
3159 js = domain%list(m)%y(tnbr)%compute%begin-shalo; je = domain%list(m)%y(tnbr)%compute%begin-1
3163 call get_fold_index_south(isg, ieg, jsg, ishift, position, is, ie, js, je)
3168 if( (position == east .OR. position == corner ) .AND. ( isc == ie .or. iec == is ) )
then
3171 call insert_update_overlap( overlap, domain%list(m)%pe, &
3172 is, ie, js, je, isc, iec, jsc, jec, dir, folded, symmetry=domain%symmetry)
3175 if(is .LT. isg)
then
3177 call insert_update_overlap( overlap, domain%list(m)%pe, &
3178 is, is, js, je, isc, iec, jsc, jec, dir, folded)
3184 is = domain%list(m)%x(tnbr)%compute%begin-whalo; ie = domain%list(m)%x(tnbr)%compute%begin-1
3185 js = domain%list(m)%y(tnbr)%compute%begin-shalo; je = domain%list(m)%y(tnbr)%compute%begin-1
3186 if( isg.GT.is .AND. ie.LT.isc )
then
3187 is = is+ioff; ie = ie+ioff
3191 call get_fold_index_south(isg, ieg, jsg, ishift, position, is, ie, js, je)
3193 call insert_update_overlap( overlap, domain%list(m)%pe, &
3194 is, ie, js, je, isc, iec, jsc, jec, dir, folded)
3196 if(is .LT. isg)
then
3198 call insert_update_overlap( overlap, domain%list(m)%pe, &
3199 is, is, js, je, isc, iec, jsc, jec, dir, folded)
3204 is = domain%list(m)%x(tnbr)%compute%begin-whalo; ie = domain%list(m)%x(tnbr)%compute%begin-1
3205 js = domain%list(m)%y(tnbr)%compute%begin; je = domain%list(m)%y(tnbr)%compute%end+jshift
3208 if( (position == north .OR. position == corner ) .AND. ( jsc == je .or. jec == js ) )
then
3211 if( isg.GT.is .AND. ie.LT.isc )
then
3212 is = is+ioff; ie = ie+ioff
3216 if( js == jsg .AND. (position == corner .OR. position == north) &
3217 .AND. ( domain%list(m)%x(tnbr)%compute%begin == isg .OR. &
3218 & domain%list(m)%x(tnbr)%compute%begin-1 .GE. middle))
then
3219 call insert_update_overlap( overlap, domain%list(m)%pe, &
3220 is, ie, js+1, je, isc, iec, jsc, jec, dir)
3221 is = domain%list(m)%x(tnbr)%compute%begin-whalo; ie = domain%list(m)%x(tnbr)%compute%begin-1
3222 js = domain%list(m)%y(tnbr)%compute%begin; je = js
3223 if ( domain%list(m)%x(tnbr)%compute%begin == isg )
then
3224 select case (position)
3226 i=is; is = 2*isg-ie-1; ie = 2*isg-i-1
3228 i=is; is = 2*isg-ie-2+2*ishift; ie = 2*isg-i-2+2*ishift
3230 if(ie .GT. domain%x(tme)%compute%end+ishift)
call mpp_error( fatal, &
3231 'mpp_domains_define.inc(compute_overlaps_fold_south): west edge ubound error send.' )
3233 select case (position)
3235 i=is; is = isg+ieg-ie; ie = isg+ieg-i
3237 i=is; is = isg+ieg-ie-1+ishift; ie = isg+ieg-i-1+ishift
3240 call insert_update_overlap( overlap, domain%list(m)%pe, &
3241 is, ie, js, je, isc, iec, jsc, jec, dir, .true.)
3243 call insert_update_overlap( overlap, domain%list(m)%pe, &
3244 is, ie, js, je, isc, iec, jsc, jec, dir, symmetry=domain%symmetry)
3250 is = domain%list(m)%x(tnbr)%compute%begin-whalo; ie = domain%list(m)%x(tnbr)%compute%begin-1
3251 js = domain%list(m)%y(tnbr)%compute%end+1+jshift; je = domain%list(m)%y(tnbr)%compute%end+nhalo+jshift
3252 if( isg.GT.is .AND. ie.LT.isc )
then
3253 is = is+ioff; ie = ie+ioff
3255 call insert_update_overlap( overlap, domain%list(m)%pe, &
3256 is, ie, js, je, isc, iec, jsc, jec, dir)
3260 is = domain%list(m)%x(tnbr)%compute%begin; ie = domain%list(m)%x(tnbr)%compute%end+ishift
3261 js = domain%list(m)%y(tnbr)%compute%end+1+jshift; je = domain%list(m)%y(tnbr)%compute%end+nhalo+jshift
3262 call insert_update_overlap( overlap, domain%list(m)%pe, &
3263 is, ie, js, je, isc, iec, jsc, jec, dir, symmetry=domain%symmetry)
3267 is = domain%list(m)%x(tnbr)%compute%end+1+ishift; ie = domain%list(m)%x(tnbr)%compute%end+ehalo+ishift
3268 js = domain%list(m)%y(tnbr)%compute%end+1+jshift; je = domain%list(m)%y(tnbr)%compute%end+nhalo+jshift
3269 if( ie.GT.ieg .AND. iec.LT.is )
then
3270 is = is-ioff; ie = ie-ioff
3272 call insert_update_overlap( overlap, domain%list(m)%pe, &
3273 is, ie, js, je, isc, iec, jsc, jec, dir)
3277 if( ( position == north .OR. position == corner) )
then
3279 if( domain%y(tme)%domain_data%begin .LE. jsg .AND. jsg .LE. domain%y(tme)%domain_data%end+jshift )
then
3282 if( domain%x(tme)%pos .LT. (
size(domain%x(tme)%list(:))+1)/2 )
then
3283 js = domain%list(m)%y(tnbr)%compute%begin; je = js
3285 is = domain%list(m)%x(tnbr)%compute%begin; ie = domain%list(m)%x(tnbr)%compute%end+ishift
3286 select case (position)
3288 is = max(is, middle)
3289 i=is; is = isg+ieg-ie; ie = isg+ieg-i
3291 is = max(is, middle)
3292 i=is; is = isg+ieg-ie-1+ishift; ie = isg+ieg-i-1+ishift
3294 call insert_update_overlap(overlap, domain%list(m)%pe, &
3295 is, ie, js, je, isc, iec, jsc, jec, dir, .true.)
3296 is = max(is, isc); ie = min(ie, iec)
3297 js = max(js, jsc); je = min(je, jec)
3298 if(debug_update_level .NE. no_check .AND. ie.GE.is .AND. je.GE.js )
then
3299 nsend_check = nsend_check+1
3300 call allocate_check_overlap(checklist(nsend_check), 1)
3301 call insert_check_overlap(checklist(nsend_check), domain%list(m)%pe, &
3302 tme, 2, one_hundred_eighty, is, ie, js, je)
3310 if( overlap%count > 0)
then
3312 if(nsend >
size(overlaplist(:)) )
then
3313 call mpp_error(note,
'mpp_domains_define.inc(compute_overlaps_south): overlapList for send is expanded')
3314 call expand_update_overlap_list(overlaplist, nlist)
3316 call add_update_overlap(overlaplist(nsend), overlap)
3317 call init_overlap_type(overlap)
3321 if(debug_message_passing)
then
3325 write(iunit, *)
"********to_pe = " ,overlaplist(m)%pe,
" count = ",overlaplist(m)%count
3326 do n = 1, overlaplist(m)%count
3327 write(iunit, *) overlaplist(m)%is(n), overlaplist(m)%ie(n), overlaplist(m)%js(n), overlaplist(m)%je(n), &
3328 overlaplist(m)%dir(n), overlaplist(m)%rotation(n)
3331 if( nsend > 0)
flush(iunit)
3336 if (
associated(update%send))
deallocate(update%send)
3337 allocate(update%send(nsend))
3338 update%nsend = nsend
3340 call add_update_overlap( update%send(m), overlaplist(m) )
3344 if(nsend_check>0)
then
3345 if (
associated(check%send))
deallocate(check%send)
3346 allocate(check%send(nsend_check))
3347 check%nsend = nsend_check
3348 do m = 1, nsend_check
3353 do m = 1,
size(overlaplist(:))
3354 call deallocate_overlap_type(overlaplist(m))
3357 if(debug_update_level .NE. no_check)
then
3358 do m = 1,
size(checklist(:))
3359 call deallocate_overlap_type(checklist(m))
3363 isgd = isg - domain%whalo
3364 iegd = ieg + domain%ehalo
3365 jsgd = jsg - domain%shalo
3366 jegd = jeg + domain%nhalo
3372 m = mod( domain%pos+nlist-list, nlist )
3373 if(domain%list(m)%tile_id(tnbr) == domain%tile_id(tme) )
then
3374 isc = domain%list(m)%x(1)%compute%begin; iec = domain%list(m)%x(1)%compute%end+ishift
3375 jsc = domain%list(m)%y(1)%compute%begin; jec = domain%list(m)%y(1)%compute%end+jshift
3378 isd = domain%x(tme)%compute%end+1+ishift; ied = domain%x(tme)%domain_data%end+ishift
3379 jsd = domain%y(tme)%compute%begin; jed = domain%y(tme)%compute%end+jshift
3380 is=isc; ie=iec; js=jsc; je=jec
3381 if( (position == north .OR. position == corner ) .AND. ( jsd == je .or. jed == js ) )
then
3384 if( ied.GT.ieg .AND. ie.LT.isd )
then
3385 is = is+ioff; ie = ie+ioff
3390 if( jsd == jsg .AND. (position == corner .OR. position == north) &
3391 .AND. isd .GE. middle .AND. ied .LE. ieg )
then
3392 call insert_update_overlap( overlap, domain%list(m)%pe, &
3393 is, ie, js, je, isd, ied, jsd+1, jed, dir)
3394 is=isc; ie=iec; js=jsc; je=jec
3396 select case (position)
3398 i=is; is = isg+ieg-ie; ie = isg+ieg-i
3400 i=is; is = isg+ieg-ie-1+ishift; ie = isg+ieg-i-1+ishift
3402 call insert_update_overlap( overlap, domain%list(m)%pe, &
3403 is, ie, js, je, isd, ied, jsd, jed, dir, .true.)
3405 call insert_update_overlap( overlap, domain%list(m)%pe, &
3406 is, ie, js, je, isd, ied, jsd, jed, dir, symmetry=domain%symmetry)
3413 isd = domain%x(tme)%compute%end+1+ishift; ied = domain%x(tme)%domain_data%end+ishift
3414 jsd = domain%y(tme)%domain_data%begin; jed = domain%y(tme)%compute%begin-1
3415 is=isc; ie=iec; js=jsc; je=jec
3416 if( jsd.LT.jsg )
then
3418 call get_fold_index_south(isg, ieg, jsg, ishift, position, is, ie, js, je)
3420 if( ied.GT.ieg .AND. ie.LT.isd )
then
3421 is = is+ioff; ie = ie+ioff
3423 call insert_update_overlap(overlap, domain%list(m)%pe, &
3424 is, ie, js, je, isd, ied, jsd, jed, dir, folded)
3429 isd = domain%x(tme)%compute%begin; ied = domain%x(tme)%compute%end+ishift
3430 jsd = domain%y(tme)%domain_data%begin; jed = domain%y(tme)%compute%begin-1
3431 is=isc; ie=iec; js=jsc; je=jec
3432 if( jsd.LT.jsg )
then
3434 call get_fold_index_south(isg, ieg, jsg, ishift, position, is, ie, js, je)
3436 if( (position == east .OR. position == corner ) .AND. (isd == ie .or. ied == is ) )
then
3439 call insert_update_overlap(overlap, domain%list(m)%pe, &
3440 is, ie, js, je, isd, ied, jsd, jed, dir, folded, symmetry=domain%symmetry)
3443 if(is .LT. isg )
then
3445 call insert_update_overlap(overlap, domain%list(m)%pe, &
3446 is, is, js, je, isd, ied, jsd, jed, dir, folded)
3452 isd = domain%x(tme)%domain_data%begin; ied = domain%x(tme)%compute%begin-1
3453 jsd = domain%y(tme)%domain_data%begin; jed = domain%y(tme)%compute%begin-1
3454 is=isc; ie=iec; js=jsc; je=jec
3455 if( jsd.LT.jsg )
then
3457 call get_fold_index_south(isg, ieg, jsg, ishift, position, is, ie, js, je)
3459 if( isd.LT.isg .AND. is.GT.ied )
then
3460 is = is-ioff; ie = ie-ioff
3462 call insert_update_overlap(overlap, domain%list(m)%pe, &
3463 is, ie, js, je, isd, ied, jsd, jed, dir, folded)
3465 if(is .LT. isg )
then
3467 call insert_update_overlap(overlap, domain%list(m)%pe, &
3468 is, is, js, je, isd, ied, jsd, jed, dir, folded )
3473 isd = domain%x(tme)%domain_data%begin; ied = domain%x(tme)%compute%begin-1
3474 jsd = domain%y(tme)%compute%begin; jed = domain%y(tme)%compute%end+jshift
3475 is=isc; ie=iec; js=jsc; je=jec
3476 if( (position == north .OR. position == corner ) .AND. ( jsd == je .or. jed == js ) )
then
3479 if( isd.LT.isg .AND. is.GT.ied )
then
3480 is = is-ioff; ie = ie-ioff
3484 if( jsd == jsg .AND. (position == corner .OR. position == north) &
3485 .AND. ( isd < isg .OR. ied .GE. middle ) )
then
3486 call insert_update_overlap(overlap, domain%list(m)%pe, &
3487 is, ie, js, je, isd, ied, jsd+1, jed, dir)
3488 is=isc; ie=iec; js=jsc; je=jec
3490 select case (position)
3492 i=is; is = 2*isg-ie-1; ie = 2*isg-i-1
3494 ied = ied -1 + ishift
3495 i=is; is = 2*isg-ie-2+2*ishift; ie = 2*isg-i-2+2*ishift
3497 if(ie .GT. domain%x(tme)%compute%end+ishift)
call mpp_error( fatal, &
3498 'mpp_domains_define.inc(compute_overlaps): west edge ubound error recv.' )
3500 select case (position)
3502 i=is; is = isg+ieg-ie; ie = isg+ieg-i
3504 i=is; is = isg+ieg-ie-1+ishift; ie = isg+ieg-i-1+ishift
3507 call insert_update_overlap(overlap, domain%list(m)%pe, &
3508 is, ie, js, je, isd, ied, jsd, jsd, dir, .true.)
3510 call insert_update_overlap(overlap, domain%list(m)%pe, &
3511 is, ie, js, je, isd, ied, jsd, jed, dir, symmetry=domain%symmetry)
3517 isd = domain%x(tme)%domain_data%begin; ied = domain%x(tme)%compute%begin-1
3518 jsd = domain%y(tme)%compute%end+1+jshift; jed = domain%y(tme)%domain_data%end+jshift
3519 is=isc; ie=iec; js=jsc; je=jec
3520 if( isd.LT.isg .AND. is.GE.ied )
then
3521 is = is-ioff; ie = ie-ioff
3524 call insert_update_overlap( overlap, domain%list(m)%pe, &
3525 is, ie, js, je, isd, ied, jsd, jed, dir)
3529 isd = domain%x(tme)%compute%begin; ied = domain%x(tme)%compute%end+ishift
3530 jsd = domain%y(tme)%compute%end+1+jshift; jed = domain%y(tme)%domain_data%end+jshift
3531 is=isc; ie=iec; js=jsc; je=jec
3532 call insert_update_overlap( overlap, domain%list(m)%pe, &
3533 is, ie, js, je, isd, ied, jsd, jed, dir, symmetry=domain%symmetry)
3537 isd = domain%x(tme)%compute%end+1+ishift; ied = domain%x(tme)%domain_data%end+ishift
3538 jsd = domain%y(tme)%compute%end+1+jshift; jed = domain%y(tme)%domain_data%end+jshift
3539 is=isc; ie=iec; js=jsc; je=jec
3540 if( ied.GT.ieg .AND. ie.LT.isd )
then
3541 is = is+ioff; ie = ie+ioff
3543 call insert_update_overlap( overlap, domain%list(m)%pe, &
3544 is, ie, js, je, isd, ied, jsd, jed, dir)
3549 if( ( position == north .OR. position == corner) )
then
3551 if( domain%y(tme)%domain_data%begin .LE. jsg .AND. jsg .LE. domain%y(tme)%domain_data%end+jshift )
then
3554 if( domain%x(tme)%pos .GE.
size(domain%x(tme)%list(:))/2 )
then
3555 jsd = domain%y(tme)%compute%begin; jed = jsd
3556 if( jsd == jsg )
then
3557 isd = domain%x(tme)%compute%begin; ied = domain%x(tme)%compute%end+ishift
3558 is=isc; ie=iec; js = jsc; je = jec
3559 select case (position)
3561 isd = max(isd, middle)
3562 i=is; is = isg+ieg-ie; ie = isg+ieg-i
3564 isd = max(isd, middle)
3565 i=is; is = isg+ieg-ie-1+ishift; ie = isg+ieg-i-1+ishift
3567 call insert_update_overlap(overlap, domain%list(m)%pe, &
3568 is, ie, js, je, isd, ied, jsd, jed, dir, .true.)
3569 is = max(is, isd); ie = min(ie, ied)
3570 js = max(js, jsd); je = min(je, jed)
3571 if(debug_update_level .NE. no_check .AND. ie.GE.is .AND. je.GE.js )
then
3572 nrecv_check = nrecv_check+1
3573 call allocate_check_overlap(checklist(nrecv_check), 1)
3574 call insert_check_overlap(checklist(nrecv_check), domain%list(m)%pe, &
3575 tme, 2, one_hundred_eighty, is, ie, js, je)
3583 if( overlap%count > 0)
then
3585 if(nrecv >
size(overlaplist(:)) )
then
3586 call mpp_error(note,
'mpp_domains_define.inc(compute_overlaps_south): overlapList for recv is expanded')
3587 call expand_update_overlap_list(overlaplist, nlist)
3589 call add_update_overlap( overlaplist(nrecv), overlap)
3590 call init_overlap_type(overlap)
3594 if(debug_message_passing)
then
3598 write(iunit, *)
"********from_pe = " ,overlaplist(m)%pe,
" count = ",overlaplist(m)%count
3599 do n = 1, overlaplist(m)%count
3600 write(iunit, *) overlaplist(m)%is(n), overlaplist(m)%ie(n), overlaplist(m)%js(n), overlaplist(m)%je(n), &
3601 overlaplist(m)%dir(n), overlaplist(m)%rotation(n)
3604 if(nrecv >0)
flush(iunit)
3609 update%nrecv = nrecv
3610 if (
associated(update%recv))
deallocate(update%recv)
3611 allocate(update%recv(nrecv))
3613 call add_update_overlap( update%recv(m), overlaplist(m) )
3614 do n = 1, update%recv(m)%count
3615 if(update%recv(m)%tileNbr(n) == domain%tile_id(tme))
then
3616 if(update%recv(m)%dir(n) == 1) domain%x(tme)%loffset = 0
3617 if(update%recv(m)%dir(n) == 7) domain%y(tme)%loffset = 0
3623 if(nrecv_check>0)
then
3624 check%nrecv = nrecv_check
3625 if (
associated(check%recv))
deallocate(check%recv)
3626 allocate(check%recv(nrecv_check))
3627 do m = 1, nrecv_check
3632 call deallocate_overlap_type(overlap)
3634 do m = 1,
size(overlaplist(:))
3635 call deallocate_overlap_type(overlaplist(m))
3638 if(debug_update_level .NE. no_check)
then
3639 do m = 1,
size(checklist(:))
3640 call deallocate_overlap_type(checklist(m))
3644 deallocate(overlaplist)
3645 deallocate(checklist)
3648 domain%initialized = .true.
3657 type(domain2d),
intent(inout) :: domain
3658 integer,
intent(in) :: position, ishift, jshift
3660 integer :: j, m, n, nlist, tMe, tNbr, dir
3661 integer :: is, ie, js, je, isc, iec, jsc, jec, isd, ied, jsd, jed
3662 integer :: isg, ieg, jsg, jeg, ioff, joff
3663 integer :: list, middle, ni, nj, isgd, iegd, jsgd, jegd
3664 integer :: ism, iem, jsm, jem, whalo, ehalo, shalo, nhalo
3666 type(overlap_type) :: overlap
3667 type(overlapspec),
pointer :: update=>null()
3668 type(overlap_type) :: overlapList(MAXLIST)
3669 type(overlap_type) :: checkList(MAXLIST)
3670 type(overlapspec),
pointer :: check =>null()
3671 integer :: nsend, nrecv
3672 integer :: nsend_check, nrecv_check
3678 if(
size(domain%x(:)) > 1)
return
3681 if(domain%whalo==0 .AND. domain%ehalo==0 .AND. domain%shalo==0 .AND. domain%nhalo==0)
return
3684 nlist =
size(domain%list(:))
3686 select case(position)
3688 update => domain%update_T
3691 update => domain%update_C
3692 check => domain%check_C
3694 update => domain%update_E
3695 check => domain%check_E
3697 update => domain%update_N
3698 check => domain%check_N
3700 call mpp_error(fatal,
"mpp_domains_define.inc(compute_overlaps_fold_west):"//&
3701 &
" the value of position should be CENTER, EAST, CORNER or NORTH")
3705 call allocate_update_overlap( overlap, maxoverlap)
3708 call mpp_get_compute_domain( domain, isc, iec, jsc, jec, position=position )
3709 call mpp_get_global_domain ( domain, isg, ieg, jsg, jeg, xsize=ni, ysize=nj, position=position )
3710 call mpp_get_memory_domain ( domain, ism, iem, jsm, jem, position=position )
3711 update%xbegin = ism; update%xend = iem
3712 update%ybegin = jsm; update%yend = jem
3713 if(
ASSOCIATED(check))
then
3714 check%xbegin = ism; check%xend = iem
3715 check%ybegin = jsm; check%yend = jem
3717 update%whalo = domain%whalo; update%ehalo = domain%ehalo
3718 update%shalo = domain%shalo; update%nhalo = domain%nhalo
3719 whalo = domain%whalo; ehalo = domain%ehalo
3720 shalo = domain%shalo; nhalo = domain%nhalo
3724 middle = (jsg+jeg)/2+1
3727 if(.NOT. btest(domain%fold,west))
then
3728 call mpp_error(fatal,
"mpp_domains_define.inc(compute_overlaps_fold_west): "//&
3729 "boundary condition in y-direction should be folded-west for "//trim(domain%name))
3731 if(.NOT. domain%y(tme)%cyclic)
then
3732 call mpp_error(fatal,
"mpp_domains_define.inc(compute_overlaps_fold_west): "//&
3733 "boundary condition in y-direction should be cyclic for "//trim(domain%name))
3736 if(.not. domain%symmetry)
then
3737 call mpp_error(fatal,
"mpp_domains_define.inc(compute_overlaps_fold_west): "//&
3738 "when west boundary is folded, the domain must be symmetry for "//trim(domain%name))
3744 m = mod( domain%pos+list, nlist )
3745 if(domain%list(m)%tile_id(tnbr) == domain%tile_id(tme) )
then
3748 is = domain%list(m)%x(tnbr)%compute%end+1+ishift; ie = domain%list(m)%x(tnbr)%compute%end+ehalo+ishift
3749 js = domain%list(m)%y(tnbr)%compute%begin; je = domain%list(m)%y(tnbr)%compute%end+jshift
3750 call insert_update_overlap( overlap, domain%list(m)%pe, &
3751 is, ie, js, je, isc, iec, jsc, jec, dir, symmetry=domain%symmetry)
3755 is = domain%list(m)%x(tnbr)%compute%end+1+ishift; ie = domain%list(m)%x(tnbr)%compute%end+ehalo+ishift
3756 js = domain%list(m)%y(tnbr)%compute%begin-shalo; je = domain%list(m)%y(tnbr)%compute%begin-1
3757 if( js.LT.jsg .AND. jsc.GT.je )
then
3758 js = js+joff; je = je+joff
3761 call insert_update_overlap( overlap, domain%list(m)%pe, &
3762 is, ie, js, je, isc, iec, jsc, jec, dir)
3766 is = domain%list(m)%x(tnbr)%compute%begin; ie = domain%list(m)%x(tnbr)%compute%end+ishift
3767 js = domain%list(m)%y(tnbr)%compute%begin-shalo; je = domain%list(m)%y(tnbr)%compute%begin-1
3769 if( (position == east .OR. position == corner ) .AND. ( isc == ie .or. iec == is ) )
then
3772 if( js.LT.jsg .AND. jsc.GT.je)
then
3773 js = js+joff; je = je+joff
3778 if( is == isg .AND. (position == corner .OR. position == east) &
3779 .AND. ( domain%list(m)%y(tnbr)%compute%begin == jsg .OR. &
3780 & domain%list(m)%y(tnbr)%compute%begin-1 .GE. middle))
then
3781 call insert_update_overlap( overlap, domain%list(m)%pe, &
3782 is+1, ie, js, je, isc, iec, jsc, jec, dir)
3783 is = domain%list(m)%x(tnbr)%compute%begin; ie = is
3784 js = domain%list(m)%y(tnbr)%compute%begin-shalo; je = domain%list(m)%y(tnbr)%compute%begin-1
3785 if ( domain%list(m)%y(tnbr)%compute%begin == jsg )
then
3786 select case (position)
3788 j=js; js = 2*jsg-je-1; je = 2*jsg-j-1
3790 j=js; js = 2*jsg-je-2+2*jshift; je = 2*jsg-j-2+2*jshift
3792 if(je .GT. domain%y(tme)%compute%end+jshift)
call mpp_error( fatal, &
3793 'mpp_domains_define.inc(compute_overlaps_fold_west: south edge ubound error send.' )
3795 select case (position)
3797 j=js; js = jsg+jeg-je; je = jsg+jeg-j
3799 j=js; js = jsg+jeg-je-1+jshift; je = jsg+jeg-j-1+jshift
3802 call insert_update_overlap( overlap, domain%list(m)%pe, &
3803 is, ie, js, je, isc, iec, jsc, jec, dir, .true.)
3805 call insert_update_overlap( overlap, domain%list(m)%pe, &
3806 is, ie, js, je, isc, iec, jsc, jec, dir, symmetry=domain%symmetry)
3813 is = domain%list(m)%x(tnbr)%compute%begin-whalo; ie = domain%list(m)%x(tnbr)%compute%begin-1
3814 js = domain%list(m)%y(tnbr)%compute%begin-shalo; je = domain%list(m)%y(tnbr)%compute%begin-1
3815 if( jsg.GT.js .AND. je.LT.jsc )
then
3816 js = js+joff; je = je+joff
3820 call get_fold_index_west(jsg, jeg, isg, jshift, position, is, ie, js, je)
3822 call insert_update_overlap( overlap, domain%list(m)%pe, &
3823 is, ie, js, je, isc, iec, jsc, jec, dir, folded)
3825 if(js .LT. jsg)
then
3827 call insert_update_overlap( overlap, domain%list(m)%pe, &
3828 is, ie, js, js, isc, iec, jsc, jec, dir, folded)
3834 is = domain%list(m)%x(tnbr)%compute%begin-whalo; ie = domain%list(m)%x(tnbr)%compute%begin-1
3835 js = domain%list(m)%y(tnbr)%compute%begin; je = domain%list(m)%y(tnbr)%compute%end+jshift
3838 call get_fold_index_west(jsg, jeg, isg, jshift, position, is, ie, js, je)
3843 if( (position == east .OR. position == corner ) .AND. ( jsc == je .or. jec == js ) )
then
3846 call insert_update_overlap( overlap, domain%list(m)%pe, &
3847 is, ie, js, je, isc, iec, jsc, jec, dir, folded, symmetry=domain%symmetry)
3850 if(js .LT. jsg)
then
3852 call insert_update_overlap( overlap, domain%list(m)%pe, &
3853 is, ie, js, js, isc, iec, jsc, jec, dir, folded)
3859 is = domain%list(m)%x(tnbr)%compute%begin-whalo; ie = domain%list(m)%x(tnbr)%compute%begin-1
3860 js = domain%list(m)%y(tnbr)%compute%end+1+jshift; je = domain%list(m)%y(tnbr)%compute%end+nhalo+jshift
3861 if( je.GT.jeg .AND. jec.LT.js )
then
3862 js = js-joff; je = je-joff
3866 call get_fold_index_west(jsg, jeg, isg, jshift, position, is, ie, js, je)
3869 call insert_update_overlap( overlap, domain%list(m)%pe, &
3870 is, ie, js, je, isc, iec, jsc, jec, dir, folded)
3874 is = domain%list(m)%x(tnbr)%compute%begin; ie = domain%list(m)%x(tnbr)%compute%end+ishift
3875 js = domain%list(m)%y(tnbr)%compute%end+1+jshift; je = domain%list(m)%y(tnbr)%compute%end+nhalo+jshift
3877 if( (position == east .OR. position == corner ) .AND. ( isc == ie .or. iec == is ) )
then
3880 if( je.GT.jeg .AND. jec.LT.js)
then
3881 js = js-joff; je = je-joff
3885 if( is == isg .AND. (position == corner .OR. position == east) &
3886 .AND. ( js .GE. middle .AND. domain%list(m)%y(tnbr)%compute%end+nhalo+jshift .LE. jeg ) )
then
3887 call insert_update_overlap( overlap, domain%list(m)%pe, &
3888 is+1, ie, js, je, isc, iec, jsc, jec, dir)
3889 is = domain%list(m)%x(tnbr)%compute%begin; ie = is
3890 js = domain%list(m)%y(tnbr)%compute%end+1+jshift; je = domain%list(m)%y(tnbr)%compute%end+nhalo+jshift
3891 select case (position)
3893 j=js; js = jsg+jeg-je; je = jsg+jeg-j
3895 j=js; js = jsg+jeg-je-1+jshift; je = jsg+jeg-j-1+jshift
3897 call insert_update_overlap( overlap, domain%list(m)%pe, &
3898 is, ie, js, je, isc, iec, jsc, jec, dir, .true.)
3900 call insert_update_overlap( overlap, domain%list(m)%pe, &
3901 is, ie, js, je, isc, iec, jsc, jec, dir, symmetry=domain%symmetry)
3907 is = domain%list(m)%x(tnbr)%compute%end+1+ishift; ie = domain%list(m)%x(tnbr)%compute%end+ehalo+ishift
3908 js = domain%list(m)%y(tnbr)%compute%end+1+jshift; je = domain%list(m)%y(tnbr)%compute%end+nhalo+jshift
3909 if( je.GT.jeg .AND. jec.LT.js )
then
3910 js = js-joff; je = je-joff
3912 call insert_update_overlap( overlap, domain%list(m)%pe, &
3913 is, ie, js, je, isc, iec, jsc, jec, dir)
3917 if( ( position == east .OR. position == corner) )
then
3919 if( domain%x(tme)%compute%begin-whalo .LE. isg .AND. isg .LE. domain%x(tme)%domain_data%end+ishift )
then
3922 if( domain%y(tme)%pos .LT. (
size(domain%y(tme)%list(:))+1)/2 )
then
3923 is = domain%list(m)%x(tnbr)%compute%begin; ie = is
3925 js = domain%list(m)%y(tnbr)%compute%begin; je = domain%list(m)%y(tnbr)%compute%end+jshift
3926 select case (position)
3928 js = max(js, middle)
3929 j=js; js = jsg+jeg-je; je = jsg+jeg-j
3931 js = max(js, middle)
3932 j=js; js = jsg+jeg-je-1+jshift; je = jsg+jeg-j-1+jshift
3934 call insert_update_overlap(overlap, domain%list(m)%pe, &
3935 is, ie, js, je, isc, iec, jsc, jec, dir, .true.)
3936 is = max(is, isc); ie = min(ie, iec)
3937 js = max(js, jsc); je = min(je, jec)
3938 if(debug_update_level .NE. no_check .AND. ie.GE.is .AND. je.GE.js )
then
3939 nsend_check = nsend_check+1
3940 call allocate_check_overlap(checklist(nsend_check), 1)
3941 call insert_check_overlap(checklist(nsend_check), domain%list(m)%pe, &
3942 tme, 3, one_hundred_eighty, is, ie, js, je)
3950 if( overlap%count > 0)
then
3952 if(nsend > maxlist)
call mpp_error(fatal, &
3953 "mpp_domains_define.inc(compute_overlaps_west): nsend is greater than MAXLIST, increase MAXLIST")
3954 call add_update_overlap(overlaplist(nsend), overlap)
3955 call init_overlap_type(overlap)
3959 if(debug_message_passing)
then
3963 write(iunit, *)
"********to_pe = " ,overlaplist(m)%pe,
" count = ",overlaplist(m)%count
3964 do n = 1, overlaplist(m)%count
3965 write(iunit, *) overlaplist(m)%is(n), overlaplist(m)%ie(n), overlaplist(m)%js(n), overlaplist(m)%je(n), &
3966 overlaplist(m)%dir(n), overlaplist(m)%rotation(n)
3969 if(nsend >0)
flush(iunit)
3974 update%nsend = nsend
3975 if (
associated(update%send))
deallocate(update%send)
3976 allocate(update%send(nsend))
3978 call add_update_overlap( update%send(m), overlaplist(m) )
3982 if(nsend_check>0)
then
3983 check%nsend = nsend_check
3984 if (
associated(check%send))
deallocate(check%send)
3985 allocate(check%send(nsend_check))
3986 do m = 1, nsend_check
3992 call deallocate_overlap_type(overlaplist(m))
3993 if(debug_update_level .NE. no_check)
call deallocate_overlap_type(checklist(m))
3996 isgd = isg - domain%whalo
3997 iegd = ieg + domain%ehalo
3998 jsgd = jsg - domain%shalo
3999 jegd = jeg + domain%nhalo
4005 m = mod( domain%pos+nlist-list, nlist )
4006 if(domain%list(m)%tile_id(tnbr) == domain%tile_id(tme) )
then
4007 isc = domain%list(m)%x(1)%compute%begin; iec = domain%list(m)%x(1)%compute%end+ishift
4008 jsc = domain%list(m)%y(1)%compute%begin; jec = domain%list(m)%y(1)%compute%end+jshift
4011 isd = domain%x(tme)%compute%end+1+ishift; ied = domain%x(tme)%domain_data%end+ishift
4012 jsd = domain%y(tme)%compute%begin; jed = domain%y(tme)%compute%end+jshift
4013 is=isc; ie=iec; js=jsc; je=jec
4014 call insert_update_overlap( overlap, domain%list(m)%pe, &
4015 is, ie, js, je, isd, ied, jsd, jed, dir, symmetry=domain%symmetry)
4019 isd = domain%x(tme)%compute%end+1+ishift; ied = domain%x(tme)%domain_data%end+ishift
4020 jsd = domain%y(tme)%domain_data%begin; jed = domain%y(tme)%compute%begin-1
4021 is=isc; ie=iec; js=jsc; je=jec
4022 if( jsd.LT.jsg .AND. js.GE.jed )
then
4023 js = js-joff; je = je-joff
4025 call insert_update_overlap(overlap, domain%list(m)%pe, &
4026 is, ie, js, je, isd, ied, jsd, jed, dir)
4031 isd = domain%x(tme)%compute%begin; ied = domain%x(tme)%compute%end+ishift
4032 jsd = domain%y(tme)%domain_data%begin; jed = domain%y(tme)%compute%begin-1
4033 is=isc; ie=iec; js=jsc; je=jec
4035 if( (position == east .OR. position == corner ) .AND. ( isd == ie .or. ied == is ) )
then
4038 if( jsd.LT.jsg .AND. js .GT. jed)
then
4039 js = js-joff; je = je-joff
4043 if( isd == isg .AND. (position == corner .OR. position == east) &
4044 .AND. ( jsd < jsg .OR. jed .GE. middle ) )
then
4045 call insert_update_overlap( overlap, domain%list(m)%pe, &
4046 is, ie, js, je, isd+1, ied, jsd, jed, dir)
4047 is=isc; ie=iec; js=jsc; je=jec
4049 select case (position)
4051 j=js; js = 2*jsg-je-1; je = 2*jsg-j-1
4053 j=js; js = 2*jsg-je-2+2*jshift; je = 2*jsg-j-2+2*jshift
4055 if(je .GT. domain%y(tme)%compute%end+jshift)
call mpp_error( fatal, &
4056 'mpp_domains_define.inc(compute_overlaps_fold_west: south edge ubound error recv.' )
4058 select case (position)
4060 j=js; js = jsg+jeg-je; je = jsg+jeg-j
4062 j=js; js = jsg+jeg-je-1+jshift; je = jsg+jeg-j-1+jshift
4065 call insert_update_overlap( overlap, domain%list(m)%pe, &
4066 is, ie, js, je, isd, isd, jsd, jed, dir, .true.)
4068 call insert_update_overlap( overlap, domain%list(m)%pe, &
4069 is, ie, js, je, isd, ied, jsd, jed, dir, symmetry=domain%symmetry)
4076 isd = domain%x(tme)%domain_data%begin; ied = domain%x(tme)%compute%begin-1
4077 jsd = domain%y(tme)%domain_data%begin; jed = domain%y(tme)%compute%begin-1
4078 is=isc; ie=iec; js=jsc; je=jec
4079 if( isd.LT.isg )
then
4081 call get_fold_index_west(jsg, jeg, isg, jshift, position, is, ie, js, je)
4083 if( jsd.LT.jsg .AND. js.GT.jed )
then
4084 js = js-joff; je = je-joff
4086 call insert_update_overlap(overlap, domain%list(m)%pe, &
4087 is, ie, js, je, isd, ied, jsd, jed, dir, folded)
4089 if(js .LT. jsg )
then
4091 call insert_update_overlap(overlap, domain%list(m)%pe, &
4092 is, ie, js, js, isd, ied, jsd, jed, dir, folded )
4098 isd = domain%x(tme)%domain_data%begin; ied = domain%x(tme)%compute%begin-1
4099 jsd = domain%y(tme)%compute%begin; jed = domain%y(tme)%compute%end+jshift
4100 is=isc; ie=iec; js=jsc; je=jec
4101 if( isd.LT.isg )
then
4103 call get_fold_index_west(jsg, jeg, isg, jshift, position, is, ie, js, je)
4105 if( (position == east .OR. position == corner ) .AND. (jsd == je .or. jed == js ) )
then
4108 call insert_update_overlap(overlap, domain%list(m)%pe, &
4109 is, ie, js, je, isd, ied, jsd, jed, dir, folded, symmetry=domain%symmetry)
4112 if(js .LT. jsg )
then
4114 call insert_update_overlap(overlap, domain%list(m)%pe, &
4115 is, ie, js, js, isd, ied, jsd, jed, dir, folded)
4121 isd = domain%x(tme)%domain_data%begin; ied = domain%x(tme)%compute%begin-1
4122 jsd = domain%y(tme)%compute%end+1+jshift; jed = domain%y(tme)%domain_data%end+jshift
4123 is=isc; ie=iec; js=jsc; je=jec
4124 if( isd.LT.isg)
then
4126 call get_fold_index_west(jsg, jeg, isg, jshift, position, is, ie, js, je)
4128 if( jed.GT.jeg .AND. je.LT.jsd )
then
4129 js = js+joff; je = je+joff
4132 call insert_update_overlap( overlap, domain%list(m)%pe, &
4133 is, ie, js, je, isd, ied, jsd, jed, dir)
4138 isd = domain%x(tme)%compute%begin; ied = domain%x(tme)%compute%end+ishift
4139 jsd = domain%y(tme)%compute%end+1+jshift; jed = domain%y(tme)%domain_data%end+jshift
4140 is=isc; ie=iec; js=jsc; je=jec
4141 if( (position == east .OR. position == corner ) .AND. ( isd == ie .or. ied == is ) )
then
4144 if( jed.GT.jeg .AND. je.LT.jsd)
then
4145 js = js+joff; je = je+joff
4149 if( isd == isg .AND. (position == corner .OR. position == east) &
4150 .AND. jsd .GE. middle .AND. jed .LE. jeg )
then
4151 call insert_update_overlap( overlap, domain%list(m)%pe, &
4152 is, ie, js, je, isd+1, ied, jsd, jed, dir)
4153 is=isc; ie=iec; js=jsc; je=jec
4154 select case (position)
4156 j=js; js = jsg+jeg-je; je = jsg+jeg-j
4158 j=js; js = jsg+jeg-je-1+jshift; je = jsg+jeg-j-1+jshift
4160 call insert_update_overlap( overlap, domain%list(m)%pe, &
4161 is, ie, js, je, isd, isd, jsd, jed, dir, .true.)
4163 call insert_update_overlap( overlap, domain%list(m)%pe, &
4164 is, ie, js, je, isd, ied, jsd, jed, dir, symmetry=domain%symmetry)
4170 isd = domain%x(tme)%compute%end+1+ishift; ied = domain%x(tme)%domain_data%end+ishift
4171 jsd = domain%y(tme)%compute%end+1+jshift; jed = domain%y(tme)%domain_data%end+jshift
4172 is=isc; ie=iec; js=jsc; je=jec
4173 if( jed.GT.jeg .AND. je.LT.jsd )
then
4174 js = js+joff; je = je+joff
4176 call insert_update_overlap( overlap, domain%list(m)%pe, &
4177 is, ie, js, je, isd, ied, jsd, jed, dir)
4182 if( ( position == east .OR. position == corner) )
then
4184 if( domain%x(tme)%domain_data%begin .LE. isg .AND. isg .LE. domain%x(tme)%domain_data%end+ishift )
then
4187 if( domain%y(tme)%pos .GE.
size(domain%y(tme)%list(:))/2 )
then
4188 isd = domain%x(tme)%compute%begin; ied = isd
4189 if( isd == isg )
then
4190 jsd = domain%y(tme)%compute%begin; jed = domain%y(tme)%compute%end+jshift
4191 is=isc; ie=iec; js = jsc; je = jec
4192 select case (position)
4194 jsd = max(jsd, middle)
4195 j=js; js = jsg+jeg-je; je = jsg+jeg-j
4197 jsd = max(jsd, middle)
4198 j=js; js = jsg+jeg-je-1+jshift; je = jsg+jeg-j-1+jshift
4200 call insert_update_overlap(overlap, domain%list(m)%pe, &
4201 is, ie, js, je, isd, ied, jsd, jed, dir, .true.)
4202 is = max(is, isd); ie = min(ie, ied)
4203 js = max(js, jsd); je = min(je, jed)
4204 if(debug_update_level .NE. no_check .AND. ie.GE.is .AND. je.GE.js )
then
4205 nrecv_check = nrecv_check+1
4206 call allocate_check_overlap(checklist(nrecv_check), 1)
4207 call insert_check_overlap(checklist(nrecv_check), domain%list(m)%pe, &
4208 tme, 3, one_hundred_eighty, is, ie, js, je)
4216 if( overlap%count > 0)
then
4218 if(nrecv > maxlist)
call mpp_error(fatal, &
4219 "mpp_domains_define.inc(compute_overlaps_west): nrecv is greater than MAXLIST, increase MAXLIST")
4220 call add_update_overlap( overlaplist(nrecv), overlap)
4221 call init_overlap_type(overlap)
4225 if(debug_message_passing)
then
4229 write(iunit, *)
"********from_pe = " ,overlaplist(m)%pe,
" count = ",overlaplist(m)%count
4230 do n = 1, overlaplist(m)%count
4231 write(iunit, *) overlaplist(m)%is(n), overlaplist(m)%ie(n), overlaplist(m)%js(n), overlaplist(m)%je(n), &
4232 overlaplist(m)%dir(n), overlaplist(m)%rotation(n)
4235 if(nrecv >0)
flush(iunit)
4240 update%nrecv = nrecv
4241 if (
associated(update%recv))
deallocate(update%recv)
4242 allocate(update%recv(nrecv))
4244 call add_update_overlap( update%recv(m), overlaplist(m) )
4245 do n = 1, update%recv(m)%count
4246 if(update%recv(m)%tileNbr(n) == domain%tile_id(tme))
then
4247 if(update%recv(m)%dir(n) == 1) domain%x(tme)%loffset = 0
4248 if(update%recv(m)%dir(n) == 7) domain%y(tme)%loffset = 0
4254 if(nrecv_check>0)
then
4255 check%nrecv = nrecv_check
4256 if (
associated(check%recv))
deallocate(check%recv)
4257 allocate(check%recv(nrecv_check))
4258 do m = 1, nrecv_check
4263 call deallocate_overlap_type(overlap)
4265 call deallocate_overlap_type(overlaplist(m))
4266 if(debug_update_level .NE. no_check)
call deallocate_overlap_type(checklist(m))
4271 domain%initialized = .true.
4281 type(domain2d),
intent(inout) :: domain
4282 integer,
intent(in) :: position, ishift, jshift
4284 integer :: j, m, n, nlist, tMe, tNbr, dir
4285 integer :: is, ie, js, je, isc, iec, jsc, jec, isd, ied, jsd
4286 integer :: jed, isg, ieg, jsg, jeg, ioff, joff
4287 integer :: list, middle, ni, nj, isgd, iegd, jsgd, jegd
4288 integer :: ism, iem, jsm, jem, whalo, ehalo, shalo, nhalo
4290 type(overlap_type) :: overlap
4291 type(overlapspec),
pointer :: update=>null()
4292 type(overlap_type) :: overlapList(MAXLIST)
4293 type(overlap_type) :: checkList(MAXLIST)
4294 type(overlapspec),
pointer :: check =>null()
4295 integer :: nsend, nrecv
4296 integer :: nsend_check, nrecv_check
4301 if(
size(domain%x(:)) > 1)
return
4304 if(domain%whalo==0 .AND. domain%ehalo==0 .AND. domain%shalo==0 .AND. domain%nhalo==0)
return
4307 nlist =
size(domain%list(:))
4309 select case(position)
4311 update => domain%update_T
4313 update => domain%update_C
4314 check => domain%check_C
4316 update => domain%update_E
4317 check => domain%check_E
4319 update => domain%update_N
4320 check => domain%check_N
4322 call mpp_error(fatal,
"mpp_domains_define.inc(compute_overlaps_fold_east):"// &
4323 &
" the value of position should be CENTER, EAST, CORNER or NORTH")
4327 call allocate_update_overlap( overlap, maxoverlap)
4330 call mpp_get_compute_domain( domain, isc, iec, jsc, jec, position=position )
4331 call mpp_get_global_domain ( domain, isg, ieg, jsg, jeg, xsize=ni, ysize=nj, position=position )
4332 call mpp_get_memory_domain ( domain, ism, iem, jsm, jem, position=position )
4333 update%xbegin = ism; update%xend = iem
4334 update%ybegin = jsm; update%yend = jem
4335 if(
ASSOCIATED(check))
then
4336 check%xbegin = ism; check%xend = iem
4337 check%ybegin = jsm; check%yend = jem
4339 update%whalo = domain%whalo; update%ehalo = domain%ehalo
4340 update%shalo = domain%shalo; update%nhalo = domain%nhalo
4341 whalo = domain%whalo; ehalo = domain%ehalo
4342 shalo = domain%shalo; nhalo = domain%nhalo
4346 middle = (jsg+jeg)/2+1
4349 if(.NOT. btest(domain%fold,east))
then
4350 call mpp_error(fatal,
"mpp_domains_define.inc(compute_overlaps_fold_east): "//&
4351 "boundary condition in y-direction should be folded-east for "//trim(domain%name))
4353 if(.NOT. domain%y(tme)%cyclic)
then
4354 call mpp_error(fatal,
"mpp_domains_define.inc(compute_overlaps_fold_east): "//&
4355 "boundary condition in y-direction should be cyclic for "//trim(domain%name))
4357 if(.not. domain%symmetry)
then
4358 call mpp_error(fatal,
"mpp_domains_define.inc(compute_overlaps_fold_east): "//&
4359 "when east boundary is folded, the domain must be symmetry for "//trim(domain%name))
4365 m = mod( domain%pos+list, nlist )
4366 if(domain%list(m)%tile_id(tnbr) == domain%tile_id(tme) )
then
4370 is = domain%list(m)%x(tnbr)%compute%end+1+ishift; ie = domain%list(m)%x(tnbr)%compute%end+ehalo+ishift
4371 js = domain%list(m)%y(tnbr)%compute%begin; je = domain%list(m)%y(tnbr)%compute%end+jshift
4374 call get_fold_index_east(jsg, jeg, ieg, jshift, position, is, ie, js, je)
4379 if( (position == east .OR. position == corner ) .AND. ( jsc == je .or. jec == js ) )
then
4382 call insert_update_overlap( overlap, domain%list(m)%pe, &
4383 is, ie, js, je, isc, iec, jsc, jec, dir, folded, symmetry=domain%symmetry)
4386 if(js .LT. jsg)
then
4388 call insert_update_overlap( overlap, domain%list(m)%pe, &
4389 is, ie, js, js, isc, iec, jsc, jec, dir, folded)
4395 is = domain%list(m)%x(tnbr)%compute%end+1+ishift; ie = domain%list(m)%x(tnbr)%compute%end+ehalo+ishift
4396 js = domain%list(m)%y(tnbr)%compute%begin-shalo; je = domain%list(m)%y(tnbr)%compute%begin-1
4397 if( jsg.GT.js .AND. je.LT.jsc )
then
4398 js = js+joff; je = je+joff
4403 call get_fold_index_east(jsg, jeg, ieg, jshift, position, is, ie, js, je)
4406 call insert_update_overlap( overlap, domain%list(m)%pe, &
4407 is, ie, js, je, isc, iec, jsc, jec, dir, folded)
4409 if(js .LT. jsg)
then
4411 call insert_update_overlap( overlap, domain%list(m)%pe, &
4412 is, ie, js, js, isc, iec, jsc, jec, dir, folded)
4417 is = domain%list(m)%x(tnbr)%compute%begin; ie = domain%list(m)%x(tnbr)%compute%end+ishift
4418 js = domain%list(m)%y(tnbr)%compute%begin-shalo; je = domain%list(m)%y(tnbr)%compute%begin-1
4420 if( (position == east .OR. position == corner ) .AND. ( isc == ie .or. iec == is ) )
then
4423 if( js.LT.jsg .AND. jsc.GT.je)
then
4424 js = js+joff; je = je+joff
4428 if( ie == ieg .AND. (position == corner .OR. position == east) &
4429 .AND. ( domain%list(m)%y(tnbr)%compute%begin == jsg .OR. &
4430 domain%list(m)%y(tnbr)%compute%begin-1 .GE. middle ) )
then
4431 call insert_update_overlap( overlap, domain%list(m)%pe, &
4432 is, ie-1, js, je, isc, iec, jsc, jec, dir)
4435 if(position == corner .AND. .NOT. domain%symmetry .AND. domain%list(m)%y(tnbr)%compute%begin==jsg)
then
4436 call insert_update_overlap(overlap, domain%list(m)%pe, &
4437 ie, ie, je, je, isc, iec, jsc, jec, dir, .true.)
4440 ie = domain%list(m)%x(tnbr)%compute%end+ishift; is = ie
4441 js = domain%list(m)%y(tnbr)%compute%begin-shalo; je = domain%list(m)%y(tnbr)%compute%begin-1
4442 if ( domain%list(m)%y(tnbr)%compute%begin == jsg )
then
4443 select case (position)
4445 j=js; js = 2*jsg-je-1; je = 2*jsg-j-1
4447 j=js; js = 2*jsg-je-2+2*jshift; je = 2*jsg-j-2+2*jshift
4449 if(je .GT. domain%y(tme)%compute%end+jshift)
call mpp_error( fatal, &
4450 'mpp_domains_define.inc(compute_overlaps_fold_east: south edge ubound error send.' )
4452 select case (position)
4454 j=js; js = jsg+jeg-je; je = jsg+jeg-j
4456 j=js; js = jsg+jeg-je-1+jshift; je = jsg+jeg-j-1+jshift
4459 call insert_update_overlap( overlap, domain%list(m)%pe, &
4460 is, ie, js, je, isc, iec, jsc, jec, dir, .true.)
4462 call insert_update_overlap( overlap, domain%list(m)%pe, &
4463 is, ie, js, je, isc, iec, jsc, jec, dir, symmetry=domain%symmetry)
4469 is = domain%list(m)%x(tnbr)%compute%begin-whalo; ie = domain%list(m)%x(tnbr)%compute%begin-1
4470 js = domain%list(m)%y(tnbr)%compute%begin-shalo; je = domain%list(m)%y(tnbr)%compute%begin-1
4471 if( js.LT.jsg .AND. jsc.GT.je )
then
4472 js = js+joff; je = je+joff
4474 call insert_update_overlap( overlap, domain%list(m)%pe, &
4475 is, ie, js, je, isc, iec, jsc, jec, dir)
4479 is = domain%list(m)%x(tnbr)%compute%begin-whalo; ie = domain%list(m)%x(tnbr)%compute%begin-1
4480 js = domain%list(m)%y(tnbr)%compute%begin; je = domain%list(m)%y(tnbr)%compute%end+jshift
4481 call insert_update_overlap( overlap, domain%list(m)%pe, &
4482 is, ie, js, je, isc, iec, jsc, jec, dir, symmetry=domain%symmetry)
4486 is = domain%list(m)%x(tnbr)%compute%begin-whalo; ie = domain%list(m)%x(tnbr)%compute%begin-1
4487 js = domain%list(m)%y(tnbr)%compute%end+1+jshift; je = domain%list(m)%y(tnbr)%compute%end+nhalo+jshift
4488 if( je.GT.jeg .AND. jec.LT.js )
then
4489 js = js-joff; je = je-joff
4491 call insert_update_overlap( overlap, domain%list(m)%pe, &
4492 is, ie, js, je, isc, iec, jsc, jec, dir)
4497 is = domain%list(m)%x(tnbr)%compute%begin; ie = domain%list(m)%x(tnbr)%compute%end+ishift
4498 js = domain%list(m)%y(tnbr)%compute%end+1+jshift; je = domain%list(m)%y(tnbr)%compute%end+nhalo+jshift
4500 if( (position == east .OR. position == corner ) .AND. ( isc == ie .or. iec == is ) )
then
4503 if( je.GT.jeg .AND. jec.LT.js)
then
4504 js = js-joff; je = je-joff
4508 if( ie == ieg .AND. (position == corner .OR. position == east) &
4509 .AND. ( js .GE. middle .AND. domain%list(m)%y(tnbr)%compute%end+nhalo+jshift .LE. jeg ) )
then
4510 call insert_update_overlap( overlap, domain%list(m)%pe, &
4511 is, ie-1, js, je, isc, iec, jsc, jec, dir)
4512 ie = domain%list(m)%x(tnbr)%compute%end+ishift; is = ie
4513 js = domain%list(m)%y(tnbr)%compute%end+1+jshift; je = domain%list(m)%y(tnbr)%compute%end+nhalo+jshift
4514 select case (position)
4516 j=js; js = jsg+jeg-je; je = jsg+jeg-j
4518 j=js; js = jsg+jeg-je-1+jshift; je = jsg+jeg-j-1+jshift
4520 call insert_update_overlap( overlap, domain%list(m)%pe, &
4521 is, ie, js, je, isc, iec, jsc, jec, dir, .true.)
4523 call insert_update_overlap( overlap, domain%list(m)%pe, &
4524 is, ie, js, je, isc, iec, jsc, jec, dir, symmetry=domain%symmetry)
4531 is = domain%list(m)%x(tnbr)%compute%end+1+ishift; ie = domain%list(m)%x(tnbr)%compute%end+ehalo+ishift
4532 js = domain%list(m)%y(tnbr)%compute%end+1+jshift; je = domain%list(m)%y(tnbr)%compute%end+nhalo+jshift
4533 if( je.GT.jeg .AND. jec.LT.js )
then
4534 js = js-joff; je = je-joff
4538 call get_fold_index_east(jsg, jeg, ieg, jshift, position, is, ie, js, je)
4541 call insert_update_overlap( overlap, domain%list(m)%pe, &
4542 is, ie, js, je, isc, iec, jsc, jec, dir, folded)
4546 if( ( position == east .OR. position == corner) )
then
4548 if( domain%x(tme)%domain_data%begin .LE. ieg .AND. ieg .LE. domain%x(tme)%domain_data%end+ishift )
then
4551 if( domain%y(tme)%pos .LT. (
size(domain%y(tme)%list(:))+1)/2 )
then
4552 ie = domain%list(m)%x(tnbr)%compute%end+ishift; is = ie
4554 js = domain%list(m)%y(tnbr)%compute%begin; je = domain%list(m)%y(tnbr)%compute%end+jshift
4555 select case (position)
4557 js = max(js, middle)
4558 j=js; js = jsg+jeg-je; je = jsg+jeg-j
4560 js = max(js, middle)
4561 j=js; js = jsg+jeg-je-1+jshift; je = jsg+jeg-j-1+jshift
4563 call insert_update_overlap(overlap, domain%list(m)%pe, &
4564 is, ie, js, je, isc, iec, jsc, jec, dir, .true.)
4565 is = max(is, isc); ie = min(ie, iec)
4566 js = max(js, jsc); je = min(je, jec)
4567 if(debug_update_level .NE. no_check .AND. ie.GE.is .AND. je.GE.js )
then
4568 nsend_check = nsend_check+1
4569 call allocate_check_overlap(checklist(nsend_check), 1)
4570 call insert_check_overlap(checklist(nsend_check), domain%list(m)%pe, &
4571 tme, 1, one_hundred_eighty, is, ie, js, je)
4579 if( overlap%count > 0)
then
4581 if(nsend > maxlist)
call mpp_error(fatal, &
4582 "mpp_domains_define.inc(compute_overlaps_east): nsend is greater than MAXLIST, increase MAXLIST")
4583 call add_update_overlap(overlaplist(nsend), overlap)
4584 call init_overlap_type(overlap)
4590 update%nsend = nsend
4591 if (
associated(update%send))
deallocate(update%send)
4592 allocate(update%send(nsend))
4594 call add_update_overlap( update%send(m), overlaplist(m) )
4598 if(nsend_check>0)
then
4599 check%nsend = nsend_check
4600 if (
associated(check%send))
deallocate(check%send)
4601 allocate(check%send(nsend_check))
4602 do m = 1, nsend_check
4608 call deallocate_overlap_type(overlaplist(m))
4609 if(debug_update_level .NE. no_check)
call deallocate_overlap_type(checklist(m))
4612 isgd = isg - domain%whalo
4613 iegd = ieg + domain%ehalo
4614 jsgd = jsg - domain%shalo
4615 jegd = jeg + domain%nhalo
4621 m = mod( domain%pos+nlist-list, nlist )
4622 if(domain%list(m)%tile_id(tnbr) == domain%tile_id(tme) )
then
4623 isc = domain%list(m)%x(1)%compute%begin; iec = domain%list(m)%x(1)%compute%end+ishift
4624 jsc = domain%list(m)%y(1)%compute%begin; jec = domain%list(m)%y(1)%compute%end+jshift
4628 isd = domain%x(tme)%compute%end+1+ishift; ied = domain%x(tme)%domain_data%end+ishift
4629 jsd = domain%y(tme)%compute%begin; jed = domain%y(tme)%compute%end+jshift
4630 is=isc; ie=iec; js=jsc; je=jec
4631 if( ied.GT.ieg )
then
4633 call get_fold_index_east(jsg, jeg, ieg, jshift, position, is, ie, js, je)
4635 if( (position == east .OR. position == corner ) .AND. (jsd == je .or. jed == js ) )
then
4638 call insert_update_overlap(overlap, domain%list(m)%pe, &
4639 is, ie, js, je, isd, ied, jsd, jed, dir, folded, symmetry=domain%symmetry)
4642 if(js .LT. jsg )
then
4644 call insert_update_overlap(overlap, domain%list(m)%pe, &
4645 is, ie, js, js, isd, ied, jsd, jed, dir, folded)
4651 isd = domain%x(tme)%compute%end+1+ishift; ied = domain%x(tme)%domain_data%end+ishift
4652 jsd = domain%y(tme)%domain_data%begin; jed = domain%y(tme)%compute%begin-1
4653 is=isc; ie=iec; js=jsc; je=jec
4654 if( ied.GT.ieg )
then
4656 call get_fold_index_east(jsg, jeg, ieg, jshift, position, is, ie, js, je)
4658 if( jsd.LT.jsg .AND. js.GT.jed )
then
4659 js = js-joff; je = je-joff
4661 call insert_update_overlap(overlap, domain%list(m)%pe, &
4662 is, ie, js, je, isd, ied, jsd, jed, dir, folded)
4664 if(js .LT. jsg )
then
4666 call insert_update_overlap(overlap, domain%list(m)%pe, &
4667 is, ie, js, js, isd, ied, jsd, jed, dir, folded )
4673 isd = domain%x(tme)%compute%begin; ied = domain%x(tme)%compute%end+ishift
4674 jsd = domain%y(tme)%domain_data%begin; jed = domain%y(tme)%compute%begin-1
4675 is=isc; ie=iec; js=jsc; je=jec
4677 if( (position == east .OR. position == corner ) .AND. ( isd == ie .or. ied == is ) )
then
4680 if( jsd.LT.jsg .AND. js .GT. jed)
then
4681 js = js-joff; je = je-joff
4685 if( ied == ieg .AND. (position == corner .OR. position == east) &
4686 .AND. ( jsd < jsg .OR. jed .GE. middle ) )
then
4687 call insert_update_overlap( overlap, domain%list(m)%pe, &
4688 is, ie, js, je, isd, ied-1, jsd, jed, dir)
4689 is=isc; ie=iec; js=jsc; je=jec
4691 select case (position)
4693 j=js; js = 2*jsg-je-1; je = 2*jsg-j-1
4695 j=js; js = 2*jsg-je-2+2*jshift; je = 2*jsg-j-2+2*jshift
4697 if(je .GT. domain%y(tme)%compute%end+jshift)
call mpp_error( fatal, &
4698 'mpp_domains_define.inc(compute_overlaps_fold_west: south edge ubound error recv.' )
4700 select case (position)
4702 j=js; js = jsg+jeg-je; je = jsg+jeg-j
4704 j=js; js = jsg+jeg-je-1+jshift; je = jsg+jeg-j-1+jshift
4707 call insert_update_overlap( overlap, domain%list(m)%pe, &
4708 is, ie, js, je, ied, ied, jsd, jed, dir, .true.)
4710 call insert_update_overlap( overlap, domain%list(m)%pe, &
4711 is, ie, js, je, isd, ied, jsd, jed, dir, symmetry=domain%symmetry)
4717 isd = domain%x(tme)%domain_data%begin; ied = domain%x(tme)%compute%begin-1
4718 jsd = domain%y(tme)%domain_data%begin; jed = domain%y(tme)%compute%begin-1
4719 is=isc; ie=iec; js=jsc; je=jec
4720 if( jsd.LT.jsg .AND. js.GE.jed )
then
4721 js = js-joff; je = je-joff
4723 call insert_update_overlap(overlap, domain%list(m)%pe, &
4724 is, ie, js, je, isd, ied, jsd, jed, dir)
4728 isd = domain%x(tme)%domain_data%begin; ied = domain%x(tme)%compute%begin-1
4729 jsd = domain%y(tme)%compute%begin; jed = domain%y(tme)%compute%end+jshift
4730 is=isc; ie=iec; js=jsc; je=jec
4731 call insert_update_overlap( overlap, domain%list(m)%pe, &
4732 is, ie, js, je, isd, ied, jsd, jed, dir, symmetry=domain%symmetry)
4737 isd = domain%x(tme)%domain_data%begin; ied = domain%x(tme)%compute%begin-1
4738 jsd = domain%y(tme)%compute%end+1+jshift; jed = domain%y(tme)%domain_data%end+jshift
4739 is=isc; ie=iec; js=jsc; je=jec
4740 if( jed.GT.jeg .AND. je.LT.jsd )
then
4741 js = js+joff; je = je+joff
4743 call insert_update_overlap( overlap, domain%list(m)%pe, &
4744 is, ie, js, je, isd, ied, jsd, jed, dir)
4749 isd = domain%x(tme)%compute%begin; ied = domain%x(tme)%compute%end+ishift
4750 jsd = domain%y(tme)%compute%end+1+jshift; jed = domain%y(tme)%domain_data%end+jshift
4751 is=isc; ie=iec; js=jsc; je=jec
4752 if( (position == east .OR. position == corner ) .AND. ( isd == ie .or. ied == is ) )
then
4755 if( jed.GT.jeg .AND. je.LT.jsd)
then
4756 js = js+joff; je = je+joff
4760 if( ied == ieg .AND. (position == corner .OR. position == east) &
4761 .AND. jsd .GE. middle .AND. jed .LE. jeg )
then
4762 call insert_update_overlap( overlap, domain%list(m)%pe, &
4763 is, ie, js, je, isd, ied-1, jsd, jed, dir)
4764 is=isc; ie=iec; js=jsc; je=jec
4765 select case (position)
4767 j=js; js = jsg+jeg-je; je = jsg+jeg-j
4769 j=js; js = jsg+jeg-je-1+jshift; je = jsg+jeg-j-1+jshift
4771 call insert_update_overlap( overlap, domain%list(m)%pe, &
4772 is, ie, js, je, ied, ied, jsd, jed, dir, .true.)
4774 call insert_update_overlap( overlap, domain%list(m)%pe, &
4775 is, ie, js, je, isd, ied, jsd, jed, dir, symmetry=domain%symmetry)
4782 isd = domain%x(tme)%compute%end+1+ishift; ied = domain%x(tme)%domain_data%end+ishift
4783 jsd = domain%y(tme)%compute%end+1+jshift; jed = domain%y(tme)%domain_data%end+jshift
4784 is=isc; ie=iec; js=jsc; je=jec
4785 if( ied.GT.ieg)
then
4787 call get_fold_index_east(jsg, jeg, ieg, jshift, position, is, ie, js, je)
4789 if( jed.GT.jeg .AND. je.LT.jsd )
then
4790 js = js+joff; je = je+joff
4793 call insert_update_overlap( overlap, domain%list(m)%pe, &
4794 is, ie, js, je, isd, ied, jsd, jed, dir)
4798 if( ( position == east .OR. position == corner) )
then
4800 if( domain%x(tme)%domain_data%begin .LE. ieg .AND. ieg .LE. domain%x(tme)%domain_data%end+ishift )
then
4803 if( domain%y(tme)%pos .GE.
size(domain%y(tme)%list(:))/2 )
then
4804 ied = domain%x(tme)%compute%end+ishift; isd = ied
4805 if( ied == ieg )
then
4806 jsd = domain%y(tme)%compute%begin; jed = domain%y(tme)%compute%end+jshift
4807 is=isc; ie=iec; js = jsc; je = jec
4808 select case (position)
4810 jsd = max(jsd, middle)
4811 j=js; js = jsg+jeg-je; je = jsg+jeg-j
4813 jsd = max(jsd, middle)
4814 j=js; js = jsg+jeg-je-1+jshift; je = jsg+jeg-j-1+jshift
4816 call insert_update_overlap(overlap, domain%list(m)%pe, &
4817 is, ie, js, je, isd, ied, jsd, jed, dir, .true.)
4818 is = max(is, isd); ie = min(ie, ied)
4819 js = max(js, jsd); je = min(je, jed)
4820 if(debug_update_level .NE. no_check .AND. ie.GE.is .AND. je.GE.js )
then
4821 nrecv_check = nrecv_check+1
4822 call allocate_check_overlap(checklist(nrecv_check), 1)
4823 call insert_check_overlap(checklist(nrecv_check), domain%list(m)%pe, &
4824 tme, 3, one_hundred_eighty, is, ie, js, je)
4832 if( overlap%count > 0)
then
4834 if(nrecv > maxlist)
call mpp_error(fatal, &
4835 "mpp_domains_define.inc(compute_overlaps_east): nrecv is greater than MAXLIST, increase MAXLIST")
4836 call add_update_overlap( overlaplist(nrecv), overlap)
4837 call init_overlap_type(overlap)
4843 update%nrecv = nrecv
4844 if (
associated(update%recv))
deallocate(update%recv)
4845 allocate(update%recv(nrecv))
4847 call add_update_overlap( update%recv(m), overlaplist(m) )
4848 do n = 1, update%recv(m)%count
4849 if(update%recv(m)%tileNbr(n) == domain%tile_id(tme))
then
4850 if(update%recv(m)%dir(n) == 1) domain%x(tme)%loffset = 0
4851 if(update%recv(m)%dir(n) == 7) domain%y(tme)%loffset = 0
4857 if(nrecv_check>0)
then
4858 check%nrecv = nrecv_check
4859 if (
associated(check%recv))
deallocate(check%recv)
4860 allocate(check%recv(nrecv_check))
4861 do m = 1, nrecv_check
4866 call deallocate_overlap_type(overlap)
4868 call deallocate_overlap_type(overlaplist(m))
4869 if(debug_update_level .NE. no_check)
call deallocate_overlap_type(checklist(m))
4875 domain%initialized = .true.
4880 subroutine get_fold_index_west(jsg, jeg, isg, jshift, position, is, ie, js, je)
4881 integer,
intent(in) :: jsg, jeg, isg, jshift, position
4882 integer,
intent(inout) :: is, ie, js, je
4885 select case(position)
4887 j=js; js = jsg+jeg-je; je = jsg+jeg-j
4888 i=is; is = 2*isg-ie-1; ie = 2*isg-i-1
4890 j=js; js = jsg+jeg-je; je = jsg+jeg-j
4891 i=is; is = 2*isg-ie; ie = 2*isg-i
4893 j=js; js = jsg+jeg-je-1+jshift; je = jsg+jeg-j-1+jshift
4894 i=is; is = 2*isg-ie-1; ie = 2*isg-i-1
4896 j=js; js = jsg+jeg-je-1+jshift; je = jsg+jeg-j-1+jshift
4897 i=is; is = 2*isg-ie; ie = 2*isg-i
4900 end subroutine get_fold_index_west
4903 subroutine get_fold_index_east(jsg, jeg, ieg, jshift, position, is, ie, js, je)
4904 integer,
intent(in) :: jsg, jeg, ieg, jshift, position
4905 integer,
intent(inout) :: is, ie, js, je
4908 select case(position)
4910 j=js; js = jsg+jeg-je; je = jsg+jeg-j
4911 i=is; is = 2*ieg-ie+1; ie = 2*ieg-i+1
4913 j=js; js = jsg+jeg-je; je = jsg+jeg-j
4914 i=is; is = 2*ieg-ie; ie = 2*ieg-i
4916 j=js; js = jsg+jeg-je-1+jshift; je = jsg+jeg-j-1+jshift
4917 i=is; is = 2*ieg-ie+1; ie = 2*ieg-i+1
4919 j=js; js = jsg+jeg-je-1+jshift; je = jsg+jeg-j-1+jshift
4920 i=is; is = 2*ieg-ie; ie = 2*ieg-i
4923 end subroutine get_fold_index_east
4926 subroutine get_fold_index_south(isg, ieg, jsg, ishift, position, is, ie, js, je)
4927 integer,
intent(in) :: isg, ieg, jsg, ishift, position
4928 integer,
intent(inout) :: is, ie, js, je
4931 select case(position)
4933 i=is; is = isg+ieg-ie; ie = isg+ieg-i
4934 j=js; js = 2*jsg-je-1; je = 2*jsg-j-1
4936 i=is; is = isg+ieg-ie-1+ishift; ie = isg+ieg-i-1+ishift
4937 j=js; js = 2*jsg-je-1; je = 2*jsg-j-1
4939 i=is; is = isg+ieg-ie; ie = isg+ieg-i
4940 j=js; js = 2*jsg-je; je = 2*jsg-j
4942 i=is; is = isg+ieg-ie-1+ishift; ie = isg+ieg-i-1+ishift
4943 j=js; js = 2*jsg-je; je = 2*jsg-j
4946 end subroutine get_fold_index_south
4948 subroutine get_fold_index_north(isg, ieg, jeg, ishift, position, is, ie, js, je)
4949 integer,
intent(in) :: isg, ieg, jeg, ishift, position
4950 integer,
intent(inout) :: is, ie, js, je
4953 select case(position)
4955 i=is; is = isg+ieg-ie; ie = isg+ieg-i
4956 j=js; js = 2*jeg-je+1; je = 2*jeg-j+1
4958 i=is; is = isg+ieg-ie-1+ishift; ie = isg+ieg-i-1+ishift
4959 j=js; js = 2*jeg-je+1; je = 2*jeg-j+1
4961 i=is; is = isg+ieg-ie; ie = isg+ieg-i
4962 j=js; js = 2*jeg-je; je = 2*jeg-j
4964 i=is; is = isg+ieg-ie-1+ishift; ie = isg+ieg-i-1+ishift
4965 j=js; js = 2*jeg-je; je = 2*jeg-j
4968 end subroutine get_fold_index_north
4974 integer,
intent(inout) :: lstart, lend
4975 integer,
intent(in ) :: offset, gstart, gend, gsize
4977 lstart = lstart + offset
4978 if(lstart > gend) lstart = lstart - gsize
4979 if(lstart < gstart) lstart = lstart + gsize
4980 lend = lend + offset
4981 if(lend > gend) lend = lend - gsize
4982 if(lend < gstart) lend = lend + gsize
4995 subroutine set_overlaps(domain, overlap_in, overlap_out, whalo_out, ehalo_out, shalo_out, nhalo_out)
4996 type(domain2d),
intent(in) :: domain
4997 type(overlapspec),
intent(in) :: overlap_in
4998 type(overlapspec),
intent(inout) :: overlap_out
4999 integer,
intent(in) :: whalo_out, ehalo_out, shalo_out, nhalo_out
5000 integer :: nlist, m, n, isoff, ieoff, jsoff, jeoff, rotation
5001 integer :: whalo_in, ehalo_in, shalo_in, nhalo_in
5003 type(overlap_type) :: overlap
5004 type(overlap_type),
allocatable :: send(:), recv(:)
5005 type(overlap_type),
pointer :: ptrIn => null()
5006 integer :: nsend, nrecv, nsend_in, nrecv_in
5008 if( domain%fold .NE. 0)
call mpp_error(fatal,
"mpp_domains_define.inc(set_overlaps):"// &
5009 &
" folded domain is not implemented for arbitrary halo update, contact developer")
5011 whalo_in = domain%whalo
5012 ehalo_in = domain%ehalo
5013 shalo_in = domain%shalo
5014 nhalo_in = domain%nhalo
5016 if( .NOT. domain%initialized)
call mpp_error(fatal, &
5017 "mpp_domains_define.inc: domain is not defined yet")
5019 nlist =
size(domain%list(:))
5020 isoff = whalo_in - abs(whalo_out)
5021 ieoff = ehalo_in - abs(ehalo_out)
5022 jsoff = shalo_in - abs(shalo_out)
5023 jeoff = nhalo_in - abs(nhalo_out)
5026 nsend_in = overlap_in%nsend
5027 nrecv_in = overlap_in%nrecv
5028 if(nsend_in>0)
allocate(send(nsend_in))
5029 if(nrecv_in>0)
allocate(recv(nrecv_in))
5030 call allocate_update_overlap(overlap, maxoverlap)
5032 overlap_out%whalo = whalo_out
5033 overlap_out%ehalo = ehalo_out
5034 overlap_out%shalo = shalo_out
5035 overlap_out%nhalo = nhalo_out
5036 overlap_out%xbegin = overlap_in%xbegin
5037 overlap_out%xend = overlap_in%xend
5038 overlap_out%ybegin = overlap_in%ybegin
5039 overlap_out%yend = overlap_in%yend
5043 ptrin => overlap_in%send(m)
5044 if(ptrin%count .LE. 0)
call mpp_error(fatal,
"mpp_domains_define.inc(set_overlaps):"// &
5045 " number of overlap for send should be a positive number for"//trim(domain%name) )
5046 do n = 1, ptrin%count
5048 rotation = ptrin%rotation(n)
5051 if(ehalo_out > 0)
then
5052 call set_single_overlap(ptrin, overlap, 0, -ieoff, 0, 0, n, dir, rotation)
5053 else if(ehalo_out<0)
then
5054 call set_single_overlap(ptrin, overlap, -ehalo_out, 0, 0, 0, n, dir, rotation)
5057 if(ehalo_out>0 .AND. shalo_out > 0)
then
5058 call set_single_overlap(ptrin, overlap, 0, -ieoff, jsoff, 0, n, dir, rotation)
5059 else if(ehalo_out<0 .AND. shalo_out < 0)
then
5060 call set_single_overlap(ptrin, overlap, -ehalo_out, 0, 0, shalo_out, n, dir, rotation)
5061 call set_single_overlap(ptrin, overlap, -ehalo_out, 0, jsoff, 0, n, dir-1, rotation)
5062 call set_single_overlap(ptrin, overlap, 0, -ieoff, 0, shalo_out, n, dir+1, rotation)
5065 if(shalo_out > 0)
then
5066 call set_single_overlap(ptrin, overlap, 0, 0, jsoff, 0, n, dir, rotation)
5067 else if(shalo_out<0)
then
5068 call set_single_overlap(ptrin, overlap, 0, 0, 0, shalo_out, n, dir, rotation)
5071 if(whalo_out>0 .AND. shalo_out > 0)
then
5072 call set_single_overlap(ptrin, overlap, isoff, 0, jsoff, 0, n, dir, rotation)
5073 else if(whalo_out<0 .AND. shalo_out < 0)
then
5074 call set_single_overlap(ptrin, overlap, 0, whalo_out, 0, shalo_out, n, dir, rotation)
5075 call set_single_overlap(ptrin, overlap, isoff, 0, 0, shalo_out, n, dir-1, rotation)
5076 call set_single_overlap(ptrin, overlap, 0, whalo_out, jsoff, 0, n, dir+1, rotation)
5079 if(whalo_out > 0)
then
5080 call set_single_overlap(ptrin, overlap, isoff, 0, 0, 0, n, dir, rotation)
5081 else if(whalo_out<0)
then
5082 call set_single_overlap(ptrin, overlap, 0, whalo_out, 0, 0, n, dir, rotation)
5085 if(whalo_out>0 .AND. nhalo_out > 0)
then
5086 call set_single_overlap(ptrin, overlap, isoff, 0, 0, -jeoff, n, dir, rotation)
5087 else if(whalo_out<0 .AND. nhalo_out < 0)
then
5088 call set_single_overlap(ptrin, overlap, 0, whalo_out, -nhalo_out, 0, n, dir, rotation)
5089 call set_single_overlap(ptrin, overlap, 0, whalo_out, 0, -jeoff, n, dir-1, rotation)
5090 call set_single_overlap(ptrin, overlap, isoff, 0, -nhalo_out, 0, n, dir+1, rotation)
5093 if(nhalo_out > 0)
then
5094 call set_single_overlap(ptrin, overlap, 0, 0, 0, -jeoff, n, dir, rotation)
5095 else if(nhalo_out<0)
then
5096 call set_single_overlap(ptrin, overlap, 0, 0, -nhalo_out, 0, n, dir, rotation)
5099 if(ehalo_out>0 .AND. nhalo_out > 0)
then
5100 call set_single_overlap(ptrin, overlap, 0, -ieoff, 0, -jeoff, n, dir, rotation)
5101 else if(ehalo_out<0 .AND. nhalo_out < 0)
then
5102 call set_single_overlap(ptrin, overlap, -ehalo_out, 0, -nhalo_out, 0, n, dir, rotation)
5103 call set_single_overlap(ptrin, overlap, 0, -ieoff, -nhalo_out, 0, n, dir-1, rotation)
5104 call set_single_overlap(ptrin, overlap, -ehalo_out, 0, 0, -jeoff, n, 1, rotation)
5108 if(overlap%count>0)
then
5110 call add_update_overlap(send(nsend), overlap)
5111 call init_overlap_type(overlap)
5116 overlap_out%nsend = nsend
5117 if (
associated(overlap_out%send))
deallocate(overlap_out%send)
5118 allocate(overlap_out%send(nsend));
5120 call add_update_overlap(overlap_out%send(n), send(n) )
5123 overlap_out%nsend = 0
5132 ptrin => overlap_in%recv(m)
5133 if(ptrin%count .LE. 0)
call mpp_error(fatal, &
5134 "mpp_domains_define.inc(set_overlaps): number of overlap for recv should be a positive number")
5136 do n = 1, ptrin%count
5138 rotation = ptrin%rotation(n)
5141 if(ehalo_out > 0)
then
5142 call set_single_overlap(ptrin, overlap, 0, -ieoff, 0, 0, n, dir)
5143 else if(ehalo_out<0)
then
5144 call set_single_overlap(ptrin, overlap, -ehalo_out, 0, 0, 0, n, dir)
5147 if(ehalo_out>0 .AND. shalo_out > 0)
then
5148 call set_single_overlap(ptrin, overlap, 0, -ieoff, jsoff, 0, n, dir)
5149 else if(ehalo_out<0 .AND. shalo_out < 0)
then
5150 call set_single_overlap(ptrin, overlap, -ehalo_out, 0, 0, shalo_out, n, dir)
5151 call set_single_overlap(ptrin, overlap, -ehalo_out, 0, jsoff, 0, n, dir-1)
5152 call set_single_overlap(ptrin, overlap, 0, -ieoff, 0, shalo_out, n, dir+1)
5155 if(shalo_out > 0)
then
5156 call set_single_overlap(ptrin, overlap, 0, 0, jsoff, 0, n, dir)
5157 else if(shalo_out<0)
then
5158 call set_single_overlap(ptrin, overlap, 0, 0, 0, shalo_out, n, dir)
5161 if(whalo_out>0 .AND. shalo_out > 0)
then
5162 call set_single_overlap(ptrin, overlap, isoff, 0, jsoff, 0, n, dir)
5163 else if(whalo_out<0 .AND. shalo_out < 0)
then
5164 call set_single_overlap(ptrin, overlap, 0, whalo_out, 0, shalo_out, n, dir)
5165 call set_single_overlap(ptrin, overlap, isoff, 0, 0, shalo_out, n, dir-1)
5166 call set_single_overlap(ptrin, overlap, 0, whalo_out, jsoff, 0, n, dir+1)
5169 if(whalo_out > 0)
then
5170 call set_single_overlap(ptrin, overlap, isoff, 0, 0, 0, n, dir)
5171 else if(whalo_out<0)
then
5172 call set_single_overlap(ptrin, overlap, 0, whalo_out, 0, 0, n, dir)
5175 if(whalo_out>0 .AND. nhalo_out > 0)
then
5176 call set_single_overlap(ptrin, overlap, isoff, 0, 0, -jeoff, n, dir)
5177 else if(whalo_out<0 .AND. nhalo_out < 0)
then
5178 call set_single_overlap(ptrin, overlap, 0, whalo_out, -nhalo_out, 0, n, dir)
5179 call set_single_overlap(ptrin, overlap, 0, whalo_out, 0, -jeoff, n, dir-1)
5180 call set_single_overlap(ptrin, overlap, isoff, 0, -nhalo_out, 0, n, dir+1)
5183 if(nhalo_out > 0)
then
5184 call set_single_overlap(ptrin, overlap, 0, 0, 0, -jeoff, n, dir)
5185 else if(nhalo_out<0)
then
5186 call set_single_overlap(ptrin, overlap, 0, 0, -nhalo_out, 0, n, dir)
5189 if(ehalo_out>0 .AND. nhalo_out > 0)
then
5190 call set_single_overlap(ptrin, overlap, 0, -ieoff, 0, -jeoff, n, dir)
5191 else if(ehalo_out<0 .AND. nhalo_out < 0)
then
5192 call set_single_overlap(ptrin, overlap, -ehalo_out, 0, -nhalo_out, 0, n, dir)
5193 call set_single_overlap(ptrin, overlap, 0, -ieoff, -nhalo_out, 0, n, dir-1)
5194 call set_single_overlap(ptrin, overlap, -ehalo_out, 0, 0, -jeoff, n, 1)
5198 if(overlap%count>0)
then
5200 call add_update_overlap(recv(nrecv), overlap)
5201 call init_overlap_type(overlap)
5206 overlap_out%nrecv = nrecv
5207 if (
associated(overlap_out%recv))
deallocate(overlap_out%recv)
5208 allocate(overlap_out%recv(nrecv));
5210 call add_update_overlap(overlap_out%recv(n), recv(n) )
5213 overlap_out%nrecv = 0
5216 call deallocate_overlap_type(overlap)
5218 call deallocate_overlap_type(send(n))
5221 call deallocate_overlap_type(recv(n))
5223 if(
allocated(send))
deallocate(send)
5224 if(
allocated(recv))
deallocate(recv)
5227 call set_domain_comm_inf(overlap_out)
5233 subroutine set_single_overlap(overlap_in, overlap_out, isoff, ieoff, jsoff, jeoff, index, dir, rotation)
5234 type(overlap_type),
intent(in) :: overlap_in
5235 type(overlap_type),
intent(inout) :: overlap_out
5236 integer,
intent(in) :: isoff, jsoff, ieoff, jeoff
5237 integer,
intent(in) :: index
5238 integer,
intent(in) :: dir
5239 integer,
optional,
intent(in) :: rotation
5243 if( overlap_out%pe == null_pe )
then
5244 overlap_out%pe = overlap_in%pe
5246 if(overlap_out%pe .NE. overlap_in%pe)
call mpp_error(fatal, &
5247 "mpp_domains_define.inc(set_single_overlap): mismatch of pe between overlap_in and overlap_out")
5250 if(isoff .NE. 0 .and. ieoff .NE. 0)
call mpp_error(fatal, &
5251 "mpp_domains_define.inc(set_single_overlap): both isoff and ieoff are non-zero")
5252 if(jsoff .NE. 0 .and. jeoff .NE. 0)
call mpp_error(fatal, &
5253 "mpp_domains_define.inc(set_single_overlap): both jsoff and jeoff are non-zero")
5256 overlap_out%count = overlap_out%count + 1
5257 count = overlap_out%count
5258 if(count > maxoverlap)
call mpp_error(fatal, &
5259 "set_single_overlap: number of overlap is greater than MAXOVERLAP, increase MAXOVERLAP")
5261 if(
present(rotation)) rotate = rotation
5262 overlap_out%rotation (count) = overlap_in%rotation(index)
5263 overlap_out%dir (count) = dir
5264 overlap_out%tileMe (count) = overlap_in%tileMe(index)
5265 overlap_out%tileNbr (count) = overlap_in%tileNbr(index)
5269 overlap_out%is(count) = overlap_in%is(index) + isoff
5270 overlap_out%ie(count) = overlap_in%ie(index) + ieoff
5271 overlap_out%js(count) = overlap_in%js(index) + jsoff
5272 overlap_out%je(count) = overlap_in%je(index) + jeoff
5274 overlap_out%is(count) = overlap_in%is(index) - jeoff
5275 overlap_out%ie(count) = overlap_in%ie(index) - jsoff
5276 overlap_out%js(count) = overlap_in%js(index) + isoff
5277 overlap_out%je(count) = overlap_in%je(index) + ieoff
5279 overlap_out%is(count) = overlap_in%is(index) + jsoff
5280 overlap_out%ie(count) = overlap_in%ie(index) + jeoff
5281 overlap_out%js(count) = overlap_in%js(index) - ieoff
5282 overlap_out%je(count) = overlap_in%je(index) - isoff
5284 call mpp_error(fatal,
"mpp_domains_define.inc: the value of rotation should be ZERO, NINETY or MINUS_NINETY")
5287 end subroutine set_single_overlap
5292 refine1, refine2, istart1, iend1, jstart1, jend1, istart2, iend2, jstart2, jend2, &
5293 isgList, iegList, jsgList, jegList )
5294 type(domain2d),
intent(inout) :: domain
5295 integer,
intent(in) :: position
5296 integer,
intent(in) :: num_contact
5297 integer,
dimension(:),
intent(in) :: tile1, tile2
5298 integer,
dimension(:),
intent(in) :: align1, align2
5299 real,
dimension(:),
intent(in) :: refine1, refine2
5300 integer,
dimension(:),
intent(in) :: istart1, iend1
5301 integer,
dimension(:),
intent(in) :: jstart1, jend1
5302 integer,
dimension(:),
intent(in) :: istart2, iend2
5303 integer,
dimension(:),
intent(in) :: jstart2, jend2
5304 integer,
dimension(:),
intent(in) :: isgList, iegList
5305 integer,
dimension(:),
intent(in) :: jsgList, jegList
5307 integer :: isc, iec, jsc, jec, isd, ied, jsd, jed
5308 integer :: isc1, iec1, jsc1, jec1, isc2, iec2, jsc2, jec2
5309 integer :: isd1, ied1, jsd1, jed1, isd2, ied2, jsd2, jed2
5310 integer :: is, ie, js, je, ioff, joff
5311 integer :: ntiles, max_contact
5312 integer :: nlist, list, m, n, l, count, numS, numR
5313 integer :: whalo, ehalo, shalo, nhalo
5314 integer :: t1, t2, tt, pos
5315 integer :: ntileMe, ntileNbr, tMe, tNbr, tileMe, dir
5316 integer :: nxd, nyd, nxc, nyc, ism, iem, jsm, jem
5317 integer :: dirlist(8)
5320 integer,
dimension(4*num_contact) :: is1Send, ie1Send, js1Send, je1Send
5321 integer,
dimension(4*num_contact) :: is2Send, ie2Send, js2Send, je2Send
5322 integer,
dimension(4*num_contact) :: is2Recv, ie2Recv, js2Recv, je2Recv
5323 integer,
dimension(4*num_contact) :: is1Recv, ie1Recv, js1Recv, je1Recv
5324 integer,
dimension(4*num_contact) :: align1Recv, align2Recv, align1Send, align2Send
5325 real,
dimension(4*num_contact) :: refineRecv, refineSend
5326 integer,
dimension(4*num_contact) :: rotateSend, rotateRecv, tileSend, tileRecv
5327 integer :: nsend, nrecv, nsend2, nrecv2
5328 type(contact_type),
dimension(domain%ntiles) :: eCont, wCont, sCont, nCont
5329 type(overlap_type),
dimension(0:size(domain%list(:))-1) :: overlapSend, overlapRecv
5332 if( position .NE. center )
call mpp_error(fatal,
"mpp_domains_define.inc: " //&
5333 "routine define_contact_point can only be used to calculate overlapping for cell center.")
5335 ntiles = domain%ntiles
5337 econt(:)%ncontact = 0
5340 econt(n)%ncontact = 0; scont(n)%ncontact = 0; wcont(n)%ncontact = 0; ncont(n)%ncontact = 0;
5341 allocate(econt(n)%tile(num_contact), wcont(n)%tile(num_contact) )
5342 allocate(ncont(n)%tile(num_contact), scont(n)%tile(num_contact) )
5343 allocate(econt(n)%align1(num_contact), econt(n)%align2(num_contact) )
5344 allocate(wcont(n)%align1(num_contact), wcont(n)%align2(num_contact) )
5345 allocate(scont(n)%align1(num_contact), scont(n)%align2(num_contact) )
5346 allocate(ncont(n)%align1(num_contact), ncont(n)%align2(num_contact) )
5347 allocate(econt(n)%refine1(num_contact), econt(n)%refine2(num_contact) )
5348 allocate(wcont(n)%refine1(num_contact), wcont(n)%refine2(num_contact) )
5349 allocate(scont(n)%refine1(num_contact), scont(n)%refine2(num_contact) )
5350 allocate(ncont(n)%refine1(num_contact), ncont(n)%refine2(num_contact) )
5351 allocate(econt(n)%is1(num_contact), econt(n)%ie1(num_contact), econt(n)%js1(num_contact), &
5352 & econt(n)%je1(num_contact))
5353 allocate(econt(n)%is2(num_contact), econt(n)%ie2(num_contact), econt(n)%js2(num_contact), &
5354 & econt(n)%je2(num_contact))
5355 allocate(wcont(n)%is1(num_contact), wcont(n)%ie1(num_contact), wcont(n)%js1(num_contact), &
5356 & wcont(n)%je1(num_contact))
5357 allocate(wcont(n)%is2(num_contact), wcont(n)%ie2(num_contact), wcont(n)%js2(num_contact), &
5358 & wcont(n)%je2(num_contact))
5359 allocate(scont(n)%is1(num_contact), scont(n)%ie1(num_contact), scont(n)%js1(num_contact), &
5360 & scont(n)%je1(num_contact))
5361 allocate(scont(n)%is2(num_contact), scont(n)%ie2(num_contact), scont(n)%js2(num_contact), &
5362 & scont(n)%je2(num_contact))
5363 allocate(ncont(n)%is1(num_contact), ncont(n)%ie1(num_contact), ncont(n)%js1(num_contact), &
5364 & ncont(n)%je1(num_contact))
5365 allocate(ncont(n)%is2(num_contact), ncont(n)%ie2(num_contact), ncont(n)%js2(num_contact), &
5366 & ncont(n)%je2(num_contact))
5370 do n = 1, num_contact
5373 select case(align1(n))
5375 call fill_contact( econt(t1), t2, istart1(n), iend1(n), jstart1(n), jend1(n), istart2(n), iend2(n), &
5376 jstart2(n), jend2(n), align1(n), align2(n), refine1(n), refine2(n))
5378 call fill_contact( wcont(t1), t2, istart1(n), iend1(n), jstart1(n), jend1(n), istart2(n), iend2(n), &
5379 jstart2(n), jend2(n), align1(n), align2(n), refine1(n), refine2(n))
5381 call fill_contact( scont(t1), t2, istart1(n), iend1(n), jstart1(n), jend1(n), istart2(n), iend2(n), &
5382 jstart2(n), jend2(n), align1(n), align2(n), refine1(n), refine2(n))
5384 call fill_contact( ncont(t1), t2, istart1(n), iend1(n), jstart1(n), jend1(n), istart2(n), iend2(n), &
5385 jstart2(n), jend2(n), align1(n), align2(n), refine1(n), refine2(n))
5387 select case(align2(n))
5389 call fill_contact( econt(t2), t1, istart2(n), iend2(n), jstart2(n), jend2(n), istart1(n), iend1(n), &
5390 jstart1(n), jend1(n), align2(n), align1(n), refine2(n), refine1(n))
5392 call fill_contact( wcont(t2), t1, istart2(n), iend2(n), jstart2(n), jend2(n), istart1(n), iend1(n), &
5393 jstart1(n), jend1(n), align2(n), align1(n), refine2(n), refine1(n))
5395 call fill_contact( scont(t2), t1, istart2(n), iend2(n), jstart2(n), jend2(n), istart1(n), iend1(n), &
5396 jstart1(n), jend1(n), align2(n), align1(n), refine2(n), refine1(n))
5398 call fill_contact( ncont(t2), t1, istart2(n), iend2(n), jstart2(n), jend2(n), istart1(n), iend1(n), &
5399 jstart1(n), jend1(n), align2(n), align1(n), refine2(n), refine1(n))
5404 whalo = domain%whalo
5405 ehalo = domain%ehalo
5406 shalo = domain%shalo
5407 nhalo = domain%nhalo
5410 nlist =
size(domain%list(:))
5412 max_contact = 4*num_contact
5414 ntileme =
size(domain%x(:))
5415 refinesend = 1; refinerecv = 1
5421 do n = 1, domain%update_T%nsend
5422 pos = domain%update_T%send(n)%pe - mpp_root_pe()
5423 call add_update_overlap(overlapsend(pos), domain%update_T%send(n) )
5425 do n = 1, domain%update_T%nrecv
5426 pos = domain%update_T%recv(n)%pe - mpp_root_pe()
5427 call add_update_overlap(overlaprecv(pos), domain%update_T%recv(n) )
5430 call mpp_get_memory_domain(domain, ism, iem, jsm, jem)
5431 domain%update_T%xbegin = ism; domain%update_T%xend = iem
5432 domain%update_T%ybegin = jsm; domain%update_T%yend = jem
5433 domain%update_T%whalo = whalo; domain%update_T%ehalo = ehalo
5434 domain%update_T%shalo = shalo; domain%update_T%nhalo = nhalo
5437 tileme = domain%tile_id(tme)
5438 rotatesend = zero; rotaterecv = zero
5442 do n = 1, econt(tileme)%ncontact
5444 tilerecv(count) = econt(tileme)%tile(n); tilesend(count) = econt(tileme)%tile(n)
5445 align1recv(count) = econt(tileme)%align1(n); align2recv(count) = econt(tileme)%align2(n)
5446 align1send(count) = econt(tileme)%align1(n); align2send(count) = econt(tileme)%align2(n)
5447 refinesend(count) = econt(tileme)%refine2(n); refinerecv(count) = econt(tileme)%refine1(n)
5448 is1recv(count) = econt(tileme)%is1(n) + 1; ie1recv(count) = is1recv(count) + ehalo - 1
5449 js1recv(count) = econt(tileme)%js1(n); je1recv(count) = econt(tileme)%je1(n)
5450 select case(econt(tileme)%align2(n))
5452 is2recv(count) = econt(tileme)%is2(n); ie2recv(count) = is2recv(count) + ehalo - 1
5453 js2recv(count) = econt(tileme)%js2(n); je2recv(count) = econt(tileme)%je2(n)
5454 ie1send(count) = econt(tileme)%is1(n); is1send(count) = ie1send(count) - whalo + 1
5455 js1send(count) = econt(tileme)%js1(n); je1send(count) = econt(tileme)%je1(n)
5456 ie2send(count) = econt(tileme)%is2(n) - 1; is2send(count) = ie2send(count) - whalo + 1
5457 js2send(count) = econt(tileme)%js2(n); je2send(count) = econt(tileme)%je2(n)
5459 rotaterecv(count) = ninety; rotatesend(count) = minus_ninety
5460 js2recv(count) = econt(tileme)%js2(n); je2recv(count) = js2recv(count) + ehalo -1
5461 is2recv(count) = econt(tileme)%is2(n); ie2recv(count) = econt(tileme)%ie2(n)
5462 ie1send(count) = econt(tileme)%is1(n); is1send(count) = ie1send(count) - shalo + 1
5463 js1send(count) = econt(tileme)%js1(n); je1send(count) = econt(tileme)%je1(n)
5464 is2send(count) = econt(tileme)%is2(n); ie2send(count) = econt(tileme)%ie2(n)
5465 je2send(count) = econt(tileme)%js2(n) - 1; js2send(count) = je2send(count) - shalo + 1
5469 do n = 1, scont(tileme)%ncontact
5471 tilerecv(count) = scont(tileme)%tile(n); tilesend(count) = scont(tileme)%tile(n)
5472 align1recv(count) = scont(tileme)%align1(n); align2recv(count) = scont(tileme)%align2(n);
5473 align1send(count) = scont(tileme)%align1(n); align2send(count) = scont(tileme)%align2(n);
5474 refinesend(count) = scont(tileme)%refine2(n); refinerecv(count) = scont(tileme)%refine1(n)
5475 is1recv(count) = scont(tileme)%is1(n); ie1recv(count) = scont(tileme)%ie1(n)
5476 je1recv(count) = scont(tileme)%js1(n) - 1; js1recv(count) = je1recv(count) - shalo + 1
5477 select case(scont(tileme)%align2(n))
5479 is2recv(count) = scont(tileme)%is2(n); ie2recv(count) = scont(tileme)%ie2(n)
5480 je2recv(count) = scont(tileme)%je2(n); js2recv(count) = je2recv(count) - shalo + 1
5481 is1send(count) = scont(tileme)%is1(n); ie1send(count) = scont(tileme)%ie1(n)
5482 js1send(count) = scont(tileme)%js1(n); je1send(count) = js1send(count) + nhalo -1
5483 is2send(count) = scont(tileme)%is2(n); ie2send(count) = scont(tileme)%ie2(n)
5484 js2send(count) = scont(tileme)%je2(n)+1; je2send(count) = js2send(count) + nhalo - 1
5486 rotaterecv(count) = minus_ninety; rotatesend(count) = ninety
5487 ie2recv(count) = scont(tileme)%ie2(n); is2recv(count) = ie2recv(count) - shalo + 1
5488 js2recv(count) = scont(tileme)%js2(n); je2recv(count) = scont(tileme)%je2(n)
5489 is1send(count) = scont(tileme)%is1(n); ie1send(count) = scont(tileme)%ie1(n)
5490 js1send(count) = scont(tileme)%js1(n); je1send(count) = js1send(count) + ehalo - 1
5491 is2send(count) = scont(tileme)%ie2(n)+1; ie2send(count) = is2send(count) + ehalo - 1
5492 js2send(count) = scont(tileme)%js2(n); je2send(count) = scont(tileme)%je2(n)
5496 do n = 1, wcont(tileme)%ncontact
5498 tilerecv(count) = wcont(tileme)%tile(n); tilesend(count) = wcont(tileme)%tile(n)
5499 align1recv(count) = wcont(tileme)%align1(n); align2recv(count) = wcont(tileme)%align2(n);
5500 align1send(count) = wcont(tileme)%align1(n); align2send(count) = wcont(tileme)%align2(n);
5501 refinesend(count) = wcont(tileme)%refine2(n); refinerecv(count) = wcont(tileme)%refine1(n)
5502 ie1recv(count) = wcont(tileme)%is1(n) - 1; is1recv(count) = ie1recv(count) - whalo + 1
5503 js1recv(count) = wcont(tileme)%js1(n); je1recv(count) = wcont(tileme)%je1(n)
5504 select case(wcont(tileme)%align2(n))
5506 ie2recv(count) = wcont(tileme)%ie2(n); is2recv(count) = ie2recv(count) - whalo + 1
5507 js2recv(count) = wcont(tileme)%js2(n); je2recv(count) = wcont(tileme)%je2(n)
5508 is1send(count) = wcont(tileme)%is1(n); ie1send(count) = is1send(count) + ehalo - 1
5509 js1send(count) = wcont(tileme)%js1(n); je1send(count) = wcont(tileme)%je1(n)
5510 is2send(count) = wcont(tileme)%ie2(n)+1; ie2send(count) = is2send(count) + ehalo - 1
5511 js2send(count) = wcont(tileme)%js2(n); je2send(count) = wcont(tileme)%je2(n)
5513 rotaterecv(count) = ninety; rotatesend(count) = minus_ninety
5514 je2recv(count) = wcont(tileme)%je2(n); js2recv(count) = je2recv(count) - whalo + 1
5515 is2recv(count) = wcont(tileme)%is2(n); ie2recv(count) = wcont(tileme)%ie2(n)
5516 is1send(count) = wcont(tileme)%is1(n); ie1send(count) = is1send(count) + nhalo - 1
5517 js1send(count) = wcont(tileme)%js1(n); je1send(count) = wcont(tileme)%je1(n)
5518 js2send(count) = wcont(tileme)%je2(n)+1; je2send(count) = js2send(count) + nhalo - 1
5519 is2send(count) = wcont(tileme)%is2(n); ie2send(count) = wcont(tileme)%ie2(n)
5523 do n = 1, ncont(tileme)%ncontact
5525 tilerecv(count) = ncont(tileme)%tile(n); tilesend(count) = ncont(tileme)%tile(n)
5526 align1recv(count) = ncont(tileme)%align1(n); align2recv(count) = ncont(tileme)%align2(n);
5527 align1send(count) = ncont(tileme)%align1(n); align2send(count) = ncont(tileme)%align2(n);
5528 refinesend(count) = ncont(tileme)%refine2(n); refinerecv(count) = ncont(tileme)%refine1(n)
5529 is1recv(count) = ncont(tileme)%is1(n); ie1recv(count) = ncont(tileme)%ie1(n)
5530 js1recv(count) = ncont(tileme)%je1(n)+1; je1recv(count) = js1recv(count) + nhalo - 1
5531 select case(ncont(tileme)%align2(n))
5533 is2recv(count) = ncont(tileme)%is2(n); ie2recv(count) = ncont(tileme)%ie2(n)
5534 js2recv(count) = ncont(tileme)%js2(n); je2recv(count) = js2recv(count) + nhalo - 1
5535 is1send(count) = ncont(tileme)%is1(n); ie1send(count) = ncont(tileme)%ie1(n)
5536 je1send(count) = ncont(tileme)%je1(n); js1send(count) = je1send(count) - shalo + 1
5537 is2send(count) = ncont(tileme)%is2(n); ie2send(count) = ncont(tileme)%ie2(n)
5538 je2send(count) = ncont(tileme)%js2(n)-1; js2send(count) = je2send(count) - shalo + 1
5540 rotaterecv(count) = minus_ninety; rotatesend(count) = ninety
5541 is2recv(count) = ncont(tileme)%ie2(n); ie2recv(count) = is2recv(count) + nhalo - 1
5542 js2recv(count) = ncont(tileme)%js2(n); je2recv(count) = ncont(tileme)%je2(n)
5543 is1send(count) = ncont(tileme)%is1(n); ie1send(count) = ncont(tileme)%ie1(n)
5544 je1send(count) = ncont(tileme)%je1(n); js1send(count) = je1send(count) - whalo + 1
5545 ie2send(count) = ncont(tileme)%is2(n)-1; is2send(count) = ie2send(count) - whalo + 1
5546 js2send(count) = ncont(tileme)%js2(n); je2send(count) = ncont(tileme)%je2(n)
5555 if(.NOT. domain%rotated_ninety)
then
5556 call fill_corner_contact(econt, scont, wcont, ncont, isglist, ieglist, jsglist, jeglist, numr, nums, &
5557 tilerecv, tilesend, is1recv, ie1recv, js1recv, je1recv, is2recv, ie2recv, &
5558 js2recv, je2recv, is1send, ie1send, js1send, je1send, is2send, ie2send, &
5559 js2send, je2send, align1recv, align2recv, align1send, align2send, &
5560 whalo, ehalo, shalo, nhalo, tileme )
5563 isc = domain%x(tme)%compute%begin; iec = domain%x(tme)%compute%end
5564 jsc = domain%y(tme)%compute%begin; jec = domain%y(tme)%compute%end
5568 do list = 0, nlist-1
5569 m = mod( domain%pos+list, nlist )
5570 ntilenbr =
size(domain%list(m)%x(:))
5571 do tnbr = 1, ntilenbr
5572 if( domain%list(m)%tile_id(tnbr) .NE. tilesend(n) ) cycle
5573 isc1 = max(isc, is1send(n)); iec1 = min(iec, ie1send(n))
5574 jsc1 = max(jsc, js1send(n)); jec1 = min(jec, je1send(n))
5575 if( isc1 > iec1 .OR. jsc1 > jec1 ) cycle
5581 if( align2send(n) .NE. east ) cycle
5582 isd = domain%list(m)%x(tnbr)%compute%end+1; ied = domain%list(m)%x(tnbr)%compute%end+ehalo
5583 jsd = domain%list(m)%y(tnbr)%compute%begin; jed = domain%list(m)%y(tnbr)%compute%end
5585 isd = domain%list(m)%x(tnbr)%compute%end+1; ied = domain%list(m)%x(tnbr)%compute%end+ehalo
5586 jsd = domain%list(m)%y(tnbr)%compute%begin-shalo; jed = domain%list(m)%y(tnbr)%compute%begin-1
5588 if( align2send(n) .NE. south ) cycle
5589 isd = domain%list(m)%x(tnbr)%compute%begin; ied = domain%list(m)%x(tnbr)%compute%end
5590 jsd = domain%list(m)%y(tnbr)%compute%begin-shalo; jed = domain%list(m)%y(tnbr)%compute%begin-1
5592 isd = domain%list(m)%x(tnbr)%compute%begin-whalo; ied = domain%list(m)%x(tnbr)%compute%begin-1
5593 jsd = domain%list(m)%y(tnbr)%compute%begin-shalo; jed = domain%list(m)%y(tnbr)%compute%begin-1
5595 if( align2send(n) .NE. west ) cycle
5596 isd = domain%list(m)%x(tnbr)%compute%begin-whalo; ied = domain%list(m)%x(tnbr)%compute%begin-1
5597 jsd = domain%list(m)%y(tnbr)%compute%begin; jed = domain%list(m)%y(tnbr)%compute%end
5599 isd = domain%list(m)%x(tnbr)%compute%begin-whalo; ied = domain%list(m)%x(tnbr)%compute%begin-1
5600 jsd = domain%list(m)%y(tnbr)%compute%end+1; jed = domain%list(m)%y(tnbr)%compute%end+nhalo
5602 if( align2send(n) .NE. north ) cycle
5603 isd = domain%list(m)%x(tnbr)%compute%begin; ied = domain%list(m)%x(tnbr)%compute%end
5604 jsd = domain%list(m)%y(tnbr)%compute%end+1; jed = domain%list(m)%y(tnbr)%compute%end+nhalo
5606 isd = domain%list(m)%x(tnbr)%compute%end+1; ied = domain%list(m)%x(tnbr)%compute%end+ehalo
5607 jsd = domain%list(m)%y(tnbr)%compute%end+1; jed = domain%list(m)%y(tnbr)%compute%end+nhalo
5609 isd = max(isd, is2send(n)); ied = min(ied, ie2send(n))
5610 jsd = max(jsd, js2send(n)); jed = min(jed, je2send(n))
5611 if( isd > ied .OR. jsd > jed ) cycle
5615 select case ( align2send(n) )
5617 ioff = isd - is2send(n)
5618 joff = jsd - js2send(n)
5619 case ( south, north )
5620 ioff = isd - is2send(n)
5621 joff = jsd - js2send(n)
5625 select case ( rotatesend(n) )
5627 isc2 = is1send(n) + ioff; iec2 = isc2 + nxd - 1
5628 jsc2 = js1send(n) + joff; jec2 = jsc2 + nyd - 1
5630 iec2 = ie1send(n) - joff; isc2 = iec2 - nyd + 1
5631 jsc2 = js1send(n) + ioff; jec2 = jsc2 + nxd - 1
5632 case ( minus_ninety )
5633 isc2 = is1send(n) + joff; iec2 = isc2 + nyd - 1
5634 jec2 = je1send(n) - ioff; jsc2 = jec2 - nxd + 1
5636 is = max(isc1,isc2); ie = min(iec1,iec2)
5637 js = max(jsc1,jsc2); je = min(jec1,jec2)
5638 if(ie.GE.is .AND. je.GE.js )
then
5639 if(.not.
associated(overlapsend(m)%tileMe))
call allocate_update_overlap(overlapsend(m), &
5641 call insert_overlap_type(overlapsend(m), domain%list(m)%pe, tme, tnbr, &
5642 is, ie, js, je, dir, rotatesend(n), .true. )
5651 do list = 0, nlist-1
5652 m = mod( domain%pos+nlist-list, nlist )
5653 ntilenbr =
size(domain%list(m)%x(:))
5654 do tnbr = 1, ntilenbr
5655 if( domain%list(m)%tile_id(tnbr) .NE. tilerecv(n) ) cycle
5656 isc = domain%list(m)%x(tnbr)%compute%begin; iec = domain%list(m)%x(tnbr)%compute%end
5657 jsc = domain%list(m)%y(tnbr)%compute%begin; jec = domain%list(m)%y(tnbr)%compute%end
5658 isc = max(isc, is2recv(n)); iec = min(iec, ie2recv(n))
5659 jsc = max(jsc, js2recv(n)); jec = min(jec, je2recv(n))
5660 if( isc > iec .OR. jsc > jec ) cycle
5663 nxc = iec - isc + 1; nyc = jec - jsc + 1
5664 select case ( align2recv(n) )
5666 if(align2recv(n) == west)
then
5667 ioff = isc - is2recv(n)
5669 ioff = ie2recv(n) - iec
5671 joff = jsc - js2recv(n)
5672 case ( north, south )
5673 ioff = isc - is2recv(n)
5674 if(align2recv(n) == south)
then
5675 joff = jsc - js2recv(n)
5677 joff = je2recv(n) - jec
5682 select case ( rotaterecv(n) )
5684 isd1 = is1recv(n) + ioff; ied1 = isd1 + nxc - 1
5685 jsd1 = js1recv(n) + joff; jed1 = jsd1 + nyc - 1
5686 if( align1recv(n) == west )
then
5687 ied1 = ie1recv(n)-ioff; isd1 = ied1 - nxc + 1
5689 if( align1recv(n) == south )
then
5690 jed1 = je1recv(n)-joff; jsd1 = jed1 - nyc + 1
5693 if( align1recv(n) == west )
then
5694 ied1 = ie1recv(n)-joff; isd1 = ied1 - nyc + 1
5696 isd1 = is1recv(n)+joff; ied1 = isd1 + nyc - 1
5698 jed1 = je1recv(n) - ioff; jsd1 = jed1 - nxc + 1
5699 case ( minus_ninety )
5700 ied1 = ie1recv(n) - joff; isd1 = ied1 - nyc + 1
5701 if( align1recv(n) == south )
then
5702 jed1 = je1recv(n)-ioff; jsd1 = jed1 - nxc + 1
5704 jsd1 = js1recv(n)+ioff; jed1 = jsd1 + nxc - 1
5712 if( align1recv(n) .NE. east ) cycle
5713 isd2 = domain%x(tme)%compute%end+1; ied2 = domain%x(tme)%domain_data%end
5714 jsd2 = domain%y(tme)%compute%begin; jed2 = domain%y(tme)%compute%end
5716 isd2 = domain%x(tme)%compute%end+1; ied2 = domain%x(tme)%domain_data%end
5717 jsd2 = domain%y(tme)%domain_data%begin; jed2 = domain%y(tme)%compute%begin-1
5719 if( align1recv(n) .NE. south ) cycle
5720 isd2 = domain%x(tme)%compute%begin; ied2 = domain%x(tme)%compute%end
5721 jsd2 = domain%y(tme)%domain_data%begin; jed2 = domain%y(tme)%compute%begin-1
5723 isd2 = domain%x(tme)%domain_data%begin; ied2 = domain%x(tme)%compute%begin-1
5724 jsd2 = domain%y(tme)%domain_data%begin; jed2 = domain%y(tme)%compute%begin-1
5726 if( align1recv(n) .NE. west ) cycle
5727 isd2 = domain%x(tme)%domain_data%begin; ied2 = domain%x(tme)%compute%begin-1
5728 jsd2 = domain%y(tme)%compute%begin; jed2 = domain%y(tme)%compute%end
5730 isd2 = domain%x(tme)%domain_data%begin; ied2 = domain%x(tme)%compute%begin-1
5731 jsd2 = domain%y(tme)%compute%end+1; jed2 = domain%y(tme)%domain_data%end
5733 if( align1recv(n) .NE. north ) cycle
5734 isd2 = domain%x(tme)%compute%begin; ied2 = domain%x(tme)%compute%end
5735 jsd2 = domain%y(tme)%compute%end+1; jed2 = domain%y(tme)%domain_data%end
5737 isd2 = domain%x(tme)%compute%end+1; ied2 = domain%x(tme)%domain_data%end
5738 jsd2 = domain%y(tme)%compute%end+1; jed2 = domain%y(tme)%domain_data%end
5740 is = max(isd1,isd2); ie = min(ied1,ied2)
5741 js = max(jsd1,jsd2); je = min(jed1,jed2)
5742 if(ie.GE.is .AND. je.GE.js )
then
5743 if(.not.
associated(overlaprecv(m)%tileMe))
call allocate_update_overlap(overlaprecv(m), &
5745 call insert_overlap_type(overlaprecv(m), domain%list(m)%pe, tme, tnbr, &
5746 is, ie, js, je, dir, rotaterecv(n), .true.)
5747 count = overlaprecv(m)%count
5756 nsend = 0; nsend2 = 0
5757 do list = 0, nlist-1
5758 m = mod( domain%pos+list, nlist )
5759 if(overlapsend(m)%count>0) nsend = nsend + 1
5762 if(debug_message_passing)
then
5765 do list = 0, nlist-1
5766 m = mod( domain%pos+list, nlist )
5767 if(overlapsend(m)%count==0) cycle
5768 write(iunit, *)
"********to_pe = " ,overlapsend(m)%pe,
" count = ",overlapsend(m)%count
5769 do n = 1, overlapsend(m)%count
5770 write(iunit, *) overlapsend(m)%is(n), overlapsend(m)%ie(n), overlapsend(m)%js(n), overlapsend(m)%je(n), &
5771 overlapsend(m)%dir(n), overlapsend(m)%rotation(n)
5774 if(nsend >0)
flush(iunit)
5777 dirlist(1) = 1; dirlist(2) = 3; dirlist(3) = 5; dirlist(4) = 7
5778 dirlist(5) = 2; dirlist(6) = 4; dirlist(7) = 6; dirlist(8) = 8
5782 if(
associated(domain%update_T%send))
then
5783 do m = 1, domain%update_T%nsend
5784 call deallocate_overlap_type(domain%update_T%send(m))
5786 deallocate(domain%update_T%send)
5788 domain%update_T%nsend = nsend
5789 allocate(domain%update_T%send(nsend))
5790 do list = 0, nlist-1
5791 m = mod( domain%pos+list, nlist )
5792 ntilenbr =
size(domain%list(m)%x(:))
5794 if(overlapsend(m)%count > 0)
then
5796 if(nsend2>nsend)
call mpp_error(fatal, &
5797 "mpp_domains_define.inc(define_contact_point): nsend2 is greater than nsend")
5798 call allocate_update_overlap(domain%update_T%send(nsend2), overlapsend(m)%count)
5800 do tnbr = 1, ntilenbr
5802 if(domain%list(m)%pe == domain%pe)
then
5804 if(tme > ntileme) tme = tme - ntileme
5809 do l = 1, overlapsend(m)%count
5810 if(overlapsend(m)%tileMe(l) .NE. tme) cycle
5811 if(overlapsend(m)%tileNbr(l) .NE. tnbr) cycle
5812 if(overlapsend(m)%dir(l) .NE. dirlist(n) ) cycle
5813 call insert_overlap_type(domain%update_T%send(nsend2), overlapsend(m)%pe, &
5814 overlapsend(m)%tileMe(l), overlapsend(m)%tileNbr(l), overlapsend(m)%is(l), &
5815 overlapsend(m)%ie(l), overlapsend(m)%js(l), overlapsend(m)%je(l), overlapsend(m)%dir(l),&
5816 overlapsend(m)%rotation(l), overlapsend(m)%from_contact(l) )
5825 if(nsend2 .NE. nsend)
call mpp_error(fatal, &
5826 "mpp_domains_define.inc(define_contact_point): nsend2 does not equal to nsend")
5828 nrecv = 0; nrecv2 = 0
5829 do list = 0, nlist-1
5830 m = mod( domain%pos+list, nlist )
5831 if(overlaprecv(m)%count>0) nrecv = nrecv + 1
5834 if(debug_message_passing)
then
5835 do list = 0, nlist-1
5836 m = mod( domain%pos+list, nlist )
5837 if(overlaprecv(m)%count==0) cycle
5838 write(iunit, *)
"********from_pe = " ,overlaprecv(m)%pe,
" count = ",overlaprecv(m)%count
5839 do n = 1, overlaprecv(m)%count
5840 write(iunit, *) overlaprecv(m)%is(n), overlaprecv(m)%ie(n), overlaprecv(m)%js(n), overlaprecv(m)%je(n), &
5841 overlaprecv(m)%dir(n), overlaprecv(m)%rotation(n)
5844 if(nrecv >0)
flush(iunit)
5848 if(
associated(domain%update_T%recv))
then
5849 do m = 1, domain%update_T%nrecv
5850 call deallocate_overlap_type(domain%update_T%recv(m))
5852 deallocate(domain%update_T%recv)
5854 domain%update_T%nrecv = nrecv
5855 allocate(domain%update_T%recv(nrecv))
5857 do list = 0, nlist-1
5858 m = mod( domain%pos+nlist-list, nlist )
5859 ntilenbr =
size(domain%list(m)%x(:))
5860 if(overlaprecv(m)%count > 0)
then
5862 if(nrecv2>nrecv)
call mpp_error(fatal, &
5863 "mpp_domains_define.inc(define_contact_point): nrecv2 is greater than nrecv")
5864 call allocate_update_overlap(domain%update_T%recv(nrecv2), overlaprecv(m)%count)
5868 if(domain%list(m)%pe == domain%pe)
then
5870 if(tnbr>ntilenbr) tnbr = tnbr - ntilenbr
5875 do l = 1, overlaprecv(m)%count
5876 if(overlaprecv(m)%tileMe(l) .NE. tme) cycle
5877 if(overlaprecv(m)%tileNbr(l) .NE. tnbr) cycle
5878 if(overlaprecv(m)%dir(l) .NE. dirlist(n) ) cycle
5879 call insert_overlap_type(domain%update_T%recv(nrecv2), overlaprecv(m)%pe, &
5880 overlaprecv(m)%tileMe(l), overlaprecv(m)%tileNbr(l), overlaprecv(m)%is(l), &
5881 overlaprecv(m)%ie(l), overlaprecv(m)%js(l), overlaprecv(m)%je(l), overlaprecv(m)%dir(l),&
5882 overlaprecv(m)%rotation(l), overlaprecv(m)%from_contact(l))
5883 count = domain%update_T%recv(nrecv2)%count
5892 if(nrecv2 .NE. nrecv)
call mpp_error(fatal, &
5893 "mpp_domains_define.inc(define_contact_point): nrecv2 does not equal to nrecv")
5896 call deallocate_overlap_type(overlapsend(m))
5897 call deallocate_overlap_type(overlaprecv(m))
5901 deallocate(econt(n)%tile, wcont(n)%tile, scont(n)%tile, ncont(n)%tile )
5902 deallocate(econt(n)%align1, wcont(n)%align1, scont(n)%align1, ncont(n)%align1)
5903 deallocate(econt(n)%align2, wcont(n)%align2, scont(n)%align2, ncont(n)%align2)
5904 deallocate(econt(n)%refine1, wcont(n)%refine1, scont(n)%refine1, ncont(n)%refine1)
5905 deallocate(econt(n)%refine2, wcont(n)%refine2, scont(n)%refine2, ncont(n)%refine2)
5906 deallocate(econt(n)%is1, econt(n)%ie1, econt(n)%js1, econt(n)%je1 )
5907 deallocate(econt(n)%is2, econt(n)%ie2, econt(n)%js2, econt(n)%je2 )
5908 deallocate(wcont(n)%is1, wcont(n)%ie1, wcont(n)%js1, wcont(n)%je1 )
5909 deallocate(wcont(n)%is2, wcont(n)%ie2, wcont(n)%js2, wcont(n)%je2 )
5910 deallocate(scont(n)%is1, scont(n)%ie1, scont(n)%js1, scont(n)%je1 )
5911 deallocate(scont(n)%is2, scont(n)%ie2, scont(n)%js2, scont(n)%je2 )
5912 deallocate(ncont(n)%is1, ncont(n)%ie1, ncont(n)%js1, ncont(n)%je1 )
5913 deallocate(ncont(n)%is2, ncont(n)%ie2, ncont(n)%js2, ncont(n)%je2 )
5916 domain%initialized = .true.
5923 subroutine fill_contact(Contact, tile, is1, ie1, js1, je1, is2, ie2, js2, je2, align1, align2, refine1, refine2 )
5924 type(contact_type),
intent(inout) :: Contact
5925 integer,
intent(in) :: tile
5926 integer,
intent(in) :: is1, ie1, js1, je1
5927 integer,
intent(in) :: is2, ie2, js2, je2
5928 integer,
intent(in) :: align1, align2
5929 real,
intent(in) :: refine1, refine2
5932 do pos = 1, contact%ncontact
5935 if( js1 < contact%js1(pos) )
exit
5937 if( is1 < contact%is1(pos) )
exit
5941 contact%ncontact = contact%ncontact + 1
5942 do n = contact%ncontact, pos+1, -1
5943 contact%tile(n) = contact%tile(n-1)
5944 contact%align1(n) = contact%align1(n-1)
5945 contact%align2(n) = contact%align2(n-1)
5946 contact%is1(n) = contact%is1(n-1); contact%ie1(n) = contact%ie1(n-1)
5947 contact%js1(n) = contact%js1(n-1); contact%je1(n) = contact%je1(n-1)
5948 contact%is2(n) = contact%is2(n-1); contact%ie2(n) = contact%ie2(n-1)
5949 contact%js2(n) = contact%js2(n-1); contact%je2(n) = contact%je2(n-1)
5952 contact%tile(pos) = tile
5953 contact%align1(pos) = align1
5954 contact%align2(pos) = align2
5955 contact%refine1(pos) = refine1
5956 contact%refine2(pos) = refine2
5957 contact%is1(pos) = is1; contact%ie1(pos) = ie1
5958 contact%js1(pos) = js1; contact%je1(pos) = je1
5959 contact%is2(pos) = is2; contact%ie2(pos) = ie2
5960 contact%js2(pos) = js2; contact%je2(pos) = je2
5967 type(domain2d),
intent(inout) :: domain
5968 integer,
intent(in) :: position
5970 integer :: ishift, jshift, nlist, list, m, n
5971 integer :: ntileMe, tMe, dir, count, pos, nsend, nrecv
5972 integer :: isoff1, ieoff1, jsoff1, jeoff1
5973 type(overlap_type),
pointer :: ptrIn => null()
5974 type(overlapspec),
pointer :: update_in => null()
5975 type(overlapspec),
pointer :: update_out => null()
5976 type(overlap_type) :: overlapList(0:size(domain%list(:))-1)
5977 type(overlap_type) :: overlap
5980 update_in => domain%update_T
5981 select case(position)
5983 update_out => domain%update_C
5985 update_out => domain%update_E
5987 update_out => domain%update_N
5989 call mpp_error(fatal,
"mpp_domains_define.inc(set_contact_point): the position should be CORNER, EAST or NORTH")
5992 update_out%xbegin = update_in%xbegin; update_out%xend = update_in%xend + ishift
5993 update_out%ybegin = update_in%ybegin; update_out%yend = update_in%yend + jshift
5994 update_out%whalo = update_in%whalo; update_out%ehalo = update_in%ehalo
5995 update_out%shalo = update_in%shalo; update_out%nhalo = update_in%nhalo
5997 nlist =
size(domain%list(:))
5998 ntileme =
size(domain%x(:))
5999 call allocate_update_overlap(overlap, maxoverlap)
6001 call init_overlap_type(overlaplist(m))
6005 nsend = update_out%nsend
6007 pos = update_out%send(m)%pe - mpp_root_pe()
6008 call add_update_overlap(overlaplist(pos), update_out%send(m))
6009 call deallocate_overlap_type(update_out%send(m))
6011 if(
ASSOCIATED(update_out%send) )
deallocate(update_out%send)
6014 nsend = update_in%nsend
6016 ptrin => update_in%send(m)
6017 pos = ptrin%pe - mpp_root_pe()
6018 do n = 1, ptrin%count
6021 if(ptrin%from_contact(n))
then
6024 select case(ptrin%rotation(n))
6026 isoff1 = ishift; ieoff1 = ishift; jsoff1 = 0; jeoff1 = jshift
6028 isoff1 = 0; ieoff1 = jshift; jsoff1 = ishift; jeoff1 = ishift
6031 select case(ptrin%rotation(n))
6033 isoff1 = ishift; ieoff1 = ishift; jsoff1 = 0; jeoff1 = 0
6035 isoff1 = jshift; ieoff1 = jshift; jsoff1 = ishift; jeoff1 = ishift
6037 isoff1 = 0; ieoff1 = 0; jsoff1 = 0; jeoff1 = 0
6040 select case(ptrin%rotation(n))
6042 isoff1 = 0; ieoff1 = ishift; jsoff1 = 0; jeoff1 = 0
6044 isoff1 = 0; ieoff1 = 0; jsoff1 = 0; jeoff1 = ishift
6047 select case(ptrin%rotation(n))
6049 isoff1 = 0; ieoff1 = 0; jsoff1 = 0; jeoff1 = 0
6051 isoff1 = jshift; ieoff1 = jshift; jsoff1 = 0; jeoff1 = 0
6053 isoff1 = 0; ieoff1 = 0; jsoff1 = ishift; jeoff1 = ishift
6056 select case(ptrin%rotation(n))
6058 isoff1 = 0; ieoff1 = 0; jsoff1 = 0; jeoff1 = jshift
6060 isoff1 = 0; ieoff1 = jshift; jsoff1 = 0; jeoff1 = 0
6063 select case(ptrin%rotation(n))
6065 isoff1 = 0; ieoff1 = 0; jsoff1 = jshift; jeoff1 = jshift
6067 isoff1 = 0; ieoff1 = 0; jsoff1 = 0; jeoff1 = 0
6069 isoff1 = jshift; ieoff1 = jshift; jsoff1 = ishift; jeoff1 = ishift
6072 select case(ptrin%rotation(n))
6074 isoff1 = 0; ieoff1 = ishift; jsoff1 = jshift; jeoff1 = jshift
6076 isoff1 = jshift; ieoff1 = jshift; jsoff1 = 0; jeoff1 = ishift
6079 select case(ptrin%rotation(n))
6081 isoff1 = ishift; ieoff1 = ishift; jsoff1 = jshift; jeoff1 = jshift
6083 isoff1 = 0; ieoff1 = 0; jsoff1 = ishift; jeoff1 = ishift
6085 isoff1 = jshift; ieoff1 = jshift; jsoff1 = 0; jeoff1 = 0
6088 call insert_overlap_type(overlap, ptrin%pe, ptrin%tileMe(n), ptrin%tileNbr(n), &
6089 ptrin%is(n) + isoff1, ptrin%ie(n) + ieoff1, ptrin%js(n) + jsoff1, &
6090 ptrin%je(n) + jeoff1, ptrin%dir(n), ptrin%rotation(n), ptrin%from_contact(n))
6093 if(overlap%count > 0)
then
6094 call add_update_overlap(overlaplist(pos), overlap)
6095 call init_overlap_type(overlap)
6100 do list = 0, nlist-1
6101 m = mod( domain%pos+list, nlist )
6102 if(overlaplist(m)%count>0) nsend = nsend+1
6105 update_out%nsend = nsend
6107 if (
associated(update_out%send))
deallocate(update_out%send)
6108 allocate(update_out%send(nsend))
6110 do list = 0, nlist-1
6111 m = mod( domain%pos+list, nlist )
6112 if(overlaplist(m)%count>0)
then
6114 if(pos>nsend)
call mpp_error(fatal, &
6115 "mpp_domains_define.inc(set_contact_point): pos should be no larger than nsend")
6116 call add_update_overlap(update_out%send(pos), overlaplist(m))
6117 call deallocate_overlap_type(overlaplist(m))
6120 if(pos .NE. nsend)
call mpp_error(fatal, &
6121 "mpp_domains_define.inc(set_contact_point): pos should equal to nsend")
6127 nrecv = update_out%nrecv
6129 pos = update_out%recv(m)%pe - mpp_root_pe()
6130 call add_update_overlap(overlaplist(pos), update_out%recv(m))
6131 call deallocate_overlap_type(update_out%recv(m))
6133 if(
ASSOCIATED(update_out%recv) )
deallocate(update_out%recv)
6136 nrecv = update_in%nrecv
6138 ptrin => update_in%recv(m)
6139 pos = ptrin%pe - mpp_root_pe()
6140 do n = 1, ptrin%count
6143 if(ptrin%from_contact(n))
then
6146 isoff1 = ishift; ieoff1 = ishift; jsoff1 = 0; jeoff1 = jshift
6148 isoff1 = ishift; ieoff1 = ishift; jsoff1 = 0; jeoff1 = 0
6150 isoff1 = 0; ieoff1 = ishift; jsoff1 = 0; jeoff1 = 0
6152 isoff1 = 0; ieoff1 = 0; jsoff1 = 0; jeoff1 = 0
6154 isoff1 = 0; ieoff1 = 0; jsoff1 = 0; jeoff1 = jshift
6156 isoff1 = 0; ieoff1 = 0; jsoff1 = jshift; jeoff1 = jshift
6158 isoff1 = 0; ieoff1 = ishift; jsoff1 = jshift; jeoff1 = jshift
6160 isoff1 = ishift; ieoff1 = ishift; jsoff1 = jshift; jeoff1 = jshift
6162 call insert_overlap_type(overlap, ptrin%pe, ptrin%tileMe(n), ptrin%tileNbr(n), &
6163 ptrin%is(n) + isoff1, ptrin%ie(n) + ieoff1, ptrin%js(n) + jsoff1, &
6164 ptrin%je(n) + jeoff1, ptrin%dir(n), ptrin%rotation(n), ptrin%from_contact(n))
6165 count = overlap%count
6168 if(overlap%count > 0)
then
6169 call add_update_overlap(overlaplist(pos), overlap)
6170 call init_overlap_type(overlap)
6172 do tme = 1,
size(domain%x(:))
6173 do n = 1, overlap%count
6174 if(overlap%tileMe(n) == tme)
then
6175 if(overlap%dir(n) == 1 ) domain%x(tme)%loffset = 0
6176 if(overlap%dir(n) == 7 ) domain%y(tme)%loffset = 0
6183 do list = 0, nlist-1
6184 m = mod( domain%pos+nlist-list, nlist )
6185 if(overlaplist(m)%count>0) nrecv = nrecv+1
6188 update_out%nrecv = nrecv
6190 if (
associated(update_out%recv))
deallocate(update_out%recv)
6191 allocate(update_out%recv(nrecv))
6193 do list = 0, nlist-1
6194 m = mod( domain%pos+nlist-list, nlist )
6195 if(overlaplist(m)%count>0)
then
6197 if(pos>nrecv)
call mpp_error(fatal, &
6198 "mpp_domains_define.inc(set_contact_point): pos should be no larger than nrecv")
6199 call add_update_overlap(update_out%recv(pos), overlaplist(m))
6200 call deallocate_overlap_type(overlaplist(m))
6203 if(pos .NE. nrecv)
call mpp_error(fatal, &
6204 "mpp_domains_define.inc(set_contact_point): pos should equal to nrecv")
6207 call deallocate_overlap_type(overlap)
6215 type(domain2d),
intent(in) :: domain
6216 integer,
intent(in) :: position
6217 integer :: nlist, m, n
6218 integer,
parameter :: MAXCOUNT = 100
6219 integer :: is, ie, js, je
6220 integer :: nsend, nrecv, pos, maxsize, rotation
6221 type(overlap_type) :: overlap
6222 type(overlapspec),
pointer :: update => null()
6223 type(overlapspec),
pointer :: check => null()
6225 select case(position)
6227 update => domain%update_C
6228 check => domain%check_C
6230 update => domain%update_E
6231 check => domain%check_E
6233 update => domain%update_N
6234 check => domain%check_N
6236 call mpp_error(fatal,
"mpp_domains_define.inc(set_check_overlap): position should be CORNER, EAST or NORTH")
6239 check%xbegin = update%xbegin; check%xend = update%xend
6240 check%ybegin = update%ybegin; check%yend = update%yend
6243 if( .NOT. domain%symmetry )
return
6247 do m = 1, update%nsend
6248 do n = 1, update%send(m)%count
6249 if( update%send(m)%rotation(n) == one_hundred_eighty ) cycle
6250 if( ( (position == east .OR. position == corner) .AND. update%send(m)%dir(n) == 1 ) .OR. &
6251 ( (position == north .OR. position == corner) .AND. update%send(m)%dir(n) == 7 ) )
then
6252 maxsize = max(maxsize, update%send(m)%count)
6260 if (
associated(check%send))
deallocate(check%send)
6261 allocate(check%send(nsend))
6262 call allocate_check_overlap(overlap, maxsize)
6266 nlist =
size(domain%list(:))
6269 do m = 1, update%nsend
6270 do n = 1, update%send(m)%count
6271 if( update%send(m)%rotation(n) == one_hundred_eighty ) cycle
6273 if( (position == east .OR. position == corner) .AND. update%send(m)%dir(n) == 1 )
then
6274 rotation = update%send(m)%rotation(n)
6275 select case( rotation )
6277 is = update%send(m)%is(n) - 1
6279 js = update%send(m)%js(n)
6280 je = update%send(m)%je(n)
6282 is = update%send(m)%is(n)
6283 ie = update%send(m)%ie(n)
6284 js = update%send(m)%js(n) - 1
6287 call insert_check_overlap(overlap, update%send(m)%pe, &
6288 update%send(m)%tileMe(n), 1, rotation, is, ie, js, je)
6292 if( (position == north .OR. position == corner) .AND. update%send(m)%dir(n) == 7 )
then
6293 rotation = update%send(m)%rotation(n)
6294 select case( rotation )
6296 is = update%send(m)%is(n)
6297 ie = update%send(m)%ie(n)
6298 js = update%send(m)%js(n) - 1
6300 case( minus_ninety )
6301 is = update%send(m)%is(n) - 1
6303 js = update%send(m)%js(n)
6304 je = update%send(m)%je(n)
6306 call insert_check_overlap(overlap, update%send(m)%pe, &
6307 update%send(m)%tileMe(n), 4, rotation, is, ie, js, je)
6310 if(overlap%count>0)
then
6312 if(pos>nsend)
call mpp_error(fatal,
"mpp_domains_define.inc(set_check_overlap): pos is greater than nsend")
6314 call init_overlap_type(overlap)
6318 if(pos .NE. nsend)
call mpp_error(fatal,
"mpp_domains_define.inc(set_check_overlap): pos is greater than nsend")
6322 do m = 1, update%nrecv
6323 do n = 1, update%recv(m)%count
6324 if( update%recv(m)%rotation(n) == one_hundred_eighty ) cycle
6325 if( ( (position == east .OR. position == corner) .AND. update%recv(m)%dir(n) == 1 ) .OR. &
6326 ( (position == north .OR. position == corner) .AND. update%recv(m)%dir(n) == 7 ) )
then
6327 maxsize = max(maxsize, update%recv(m)%count)
6334 if(nsend>0)
call deallocate_overlap_type(overlap)
6337 if (
associated(check%recv))
deallocate(check%recv)
6338 allocate(check%recv(nrecv))
6339 call allocate_check_overlap(overlap, maxsize)
6343 do m = 1, update%nrecv
6344 do n = 1, update%recv(m)%count
6345 if( update%recv(m)%rotation(n) == one_hundred_eighty ) cycle
6346 if( (position == east .OR. position == corner) .AND. update%recv(m)%dir(n) == 1 )
then
6347 is = update%recv(m)%is(n) - 1
6349 js = update%recv(m)%js(n)
6350 je = update%recv(m)%je(n)
6351 call insert_check_overlap(overlap, update%recv(m)%pe, &
6352 update%recv(m)%tileMe(n), 1, update%recv(m)%rotation(n), is, ie, js, je)
6354 if( (position == north .OR. position == corner) .AND. update%recv(m)%dir(n) == 7 )
then
6355 is = update%recv(m)%is(n)
6356 ie = update%recv(m)%ie(n)
6357 js = update%recv(m)%js(n) - 1
6359 call insert_check_overlap(overlap, update%recv(m)%pe, &
6360 update%recv(m)%tileMe(n), 3, update%recv(m)%rotation(n), is, ie, js, je)
6363 if(overlap%count>0)
then
6365 if(pos>nrecv)
call mpp_error(fatal,
"mpp_domains_define.inc(set_check_overlap): pos is greater than nrecv")
6367 call init_overlap_type(overlap)
6371 if(pos .NE. nrecv)
call mpp_error(fatal,
"mpp_domains_define.inc(set_check_overlap): pos is greater than nrecv")
6372 if(nrecv>0)
call deallocate_overlap_type(overlap)
6379 type(domain2d),
intent(inout) :: domain
6380 integer,
intent(in) :: position
6381 integer :: m, n, l, count, dr, tMe
6382 integer,
parameter :: MAXCOUNT = 100
6383 integer,
dimension(MAXCOUNT) :: dir, rotation, is, ie, js, je, tileMe, index
6384 integer,
dimension(size(domain%x(:)), 4) :: nrecvl
6385 integer,
dimension(size(domain%x(:)), 4, MAXCOUNT) :: isl, iel, jsl, jel
6386 type(overlap_type),
pointer :: overlap => null()
6387 type(overlapspec),
pointer :: update => null()
6388 type(overlapspec),
pointer :: bound => null()
6389 integer :: nlist_send, nlist_recv, ishift, jshift
6390 integer :: ism, iem, jsm, jem, nsend, nrecv
6391 integer :: isg, ieg, jsg, jeg, nlist, list
6392 integer :: npes_x, npes_y, ipos, jpos, inbr, jnbr
6393 integer :: isc, iec, jsc, jec, my_pe
6394 integer :: pe_south1, pe_south2, pe_west0, pe_west1, pe_west2
6395 integer :: is_south1, ie_south1, js_south1, je_south1
6396 integer :: is_south2, ie_south2, js_south2, je_south2
6397 integer :: is_west0, ie_west0, js_west0, je_west0
6398 integer :: is_west1, ie_west1, js_west1, je_west1
6399 integer :: is_west2, ie_west2, js_west2, je_west2
6400 logical :: x_cyclic, y_cyclic, folded_north
6402 is_south1=0; ie_south1=0; js_south1=0; je_south1=0
6403 is_south2=0; ie_south2=0; js_south2=0; je_south2=0
6404 is_west0=0; ie_west0=0; js_west0=0; je_west0=0
6405 is_west1=0; ie_west1=0; js_west1=0; je_west1=0
6406 is_west2=0; ie_west2=0; js_west2=0; je_west2=0
6409 if( position == center .OR. .NOT. domain%symmetry )
return
6411 call mpp_get_global_domain(domain, isg, ieg, jsg, jeg)
6412 call mpp_get_memory_domain ( domain, ism, iem, jsm, jem )
6414 select case(position)
6416 update => domain%update_C
6417 bound => domain%bound_C
6419 update => domain%update_E
6420 bound => domain%bound_E
6422 update => domain%update_N
6423 bound => domain%bound_N
6425 call mpp_error( fatal,
"mpp_domains_mod(set_bound_overlap): invalid option of position")
6428 bound%xbegin = ism; bound%xend = iem + ishift
6429 bound%ybegin = jsm; bound%yend = jem + jshift
6431 nlist_send = max(update%nsend,4)
6432 nlist_recv = max(update%nrecv,4)
6433 bound%nsend = nlist_send
6434 bound%nrecv = nlist_recv
6435 if(nlist_send >0)
then
6436 if (
associated(bound%send))
deallocate(bound%send)
6437 allocate(bound%send(nlist_send))
6438 bound%send(:)%count = 0
6440 if(nlist_recv >0)
then
6441 if (
associated(bound%recv))
deallocate(bound%recv)
6442 allocate(bound%recv(nlist_recv))
6443 bound%recv(:)%count = 0
6446 nlist =
size(domain%list(:))
6448 npes_x =
size(domain%x(1)%list(:))
6449 npes_y =
size(domain%y(1)%list(:))
6450 x_cyclic = domain%x(1)%cyclic
6451 y_cyclic = domain%y(1)%cyclic
6452 folded_north = btest(domain%fold,north)
6453 ipos = domain%x(1)%pos
6454 jpos = domain%y(1)%pos
6455 isc = domain%x(1)%compute%begin; iec = domain%x(1)%compute%end
6456 jsc = domain%y(1)%compute%begin; jec = domain%y(1)%compute%end
6459 if(domain%ntiles == 1)
then
6463 pe_south1 = null_pe; pe_south2 = null_pe
6464 if( position == north .OR. position == corner )
then
6465 inbr = ipos; jnbr = jpos + 1
6466 if( jnbr == npes_y .AND. y_cyclic) jnbr = 0
6467 if( inbr .GE. 0 .AND. inbr .LT. npes_x .AND. jnbr .GE. 0 .AND. jnbr .LT. npes_y )
then
6468 pe_south1 = domain%pearray(inbr,jnbr)
6469 is_south1 = isc + ishift; ie_south1 = iec+ishift
6470 js_south1 = jec + jshift; je_south1 = js_south1
6474 if( position == corner )
then
6475 inbr = ipos + 1; jnbr = jpos + 1
6476 if( inbr == npes_x .AND. x_cyclic) inbr = 0
6477 if( jnbr == npes_y .AND. y_cyclic) jnbr = 0
6478 if( inbr .GE. 0 .AND. inbr .LT. npes_x .AND. jnbr .GE. 0 .AND. jnbr .LT. npes_y )
then
6479 pe_south2 = domain%pearray(inbr,jnbr)
6480 is_south2 = iec + ishift; ie_south2 = is_south2
6481 js_south2 = jec + jshift; je_south2 = js_south2
6486 pe_west0 = null_pe; pe_west1 = null_pe; pe_west2 = null_pe
6487 if( position == east )
then
6488 inbr = ipos+1; jnbr = jpos
6489 if( inbr == npes_x .AND. x_cyclic) inbr = 0
6490 if( inbr .GE. 0 .AND. inbr .LT. npes_x .AND. jnbr .GE. 0 .AND. jnbr .LT. npes_y )
then
6491 pe_west1 = domain%pearray(inbr,jnbr)
6492 is_west1 = iec + ishift; ie_west1 = is_west1
6493 js_west1 = jsc + jshift; je_west1 = jec + jshift
6495 else if ( position == corner )
then
6497 if( folded_north .AND. jec == jeg .AND. ipos .LT. (npes_x-1)/2 )
then
6498 inbr = npes_x - ipos - 1; jnbr = jpos
6499 if( inbr .GE. 0 .AND. inbr .LT. npes_x .AND. jnbr .GE. 0 .AND. jnbr .LT. npes_y )
then
6500 pe_west0 = domain%pearray(inbr,jnbr)
6501 is_west0 = iec+ishift; ie_west0 = is_west0
6502 js_west0 = jec+jshift; je_west0 = js_west0
6506 if( folded_north .AND. jec == jeg .AND. ipos .GE. npes_x/2 .AND. ipos .LT. (npes_x-1) )
then
6507 inbr = ipos+1; jnbr = jpos
6508 if( inbr == npes_x .AND. x_cyclic) inbr = 0
6509 if( inbr .GE. 0 .AND. inbr .LT. npes_x .AND. jnbr .GE. 0 .AND. jnbr .LT. npes_y )
then
6510 pe_west1 = domain%pearray(inbr,jnbr)
6511 is_west1 = iec + ishift; ie_west1 = is_west1
6512 js_west1 = jsc + jshift; je_west1 = jec
6515 inbr = ipos+1; jnbr = jpos
6516 if( inbr == npes_x .AND. x_cyclic) inbr = 0
6517 if( inbr .GE. 0 .AND. inbr .LT. npes_x .AND. jnbr .GE. 0 .AND. jnbr .LT. npes_y )
then
6518 pe_west1 = domain%pearray(inbr,jnbr)
6519 is_west1 = iec + ishift; ie_west1 = is_west1
6520 js_west1 = jsc + jshift; je_west1 = jec + jshift
6525 if( position == corner )
then
6526 inbr = ipos + 1; jnbr = jpos + 1
6527 if( inbr == npes_x .AND. x_cyclic) inbr = 0
6528 if( jnbr == npes_y .AND. y_cyclic) jnbr = 0
6529 if( inbr .GE. 0 .AND. inbr .LT. npes_x .AND. jnbr .GE. 0 .AND. jnbr .LT. npes_y )
then
6530 pe_west2 = domain%pearray(inbr,jnbr)
6531 is_west2 = iec + ishift; ie_west2 = is_west2
6532 js_west2 = jec + jshift; je_west2 = js_west2
6537 m = mod( domain%pos+list, nlist )
6539 my_pe = domain%list(m)%pe
6540 if(my_pe == pe_south1)
then
6542 is(count) = is_south1; ie(count) = ie_south1
6543 js(count) = js_south1; je(count) = je_south1
6545 rotation(count) = zero
6547 if(my_pe == pe_south2)
then
6549 is(count) = is_south2; ie(count) = ie_south2
6550 js(count) = js_south2; je(count) = je_south2
6552 rotation(count) = zero
6555 if(my_pe == pe_west0)
then
6557 is(count) = is_west0; ie(count) = ie_west0
6558 js(count) = js_west0; je(count) = je_west0
6560 rotation(count) = one_hundred_eighty
6562 if(my_pe == pe_west1)
then
6564 is(count) = is_west1; ie(count) = ie_west1
6565 js(count) = js_west1; je(count) = je_west1
6567 rotation(count) = zero
6569 if(my_pe == pe_west2)
then
6571 is(count) = is_west2; ie(count) = ie_west2
6572 js(count) = js_west2; je(count) = je_west2
6574 rotation(count) = zero
6579 if(nsend > nlist_send)
call mpp_error(fatal,
"set_bound_overlap: nsend > nlist_send")
6580 bound%send(nsend)%count = count
6581 bound%send(nsend)%pe = my_pe
6582 if (
associated(bound%send(nsend)%is))
deallocate(bound%send(nsend)%is)
6583 if (
associated(bound%send(nsend)%ie))
deallocate(bound%send(nsend)%ie)
6584 if (
associated(bound%send(nsend)%js))
deallocate(bound%send(nsend)%js)
6585 if (
associated(bound%send(nsend)%je))
deallocate(bound%send(nsend)%je)
6586 if (
associated(bound%send(nsend)%dir))
deallocate(bound%send(nsend)%dir)
6587 if (
associated(bound%send(nsend)%rotation))
deallocate(bound%send(nsend)%rotation)
6588 if (
associated(bound%send(nsend)%tileMe))
deallocate(bound%send(nsend)%tileMe)
6589 allocate(bound%send(nsend)%is(count), bound%send(nsend)%ie(count) )
6590 allocate(bound%send(nsend)%js(count), bound%send(nsend)%je(count) )
6591 allocate(bound%send(nsend)%dir(count), bound%send(nsend)%rotation(count) )
6592 allocate(bound%send(nsend)%tileMe(count))
6593 bound%send(nsend)%is(:) = is(1:count)
6594 bound%send(nsend)%ie(:) = ie(1:count)
6595 bound%send(nsend)%js(:) = js(1:count)
6596 bound%send(nsend)%je(:) = je(1:count)
6597 bound%send(nsend)%dir(:) = dir(1:count)
6598 bound%send(nsend)%tileMe(:) = 1
6599 bound%send(nsend)%rotation(:) = rotation(1:count)
6604 do m = 1, update%nsend
6605 overlap => update%send(m)
6606 if( overlap%count == 0 ) cycle
6608 do n = 1, overlap%count
6610 if( overlap%rotation(n) == one_hundred_eighty ) cycle
6611 if( (position == east .OR. position == corner) .AND. overlap%dir(n) == 1)
then
6614 rotation(count) = overlap%rotation(n)
6615 tileme(count) = overlap%tileMe(n)
6616 select case( rotation(count) )
6618 is(count) = overlap%is(n) - 1
6619 ie(count) = is(count)
6620 js(count) = overlap%js(n)
6621 je(count) = overlap%je(n)
6623 is(count) = overlap%is(n)
6624 ie(count) = overlap%ie(n)
6625 js(count) = overlap%js(n) - 1
6626 je(count) = js(count)
6629 if( (position == north .OR. position == corner) .AND. overlap%dir(n) == 3 )
then
6632 rotation(count) = overlap%rotation(n)
6633 tileme(count) = overlap%tileMe(n)
6634 select case( rotation(count) )
6636 is(count) = overlap%is(n)
6637 ie(count) = overlap%ie(n)
6638 js(count) = overlap%je(n) + 1
6639 je(count) = js(count)
6640 case( minus_ninety )
6641 is(count) = overlap%ie(n) + 1
6642 ie(count) = is(count)
6643 js(count) = overlap%js(n)
6644 je(count) = overlap%je(n)
6647 if( (position == east .OR. position == corner) .AND. overlap%dir(n) == 5 )
then
6650 rotation(count) = overlap%rotation(n)
6651 tileme(count) = overlap%tileMe(n)
6652 select case( rotation(count) )
6654 is(count) = overlap%ie(n) + 1
6655 ie(count) = is(count)
6656 js(count) = overlap%js(n)
6657 je(count) = overlap%je(n)
6659 is(count) = overlap%is(n)
6660 ie(count) = overlap%ie(n)
6661 js(count) = overlap%je(n) + 1
6662 je(count) = js(count)
6665 if( (position == north .OR. position == corner) .AND. overlap%dir(n) == 7 )
then
6668 rotation(count) = overlap%rotation(n)
6669 tileme(count) = overlap%tileMe(n)
6670 select case( rotation(count) )
6672 is(count) = overlap%is(n)
6673 ie(count) = overlap%ie(n)
6674 js(count) = overlap%js(n) - 1
6675 je(count) = js(count)
6676 case( minus_ninety )
6677 is(count) = overlap%is(n) - 1
6678 ie(count) = is(count)
6679 js(count) = overlap%js(n)
6680 je(count) = overlap%je(n)
6686 bound%send(nsend)%count = count
6687 bound%send(nsend)%pe = overlap%pe
6688 if (
associated(bound%send(nsend)%is))
deallocate(bound%send(nsend)%is)
6689 if (
associated(bound%send(nsend)%ie))
deallocate(bound%send(nsend)%ie)
6690 if (
associated(bound%send(nsend)%js))
deallocate(bound%send(nsend)%js)
6691 if (
associated(bound%send(nsend)%je))
deallocate(bound%send(nsend)%je)
6692 if (
associated(bound%send(nsend)%dir))
deallocate(bound%send(nsend)%dir)
6693 if (
associated(bound%send(nsend)%rotation))
deallocate(bound%send(nsend)%rotation)
6694 if (
associated(bound%send(nsend)%tileMe))
deallocate(bound%send(nsend)%tileMe)
6695 allocate(bound%send(nsend)%is(count), bound%send(nsend)%ie(count) )
6696 allocate(bound%send(nsend)%js(count), bound%send(nsend)%je(count) )
6697 allocate(bound%send(nsend)%dir(count), bound%send(nsend)%rotation(count) )
6698 allocate(bound%send(nsend)%tileMe(count))
6699 bound%send(nsend)%is(:) = is(1:count)
6700 bound%send(nsend)%ie(:) = ie(1:count)
6701 bound%send(nsend)%js(:) = js(1:count)
6702 bound%send(nsend)%je(:) = je(1:count)
6703 bound%send(nsend)%dir(:) = dir(1:count)
6704 bound%send(nsend)%tileMe(:) = tileme(1:count)
6705 bound%send(nsend)%rotation(:) = rotation(1:count)
6716 if( domain%ntiles == 1 )
then
6720 pe_south1 = null_pe; pe_south2 = null_pe
6721 if( position == north .OR. position == corner )
then
6722 inbr = ipos; jnbr = jpos - 1
6723 if( jnbr == -1 .AND. y_cyclic) jnbr = npes_y-1
6724 if( inbr .GE. 0 .AND. inbr .LT. npes_x .AND. jnbr .GE. 0 .AND. jnbr .LT. npes_y )
then
6725 pe_south1 = domain%pearray(inbr,jnbr)
6726 is_south1 = isc + ishift; ie_south1 = iec+ishift
6727 js_south1 = jsc; je_south1 = js_south1
6732 if( position == corner )
then
6733 inbr = ipos - 1; jnbr = jpos - 1
6734 if( inbr == -1 .AND. x_cyclic) inbr = npes_x-1
6735 if( jnbr == -1 .AND. y_cyclic) jnbr = npes_y-1
6736 if( inbr .GE. 0 .AND. inbr .LT. npes_x .AND. jnbr .GE. 0 .AND. jnbr .LT. npes_y )
then
6737 pe_south2 = domain%pearray(inbr,jnbr)
6738 is_south2 = isc; ie_south2 = is_south2
6739 js_south2 = jsc; je_south2 = js_south2
6745 pe_west0 = null_pe; pe_west1 = null_pe; pe_west2 = null_pe
6746 if( position == east )
then
6747 inbr = ipos-1; jnbr = jpos
6748 if( inbr == -1 .AND. x_cyclic) inbr = npes_x-1
6749 if( inbr .GE. 0 .AND. inbr .LT. npes_x .AND. jnbr .GE. 0 .AND. jnbr .LT. npes_y )
then
6750 pe_west1 = domain%pearray(inbr,jnbr)
6751 is_west1 = isc; ie_west1 = is_west1
6752 js_west1 = jsc + jshift; je_west1 = jec + jshift
6754 else if ( position == corner )
then
6756 if( folded_north .AND. jec == jeg .AND. ipos .GT. npes_x/2 )
then
6757 inbr = npes_x - ipos - 1; jnbr = jpos
6758 if( inbr .GE. 0 .AND. inbr .LT. npes_x .AND. jnbr .GE. 0 .AND. jnbr .LT. npes_y )
then
6759 pe_west0 = domain%pearray(inbr,jnbr)
6760 is_west0 = isc; ie_west0 = is_west0
6761 js_west0 = jec+jshift; je_west0 = js_west0
6763 inbr = ipos-1; jnbr = jpos
6764 if( inbr == -1 .AND. x_cyclic) inbr = npes_x-1
6765 if( inbr .GE. 0 .AND. inbr .LT. npes_x .AND. jnbr .GE. 0 .AND. jnbr .LT. npes_y )
then
6766 pe_west1 = domain%pearray(inbr,jnbr)
6767 is_west1 = isc; ie_west1 = is_west1
6768 js_west1 = jsc + jshift; je_west1 = jec
6771 inbr = ipos-1; jnbr = jpos
6772 if( inbr == -1 .AND. x_cyclic) inbr = npes_x-1
6773 if( inbr .GE. 0 .AND. inbr .LT. npes_x .AND. jnbr .GE. 0 .AND. jnbr .LT. npes_y )
then
6774 pe_west1 = domain%pearray(inbr,jnbr)
6775 is_west1 = isc; ie_west1 = is_west1
6776 js_west1 = jsc + jshift; je_west1 = jec+jshift
6782 if( position == corner )
then
6783 inbr = ipos - 1; jnbr = jpos - 1
6784 if( inbr == -1 .AND. x_cyclic) inbr = npes_x - 1
6785 if( jnbr == -1 .AND. y_cyclic) jnbr = npes_y - 1
6786 if( inbr .GE. 0 .AND. inbr .LT. npes_x .AND. jnbr .GE. 0 .AND. jnbr .LT. npes_y )
then
6787 pe_west2 = domain%pearray(inbr,jnbr)
6788 is_west2 = isc; ie_west2 = is_west2
6789 js_west2 = jsc; je_west2 = js_west2
6795 m = mod( domain%pos+nlist-list, nlist )
6797 my_pe = domain%list(m)%pe
6798 if(my_pe == pe_south1)
then
6800 is(count) = is_south1; ie(count) = ie_south1
6801 js(count) = js_south1; je(count) = je_south1
6803 rotation(count) = zero
6804 index(count) = 1 + ishift
6806 if(my_pe == pe_south2)
then
6808 is(count) = is_south2; ie(count) = ie_south2
6809 js(count) = js_south2; je(count) = je_south2
6811 rotation(count) = zero
6814 if(my_pe == pe_west0)
then
6816 is(count) = is_west0; ie(count) = ie_west0
6817 js(count) = js_west0; je(count) = je_west0
6819 rotation(count) = one_hundred_eighty
6820 index(count) = jec-jsc+1+jshift
6822 if(my_pe == pe_west1)
then
6824 is(count) = is_west1; ie(count) = ie_west1
6825 js(count) = js_west1; je(count) = je_west1
6827 rotation(count) = zero
6828 index(count) = 1 + jshift
6830 if(my_pe == pe_west2)
then
6832 is(count) = is_west2; ie(count) = ie_west2
6833 js(count) = js_west2; je(count) = je_west2
6835 rotation(count) = zero
6841 if(nrecv > nlist_recv)
call mpp_error(fatal,
"set_bound_overlap: nrecv > nlist_recv")
6842 bound%recv(nrecv)%count = count
6843 bound%recv(nrecv)%pe = my_pe
6844 if (
associated(bound%recv(nrecv)%is))
deallocate(bound%recv(nrecv)%is)
6845 if (
associated(bound%recv(nrecv)%ie))
deallocate(bound%recv(nrecv)%ie)
6846 if (
associated(bound%recv(nrecv)%js))
deallocate(bound%recv(nrecv)%js)
6847 if (
associated(bound%recv(nrecv)%je))
deallocate(bound%recv(nrecv)%je)
6848 if (
associated(bound%recv(nrecv)%dir))
deallocate(bound%recv(nrecv)%dir)
6849 if (
associated(bound%recv(nrecv)%index))
deallocate(bound%recv(nrecv)%index)
6850 if (
associated(bound%recv(nrecv)%tileMe))
deallocate(bound%recv(nrecv)%tileMe)
6851 if (
associated(bound%recv(nrecv)%rotation))
deallocate(bound%recv(nrecv)%rotation)
6852 allocate(bound%recv(nrecv)%is(count), bound%recv(nrecv)%ie(count) )
6853 allocate(bound%recv(nrecv)%js(count), bound%recv(nrecv)%je(count) )
6854 allocate(bound%recv(nrecv)%dir(count), bound%recv(nrecv)%index(count) )
6855 allocate(bound%recv(nrecv)%tileMe(count), bound%recv(nrecv)%rotation(count) )
6857 bound%recv(nrecv)%is(:) = is(1:count)
6858 bound%recv(nrecv)%ie(:) = ie(1:count)
6859 bound%recv(nrecv)%js(:) = js(1:count)
6860 bound%recv(nrecv)%je(:) = je(1:count)
6861 bound%recv(nrecv)%dir(:) = dir(1:count)
6862 bound%recv(nrecv)%tileMe(:) = 1
6863 bound%recv(nrecv)%rotation(:) = rotation(1:count)
6864 bound%recv(nrecv)%index(:) = index(1:count)
6868 do m = 1, update%nrecv
6869 overlap => update%recv(m)
6870 if( overlap%count == 0 ) cycle
6872 do n = 1, overlap%count
6874 if( overlap%rotation(n) == one_hundred_eighty ) cycle
6875 if( (position == east .OR. position == corner) .AND. overlap%dir(n) == 1)
then
6878 rotation(count) = overlap%rotation(n)
6879 tileme(count) = overlap%tileMe(n)
6880 is(count) = overlap%is(n) - 1
6881 ie(count) = is(count)
6882 js(count) = overlap%js(n)
6883 je(count) = overlap%je(n)
6885 nrecvl(tme, 1) = nrecvl(tme,1) + 1
6886 isl(tme,1,nrecvl(tme, 1)) = is(count)
6887 iel(tme,1,nrecvl(tme, 1)) = ie(count)
6888 jsl(tme,1,nrecvl(tme, 1)) = js(count)
6889 jel(tme,1,nrecvl(tme, 1)) = je(count)
6892 if( (position == north .OR. position == corner) .AND. overlap%dir(n) == 3)
then
6895 rotation(count) = overlap%rotation(n)
6896 tileme(count) = overlap%tileMe(n)
6897 is(count) = overlap%is(n)
6898 ie(count) = overlap%ie(n)
6899 js(count) = overlap%je(n) + 1
6900 je(count) = js(count)
6902 nrecvl(tme, 2) = nrecvl(tme,2) + 1
6903 isl(tme,2,nrecvl(tme, 2)) = is(count)
6904 iel(tme,2,nrecvl(tme, 2)) = ie(count)
6905 jsl(tme,2,nrecvl(tme, 2)) = js(count)
6906 jel(tme,2,nrecvl(tme, 2)) = je(count)
6909 if( (position == east .OR. position == corner) .AND. overlap%dir(n) == 5)
then
6912 rotation(count) = overlap%rotation(n)
6913 tileme(count) = overlap%tileMe(n)
6914 is(count) = overlap%ie(n) + 1
6915 ie(count) = is(count)
6916 js(count) = overlap%js(n)
6917 je(count) = overlap%je(n)
6919 nrecvl(tme, 3) = nrecvl(tme,3) + 1
6920 isl(tme,3,nrecvl(tme, 3)) = is(count)
6921 iel(tme,3,nrecvl(tme, 3)) = ie(count)
6922 jsl(tme,3,nrecvl(tme, 3)) = js(count)
6923 jel(tme,3,nrecvl(tme, 3)) = je(count)
6926 if( (position == north .OR. position == corner) .AND. overlap%dir(n) == 7)
then
6929 rotation(count) = overlap%rotation(n)
6930 tileme(count) = overlap%tileMe(n)
6931 is(count) = overlap%is(n)
6932 ie(count) = overlap%ie(n)
6933 js(count) = overlap%js(n) - 1
6934 je(count) = js(count)
6936 nrecvl(tme, 4) = nrecvl(tme,4) + 1
6937 isl(tme,4,nrecvl(tme, 4)) = is(count)
6938 iel(tme,4,nrecvl(tme, 4)) = ie(count)
6939 jsl(tme,4,nrecvl(tme, 4)) = js(count)
6940 jel(tme,4,nrecvl(tme, 4)) = je(count)
6945 bound%recv(nrecv)%count = count
6946 bound%recv(nrecv)%pe = overlap%pe
6947 if (
associated(bound%recv(nrecv)%is))
deallocate(bound%recv(nrecv)%is)
6948 if (
associated(bound%recv(nrecv)%ie))
deallocate(bound%recv(nrecv)%ie)
6949 if (
associated(bound%recv(nrecv)%js))
deallocate(bound%recv(nrecv)%js)
6950 if (
associated(bound%recv(nrecv)%je))
deallocate(bound%recv(nrecv)%je)
6951 if (
associated(bound%recv(nrecv)%dir))
deallocate(bound%recv(nrecv)%dir)
6952 if (
associated(bound%recv(nrecv)%index))
deallocate(bound%recv(nrecv)%index)
6953 if (
associated(bound%recv(nrecv)%tileMe))
deallocate(bound%recv(nrecv)%tileMe)
6954 if (
associated(bound%recv(nrecv)%rotation))
deallocate(bound%recv(nrecv)%rotation)
6955 allocate(bound%recv(nrecv)%is(count), bound%recv(nrecv)%ie(count) )
6956 allocate(bound%recv(nrecv)%js(count), bound%recv(nrecv)%je(count) )
6957 allocate(bound%recv(nrecv)%dir(count), bound%recv(nrecv)%index(count) )
6958 allocate(bound%recv(nrecv)%tileMe(count), bound%recv(nrecv)%rotation(count) )
6959 bound%recv(nrecv)%is(:) = is(1:count)
6960 bound%recv(nrecv)%ie(:) = ie(1:count)
6961 bound%recv(nrecv)%js(:) = js(1:count)
6962 bound%recv(nrecv)%je(:) = je(1:count)
6963 bound%recv(nrecv)%dir(:) = dir(1:count)
6964 bound%recv(nrecv)%tileMe(:) = tileme(1:count)
6965 bound%recv(nrecv)%rotation(:) = rotation(1:count)
6970 do n = 1, bound%recv(m)%count
6971 tme = bound%recv(m)%tileMe(n)
6972 dr = bound%recv(m)%dir(n)
6973 bound%recv(m)%index(n) = 1
6974 do l = 1, nrecvl(tme,dr)
6975 if(dr == 1 .OR. dr == 3)
then
6976 if( bound%recv(m)%js(n) > jsl(tme, dr, l) )
then
6977 if( bound%recv(m)%rotation(n) == one_hundred_eighty )
then
6978 bound%recv(m)%index(n) = bound%recv(m)%index(n) + &
6979 max(abs(jel(tme, dr, l)-jsl(tme, dr, l))+1, &
6980 abs(iel(tme, dr, l)-isl(tme, dr, l))+1)
6982 bound%recv(m)%index(n) = bound%recv(m)%index(n) + &
6983 max(abs(jel(tme, dr, l)-jsl(tme, dr, l)), &
6984 abs(iel(tme, dr, l)-isl(tme, dr, l))) + 1 - jshift
6988 if( bound%recv(m)%is(n) > isl(tme, dr, l) )
then
6989 bound%recv(m)%index(n) = bound%recv(m)%index(n) + &
6990 max(abs(jel(tme, dr, l)-jsl(tme, dr, l)), &
6991 abs(iel(tme, dr, l)-isl(tme, dr, l))) + 1 - ishift
7007 subroutine fill_corner_contact(eCont, sCont, wCont, nCont, isg, ieg, jsg, jeg, numR, numS, tileRecv, tileSend, &
7008 is1Recv, ie1Recv, js1Recv, je1Recv, is2Recv, ie2Recv, js2Recv, je2Recv, &
7009 is1Send, ie1Send, js1Send, je1Send, is2Send, ie2Send, js2Send, je2Send, &
7010 align1Recv, align2Recv, align1Send, align2Send, &
7011 whalo, ehalo, shalo, nhalo, tileMe)
7012 type(contact_type),
dimension(:),
intent(in) :: eCont, sCont, wCont, nCont
7013 integer,
dimension(:),
intent(in) :: isg, ieg, jsg, jeg
7014 integer,
intent(inout) :: numR, numS
7015 integer,
dimension(:),
intent(inout) :: tileRecv, tileSend
7016 integer,
dimension(:),
intent(inout) :: is1Recv, ie1Recv, js1Recv, je1Recv
7017 integer,
dimension(:),
intent(inout) :: is2Recv, ie2Recv, js2Recv, je2Recv
7018 integer,
dimension(:),
intent(inout) :: is1Send, ie1Send, js1Send, je1Send
7019 integer,
dimension(:),
intent(inout) :: is2Send, ie2Send, js2Send, je2Send
7020 integer,
dimension(:),
intent(inout) :: align1Recv, align2Recv, align1Send, align2Send
7021 integer,
intent(in) :: tileMe, whalo, ehalo, shalo, nhalo
7022 integer :: is1, ie1, js1, je1, is2, ie2, js2, je2
7023 integer :: tn, tc, n, m
7024 logical :: found_corner
7026 found_corner = .false.
7028 if(econt(tileme)%ncontact > 0)
then
7029 if(econt(tileme)%js1(1) == jsg(tileme) )
then
7030 tn = econt(tileme)%tile(1)
7031 if(econt(tileme)%js2(1) > jsg(tn) )
then
7032 if( econt(tileme)%js2(1) - jsg(tn) < shalo )
call mpp_error(fatal, &
7033 "mpp_domains_define.inc: southeast tile for recv 1 is not tiled properly")
7034 found_corner = .true.; tc = tn
7035 is1 = econt(tileme)%ie1(1) + 1; je1 = econt(tileme)%js1(1) - 1
7036 is2 = econt(tileme)%is2(1); je2 = econt(tileme)%js2(1) - 1
7037 else if(scont(tn)%ncontact >0)
then
7038 if(scont(tn)%is1(1) == isg(tn))
then
7039 found_corner = .true.; tc = scont(tn)%tile(1)
7040 is1 = econt(tileme)%ie1(1) + 1; je1 = econt(tileme)%js1(1) - 1
7041 is2 = scont(tn)%is2(1); je2 = scont(tn)%je2(1)
7046 if( .not. found_corner )
then
7047 n = scont(tileme)%ncontact
7049 if( scont(tileme)%ie1(n) == ieg(tileme))
then
7050 tn = scont(tileme)%tile(n)
7051 if(scont(tileme)%ie2(n) < ieg(tn) )
then
7052 if(ieg(tn) - scont(tileme)%ie2(n) < ehalo )
call mpp_error(fatal, &
7053 "mpp_domains_define.inc: southeast tile for recv 2 is not tiled properly")
7054 found_corner = .true.; tc = tn
7055 is1 = scont(tileme)%ie1(n) + 1; je1 = scont(tileme)%js1(n) - 1
7056 is2 = scont(tileme)%ie2(n) + 1; je2 = scont(tileme)%je2(n)
7057 else if(econt(tn)%ncontact >0)
then
7058 m = econt(tn)%ncontact
7059 if(econt(tn)%je1(m) == jeg(tn))
then
7060 found_corner = .true.; tc = econt(tn)%tile(m)
7061 is1 = scont(tileme)%ie1(n) + 1; je1 = scont(tileme)%js1(n) - 1
7062 is2 = econt(tn)%is2(m); je2 = econt(tn)%je2(m)
7068 if(found_corner)
then
7070 tilerecv(numr) = tc; align1recv(numr) = south_east; align2recv(numr) = north_west
7071 is1recv(numr) = is1; ie1recv(numr) = is1 + ehalo - 1
7072 js1recv(numr) = je1 - shalo + 1; je1recv(numr) = je1
7073 is2recv(numr) = is2; ie2recv(numr) = is2 + ehalo - 1
7074 js2recv(numr) = je2 - shalo + 1; je2recv(numr) = je2
7078 found_corner = .false.
7079 if(wcont(tileme)%ncontact > 0)
then
7080 if(wcont(tileme)%js1(1) == jsg(tileme) )
then
7081 tn = wcont(tileme)%tile(1)
7082 if(wcont(tileme)%js2(1) > jsg(tn) )
then
7083 if( wcont(tileme)%js2(1) - jsg(tn) < shalo )
call mpp_error(fatal, &
7084 "mpp_domains_define.inc: southwest tile for recv 1 is not tiled properly")
7085 found_corner = .true.; tc = tn
7086 ie1 = wcont(tileme)%is1(1) - 1; je1 = wcont(tileme)%js1(1) - 1
7087 ie2 = wcont(tileme)%is2(1); je2 = wcont(tileme)%js2(1) - 1
7088 else if(scont(tn)%ncontact >0)
then
7089 n = scont(tn)%ncontact
7090 if(scont(tn)%ie1(n) == ieg(tn))
then
7091 found_corner = .true.; tc = scont(tn)%tile(n)
7092 ie1 = wcont(tileme)%is1(1) - 1; je1 = wcont(tileme)%js1(1) - 1
7093 ie2 = scont(tn)%ie2(1); je2 = scont(tn)%je2(1)
7098 if( .not. found_corner )
then
7099 n = scont(tileme)%ncontact
7101 if( scont(tileme)%is1(1) == isg(tileme))
then
7102 tn = scont(tileme)%tile(1)
7103 if(scont(tileme)%is2(1) > isg(tn) )
then
7104 if( scont(tileme)%is2(1)-isg(tn) < whalo )
call mpp_error(fatal, &
7105 "mpp_domains_define.inc: southwest tile for recv 1 is not tiled properly")
7106 found_corner = .true.; tc = tn
7107 ie1 = scont(tileme)%is1(1) - 1; je1 = scont(tileme)%js1(1) - 1
7108 ie2 = scont(tileme)%is2(1) - 1; je2 = scont(tileme)%js2(1)
7109 else if(wcont(tn)%ncontact >0)
then
7110 m = wcont(tn)%ncontact
7111 if(wcont(tn)%je1(m) == jeg(tn))
then
7112 found_corner = .true.; tc = wcont(tn)%tile(m)
7113 ie1 = scont(tileme)%is1(1) - 1; je1 = scont(tileme)%js1(1) - 1
7114 ie2 = wcont(tn)%ie2(m); je2 = wcont(tn)%je2(m)
7120 if(found_corner)
then
7122 tilerecv(numr) = tc; align1recv(numr) = south_west; align2recv(numr) = north_east
7123 is1recv(numr) = ie1 - whalo + 1; ie1recv(numr) = ie1
7124 js1recv(numr) = je1 - shalo + 1; je1recv(numr) = je1
7125 is2recv(numr) = ie2 - whalo + 1; ie2recv(numr) = ie2
7126 js2recv(numr) = je2 - shalo + 1; je2recv(numr) = je2
7130 found_corner = .false.
7131 n = wcont(tileme)%ncontact
7133 if(wcont(tileme)%je1(n) == jeg(tileme) )
then
7134 tn = wcont(tileme)%tile(n)
7135 if(wcont(tileme)%je2(n) < jeg(tn) )
then
7136 if( jeg(tn) - wcont(tileme)%je2(n) < nhalo )
call mpp_error(fatal, &
7137 "mpp_domains_define.inc: northwest tile for recv 1 is not tiled properly")
7138 found_corner = .true.; tc = tn
7139 ie1 = wcont(tileme)%is1(n) - 1; js1 = wcont(tileme)%je1(n) + 1
7140 ie2 = wcont(tileme)%is2(n); js2 = wcont(tileme)%je2(n) + 1
7141 else if(ncont(tn)%ncontact >0)
then
7142 m = ncont(tn)%ncontact
7143 if(ncont(tn)%ie1(m) == ieg(tn))
then
7144 found_corner = .true.; tc = ncont(tn)%tile(m)
7145 ie1 = wcont(tileme)%is1(n) - 1; js1 = wcont(tileme)%je1(n) + 1
7146 ie2 = ncont(tn)%ie2(m); js2 = ncont(tn)%js2(m)
7151 if( .not. found_corner )
then
7152 if( ncont(tileme)%ncontact > 0)
then
7153 if( ncont(tileme)%is1(1) == isg(tileme))
then
7154 tn = ncont(tileme)%tile(1)
7155 if(ncont(tileme)%is2(1) > isg(tn) )
then
7156 if( ncont(tileme)%is2(1)-isg(tn) < whalo )
call mpp_error(fatal, &
7157 "mpp_domains_define.inc: northwest tile for recv 2 is not tiled properly")
7158 found_corner = .true.; tc = tn
7159 ie1 = ncont(tileme)%is1(1) - 1; js1 = ncont(tileme)%je1(1) + 1
7160 ie2 = ncont(tileme)%is2(1) - 1; js2 = ncont(tileme)%js2(1)
7161 else if(wcont(tn)%ncontact >0)
then
7162 if(wcont(tn)%js1(1) == jsg(tn))
then
7163 found_corner = .true.; tc = wcont(tn)%tile(1)
7164 ie1 = ncont(tileme)%is1(1) - 1; js1 = ncont(tileme)%je1(1) + 1
7165 ie2 = wcont(tn)%ie2(1); js2 = wcont(tn)%js2(1)
7171 if(found_corner)
then
7173 tilerecv(numr) = tc; align1recv(numr) =north_west; align2recv(numr) = south_east
7174 is1recv(numr) = ie1 - whalo + 1; ie1recv(numr) = ie1
7175 js1recv(numr) = js1; je1recv(numr) = js1 + nhalo - 1
7176 is2recv(numr) = ie2 - whalo + 1; ie2recv(numr) = ie2
7177 js2recv(numr) = js2; je2recv(numr) = js2 + nhalo - 1
7181 found_corner = .false.
7182 n = econt(tileme)%ncontact
7184 if(econt(tileme)%je1(n) == jeg(tileme) )
then
7185 tn = econt(tileme)%tile(n)
7186 if(econt(tileme)%je2(n) < jeg(tn) )
then
7187 if( jeg(tn) - econt(tileme)%je2(n) < nhalo )
call mpp_error(fatal, &
7188 "mpp_domains_define.inc: northeast tile for recv 1 is not tiled properly")
7189 found_corner = .true.; tc = tn
7190 is1 = econt(tileme)%ie1(n) + 1; js1 = econt(tileme)%je1(n) + 1
7191 is2 = econt(tileme)%is2(1); js2 = econt(tileme)%je2(1) + 1
7192 else if(ncont(tn)%ncontact >0)
then
7193 if(ncont(tn)%is1(1) == isg(tn))
then
7194 found_corner = .true.; tc = ncont(tn)%tile(1)
7195 is1 = econt(tileme)%ie1(n) + 1; js1 = econt(tileme)%je1(n) + 1
7196 is2 = ncont(tn)%is2(1); js2 = ncont(tn)%js2(1)
7201 if( .not. found_corner )
then
7202 n = ncont(tileme)%ncontact
7204 if( ncont(tileme)%ie1(n) == ieg(tileme))
then
7205 tn = ncont(tileme)%tile(n)
7206 if(ncont(tileme)%ie2(n) < ieg(tn) )
then
7207 if(ieg(tn) - scont(tileme)%ie2(n) < ehalo )
call mpp_error(fatal, &
7208 "mpp_domains_define.inc: northeast tile for recv 2 is not tiled properly")
7209 found_corner = .true.; tc = tn
7210 is1 = scont(tileme)%ie1(n) + 1; js1 = scont(tileme)%je1(n) + 1
7211 is2 = scont(tileme)%ie2(n) + 1; js2 = scont(tileme)%js2(n)
7212 else if(econt(tn)%ncontact >0)
then
7213 if(econt(tn)%js1(1) == jsg(tn))
then
7214 found_corner = .true.; tc = econt(tn)%tile(1)
7215 is1 = scont(tileme)%ie1(n) + 1; js1 = scont(tileme)%je1(n) + 1
7216 is2 = econt(tn)%is2(m); js2 = econt(tn)%js2(m)
7222 if(found_corner)
then
7224 tilerecv(numr) = tc; align1recv(numr) =north_east; align2recv(numr) = south_west
7225 is1recv(numr) = is1; ie1recv(numr) = is1 + ehalo - 1
7226 js1recv(numr) = js1; je1recv(numr) = js1 + nhalo - 1
7227 is2recv(numr) = is2; ie2recv(numr) = is2 + ehalo - 1
7228 js2recv(numr) = js2; je2recv(numr) = js2 + nhalo - 1
7232 do n = 1, wcont(tileme)%ncontact
7233 tn = wcont(tileme)%tile(n)
7234 if(wcont(tileme)%js2(n) == jsg(tn) )
then
7235 if(wcont(tileme)%js1(n) > jsg(tileme) )
then
7236 if( wcont(tileme)%js1(n) - jsg(tileme) < shalo )
call mpp_error(fatal, &
7237 "mpp_domains_define.inc: southeast tile for send 1 is not tiled properly")
7238 nums = nums+1; tilesend(nums) = tn
7239 align1send(nums) = north_west; align2send(nums) = south_east
7240 is1send(nums) = wcont(tileme)%is1(n); ie1send(nums) = is1send(nums) + ehalo - 1
7241 je1send(nums) = wcont(tileme)%js1(n) - 1; js1send(nums) = je1send(nums) - shalo + 1
7242 is2send(nums) = wcont(tileme)%ie2(n) + 1; ie2send(nums) = is2send(nums) + ehalo - 1
7243 je2send(nums) = wcont(tileme)%js2(n) - 1; js2send(nums) = je2send(nums) - shalo + 1
7247 do n = 1, ncont(tileme)%ncontact
7248 tn = ncont(tileme)%tile(n)
7249 if(ncont(tileme)%ie2(n) == ieg(tn) )
then
7250 if(ncont(tileme)%ie1(n) < ieg(tileme) )
then
7251 if( ieg(tileme) - ncont(tileme)%ie1(n) < ehalo )
call mpp_error(fatal, &
7252 "mpp_domains_define.inc: southeast tile for send 2 is not tiled properly")
7253 nums = nums+1; tilesend(nums) = tn
7254 align1send(nums) = north_west; align2send(nums) = south_east
7255 is1send(nums) = ncont(tileme)%ie1(n) + 1; ie1send(nums) = is1send(nums) + ehalo - 1
7256 je1send(nums) = ncont(tileme)%je1(n) ; js1send(nums) = je1send(nums) - shalo + 1
7257 is2send(nums) = ncont(tileme)%ie2(n) + 1; ie2send(nums) = is2send(nums) + ehalo - 1
7258 je2send(nums) = ncont(tileme)%je2(n) - 1; js2send(nums) = je2send(nums) - shalo + 1
7264 n = wcont(tileme)%ncontact
7265 found_corner = .false.
7267 tn = wcont(tileme)%tile(n)
7268 if( wcont(tileme)%je1(n) == jeg(tileme) .AND. wcont(tileme)%je2(n) == jeg(tn) )
then
7269 m = ncont(tn)%ncontact
7271 tc = ncont(tn)%tile(m)
7272 if( ncont(tn)%ie1(m) == ieg(tn) .AND. ncont(tn)%ie2(m) == ieg(tc) ) found_corner = .true.
7276 if( .not. found_corner )
then
7277 if( ncont(tileme)%ncontact > 0)
then
7278 tn = ncont(tileme)%tile(1)
7279 if( ncont(tileme)%is1(1) == isg(tileme) .AND. ncont(tileme)%is2(1) == isg(tn) )
then
7280 if(wcont(tn)%ncontact >0)
then
7281 tc = wcont(tn)%tile(1)
7282 if( wcont(tn)%js1(1) == jsg(tn) .AND. wcont(tn)%js2(1) == jsg(tc) ) found_corner = .true.
7288 if(found_corner)
then
7289 nums = nums+1; tilesend(nums) = tc
7290 align1send(nums) = north_west; align2send(nums) = south_east
7291 is1send(nums) = isg(tileme); ie1send(nums) = is1send(nums) + ehalo - 1
7292 je1send(nums) = jeg(tileme); js1send(nums) = je1send(nums) - shalo + 1
7293 is2send(nums) = ieg(tc) + 1; ie2send(nums) = is2send(nums) + ehalo - 1
7294 je2send(nums) = jsg(tc) - 1; js2send(nums) = je2send(nums) - shalo + 1
7298 do n = 1, econt(tileme)%ncontact
7299 tn = econt(tileme)%tile(n)
7300 if(econt(tileme)%js2(n) == jsg(tn) )
then
7301 if(econt(tileme)%js1(n) > jsg(tileme) )
then
7302 if( econt(tileme)%js1(n) - jsg(tileme) < shalo )
call mpp_error(fatal, &
7303 "mpp_domains_define.inc: southwest tile for send 1 is not tiled properly")
7304 nums = nums+1; tilesend(nums) = tn
7305 align1send(nums) = north_east; align2send(nums) = south_west
7306 ie1send(nums) = econt(tileme)%ie1(n); is1send(nums) = ie1send(nums) - whalo + 1
7307 je1send(nums) = econt(tileme)%js1(n) - 1; js1send(nums) = je1send(nums) - shalo + 1
7308 ie2send(nums) = econt(tileme)%is2(n) - 1; is2send(nums) = ie2send(nums) - whalo + 1
7309 je2send(nums) = econt(tileme)%js2(n) - 1; js2send(nums) = je2send(nums) - shalo + 1
7313 do n = 1, ncont(tileme)%ncontact
7314 tn = ncont(tileme)%tile(n)
7315 if(ncont(tileme)%is2(n) == isg(tn) )
then
7316 if(ncont(tileme)%is1(n) > isg(tileme) )
then
7317 if( ncont(tileme)%is1(n) - isg(tileme) < whalo )
call mpp_error(fatal, &
7318 "mpp_domains_define.inc: southwest tile for send 2 is not tiled properly")
7319 nums = nums+1; tilesend(nums) = tn
7320 align1send(nums) = north_east; align2send(nums) = south_west
7321 ie1send(nums) = ncont(tileme)%is1(n) - 1; is1send(nums) = ie1send(nums) - whalo + 1
7322 ie1send(nums) = ncont(tileme)%je1(n) ; js1send(nums) = je1send(nums) - shalo + 1
7323 ie2send(nums) = ncont(tileme)%is2(n) - 1; is2send(nums) = je2send(nums) - whalo + 1
7324 je2send(nums) = ncont(tileme)%js2(n) - 1; js2send(nums) = je2send(nums) - shalo + 1
7330 n = econt(tileme)%ncontact
7331 found_corner = .false.
7333 tn = econt(tileme)%tile(n)
7334 if( econt(tileme)%je1(n) == jeg(tileme) .AND. econt(tileme)%je2(n) == jeg(tn) )
then
7335 if(ncont(tn)%ncontact >0)
then
7336 tc = ncont(tn)%tile(1)
7337 if( ncont(tn)%is1(1) == isg(tn) .AND. ncont(tn)%is2(n) == isg(tc) ) found_corner = .true.
7341 if( .not. found_corner )
then
7342 n = ncont(tileme)%ncontact
7344 tn = ncont(tileme)%tile(n)
7345 if( ncont(tileme)%ie1(n) == ieg(tileme) .AND. ncont(tileme)%ie2(n) == ieg(tn) )
then
7346 if(econt(tn)%ncontact >0)
then
7347 tc = econt(tn)%tile(1)
7348 if( econt(tn)%js1(1) == jsg(tn) .AND. econt(tn)%js2(n) == jsg(tc) ) found_corner = .true.
7354 if(found_corner)
then
7355 nums = nums+1; tilesend(nums) = tc
7356 align1send(nums) = north_east; align2send(nums) = south_west
7357 ie1send(nums) = ieg(tileme); is1send(nums) = ie1send(nums) - whalo + 1
7358 je1send(nums) = jeg(tileme); js1send(nums) = je1send(nums) - shalo + 1
7359 ie2send(nums) = isg(tc) - 1; is2send(nums) = ie2send(nums) - whalo + 1
7360 je2send(nums) = jsg(tc) - 1; js2send(nums) = je2send(nums) - shalo + 1
7364 do n = 1, econt(tileme)%ncontact
7365 tn = econt(tileme)%tile(n)
7366 if(econt(tileme)%je2(n) == jeg(tn) )
then
7367 if(econt(tileme)%je1(n) < jeg(tileme) )
then
7368 if( jeg(tileme) - econt(tileme)%je1(n) < nhalo )
call mpp_error(fatal, &
7369 "mpp_domains_define.inc: northwest tile for send 1 is not tiled properly")
7370 nums = nums+1; tilesend(nums) = tn
7371 align1send(nums) = south_east; align2send(nums) = north_west
7372 ie1send(nums) = econt(tileme)%ie1(n) ; is1send(nums) = ie1send(nums) - whalo + 1
7373 js1send(nums) = econt(tileme)%je1(n) + 1; je1send(nums) = js1send(nums) + nhalo - 1
7374 ie2send(nums) = econt(tileme)%is2(n) - 1; is2send(nums) = ie2send(nums) - whalo + 1
7375 js2send(nums) = econt(tileme)%je2(n) + 1; je2send(nums) = js2send(nums) + nhalo - 1
7380 do n = 1, scont(tileme)%ncontact
7381 tn = scont(tileme)%tile(n)
7382 if(scont(tileme)%is2(n) == isg(tn) )
then
7383 if(scont(tileme)%is1(n) > isg(tileme) )
then
7384 if( scont(tileme)%is1(n) - isg(tileme) < whalo )
call mpp_error(fatal, &
7385 "mpp_domains_define.inc: southwest tile for send 2 is not tiled properly")
7386 nums = nums+1; tilesend(nums) = tn
7387 align1send(nums) = south_east; align2send(nums) = north_west
7388 ie1send(nums) = ncont(tileme)%is1(n) - 1; is1send(nums) = ie1send(nums) - whalo + 1
7389 js1send(nums) = ncont(tileme)%je1(n) ; je1send(nums) = js1send(nums) + nhalo - 1
7390 ie2send(nums) = ncont(tileme)%is2(n) - 1; is2send(nums) = ie2send(nums) - whalo + 1
7391 js2send(nums) = ncont(tileme)%je2(n) + 1; je2send(nums) = js2send(nums) + nhalo - 1
7397 n = econt(tileme)%ncontact
7398 found_corner = .false.
7400 tn = econt(tileme)%tile(1)
7401 if( econt(tileme)%js1(1) == jsg(tileme) .AND. econt(tileme)%js2(1) == jsg(tn) )
then
7402 if(scont(tn)%ncontact >0)
then
7403 tc = scont(tn)%tile(1)
7404 if( scont(tn)%is1(1) == isg(tn) .AND. scont(tn)%is2(1) == isg(tc) ) found_corner = .true.
7408 if( .not. found_corner )
then
7409 n = scont(tileme)%ncontact
7410 found_corner = .false.
7412 tn = scont(tileme)%tile(n)
7413 if( scont(tileme)%ie1(n) == ieg(tileme) .AND. scont(tileme)%ie2(n) == ieg(tn) )
then
7414 if(econt(tn)%ncontact >0)
then
7415 tc = econt(tn)%tile(n)
7416 if( econt(tn)%je1(n) == jeg(tn) .AND. econt(tn)%je2(n) == jeg(tc) ) found_corner = .true.
7422 if(found_corner)
then
7423 nums = nums+1; tilesend(nums) = tc
7424 align1send(nums) = south_east; align2send(nums) = north_west
7425 ie1send(nums) = ieg(tileme); is1send(nums) = ie1send(nums) - whalo + 1
7426 js1send(nums) = jsg(tileme); je1send(nums) = js1send(nums) + nhalo - 1
7427 ie2send(nums) = isg(tc) - 1; is2send(nums) = ie2send(nums) - whalo + 1
7428 js2send(nums) = jeg(tc) + 1; je2send(nums) = js2send(nums) + nhalo - 1
7432 do n = 1, wcont(tileme)%ncontact
7433 tn = wcont(tileme)%tile(n)
7434 if(wcont(tileme)%je2(n) == jeg(tn) )
then
7435 if(wcont(tileme)%je1(n) < jeg(tileme) )
then
7436 if( jeg(tileme) - wcont(tileme)%je1(n) < nhalo )
call mpp_error(fatal, &
7437 "mpp_domains_define.inc: northeast tile for send 1 is not tiled properly")
7438 nums = nums+1; tilesend(nums) = tn
7439 align1send(nums) = south_west; align2send(nums) = north_east
7440 is1send(nums) = wcont(tileme)%is1(n) ; ie1send(nums) = is1send(nums) + ehalo - 1
7441 js1send(nums) = wcont(tileme)%je1(n) + 1; je1send(nums) = js1send(nums) + nhalo - 1
7442 is2send(nums) = wcont(tileme)%ie2(n) + 1; ie2send(nums) = is2send(nums) + ehalo - 1
7443 js2send(nums) = wcont(tileme)%je2(n) + 1; je2send(nums) = js2send(nums) + nhalo - 1
7448 do n = 1, scont(tileme)%ncontact
7449 tn = scont(tileme)%tile(n)
7450 if(scont(tileme)%ie2(n) == ieg(tn) )
then
7451 if(scont(tileme)%ie1(n) < ieg(tileme) )
then
7452 if( ieg(tileme) - scont(tileme)%ie1(n) < ehalo )
call mpp_error(fatal, &
7453 "mpp_domains_define.inc: southeast tile for send 2 is not tiled properly")
7454 nums = nums+1; tilesend(nums) = tn
7455 align1send(nums) = south_west; align2send(nums) = north_east
7456 is1send(nums) = scont(tileme)%ie1(n) + 1; ie1send(nums) = is1send(nums) + ehalo - 1
7457 js1send(nums) = scont(tileme)%js1(n) ; je1send(nums) = js1send(nums) + nhalo - 1
7458 is2send(nums) = scont(tileme)%ie2(n) + 1; ie2send(nums) = is1send(nums) + ehalo - 1
7459 js2send(nums) = scont(tileme)%je2(n) + 1; je2send(nums) = js2send(nums) + nhalo - 1
7465 n = wcont(tileme)%ncontact
7466 found_corner = .false.
7468 tn = wcont(tileme)%tile(1)
7469 if( wcont(tileme)%js1(n) == jsg(tileme) .AND. wcont(tileme)%js2(n) == jsg(tn) )
then
7470 m = scont(tn)%ncontact
7472 tc = scont(tn)%tile(m)
7473 if( scont(tn)%ie1(m) == ieg(tn) .AND. scont(tn)%ie2(m) == ieg(tc) ) found_corner = .true.
7477 if( .not. found_corner )
then
7478 n = scont(tileme)%ncontact
7479 found_corner = .false.
7481 tn = scont(tileme)%tile(1)
7482 if( scont(tileme)%is1(1) == isg(tileme) .AND. scont(tileme)%is2(1) == isg(tn) )
then
7483 m = wcont(tn)%ncontact
7485 tc = wcont(tn)%tile(m)
7486 if( wcont(tn)%je1(m) == jeg(tn) .AND. wcont(tn)%je2(m) == jeg(tc) ) found_corner = .true.
7491 if(found_corner)
then
7492 nums = nums+1; tilesend(nums) = tc
7493 align1send(nums) = south_west; align2send(nums) = north_east
7494 is1send(nums) = isg(tileme); ie1send(nums) = is1send(nums) + ehalo - 1
7495 js1send(nums) = jsg(tileme); je1send(nums) = js1send(nums) + nhalo - 1
7496 is2send(nums) = ieg(tc) + 1; ie2send(nums) = is2send(nums) + ehalo - 1
7497 js2send(nums) = jeg(tc) + 1; je2send(nums) = js2send(nums) + nhalo - 1
7500 end subroutine fill_corner_contact
7503 subroutine check_alignment( is, ie, js, je, isg, ieg, jsg, jeg, alignment )
7504 integer,
intent(inout) :: is, ie, js, je, isg, ieg, jsg, jeg
7505 integer,
intent(out) :: alignment
7509 if ( is == ie )
then
7510 if ( is == isg )
then
7512 else if ( is == ieg )
then
7515 call mpp_error(fatal,
'mpp_domains_define.inc: The contact region is not on the x-boundary of the tile')
7518 j = js; js = je; je = j
7520 else if ( js == je )
then
7521 if ( js == jsg )
then
7523 else if ( js == jeg )
then
7526 call mpp_error(fatal,
'mpp_domains_define.inc: The contact region is not on the y-boundary of the tile')
7529 i = is; is = ie; ie = i
7532 call mpp_error(fatal,
'mpp_domains_define.inc: The contact region should be line contact' )
7535 end subroutine check_alignment
7547 type(domain1d),
intent(in) :: domain_in
7548 type(domain1d),
intent(inout) :: domain_out
7549 integer,
intent(in),
optional :: hbegin, hend
7550 integer,
intent(in),
optional :: cbegin, cend
7552 integer,
intent(in),
optional :: gbegin, gend
7554 integer :: ndivs, global_indices(2)
7557 global_indices(1) = domain_in%global%begin; global_indices(2) = domain_in%global%end
7560 ndivs =
size(domain_in%list(:))
7564 if(domain_in%cyclic) flag = flag + cyclic_global_domain
7565 if(domain_in%domain_data%is_global) flag = flag + global_data_domain
7567 call mpp_define_domains( global_indices, ndivs, domain_out, pelist = domain_in%list(:)%pe, &
7568 flags = flag, begin_halo = hbegin, end_halo = hend, extent = domain_in%list(:)%compute%size )
7570 if(
present(cbegin)) domain_out%compute%begin = cbegin
7571 if(
present(cend)) domain_out%compute%end = cend
7572 domain_out%compute%size = domain_out%compute%end - domain_out%compute%begin + 1
7573 if(
present(gbegin)) domain_out%global%begin = gbegin
7574 if(
present(gend)) domain_out%global%end = gend
7575 domain_out%global%size = domain_out%global%end - domain_out%global%begin + 1
7581 subroutine mpp_modify_domain2d(domain_in, domain_out, isc, iec, jsc, jec, isg, ieg, jsg, jeg, whalo, ehalo, &
7584 type(domain2d),
intent(in) :: domain_in
7585 type(domain2d),
intent(inout) :: domain_out
7586 integer,
intent(in),
optional :: isc, iec, jsc, jec
7588 integer,
intent(in),
optional :: isg, ieg, jsg, jeg
7590 integer,
intent(in),
optional :: whalo, ehalo, shalo, nhalo
7591 integer :: global_indices(4), layout(2)
7592 integer :: xflag, yflag, nlist, i
7594 if(
present(whalo) .or.
present(ehalo) .or.
present(shalo) .or.
present(nhalo) )
then
7596 global_indices(1) = domain_in%x(1)%global%begin; global_indices(2) = domain_in%x(1)%global%end
7597 global_indices(3) = domain_in%y(1)%global%begin; global_indices(4) = domain_in%y(1)%global%end
7600 layout(1) =
size(domain_in%x(1)%list(:)); layout(2) =
size(domain_in%y(1)%list(:))
7603 xflag = 0; yflag = 0
7604 if(domain_in%x(1)%cyclic) xflag = xflag + cyclic_global_domain
7605 if(domain_in%x(1)%domain_data%is_global) xflag = xflag + global_data_domain
7606 if(domain_in%y(1)%cyclic) yflag = yflag + cyclic_global_domain
7607 if(domain_in%y(1)%domain_data%is_global) yflag = yflag + global_data_domain
7609 call mpp_define_domains( global_indices, layout, domain_out, pelist = domain_in%list(:)%pe, &
7610 xflags = xflag, yflags = yflag, whalo = whalo, ehalo = ehalo, &
7611 shalo = shalo, nhalo = nhalo, &
7612 xextent = domain_in%x(1)%list(:)%compute%size, &
7613 yextent = domain_in%y(1)%list(:)%compute%size, &
7614 symmetry=domain_in%symmetry, &
7615 maskmap = domain_in%pearray .NE. null_pe )
7616 domain_out%ntiles = domain_in%ntiles
7617 domain_out%tile_id = domain_in%tile_id
7619 call mpp_define_null_domain(domain_out)
7620 nlist =
size(domain_in%list(:))
7621 if (
associated(domain_out%list))
deallocate(domain_out%list)
7622 allocate(domain_out%list(0:nlist-1) )
7624 allocate(domain_out%list(i)%tile_id(1))
7625 domain_out%list(i)%tile_id(1) = 1
7627 call mpp_modify_domain(domain_in%x(1), domain_out%x(1), isc, iec, isg, ieg)
7628 call mpp_modify_domain(domain_in%y(1), domain_out%y(1), jsc, jec, jsg, jeg)
7629 domain_out%ntiles = domain_in%ntiles
7630 domain_out%tile_id = domain_in%tile_id
7639 subroutine mpp_define_null_domain1d(domain)
7640 type(domain1d),
intent(inout) :: domain
7642 domain%global%begin = -1; domain%global%end = -1; domain%global%size = 0
7643 domain%domain_data%begin = -1; domain%domain_data%end = -1; domain%domain_data%size = 0
7644 domain%compute%begin = -1; domain%compute%end = -1; domain%compute%size = 0
7647 end subroutine mpp_define_null_domain1d
7652 subroutine mpp_define_null_domain2d(domain)
7653 type(domain2d),
intent(inout) :: domain
7655 allocate(domain%x(1), domain%y(1), domain%tile_id(1))
7656 call mpp_define_null_domain(domain%x(1))
7657 call mpp_define_null_domain(domain%y(1))
7659 domain%tile_id(1) = 1
7661 domain%max_ntile_pe = 1
7662 domain%ncontacts = 0
7664 end subroutine mpp_define_null_domain2d
7668 subroutine mpp_deallocate_domain1d(domain)
7669 type(domain1d),
intent(inout) :: domain
7671 if(
ASSOCIATED(domain%list))
deallocate(domain%list)
7673 end subroutine mpp_deallocate_domain1d
7677 subroutine mpp_deallocate_domain2d(domain)
7678 type(domain2d),
intent(inout) :: domain
7680 call deallocate_domain2d_local(domain)
7681 if(
ASSOCIATED(domain%io_domain) )
then
7682 call deallocate_domain2d_local(domain%io_domain)
7683 deallocate(domain%io_domain)
7686 end subroutine mpp_deallocate_domain2d
7690 subroutine deallocate_domain2d_local(domain)
7691 type(domain2d),
intent(inout) :: domain
7692 integer :: i, ntileMe
7694 ntileme =
size(domain%x(:))
7696 if(
ASSOCIATED(domain%pearray))
deallocate(domain%pearray)
7698 call mpp_deallocate_domain1d(domain%x(i))
7699 call mpp_deallocate_domain1d(domain%y(i))
7701 deallocate(domain%x, domain%y, domain%tile_id)
7704 if(
ASSOCIATED(domain%tileList))
deallocate(domain%tileList)
7705 if(
ASSOCIATED(domain%tile_id_all))
deallocate(domain%tile_id_all)
7707 if(
ASSOCIATED(domain%list))
then
7708 do i = 0,
size(domain%list(:))-1
7709 deallocate(domain%list(i)%x, domain%list(i)%y, domain%list(i)%tile_id)
7711 deallocate(domain%list)
7714 if(
ASSOCIATED(domain%check_C))
then
7715 call deallocate_overlapspec(domain%check_C)
7716 deallocate(domain%check_C)
7719 if(
ASSOCIATED(domain%check_E))
then
7720 call deallocate_overlapspec(domain%check_E)
7721 deallocate(domain%check_E)
7724 if(
ASSOCIATED(domain%check_N))
then
7725 call deallocate_overlapspec(domain%check_N)
7726 deallocate(domain%check_N)
7729 if(
ASSOCIATED(domain%bound_C))
then
7730 call deallocate_overlapspec(domain%bound_C)
7731 deallocate(domain%bound_C)
7734 if(
ASSOCIATED(domain%bound_E))
then
7735 call deallocate_overlapspec(domain%bound_E)
7736 deallocate(domain%bound_E)
7739 if(
ASSOCIATED(domain%bound_N))
then
7740 call deallocate_overlapspec(domain%bound_N)
7741 deallocate(domain%bound_N)
7744 if(
ASSOCIATED(domain%update_T))
then
7745 call deallocate_overlapspec(domain%update_T)
7746 deallocate(domain%update_T)
7749 if(
ASSOCIATED(domain%update_E))
then
7750 call deallocate_overlapspec(domain%update_E)
7751 deallocate(domain%update_E)
7754 if(
ASSOCIATED(domain%update_C))
then
7755 call deallocate_overlapspec(domain%update_C)
7756 deallocate(domain%update_C)
7759 if(
ASSOCIATED(domain%update_N))
then
7760 call deallocate_overlapspec(domain%update_N)
7761 deallocate(domain%update_N)
7764 end subroutine deallocate_domain2d_local
7768 subroutine allocate_check_overlap(overlap, count)
7769 type(overlap_type),
intent(inout) :: overlap
7770 integer,
intent(in ) :: count
7773 overlap%pe = null_pe
7774 if(
associated(overlap%tileMe))
call mpp_error(fatal, &
7775 "allocate_check_overlap(mpp_domains_define): overlap is already been allocated")
7776 if(count < 1)
call mpp_error(fatal, &
7777 "allocate_check_overlap(mpp_domains_define): count should be a positive integer")
7778 allocate(overlap%tileMe (count), overlap%dir(count) )
7779 allocate(overlap%is (count), overlap%ie (count) )
7780 allocate(overlap%js (count), overlap%je (count) )
7781 allocate(overlap%rotation(count) )
7782 overlap%rotation = zero
7784 end subroutine allocate_check_overlap
7787 subroutine insert_check_overlap(overlap, pe, tileMe, dir, rotation, is, ie, js, je)
7788 type(overlap_type),
intent(inout) :: overlap
7789 integer,
intent(in ) :: pe
7790 integer,
intent(in ) :: tileMe, dir, rotation
7791 integer,
intent(in ) :: is, ie, js, je
7794 overlap%count = overlap%count + 1
7795 count = overlap%count
7796 if(.NOT.
associated(overlap%tileMe))
call mpp_error(fatal, &
7797 "mpp_domains_define.inc(insert_check_overlap): overlap is not assigned any memory")
7798 if(count >
size(overlap%tileMe(:)) )
call mpp_error(fatal, &
7799 "mpp_domains_define.inc(insert_check_overlap): overlap%count is greater than size(overlap%tileMe)")
7800 if( overlap%pe == null_pe )
then
7803 if(overlap%pe .NE. pe)
call mpp_error(fatal, &
7804 "mpp_domains_define.inc(insert_check_overlap): mismatch on pe")
7806 overlap%tileMe (count) = tileme
7807 overlap%dir (count) = dir
7808 overlap%rotation(count) = rotation
7809 overlap%is (count) = is
7810 overlap%ie (count) = ie
7811 overlap%js (count) = js
7812 overlap%je (count) = je
7814 end subroutine insert_check_overlap
7819 type(overlap_type),
intent(inout) :: overlap_out
7820 type(overlap_type),
intent(in ) :: overlap_in
7821 type(overlap_type) :: overlap
7822 integer :: count, count_in, count_out
7825 count_in = overlap_in %count
7826 count_out = overlap_out%count
7827 count = count_in+count_out
7828 if(count_in == 0)
call mpp_error(fatal, &
7829 "add_check_overlap(mpp_domains_define): overlap_in%count is zero")
7831 if(count_out == 0)
then
7832 if(
associated(overlap_out%tileMe))
call mpp_error(fatal, &
7833 "add_check_overlap(mpp_domains_define): overlap is already been allocated but count=0")
7834 call allocate_check_overlap(overlap_out, count_in)
7835 overlap_out%pe = overlap_in%pe
7837 call allocate_check_overlap(overlap, count_out)
7838 if(overlap_out%pe .NE. overlap_in%pe)
call mpp_error(fatal, &
7839 "mpp_domains_define.inc(add_check_overlap): mismatch of pe between overlap_in and overlap_out")
7840 overlap%tileMe (1:count_out) = overlap_out%tileMe (1:count_out)
7841 overlap%is (1:count_out) = overlap_out%is (1:count_out)
7842 overlap%ie (1:count_out) = overlap_out%ie (1:count_out)
7843 overlap%js (1:count_out) = overlap_out%js (1:count_out)
7844 overlap%je (1:count_out) = overlap_out%je (1:count_out)
7845 overlap%dir (1:count_out) = overlap_out%dir (1:count_out)
7846 overlap%rotation (1:count_out) = overlap_out%rotation (1:count_out)
7847 call deallocate_overlap_type(overlap_out)
7848 call allocate_check_overlap(overlap_out, count)
7849 overlap_out%tileMe (1:count_out) = overlap%tileMe (1:count_out)
7850 overlap_out%is (1:count_out) = overlap%is (1:count_out)
7851 overlap_out%ie (1:count_out) = overlap%ie (1:count_out)
7852 overlap_out%js (1:count_out) = overlap%js (1:count_out)
7853 overlap_out%je (1:count_out) = overlap%je (1:count_out)
7854 overlap_out%dir (1:count_out) = overlap%dir (1:count_out)
7855 overlap_out%rotation (1:count_out) = overlap%rotation (1:count_out)
7856 call deallocate_overlap_type(overlap)
7858 overlap_out%count = count
7859 overlap_out%tileMe (count_out+1:count) = overlap_in%tileMe (1:count_in)
7860 overlap_out%is (count_out+1:count) = overlap_in%is (1:count_in)
7861 overlap_out%ie (count_out+1:count) = overlap_in%ie (1:count_in)
7862 overlap_out%js (count_out+1:count) = overlap_in%js (1:count_in)
7863 overlap_out%je (count_out+1:count) = overlap_in%je (1:count_in)
7864 overlap_out%dir (count_out+1:count) = overlap_in%dir (1:count_in)
7865 overlap_out%rotation (count_out+1:count) = overlap_in%rotation (1:count_in)
7870 subroutine init_overlap_type(overlap)
7871 type(overlap_type),
intent(inout) :: overlap
7874 overlap%pe = null_pe
7876 end subroutine init_overlap_type
7880 subroutine allocate_update_overlap( overlap, count)
7881 type(overlap_type),
intent(inout) :: overlap
7882 integer,
intent(in ) :: count
7885 overlap%pe = null_pe
7886 if(
associated(overlap%tileMe))
call mpp_error(fatal, &
7887 "allocate_update_overlap(mpp_domains_define): overlap is already been allocated")
7888 if(count < 1)
call mpp_error(fatal, &
7889 "allocate_update_overlap(mpp_domains_define): count should be a positive integer")
7890 allocate(overlap%tileMe (count), overlap%tileNbr (count) )
7891 allocate(overlap%is (count), overlap%ie (count) )
7892 allocate(overlap%js (count), overlap%je (count) )
7893 allocate(overlap%dir (count), overlap%rotation(count) )
7894 allocate(overlap%from_contact(count), overlap%msgsize (count) )
7895 overlap%rotation = zero
7896 overlap%from_contact = .false.
7898 end subroutine allocate_update_overlap
7901 subroutine insert_update_overlap(overlap, pe, is1, ie1, js1, je1, is2, ie2, js2, je2, dir, reverse, symmetry)
7902 type(overlap_type),
intent(inout) :: overlap
7903 integer,
intent(in ) :: pe
7904 integer,
intent(in ) :: is1, ie1, js1, je1, is2, ie2, js2, je2
7905 integer,
intent(in ) :: dir
7906 logical,
optional,
intent(in ) :: reverse, symmetry
7908 logical :: is_reverse, is_symmetry, is_overlapped
7909 integer :: is, ie, js, je, count
7911 is_reverse = .false.
7912 if(
PRESENT(reverse)) is_reverse = reverse
7913 is_symmetry = .false.
7914 if(
PRESENT(symmetry)) is_symmetry = symmetry
7916 is = max(is1,is2); ie = min(ie1,ie2)
7917 js = max(js1,js2); je = min(je1,je2)
7918 is_overlapped = .false.
7920 if(is_symmetry .AND. (dir == 1 .OR. dir == 5))
then
7921 if( ie .GE. is .AND. je .GT. js ) is_overlapped = .true.
7922 else if(is_symmetry .AND. (dir == 3 .OR. dir == 7))
then
7923 if( ie .GT. is .AND. je .GE. js ) is_overlapped = .true.
7924 else if(ie.GE.is .AND. je.GE.js )
then
7925 is_overlapped = .true.
7928 if(is_overlapped)
then
7929 if( overlap%count == 0 )
then
7932 if(overlap%pe .NE. pe)
call mpp_error(fatal, &
7933 "mpp_domains_define.inc(insert_update_overlap): mismatch on pe")
7935 overlap%count = overlap%count+1
7936 count = overlap%count
7937 if(count > maxoverlap)
call mpp_error(fatal,
"mpp_domains_define.inc(insert_update_overlap):"//&
7938 &
" number of overlap is greater than MAXOVERLAP, increase MAXOVERLAP")
7939 overlap%is(count) = is
7940 overlap%ie(count) = ie
7941 overlap%js(count) = js
7942 overlap%je(count) = je
7943 overlap%tileMe (count) = 1
7944 overlap%tileNbr(count) = 1
7945 overlap%dir(count) = dir
7947 overlap%rotation(count) = one_hundred_eighty
7949 overlap%rotation(count) = zero
7953 end subroutine insert_update_overlap
7956 subroutine insert_overlap_type(overlap, pe, tileMe, tileNbr, is, ie, js, je, dir, &
7957 rotation, from_contact)
7958 type(overlap_type),
intent(inout) :: overlap
7959 integer,
intent(in ) :: tileMe, tileNbr, pe
7960 integer,
intent(in ) :: is, ie, js, je
7961 integer,
intent(in ) :: dir, rotation
7962 logical,
intent(in ) :: from_contact
7965 if( overlap%count == 0 )
then
7968 if(overlap%pe .NE. pe)
call mpp_error(fatal, &
7969 "mpp_domains_define.inc(insert_overlap_type): mismatch on pe")
7971 overlap%count = overlap%count+1
7972 count = overlap%count
7973 if(count > maxoverlap)
call mpp_error(fatal,
"mpp_domains_define.inc(insert_overlap_type):"//&
7974 &
" number of overlap is greater than MAXOVERLAP, increase MAXOVERLAP")
7975 overlap%tileMe (count) = tileme
7976 overlap%tileNbr (count) = tilenbr
7977 overlap%is (count) = is
7978 overlap%ie (count) = ie
7979 overlap%js (count) = js
7980 overlap%je (count) = je
7981 overlap%dir (count) = dir
7982 overlap%rotation (count) = rotation
7983 overlap%from_contact(count) = from_contact
7984 overlap%msgsize (count) = (ie-is+1)*(je-js+1)
7986 end subroutine insert_overlap_type
7990 subroutine deallocate_overlap_type( overlap)
7991 type(overlap_type),
intent(inout) :: overlap
7993 if(overlap%count == 0)
then
7994 if( .NOT.
associated(overlap%tileMe))
return
7996 if( .NOT.
associated(overlap%tileMe))
call mpp_error(fatal, &
7997 "deallocate_overlap_type(mpp_domains_define): overlap is not been allocated")
7999 if(
ASSOCIATED(overlap%tileMe))
deallocate(overlap%tileMe)
8000 if(
ASSOCIATED(overlap%tileNbr))
deallocate(overlap%tileNbr)
8001 if(
ASSOCIATED(overlap%is))
deallocate(overlap%is)
8002 if(
ASSOCIATED(overlap%ie))
deallocate(overlap%ie)
8003 if(
ASSOCIATED(overlap%js))
deallocate(overlap%js)
8004 if(
ASSOCIATED(overlap%je))
deallocate(overlap%je)
8005 if(
ASSOCIATED(overlap%dir))
deallocate(overlap%dir)
8006 if(
ASSOCIATED(overlap%index))
deallocate(overlap%index)
8007 if(
ASSOCIATED(overlap%rotation))
deallocate(overlap%rotation)
8008 if(
ASSOCIATED(overlap%from_contact))
deallocate(overlap%from_contact)
8009 if(
ASSOCIATED(overlap%msgsize))
deallocate(overlap%msgsize)
8012 end subroutine deallocate_overlap_type
8015 subroutine deallocate_overlapspec(overlap)
8016 type(overlapspec),
intent(inout) :: overlap
8019 if(
ASSOCIATED(overlap%send))
then
8020 do n = 1,
size(overlap%send(:))
8021 call deallocate_overlap_type(overlap%send(n))
8023 deallocate(overlap%send)
8025 if(
ASSOCIATED(overlap%recv))
then
8026 do n = 1,
size(overlap%recv(:))
8027 call deallocate_overlap_type(overlap%recv(n))
8029 deallocate(overlap%recv)
8033 end subroutine deallocate_overlapspec
8037 subroutine add_update_overlap( overlap_out, overlap_in)
8038 type(overlap_type),
intent(inout) :: overlap_out
8039 type(overlap_type),
intent(in ) :: overlap_in
8040 type(overlap_type) :: overlap
8041 integer :: count, count_in, count_out, n
8044 count_in = overlap_in %count
8045 count_out = overlap_out%count
8046 count = count_in+count_out
8047 if(count_in == 0)
call mpp_error(fatal, &
8048 "mpp_domains_define.inc(add_update_overlap): overlap_in%count is zero")
8050 if(count_out == 0)
then
8051 if(
associated(overlap_out%tileMe))
call mpp_error(fatal, &
8052 "mpp_domains_define.inc(add_update_overlap): overlap is already been allocated but count=0")
8053 call allocate_update_overlap(overlap_out, count_in)
8054 overlap_out%pe = overlap_in%pe
8056 if(overlap_in%pe .NE. overlap_out%pe)
call mpp_error(fatal, &
8057 "mpp_domains_define.inc(add_update_overlap): mismatch of pe between overlap_in and overlap_out")
8059 call allocate_update_overlap(overlap, count_out)
8060 overlap%tileMe (1:count_out) = overlap_out%tileMe (1:count_out)
8061 overlap%tileNbr (1:count_out) = overlap_out%tileNbr (1:count_out)
8062 overlap%is (1:count_out) = overlap_out%is (1:count_out)
8063 overlap%ie (1:count_out) = overlap_out%ie (1:count_out)
8064 overlap%js (1:count_out) = overlap_out%js (1:count_out)
8065 overlap%je (1:count_out) = overlap_out%je (1:count_out)
8066 overlap%dir (1:count_out) = overlap_out%dir (1:count_out)
8067 overlap%rotation (1:count_out) = overlap_out%rotation (1:count_out)
8068 overlap%from_contact(1:count_out) = overlap_out%from_contact(1:count_out)
8069 call deallocate_overlap_type(overlap_out)
8070 call allocate_update_overlap(overlap_out, count)
8071 overlap_out%tileMe (1:count_out) = overlap%tileMe (1:count_out)
8072 overlap_out%tileNbr (1:count_out) = overlap%tileNbr (1:count_out)
8073 overlap_out%is (1:count_out) = overlap%is (1:count_out)
8074 overlap_out%ie (1:count_out) = overlap%ie (1:count_out)
8075 overlap_out%js (1:count_out) = overlap%js (1:count_out)
8076 overlap_out%je (1:count_out) = overlap%je (1:count_out)
8077 overlap_out%dir (1:count_out) = overlap%dir (1:count_out)
8078 overlap_out%rotation (1:count_out) = overlap%rotation (1:count_out)
8079 overlap_out%index (1:count_out) = overlap%index (1:count_out)
8080 overlap_out%from_contact(1:count_out) = overlap%from_contact(1:count_out)
8081 overlap_out%msgsize (1:count_out) = overlap%msgsize (1:count_out)
8082 call deallocate_overlap_type(overlap)
8084 overlap_out%count = count
8085 overlap_out%tileMe (count_out+1:count) = overlap_in%tileMe (1:count_in)
8086 overlap_out%tileNbr (count_out+1:count) = overlap_in%tileNbr (1:count_in)
8087 overlap_out%is (count_out+1:count) = overlap_in%is (1:count_in)
8088 overlap_out%ie (count_out+1:count) = overlap_in%ie (1:count_in)
8089 overlap_out%js (count_out+1:count) = overlap_in%js (1:count_in)
8090 overlap_out%je (count_out+1:count) = overlap_in%je (1:count_in)
8091 overlap_out%dir (count_out+1:count) = overlap_in%dir (1:count_in)
8092 overlap_out%rotation (count_out+1:count) = overlap_in%rotation (1:count_in)
8093 overlap_out%from_contact(count_out+1:count) = overlap_in%from_contact(1:count_in)
8095 do n = count_out+1, count
8096 overlap_out%msgsize(n) = (overlap_out%ie(n)-overlap_out%is(n)+1)*(overlap_out%je(n)-overlap_out%js(n)+1)
8100 end subroutine add_update_overlap
8103 subroutine expand_update_overlap_list(overlapList, npes)
8104 type(overlap_type),
pointer :: overlapList(:)
8105 integer,
intent(in ) :: npes
8106 type(overlap_type),
pointer,
save :: newlist(:) => null()
8107 integer :: nlist_old, nlist, m
8109 nlist_old =
size(overlaplist(:))
8110 if(nlist_old .GE. npes)
call mpp_error(fatal, &
8111 'mpp_domains_define.inc(expand_update_overlap_list): size of overlaplist should be smaller than npes')
8112 nlist = min(npes, 2*nlist_old)
8113 allocate(newlist(nlist))
8115 call add_update_overlap(newlist(m), overlaplist(m))
8116 call deallocate_overlap_type(overlaplist(m))
8119 deallocate(overlaplist)
8120 overlaplist => newlist
8125 end subroutine expand_update_overlap_list
8128 subroutine expand_check_overlap_list(overlaplist, npes)
8129 type(overlap_type),
pointer :: overlaplist(:)
8130 integer,
intent(in) :: npes
8131 type(overlap_type),
pointer,
save :: newlist(:) => null()
8132 integer :: nlist_old, nlist, m
8134 nlist_old =
size(overlaplist(:))
8135 if(nlist_old .GE. npes)
call mpp_error(fatal, &
8136 'mpp_domains_define.inc(expand_check_overlap_list): size of overlaplist should be smaller than npes')
8137 nlist = min(npes, 2*nlist_old)
8138 allocate(newlist(nlist))
8139 do m = 1,
size(overlaplist(:))
8141 call deallocate_overlap_type(overlaplist(m))
8143 deallocate(overlaplist)
8144 overlaplist => newlist
8149 end subroutine expand_check_overlap_list
8153 subroutine check_overlap_pe_order(domain, overlap, name)
8154 type(domain2d),
intent(in) :: domain
8155 type(overlapspec),
intent(in) :: overlap
8156 character(len=*),
intent(in) :: name
8161 if( overlap%nsend > maxlist)
call mpp_error(fatal, &
8162 "mpp_domains_define.inc(check_overlap_pe_order): overlap%nsend > MAXLIST, increase MAXLIST")
8163 if( overlap%nrecv > maxlist)
call mpp_error(fatal, &
8164 "mpp_domains_define.inc(check_overlap_pe_order): overlap%nrecv > MAXLIST, increase MAXLIST")
8166 do m = 2, overlap%nsend
8167 pe1 = overlap%send(m-1)%pe
8168 pe2 = overlap%send(m)%pe
8170 if( pe2 == domain%pe )
then
8171 print*, trim(name)//
" at pe = ", domain%pe,
": send pe is ", pe1, pe2
8172 call mpp_error(fatal, &
8173 "mpp_domains_define.inc(check_overlap_pe_order): send pe2 can not equal to domain%pe")
8174 else if( (pe1 > domain%pe .AND. pe2 > domain%pe) .OR. (pe1 < domain%pe .AND. pe2 < domain%pe))
then
8175 if( pe2 < pe1 )
then
8176 print*, trim(name)//
" at pe = ", domain%pe,
": send pe is ", pe1, pe2
8177 call mpp_error(fatal, &
8178 "mpp_domains_define.inc(check_overlap_pe_order): pe is not in right order for send 1")
8180 else if ( pe2 > domain%pe .AND. pe1 < domain%pe )
then
8181 print*, trim(name)//
" at pe = ", domain%pe,
": send pe is ", pe1, pe2
8182 call mpp_error(fatal, &
8183 "mpp_domains_define.inc(check_overlap_pe_order): pe is not in right order for send 2")
8188 do m = 2, overlap%nrecv
8189 pe1 = overlap%recv(m-1)%pe
8190 pe2 = overlap%recv(m)%pe
8192 if( pe2 == domain%pe )
then
8193 print*, trim(name)//
" at pe = ", domain%pe,
": recv pe is ", pe1, pe2
8194 call mpp_error(fatal, &
8195 "mpp_domains_define.inc(check_overlap_pe_order): recv pe2 can not equal to domain%pe")
8196 else if( (pe1 > domain%pe .AND. pe2 > domain%pe) .OR. (pe1 < domain%pe .AND. pe2 < domain%pe))
then
8197 if( pe2 > pe1 )
then
8198 print*, trim(name)//
" at pe = ", domain%pe,
": recv pe is ", pe1, pe2
8199 call mpp_error(fatal, &
8200 "mpp_domains_define.inc(check_overlap_pe_order): pe is not in right order for recv 1")
8202 else if ( pe2 < domain%pe .AND. pe1 > domain%pe )
then
8203 print*, trim(name)//
" at pe = ", domain%pe,
": recv pe is ", pe1, pe2
8204 call mpp_error(fatal, &
8205 "mpp_domains_define.inc(check_overlap_pe_order): pe is not in right order for recv 2")
8210 end subroutine check_overlap_pe_order
8214 subroutine set_domain_comm_inf(update)
8215 type(overlapspec),
intent(inout) :: update
8217 integer :: m, totsize, n
8223 do m = 1, update%nrecv
8225 do n = 1, update%recv(m)%count
8226 totsize = totsize + update%recv(m)%msgsize(n)
8228 update%recv(m)%totsize = totsize
8230 update%recv(m)%start_pos = 0
8232 update%recv(m)%start_pos = update%recv(m-1)%start_pos + update%recv(m-1)%totsize
8234 update%recvsize = update%recvsize + totsize
8237 do m = 1, update%nsend
8239 do n = 1, update%send(m)%count
8240 totsize = totsize + update%send(m)%msgsize(n)
8242 update%send(m)%totsize = totsize
8244 update%send(m)%start_pos = 0
8246 update%send(m)%start_pos = update%send(m-1)%start_pos + update%send(m-1)%totsize
8248 update%sendsize = update%sendsize + totsize
8254 end subroutine set_domain_comm_inf
subroutine mpp_modify_domain2d(domain_in, domain_out, isc, iec, jsc, jec, isg, ieg, jsg, jeg, whalo, ehalo, shalo, nhalo)
subroutine set_check_overlap(domain, position)
set up the overlapping for boundary check if the domain is symmetry. The check will be done on curren...
subroutine apply_cyclic_offset(lstart, lend, offset, gstart, gend, gsize)
add offset to the index
logical function mpp_mosaic_defined()
Accessor function for value of mosaic_defined.
subroutine set_contact_point(domain, position)
this routine sets the overlapping between tiles for E,C,N-cell based on T-cell overlapping
subroutine mpp_define_domains1d(global_indices, ndivs, domain, pelist, flags, halo, extent, maskmap, memory_size, begin_halo, end_halo)
Define data and computational domains on a 1D set of data (isg:ieg) and assign them to PEs.
subroutine set_bound_overlap(domain, position)
set up the overlapping for boundary if the domain is symmetry.
subroutine define_contact_point(domain, position, num_contact, tile1, tile2, align1, align2, refine1, refine2, istart1, iend1, jstart1, jend1, istart2, iend2, jstart2, jend2, isgList, iegList, jsgList, jegList)
compute the overlapping between tiles for the T-cell.
subroutine mpp_define_mosaic_pelist(sizes, pe_start, pe_end, pelist, costpertile)
Defines a pelist for use with mosaic tiles.
subroutine mpp_define_io_domain(domain, io_layout)
Define the layout for IO pe's for the given domain.
subroutine mpp_compute_extent(isg, ieg, ndivs, ibegin, iend, extent)
Computes extents for a grid decomposition with the given indices and divisions.
subroutine mpp_modify_domain1d(domain_in, domain_out, cbegin, cend, gbegin, gend, hbegin, hend)
Modifies the exents of a domain.
subroutine compute_overlaps_fold_west(domain, position, ishift, jshift)
Computes remote domain overlaps assumes only one in each direction will calculate the overlapping for...
subroutine mpp_define_mosaic(global_indices, layout, domain, num_tile, num_contact, tile1, tile2, istart1, iend1, jstart1, jend1, istart2, iend2, jstart2, jend2, pe_start, pe_end, pelist, whalo, ehalo, shalo, nhalo, xextent, yextent, maskmap, name, memory_size, symmetry, xflags, yflags, tile_id)
Defines a domain for mosaic tile grids.
subroutine fill_contact(Contact, tile, is1, ie1, js1, je1, is2, ie2, js2, je2, align1, align2, refine1, refine2)
always fill the contact according to index order.
subroutine mpp_define_layout2d(global_indices, ndivs, layout)
subroutine add_check_overlap(overlap_out, overlap_in)
this routine adds the overlap_in into overlap_out
subroutine mpp_compute_block_extent(isg, ieg, ndivs, ibegin, iend)
Computes the extents of a grid block.
subroutine compute_overlaps(domain, position, update, check, ishift, jshift, x_cyclic_offset, y_cyclic_offset, whalo, ehalo, shalo, nhalo)
Computes remote domain overlaps.
subroutine mpp_get_domain_shift(domain, ishift, jshift, position)
Returns the shift value in x and y-direction according to domain position..
subroutine compute_overlaps_fold_east(domain, position, ishift, jshift)
computes remote domain overlaps assumes only one in each direction will calculate the overlapping for...
subroutine compute_overlaps_fold_south(domain, position, ishift, jshift)
Computes remote domain overlaps assumes only one in each direction will calculate the overlapping for...
subroutine set_overlaps(domain, overlap_in, overlap_out, whalo_out, ehalo_out, shalo_out, nhalo_out)
this routine sets up the overlapping for mpp_update_domains for arbitrary halo update....
subroutine mpp_define_domains2d(global_indices, layout, domain, pelist, xflags, yflags, xhalo, yhalo, xextent, yextent, maskmap, name, symmetry, memory_size, whalo, ehalo, shalo, nhalo, is_mosaic, tile_count, tile_id, complete, x_cyclic_offset, y_cyclic_offset)
Define 2D data and computational domain on global rectilinear cartesian domain (isg:ieg,...
subroutine mpp_sync_self(pelist, check, request, msg_size, msg_type)
This is to check if current PE's outstanding puts are complete but we can't use shmem_fence because w...
integer function stdout()
This function returns the current standard fortran unit numbers for output.
integer function stderr()
This function returns the current standard fortran unit numbers for error messages.
subroutine mpp_declare_pelist(pelist, name, commID)
Declare a pelist.
integer function stdlog()
This function returns the current standard fortran unit numbers for log messages. Log messages,...
integer function mpp_npes()
Returns processor count for current pelist.
integer function mpp_pe()
Returns processor ID.