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) )
692 allocate( pesall(0:mpp_npes()-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)
700 allocate( pes(0:mpp_npes()-1) )
701 allocate( pesall(0:mpp_npes()-1) )
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)
1115110
format (
' X-AXIS = ',24i4,/,(11x,24i4))
1116120
format (
' Y-AXIS = ',24i4,/,(11x,24i4))
1119 deallocate( pes, pesall)
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
1396 call mpp_declare_pelist(pelist_tile, commid=domain%tile_comm_id)
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
2151 iunit = mpp_pe() + 1000
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
2730 iunit = mpp_pe() + 1000
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.
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
3323 iunit = mpp_pe() + 1000
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
3596 iunit = mpp_pe() + 1000
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
3961 iunit = mpp_pe() + 1000
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
4227 iunit = mpp_pe() + 1000
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.
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)
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
5764 iunit = mpp_pe() + 1000
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.
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