4 !***********************************************************************
5 !* GNU Lesser General Public License
7 !* This file
is part of the GFDL Flexible Modeling System (FMS).
9 !* FMS
is free software: you can redistribute it and/or modify it under
10 !* the terms of the GNU Lesser General Public License as published by
11 !* the Free Software Foundation, either
version 3 of the License, or (at
12 !* your option) any later
version.
14 !* FMS
is distributed in the hope that it
will be useful, but WITHOUT
15 !* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 !* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 !* You should have
received a copy of the GNU Lesser General Public
20 !* License along with FMS. If
not, see <http:
21 !***********************************************************************
23 subroutine MPP_DO_UPDATE_AD_3D_V_(f_addrsx,f_addrsy, domain, update_x, update_y, &
24 d_type, ke, gridtype, flags)
25 !updates data domain of 3D
field whose computational domains have been computed
27 type(domain2d), intent(in) :: domain
28 type(overlapSpec), intent(in) :: update_x, update_y
30 MPP_TYPE_, intent(in) :: d_type ! creates unique interface
32 integer, intent(in), optional :: flags
34 MPP_TYPE_ :: fieldx(update_x%xbegin:update_x%xend, update_x%ybegin:update_x%yend,ke)
35 MPP_TYPE_ :: fieldy(update_y%xbegin:update_y%xend, update_y%ybegin:update_y%yend,ke)
36 pointer(ptr_fieldx, fieldx)
37 pointer(ptr_fieldy, fieldy)
40 integer :: l_size, l,
i,
j,
k,
is,
ie,
js,
je,
n,
m 45 integer :: send_start_pos, nsend
46 integer :: send_msgsize(2*MAXLIST)
49 logical ::
send(8),
recv(8), update_edge_only
54 integer :: buffer_recv_size, shift
55 integer :: rank_x, rank_y, ind_x, ind_y, cur_rank
60 if( PRESENT(flags) ) then
62 ! The following
test is so that SCALAR_PAIR can be used alone with the
63 ! same default update pattern as without.
71 if( BTEST(
update_flags,NORTH) .AND. BTEST(domain%fold,NORTH) .AND. BTEST(gridtype,SOUTH) ) &
72 call
mpp_error( FATAL,
'MPP_DO_UPDATE_V: Incompatible grid offset and fold.' )
79 if( update_edge_only ) then
95 l_size =
size(f_addrsx,1)
96 nlist =
size(domain%list(:))
97 ptr = LOC(mpp_domains_stack)
100 nsend_x = update_x%nsend
101 nsend_y = update_y%nsend
102 nrecv_x = update_x%nrecv
103 nrecv_y = update_y%nrecv
106 allocate(msg1(0:nlist-1), msg2(0:nlist-1) )
109 cur_rank = get_rank_recv(domain, update_x, update_y, rank_x, rank_y, ind_x, ind_y)
111 do while (ind_x .LE. nrecv_x .OR. ind_y .LE. nrecv_y)
113 if(cur_rank == rank_x) then
115 do
n = 1, update_x%
recv(ind_x)%count
116 dir = update_x%
recv(ind_x)%dir(
n)
124 if(ind_x .LE. nrecv_x) then
125 rank_x = update_x%
recv(ind_x)%
pe - domain%
pe 126 if(rank_x .LE.0) rank_x = rank_x + nlist
131 if(cur_rank == rank_y) then
133 do
n = 1, update_y%
recv(ind_y)%count
134 dir = update_y%
recv(ind_y)%dir(
n)
142 if(ind_y .LE. nrecv_y) then
143 rank_y = update_y%
recv(ind_y)%
pe - domain%
pe 144 if(rank_y .LE.0) rank_y = rank_y + nlist
149 cur_rank =
max(rank_x, rank_y)
151 call mpp_recv( msg1(
m), glen=1,
from_pe=
from_pe, block=.FALSE., tag=COMM_TAG_1)
155 cur_rank = get_rank_send(domain, update_x, update_y, rank_x, rank_y, ind_x, ind_y)
156 do while (ind_x .LE. nsend_x .OR. ind_y .LE. nsend_y)
158 if(cur_rank == rank_x) then
160 do
n = 1, update_x%
send(ind_x)%count
161 dir = update_x%
send(ind_x)%dir(
n)
169 if(ind_x .LE. nsend_x) then
170 rank_x = update_x%
send(ind_x)%
pe - domain%
pe 171 if(rank_x .LT.0) rank_x = rank_x + nlist
176 if(cur_rank == rank_y) then
178 do
n = 1, update_y%
send(ind_y)%count
179 dir = update_y%
send(ind_y)%dir(
n)
187 if(ind_y .LE. nsend_y) then
188 rank_y = update_y%
send(ind_y)%
pe - domain%
pe 189 if(rank_y .LT.0) rank_y = rank_y + nlist
194 cur_rank =
min(rank_x, rank_y)
197 call mpp_sync_self(
check=EVENT_RECV)
199 if(msg1(
m) .NE. msg2(
m)) then
200 print*, "My
pe = ", mpp_pe(), ",domain
name =", trim(domain%
name), ",from
pe=", &
207 write(
outunit,*)"NOTE from mpp_do_updateV: message sizes are matched between
send and
recv for domain " &
209 deallocate(msg1, msg2)
213 cur_rank = get_rank_recv(domain, update_x, update_y, rank_x, rank_y, ind_x, ind_y)
215 do while (ind_x .LE. nrecv_x .OR. ind_y .LE. nrecv_y)
217 select
case(gridtype)
218 case(BGRID_NE, BGRID_SW, AGRID)
219 if(cur_rank == rank_x) then
221 do
n = 1, update_x%
recv(ind_x)%count
222 dir = update_x%
recv(ind_x)%dir(
n)
224 tMe = update_x%
recv(ind_x)%tileMe(
n)
233 if(ind_x .LE. nrecv_x) then
234 rank_x = update_x%
recv(ind_x)%
pe - domain%
pe 235 if(rank_x .LE.0) rank_x = rank_x + nlist
241 case(CGRID_NE, CGRID_SW)
242 if(cur_rank == rank_x) then
244 do
n = 1, update_x%
recv(ind_x)%count
245 dir = update_x%
recv(ind_x)%dir(
n)
253 if(ind_x .LE. nrecv_x) then
254 rank_x = update_x%
recv(ind_x)%
pe - domain%
pe 255 if(rank_x .LE.0) rank_x = rank_x + nlist
260 if(cur_rank == rank_y) then
262 do
n = 1, update_y%
recv(ind_y)%count
263 dir = update_y%
recv(ind_y)%dir(
n)
271 if(ind_y .LE. nrecv_y) then
272 rank_y = update_y%
recv(ind_y)%
pe - domain%
pe 273 if(rank_y .LE.0) rank_y = rank_y + nlist
279 cur_rank =
max(rank_x, rank_y)
283 buffer_pos = buffer_pos +
msgsize 286 buffer_recv_size = buffer_pos
289 buffer_pos = buffer_recv_size
290 cur_rank = get_rank_unpack(domain, update_x, update_y, rank_x, rank_y, ind_x, ind_y)
292 do while (ind_x > 0 .OR. ind_y > 0)
294 select
case ( gridtype )
295 case(BGRID_NE, BGRID_SW, AGRID)
296 if(cur_rank == rank_x) then
297 do
n = update_x%
recv(ind_x)%count, 1, -1
298 dir = update_x%
recv(ind_x)%dir(
n)
300 tMe = update_x%
recv(ind_x)%tileMe(
n)
306 do l=1, l_size ! loop over number of
fields 307 ptr_fieldx = f_addrsx(l, tMe)
308 ptr_fieldy = f_addrsy(l, tMe)
313 buffer(
pos-1) = fieldx(
i,
j,
k)
314 buffer(
pos) = fieldy(
i,
j,
k)
322 end do ! do dir=8,1,-1
325 if(ind_x .GT. 0) then
326 rank_x = update_x%
recv(ind_x)%
pe - domain%
pe 327 if(rank_x .LE.0) rank_x = rank_x + nlist
333 case(CGRID_NE, CGRID_SW)
334 if(cur_rank == rank_y) then
335 do
n = update_y%
recv(ind_y)%count, 1, -1
336 dir = update_y%
recv(ind_y)%dir(
n)
338 tMe = update_y%
recv(ind_y)%tileMe(
n)
344 do l=1,l_size ! loop over number of
fields 345 ptr_fieldx = f_addrsx(l, tMe)
346 ptr_fieldy = f_addrsy(l, tMe)
351 buffer(
pos) = fieldy(
i,
j,
k)
360 if(ind_y .GT. 0) then
361 rank_y = update_y%
recv(ind_y)%
pe - domain%
pe 362 if(rank_y .LE.0) rank_y = rank_y + nlist
367 if(cur_rank == rank_x) then
368 do
n = update_x%
recv(ind_x)%count, 1, -1
369 dir = update_x%
recv(ind_x)%dir(
n)
371 tMe = update_x%
recv(ind_x)%tileMe(
n)
377 do l=1,l_size ! loop over number of
fields 378 ptr_fieldx = f_addrsx(l, tMe)
379 ptr_fieldy = f_addrsy(l, tMe)
384 buffer(
pos) = fieldx(
i,
j,
k)
393 if(ind_x .GT. 0) then
394 rank_x = update_x%
recv(ind_x)%
pe - domain%
pe 395 if(rank_x .LE.0) rank_x = rank_x + nlist
401 cur_rank =
min(rank_x, rank_y)
404 ! ---northern boundary fold
406 if(domain%symmetry) shift = 1
407 if( BTEST(domain%fold,NORTH) .AND. (.NOT.BTEST(
update_flags,SCALAR_BIT)) )then
409 if( domain%y(1)%data%
begin.LE.
j .AND.
j.LE.domain%y(1)%data%
end+shift )then !fold
is within domain
410 !poles
set to 0: BGRID only
411 if( gridtype.EQ.BGRID_NE )then
415 if( .NOT. domain%symmetry )
is =
is - 1
416 do
i =
is ,
ie, midpoint
417 if( domain%x(1)%data%
begin.LE.
i .AND.
i.LE. domain%x(1)%data%
end+shift )then
419 ptr_fieldx = f_addrsx(l, 1)
420 ptr_fieldy = f_addrsy(l, 1)
430 ! the following code code block correct an
error where the data in your halo coming from
431 ! other
half may have the wrong sign
435 select
case(gridtype)
437 if(domain%symmetry) then
444 if( 2*
is-domain%x(1)%data%
begin.GT.domain%x(1)%data%
end+shift ) &
447 ptr_fieldx = f_addrsx(l, 1)
448 ptr_fieldy = f_addrsy(l, 1)
460 if( 2*
is-domain%x(1)%data%
begin-1.GT.domain%x(1)%data%
end ) &
463 ptr_fieldy = f_addrsy(l, 1)
477 ie = domain%x(1)%data%
end 479 select
case(gridtype)
484 ptr_fieldx = f_addrsx(l, 1)
485 ptr_fieldy = f_addrsy(l, 1)
488 fieldx(
i,
j,
k) = -fieldx(
i,
j,
k)
489 fieldy(
i,
j,
k) = -fieldy(
i,
j,
k)
495 ptr_fieldy = f_addrsy(l, 1)
498 fieldy(
i,
j,
k) = -fieldy(
i,
j,
k)
505 else
if( BTEST(domain%fold,SOUTH) .AND. (.NOT.BTEST(
update_flags,SCALAR_BIT)) )then ! ---southern boundary fold
506 ! NOTE: symmetry
is assumed for fold-
south boundary
508 if( domain%y(1)%data%
begin.LE.
j .AND.
j.LE.domain%y(1)%data%
end+shift )then !fold
is within domain
510 !poles
set to 0: BGRID only
511 if( gridtype.EQ.BGRID_NE )then
514 do
i =
is ,
ie, midpoint
515 if( domain%x(1)%data%
begin.LE.
i .AND.
i.LE. domain%x(1)%data%
end+shift )then
517 ptr_fieldx = f_addrsx(l, 1)
518 ptr_fieldy = f_addrsy(l, 1)
528 ! the following code code block correct an
error where the data in your halo coming from
529 ! other
half may have the wrong sign
533 select
case(gridtype)
538 if( 2*
is-domain%x(1)%data%
begin.GT.domain%x(1)%data%
end+shift ) &
541 ptr_fieldx = f_addrsx(l, 1)
542 ptr_fieldy = f_addrsy(l, 1)
554 if( 2*
is-domain%x(1)%data%
begin-1.GT.domain%x(1)%data%
end ) &
557 ptr_fieldy = f_addrsy(l, 1)
571 ie = domain%x(1)%data%
end 573 select
case(gridtype)
578 ptr_fieldx = f_addrsx(l, 1)
579 ptr_fieldy = f_addrsy(l, 1)
582 fieldx(
i,
j,
k) = -fieldx(
i,
j,
k)
583 fieldy(
i,
j,
k) = -fieldy(
i,
j,
k)
589 ptr_fieldy = f_addrsy(l, 1)
592 fieldy(
i,
j,
k) = -fieldy(
i,
j,
k)
599 else
if( BTEST(domain%fold,WEST) .AND. (.NOT.BTEST(
update_flags,SCALAR_BIT)) )then ! ---eastern boundary fold
600 ! NOTE: symmetry
is assumed for fold-
west boundary
602 if( domain%x(1)%data%
begin.LE.
i .AND.
i.LE.domain%x(1)%data%
end+shift )then !fold
is within domain
604 !poles
set to 0: BGRID only
605 if( gridtype.EQ.BGRID_NE )then
608 do
j =
js ,
je, midpoint
609 if( domain%y(1)%data%
begin.LE.
j .AND.
j.LE. domain%y(1)%data%
end+shift )then
611 ptr_fieldx = f_addrsx(l, 1)
612 ptr_fieldy = f_addrsy(l, 1)
622 ! the following code code block correct an
error where the data in your halo coming from
623 ! other
half may have the wrong sign
627 select
case(gridtype)
632 if( 2*
js-domain%y(1)%data%
begin.GT.domain%y(1)%data%
end+shift ) &
635 ptr_fieldx = f_addrsx(l, 1)
636 ptr_fieldy = f_addrsy(l, 1)
648 if( 2*
js-domain%y(1)%data%
begin-1.GT.domain%y(1)%data%
end ) &
651 ptr_fieldx = f_addrsx(l, 1)
654 fieldx(
i, 2*
js-
j-1,
k) = fieldx(
i, 2*
js-
j-1,
k) + fieldx(
i,
j,
k)
665 je = domain%y(1)%data%
end 667 select
case(gridtype)
672 ptr_fieldx = f_addrsx(l, 1)
673 ptr_fieldy = f_addrsy(l, 1)
676 fieldx(
i,
j,
k) = -fieldx(
i,
j,
k)
677 fieldy(
i,
j,
k) = -fieldy(
i,
j,
k)
683 ptr_fieldx = f_addrsx(l, 1)
686 fieldx(
i,
j,
k) = -fieldx(
i,
j,
k)
693 else
if( BTEST(domain%fold,EAST) .AND. (.NOT.BTEST(
update_flags,SCALAR_BIT)) )then ! ---eastern boundary fold
694 ! NOTE: symmetry
is assumed for fold-
west boundary
696 if( domain%x(1)%data%
begin.LE.
i .AND.
i.LE.domain%x(1)%data%
end+shift )then !fold
is within domain
698 !poles
set to 0: BGRID only
699 if( gridtype.EQ.BGRID_NE )then
702 do
j =
js ,
je, midpoint
703 if( domain%y(1)%data%
begin.LE.
j .AND.
j.LE. domain%y(1)%data%
end+shift )then
705 ptr_fieldx = f_addrsx(l, 1)
706 ptr_fieldy = f_addrsy(l, 1)
716 ! the following code code block correct an
error where the data in your halo coming from
717 ! other
half may have the wrong sign
721 select
case(gridtype)
726 if( 2*
js-domain%y(1)%data%
begin.GT.domain%y(1)%data%
end+shift ) &
729 ptr_fieldx = f_addrsx(l, 1)
730 ptr_fieldy = f_addrsy(l, 1)
742 if( 2*
js-domain%y(1)%data%
begin-1.GT.domain%y(1)%data%
end ) &
745 ptr_fieldx = f_addrsx(l, 1)
748 fieldx(
i, 2*
js-
j-1,
k) = fieldx(
i, 2*
js-
j-1,
k) + fieldx(
i,
j,
k)
759 je = domain%y(1)%data%
end 761 select
case(gridtype)
766 ptr_fieldx = f_addrsx(l, 1)
767 ptr_fieldy = f_addrsy(l, 1)
770 fieldx(
i,
j,
k) = -fieldx(
i,
j,
k)
771 fieldy(
i,
j,
k) = -fieldy(
i,
j,
k)
777 ptr_fieldx = f_addrsx(l, 1)
780 fieldx(
i,
j,
k) = -fieldx(
i,
j,
k)
792 cur_rank = get_rank_recv(domain, update_x, update_y, rank_x, rank_y, ind_x, ind_y)
794 do while (ind_x .LE. nrecv_x .OR. ind_y .LE. nrecv_y)
796 select
case(gridtype)
797 case(BGRID_NE, BGRID_SW, AGRID)
798 if(cur_rank == rank_x) then
800 do
n = 1, update_x%
recv(ind_x)%count
801 dir = update_x%
recv(ind_x)%dir(
n)
803 tMe = update_x%
recv(ind_x)%tileMe(
n)
812 if(ind_x .LE. nrecv_x) then
813 rank_x = update_x%
recv(ind_x)%
pe - domain%
pe 814 if(rank_x .LE.0) rank_x = rank_x + nlist
820 case(CGRID_NE, CGRID_SW)
821 if(cur_rank == rank_x) then
823 do
n = 1, update_x%
recv(ind_x)%count
824 dir = update_x%
recv(ind_x)%dir(
n)
832 if(ind_x .LE. nrecv_x) then
833 rank_x = update_x%
recv(ind_x)%
pe - domain%
pe 834 if(rank_x .LE.0) rank_x = rank_x + nlist
839 if(cur_rank == rank_y) then
841 do
n = 1, update_y%
recv(ind_y)%count
842 dir = update_y%
recv(ind_y)%dir(
n)
850 if(ind_y .LE. nrecv_y) then
851 rank_y = update_y%
recv(ind_y)%
pe - domain%
pe 852 if(rank_y .LE.0) rank_y = rank_y + nlist
858 cur_rank =
max(rank_x, rank_y)
863 buffer_pos = buffer_pos +
msgsize 866 buffer_recv_size = buffer_pos
867 cur_rank = get_rank_send(domain, update_x, update_y, rank_x, rank_y, ind_x, ind_y)
869 do while (ind_x .LE. nsend_x .OR. ind_y .LE. nsend_y)
871 !--- make sure the domain stack
size is big enough
874 if(cur_rank == rank_x) then
876 do
n = 1, update_x%
send(ind_x)%count
877 dir = update_x%
send(ind_x)%dir(
n)
881 if(cur_rank == rank_y) then
883 do
n = 1, update_y%
send(ind_y)%count
884 dir = update_y%
send(ind_y)%dir(
n)
889 select
case( gridtype )
890 case(BGRID_NE, BGRID_SW, AGRID)
891 if(cur_rank == rank_x) then
895 if(ind_x .LE. nsend_x) then
896 rank_x = update_x%
send(ind_x)%
pe - domain%
pe 897 if(rank_x .LT.0) rank_x = rank_x + nlist
903 case(CGRID_NE, CGRID_SW)
904 if(cur_rank == rank_x) then
907 if(ind_x .LE. nsend_x) then
908 rank_x = update_x%
send(ind_x)%
pe - domain%
pe 909 if(rank_x .LT.0) rank_x = rank_x + nlist
914 if(cur_rank == rank_y) then
917 if(ind_y .LE. nsend_y) then
918 rank_y = update_y%
send(ind_y)%
pe - domain%
pe 919 if(rank_y .LT.0) rank_y = rank_y + nlist
925 cur_rank =
min(rank_x, rank_y)
933 buffer_pos = buffer_pos +
msgsize 938 call mpp_sync_self(
check=EVENT_RECV)
941 buffer_pos = buffer_recv_size
944 cur_rank = get_rank_send(domain, update_x, update_y, rank_x, rank_y, ind_x, ind_y)
946 do while (ind_x .LE. nsend_x .OR. ind_y .LE. nsend_y)
948 select
case( gridtype )
949 case(BGRID_NE, BGRID_SW, AGRID)
950 if(cur_rank == rank_x) then
952 do
n = 1, update_x%
send(ind_x)%count
953 dir = update_x%
send(ind_x)%dir(
n)
955 tMe = update_x%
send(ind_x)%tileMe(
n)
960 select
case( update_x%
send(ind_x)%rotation(
n) )
962 do l=1,l_size ! loop over number of
fields 963 ptr_fieldx = f_addrsx(l,tMe)
964 ptr_fieldy = f_addrsy(l,tMe)
969 fieldx(
i,
j,
k)=fieldx(
i,
j,
k)+buffer(
pos-1)
977 do l=1,l_size ! loop over number of
fields 978 ptr_fieldx = f_addrsx(l,tMe)
979 ptr_fieldy = f_addrsy(l,tMe)
984 fieldy(
i,
j,
k)=fieldy(
i,
j,
k)+buffer(
pos-1)
991 do l=1,l_size ! loop over number of
fields 992 ptr_fieldx = f_addrsx(l,tMe)
993 ptr_fieldy = f_addrsy(l,tMe)
998 fieldy(
i,
j,
k)=fieldy(
i,
j,
k)-buffer(
pos-1)
1007 do l=1,l_size ! loop over number of
fields 1008 ptr_fieldx = f_addrsx(l,tMe)
1009 ptr_fieldy = f_addrsy(l,tMe)
1014 fieldy(
i,
j,
k)=fieldy(
i,
j,
k)+buffer(
pos-1)
1021 do l=1,l_size ! loop over number of
fields 1022 ptr_fieldx = f_addrsx(l,tMe)
1023 ptr_fieldy = f_addrsy(l,tMe)
1028 fieldy(
i,
j,
k)=fieldy(
i,
j,
k)+buffer(
pos-1)
1035 case( ONE_HUNDRED_EIGHTY )
1037 do l=1,l_size ! loop over number of
fields 1038 ptr_fieldx = f_addrsx(l,tMe)
1039 ptr_fieldy = f_addrsy(l,tMe)
1044 fieldx(
i,
j,
k)=fieldx(
i,
j,
k)+buffer(
pos-1)
1051 do l=1,l_size ! loop over number of
fields 1052 ptr_fieldx = f_addrsx(l,tMe)
1053 ptr_fieldy = f_addrsy(l,tMe)
1058 fieldx(
i,
j,
k)=fieldx(
i,
j,
k)-buffer(
pos-1)
1065 end select ! select
case( rotation(
n) )
1067 end do ! do
n = 1, update_x%
send(ind_x)%count
1070 if(ind_x .LE. nsend_x) then
1071 rank_x = update_x%
send(ind_x)%
pe - domain%
pe 1072 if(rank_x .LT.0) rank_x = rank_x + nlist
1078 case(CGRID_NE, CGRID_SW)
1079 if(cur_rank == rank_x) then
1081 do
n = 1, update_x%
send(ind_x)%count
1082 dir = update_x%
send(ind_x)%dir(
n)
1084 tMe = update_x%
send(ind_x)%tileMe(
n)
1087 select
case( update_x%
send(ind_x)%rotation(
n) )
1089 do l=1,l_size ! loop over number of
fields 1090 ptr_fieldx = f_addrsx(l, tMe)
1091 ptr_fieldy = f_addrsy(l, tMe)
1103 do l=1,l_size ! loop over number of
fields 1104 ptr_fieldx = f_addrsx(l, tMe)
1105 ptr_fieldy = f_addrsy(l, tMe)
1116 do l=1,l_size ! loop over number of
fields 1117 ptr_fieldx = f_addrsx(l, tMe)
1118 ptr_fieldy = f_addrsy(l, tMe)
1130 do l=1,l_size ! loop over number of
fields 1131 ptr_fieldx = f_addrsx(l, tMe)
1132 ptr_fieldy = f_addrsy(l, tMe)
1142 case(ONE_HUNDRED_EIGHTY)
1144 do l=1,l_size ! loop over number of
fields 1145 ptr_fieldx = f_addrsx(l, tMe)
1146 ptr_fieldy = f_addrsy(l, tMe)
1157 do l=1,l_size ! loop over number of
fields 1158 ptr_fieldx = f_addrsx(l, tMe)
1159 ptr_fieldy = f_addrsy(l, tMe)
1174 if(ind_x .LE. nsend_x) then
1175 rank_x = update_x%
send(ind_x)%
pe - domain%
pe 1176 if(rank_x .LT.0) rank_x = rank_x + nlist
1181 if(cur_rank == rank_y) then
1183 do
n = 1, update_y%
send(ind_y)%count
1184 dir = update_y%
send(ind_y)%dir(
n)
1186 tMe = update_y%
send(ind_y)%tileMe(
n)
1190 select
case( update_y%
send(ind_y)%rotation(
n) )
1192 do l=1,l_size ! loop over number of
fields 1193 ptr_fieldx = f_addrsx(l, tMe)
1194 ptr_fieldy = f_addrsy(l, tMe)
1205 do l=1,l_size ! loop over number of
fields 1206 ptr_fieldx = f_addrsx(l, tMe)
1207 ptr_fieldy = f_addrsy(l, tMe)
1219 do l=1,l_size ! loop over number of
fields 1220 ptr_fieldx = f_addrsx(l, tMe)
1221 ptr_fieldy = f_addrsy(l, tMe)
1232 do l=1,l_size ! loop over number of
fields 1233 ptr_fieldx = f_addrsx(l, tMe)
1234 ptr_fieldy = f_addrsy(l, tMe)
1245 case(ONE_HUNDRED_EIGHTY)
1247 do l=1,l_size ! loop over number of
fields 1248 ptr_fieldx = f_addrsx(l, tMe)
1249 ptr_fieldy = f_addrsy(l, tMe)
1260 do l=1,l_size ! loop over number of
fields 1261 ptr_fieldx = f_addrsx(l, tMe)
1262 ptr_fieldy = f_addrsy(l, tMe)
1277 if(ind_y .LE. nsend_y) then
1278 rank_y = update_y%
send(ind_y)%
pe - domain%
pe 1279 if(rank_y .LT.0) rank_y = rank_y + nlist
1285 cur_rank =
min(rank_x, rank_y)
1292 call mpp_sync_self( )
1296 end subroutine MPP_DO_UPDATE_AD_3D_V_
real(fp), parameter, public half
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! MPP_TRANSMIT !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! subroutine MPP_TRANSMIT_(put_data, put_len, to_pe, get_data, get_len, from_pe, block, tag, recv_request, send_request)!a message-passing routine intended to be reminiscent equally of both MPI and SHMEM!put_data and get_data are contiguous MPP_TYPE_ arrays!at each call, your put_data array is put to to_pe 's get_data! your get_data array is got from from_pe 's put_data!i.e we assume that typically(e.g updating halo regions) each PE performs a put _and_ a get!special PE designations:! NULL_PE:to disable a put or a get(e.g at boundaries)! ANY_PE:if remote PE for the put or get is to be unspecific! ALL_PES:broadcast and collect operations(collect not yet implemented)!ideally we would not pass length, but this f77-style call performs better(arrays passed by address, not descriptor)!further, this permits< length > contiguous words from an array of any rank to be passed(avoiding f90 rank conformance check)!caller is responsible for completion checks(mpp_sync_self) before and after integer, intent(in) ::put_len, to_pe, get_len, from_pe MPP_TYPE_, intent(in) ::put_data(*) MPP_TYPE_, intent(out) ::get_data(*) logical, intent(in), optional ::block integer, intent(in), optional ::tag integer, intent(out), optional ::recv_request, send_request logical ::block_comm integer ::i MPP_TYPE_, allocatable, save ::local_data(:) !local copy used by non-parallel code(no SHMEM or MPI) integer ::comm_tag integer ::rsize if(.NOT.module_is_initialized) call mpp_error(FATAL, 'MPP_TRANSMIT:You must first call mpp_init.') if(to_pe.EQ.NULL_PE .AND. from_pe.EQ.NULL_PE) return block_comm=.true. if(PRESENT(block)) block_comm=block if(debug) then call SYSTEM_CLOCK(tick) write(stdout_unit,'(a, i18, a, i6, a, 2i6, 2i8)')&'T=', tick, ' PE=', pe, ' MPP_TRANSMIT begin:to_pe, from_pe, put_len, get_len=', to_pe, from_pe, put_len, get_len end if comm_tag=DEFAULT_TAG if(present(tag)) comm_tag=tag!do put first and then get if(to_pe.GE.0 .AND. to_pe.LT.npes) then!use non-blocking sends if(debug .and.(current_clock.NE.0)) call SYSTEM_CLOCK(start_tick)!z1l:truly non-blocking send.! if(request(to_pe).NE.MPI_REQUEST_NULL) then !only one message from pe-> to_pe in queue *PE waiting for to_pe ! call error else get_len so only do gets but you cannot have a pure get with MPI call a get means do a wait to ensure put on remote PE is complete error call increase mpp_nml request_multiply call MPP_TRANSMIT get_len end if return end subroutine MPP_TRANSMIT_ ! MPP_BROADCAST ! subroutine but that doesn t allow !broadcast to a subset of PEs This version will
type(ext_fieldtype), dimension(:), pointer, save, private field
*f90 *************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************subroutine MPP_UPDATE_NEST_FINE_2D_(field, nest_domain, wbuffer, ebuffer, sbuffer, nbuffer, &flags, complete, position, extra_halo, name, tile_count) MPP_TYPE_, intent(in) ::field(:,:) type(nest_domain_type), intent(inout) ::nest_domain MPP_TYPE_, intent(inout) ::wbuffer(:,:) MPP_TYPE_, intent(inout) ::ebuffer(:,:) MPP_TYPE_, intent(inout) ::sbuffer(:,:) MPP_TYPE_, intent(inout) ::nbuffer(:,:) integer, intent(in), optional ::flags logical, intent(in), optional ::complete integer, intent(in), optional ::position integer, intent(in), optional ::extra_halo character(len= *), intent(in), optional ::name integer, intent(in), optional ::tile_count MPP_TYPE_ ::field3D(size(field, 1), size(field, 2), 1) MPP_TYPE_ ::wbuffer3D(size(wbuffer, 1), size(wbuffer, 2), 1) MPP_TYPE_ ::ebuffer3D(size(ebuffer, 1), size(ebuffer, 2), 1) MPP_TYPE_ ::sbuffer3D(size(sbuffer, 1), size(sbuffer, 2), 1) MPP_TYPE_ ::nbuffer3D(size(nbuffer, 1), size(nbuffer, 2), 1) pointer(ptr, field3D) pointer(ptr_w, wbuffer3D) pointer(ptr_e, ebuffer3D) pointer(ptr_s, sbuffer3D) pointer(ptr_n, nbuffer3D) ptr=LOC(field) ptr_w=LOC(wbuffer) ptr_e=LOC(ebuffer) ptr_s=LOC(sbuffer) ptr_n=LOC(nbuffer) call mpp_update_nest_fine(field3D, nest_domain, wbuffer3D, ebuffer3D, sbuffer3D, nbuffer3D, &flags, complete, position, extra_halo, name, tile_count) returnend subroutine MPP_UPDATE_NEST_FINE_2D_subroutine MPP_UPDATE_NEST_FINE_3D_(field, nest_domain, wbuffer, sbuffer, ebuffer, nbuffer, &flags, complete, position, extra_halo, name, tile_count) MPP_TYPE_, intent(in) ::field(:,:,:) type(nest_domain_type), intent(inout) ::nest_domain MPP_TYPE_, intent(inout) ::wbuffer(:,:,:) MPP_TYPE_, intent(inout) ::ebuffer(:,:,:) MPP_TYPE_, intent(inout) ::sbuffer(:,:,:) MPP_TYPE_, intent(inout) ::nbuffer(:,:,:) integer, intent(in), optional ::flags logical, intent(in), optional ::complete integer, intent(in), optional ::position integer, intent(in), optional ::extra_halo character(len= *), intent(in), optional ::name integer, intent(in), optional ::tile_count MPP_TYPE_ ::d_type type(nestSpec), pointer ::update=> set_mismatch integer ::tile update_position nbuffersz l_size integer
l_size ! loop over number of fields ke do je do i
*f90 *************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If not
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************subroutine MPP_WRITE_UNLIMITED_AXIS_1D_(unit, field, domain, data, nelems_io) integer, intent(in) ::unit type(fieldtype), intent(inout) ::field type(domain2D), intent(inout) ::domain MPP_TYPE_, intent(inout) ::data(:) integer, intent(in) ::nelems_io(:) ! number of compressed elements from each ! member of the io_domain. It MUST have the ! same order as the io_domain pelist. integer, allocatable ::pelist(:) integer ::i, j, nelems, npes type(domain2d), pointer ::io_domain=> allocatable
subroutine, public copy(self, rhs)
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! MPP_TRANSMIT !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! subroutine MPP_TRANSMIT_(put_data, put_len, to_pe, get_data, get_len, from_pe, block, tag, recv_request, send_request)!a message-passing routine intended to be reminiscent equally of both MPI and SHMEM!put_data and get_data are contiguous MPP_TYPE_ arrays!at each call, your put_data array is put to to_pe 's get_data! your get_data array is got from from_pe 's put_data!i.e we assume that typically(e.g updating halo regions) each PE performs a put _and_ a get!special PE designations:! NULL_PE:to disable a put or a get(e.g at boundaries)! ANY_PE:if remote PE for the put or get is to be unspecific! ALL_PES:broadcast and collect operations(collect not yet implemented)!ideally we would not pass length, but this f77-style call performs better(arrays passed by address, not descriptor)!further, this permits< length > contiguous words from an array of any rank to be passed(avoiding f90 rank conformance check)!caller is responsible for completion checks(mpp_sync_self) before and after integer, intent(in) ::put_len, to_pe, get_len, from_pe MPP_TYPE_, intent(in) ::put_data(*) MPP_TYPE_, intent(out) ::get_data(*) logical, intent(in), optional ::block integer, intent(in), optional ::tag integer, intent(out), optional ::recv_request, send_request logical ::block_comm integer ::i MPP_TYPE_, allocatable, save ::local_data(:) !local copy used by non-parallel code(no SHMEM or MPI) integer ::comm_tag integer ::rsize if(.NOT.module_is_initialized) call mpp_error(FATAL, 'MPP_TRANSMIT:You must first call mpp_init.') if(to_pe.EQ.NULL_PE .AND. from_pe.EQ.NULL_PE) return block_comm=.true. if(PRESENT(block)) block_comm=block if(debug) then call SYSTEM_CLOCK(tick) write(stdout_unit,'(a, i18, a, i6, a, 2i6, 2i8)')&'T=', tick, ' PE=', pe, ' MPP_TRANSMIT begin:to_pe, from_pe, put_len, get_len=', to_pe, from_pe, put_len, get_len end if comm_tag=DEFAULT_TAG if(present(tag)) comm_tag=tag!do put first and then get if(to_pe.GE.0 .AND. to_pe.LT.npes) then!use non-blocking sends if(debug .and.(current_clock.NE.0)) call SYSTEM_CLOCK(start_tick)!z1l:truly non-blocking send.! if(request(to_pe).NE.MPI_REQUEST_NULL) then !only one message from pe-> to_pe in queue *PE waiting for to_pe ! call error else get_len so only do gets but you cannot have a pure get with MPI call a get means do a wait to ensure put on remote PE is complete error call increase mpp_nml request_multiply call MPP_TRANSMIT end
integer(long), parameter true
type(field_mgr_type), dimension(max_fields), private fields
integer(long), parameter false
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! MPP_TRANSMIT !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! subroutine MPP_TRANSMIT_(put_data, put_len, to_pe, get_data, get_len, from_pe, block, tag, recv_request, send_request)!a message-passing routine intended to be reminiscent equally of both MPI and SHMEM!put_data and get_data are contiguous MPP_TYPE_ arrays!at each call, your put_data array is put to to_pe 's get_data! your get_data array is got from from_pe 's put_data!i.e we assume that typically(e.g updating halo regions) each PE performs a put _and_ a get!special PE designations:! NULL_PE:to disable a put or a get(e.g at boundaries)! ANY_PE:if remote PE for the put or get is to be unspecific! ALL_PES:broadcast and collect operations(collect not yet implemented)!ideally we would not pass length, but this f77-style call performs better(arrays passed by address, not descriptor)!further, this permits< length > contiguous words from an array of any rank to be passed(avoiding f90 rank conformance check)!caller is responsible for completion checks(mpp_sync_self) before and after integer, intent(in) ::put_len, to_pe, get_len, from_pe MPP_TYPE_, intent(in) ::put_data(*) MPP_TYPE_, intent(out) ::get_data(*) logical, intent(in), optional ::block integer, intent(in), optional ::tag integer, intent(out), optional ::recv_request, send_request logical ::block_comm integer ::i MPP_TYPE_, allocatable, save ::local_data(:) !local copy used by non-parallel code(no SHMEM or MPI) integer ::comm_tag integer ::rsize if(.NOT.module_is_initialized) call mpp_error(FATAL, 'MPP_TRANSMIT:You must first call mpp_init.') if(to_pe.EQ.NULL_PE .AND. from_pe.EQ.NULL_PE) return block_comm=.true. if(PRESENT(block)) block_comm=block if(debug) then call SYSTEM_CLOCK(tick) write(stdout_unit,'(a, i18, a, i6, a, 2i6, 2i8)')&'T=', tick, ' PE=', pe, ' MPP_TRANSMIT begin:to_pe, from_pe, put_len, get_len=', to_pe, from_pe, put_len, get_len end if comm_tag=DEFAULT_TAG if(present(tag)) comm_tag=tag!do put first and then get if(to_pe.GE.0 .AND. to_pe.LT.npes) then!use non-blocking sends if(debug .and.(current_clock.NE.0)) call SYSTEM_CLOCK(start_tick)!z1l:truly non-blocking send.! if(request(to_pe).NE.MPI_REQUEST_NULL) then !only one message from pe-> to_pe in queue *PE waiting for to_pe ! call error else get_len so only do gets but you cannot have a pure get with MPI call a get means do a wait to ensure put on remote PE is complete error call increase mpp_nml request_multiply call MPP_TRANSMIT get_len end if return end subroutine MPP_TRANSMIT_ ! MPP_BROADCAST ! subroutine but that doesn t allow !broadcast to a subset of PEs This version and mpp_transmit will remain !backward compatible MPP_TYPE_
l_size ! loop over number of fields ke do j
integer, parameter, public west
l_size ! loop over number of fields ke do je do ie to je n if(.NOT. d_comm%R_do_buf(list)) cycle from_pe
l_size ! loop over number of fields ke do je do ie to to_pe
character(len=128) version
l_size ! loop over number of fields ke do je do ie to is
integer, parameter, public global
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! MPP_TRANSMIT !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! subroutine MPP_TRANSMIT_(put_data, put_len, to_pe, get_data, get_len, from_pe, block, tag, recv_request, send_request)!a message-passing routine intended to be reminiscent equally of both MPI and SHMEM!put_data and get_data are contiguous MPP_TYPE_ arrays!at each call, your put_data array is put to to_pe 's get_data! your get_data array is got from from_pe 's put_data!i.e we assume that typically(e.g updating halo regions) each PE performs a put _and_ a get!special PE designations:! NULL_PE:to disable a put or a get(e.g at boundaries)! ANY_PE:if remote PE for the put or get is to be unspecific! ALL_PES:broadcast and collect operations(collect not yet implemented)!ideally we would not pass length, but this f77-style call performs better(arrays passed by address, not descriptor)!further, this permits< length > contiguous words from an array of any rank to be passed(avoiding f90 rank conformance check)!caller is responsible for completion checks(mpp_sync_self) before and after integer, intent(in) ::put_len, to_pe, get_len, from_pe MPP_TYPE_, intent(in) ::put_data(*) MPP_TYPE_, intent(out) ::get_data(*) logical, intent(in), optional ::block integer, intent(in), optional ::tag integer, intent(out), optional ::recv_request, send_request logical ::block_comm integer ::i MPP_TYPE_, allocatable, save ::local_data(:) !local copy used by non-parallel code(no SHMEM or MPI) integer ::comm_tag integer ::rsize if(.NOT.module_is_initialized) call mpp_error(FATAL, 'MPP_TRANSMIT:You must first call mpp_init.') if(to_pe.EQ.NULL_PE .AND. from_pe.EQ.NULL_PE) return block_comm=.true. if(PRESENT(block)) block_comm=block if(debug) then call SYSTEM_CLOCK(tick) write(stdout_unit,'(a, i18, a, i6, a, 2i6, 2i8)')&'T=', tick, ' PE=', pe, ' MPP_TRANSMIT begin:to_pe, from_pe, put_len, get_len=', to_pe, from_pe, put_len, get_len end if comm_tag=DEFAULT_TAG if(present(tag)) comm_tag=tag!do put first and then get if(to_pe.GE.0 .AND. to_pe.LT.npes) then!use non-blocking sends if(debug .and.(current_clock.NE.0)) call SYSTEM_CLOCK(start_tick)!z1l:truly non-blocking send.! if(request(to_pe).NE.MPI_REQUEST_NULL) then !only one message from pe-> to_pe in queue *PE waiting for to_pe ! call error else get_len so only do gets but you cannot have a pure get with MPI call mpp_error(FATAL, 'MPP_TRANSMIT:you cannot transmit to ANY_PE using MPI.') else if(to_pe.NE.NULL_PE) then !no other valid cases except NULL_PE call mpp_error(FATAL
l_size ! loop over number of fields ke do je do ie to je msgsize
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************subroutine READ_RECORD_CORE_(unit, field, nwords, data, start, axsiz) integer, intent(in) ::unit type(fieldtype), intent(in) ::field integer, intent(in) ::nwords MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in) ::start(:), axsiz(:) integer(SHORT_KIND) ::i2vals(nwords)!rab used in conjunction with transfer intrinsic to determine size of a variable integer(KIND=1) ::one_byte(8) integer ::word_sz!#ifdef __sgi integer(INT_KIND) ::ivals(nwords) real(FLOAT_KIND) ::rvals(nwords)!#else! integer ::ivals(nwords)! real ::rvals(nwords)!#endif real(DOUBLE_KIND) ::r8vals(nwords) pointer(ptr1, i2vals) pointer(ptr2, ivals) pointer(ptr3, rvals) pointer(ptr4, r8vals) if(mpp_io_stack_size< nwords) call mpp_io_set_stack_size(nwords) call mpp_error(FATAL, 'MPP_READ currently requires use_netCDF option') end subroutine READ_RECORD_CORE_ subroutine READ_RECORD_(unit, field, nwords, data, time_level, domain, position, tile_count, start_in, axsiz_in)!routine that is finally called by all mpp_read routines to perform the read!a non-netCDF record contains:! field ID! a set of 4 coordinates(is:ie, js:je) giving the data subdomain! a timelevel and a timestamp(=NULLTIME if field is static)! 3D real data(stored as 1D)!if you are using direct access I/O, the RECL argument to OPEN must be large enough for the above!in a global direct access file, record position on PE is given by %record.!Treatment of timestamp:! We assume that static fields have been passed without a timestamp.! Here that is converted into a timestamp of NULLTIME.! For non-netCDF fields, field is treated no differently, but is written! with a timestamp of NULLTIME. There is no check in the code to prevent! the user from repeatedly writing a static field. integer, intent(in) ::unit, nwords type(fieldtype), intent(in) ::field MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in), optional ::time_level type(domain2D), intent(in), optional ::domain integer, intent(in), optional ::position, tile_count integer, intent(in), optional ::start_in(:), axsiz_in(:) integer, dimension(size(field%axes(:))) ::start, axsiz integer ::tlevel !, subdomain(4) integer ::i, error, is, ie, js, je, isg, ieg, jsg, jeg type(domain2d), pointer ::io_domain=> tlevel if(PRESENT(start_in) .AND. PRESENT(axsiz_in)) then if(size(start(! the data domain and compute domain must refer to the subdomain being passed ! In this case
integer, parameter, public east
logical function received(this, seqno)
logical debug_message_passing
*f90 *************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************subroutine MPP_UPDATE_NEST_FINE_2D_(field, nest_domain, wbuffer, ebuffer, sbuffer, nbuffer, &flags, complete, position, extra_halo, name, tile_count) MPP_TYPE_, intent(in) ::field(:,:) type(nest_domain_type), intent(inout) ::nest_domain MPP_TYPE_, intent(inout) ::wbuffer(:,:) MPP_TYPE_, intent(inout) ::ebuffer(:,:) MPP_TYPE_, intent(inout) ::sbuffer(:,:) MPP_TYPE_, intent(inout) ::nbuffer(:,:) integer, intent(in), optional ::flags logical, intent(in), optional ::complete integer, intent(in), optional ::position integer, intent(in), optional ::extra_halo character(len= *), intent(in), optional ::name integer, intent(in), optional ::tile_count MPP_TYPE_ ::field3D(size(field, 1), size(field, 2), 1) MPP_TYPE_ ::wbuffer3D(size(wbuffer, 1), size(wbuffer, 2), 1) MPP_TYPE_ ::ebuffer3D(size(ebuffer, 1), size(ebuffer, 2), 1) MPP_TYPE_ ::sbuffer3D(size(sbuffer, 1), size(sbuffer, 2), 1) MPP_TYPE_ ::nbuffer3D(size(nbuffer, 1), size(nbuffer, 2), 1) pointer(ptr, field3D) pointer(ptr_w, wbuffer3D) pointer(ptr_e, ebuffer3D) pointer(ptr_s, sbuffer3D) pointer(ptr_n, nbuffer3D) ptr=LOC(field) ptr_w=LOC(wbuffer) ptr_e=LOC(ebuffer) ptr_s=LOC(sbuffer) ptr_n=LOC(nbuffer) call mpp_update_nest_fine(field3D, nest_domain, wbuffer3D, ebuffer3D, sbuffer3D, nbuffer3D, &flags, complete, position, extra_halo, name, tile_count) returnend subroutine MPP_UPDATE_NEST_FINE_2D_subroutine MPP_UPDATE_NEST_FINE_3D_(field, nest_domain, wbuffer, sbuffer, ebuffer, nbuffer, &flags, complete, position, extra_halo, name, tile_count) MPP_TYPE_, intent(in) ::field(:,:,:) type(nest_domain_type), intent(inout) ::nest_domain MPP_TYPE_, intent(inout) ::wbuffer(:,:,:) MPP_TYPE_, intent(inout) ::ebuffer(:,:,:) MPP_TYPE_, intent(inout) ::sbuffer(:,:,:) MPP_TYPE_, intent(inout) ::nbuffer(:,:,:) integer, intent(in), optional ::flags logical, intent(in), optional ::complete integer, intent(in), optional ::position integer, intent(in), optional ::extra_halo character(len= *), intent(in), optional ::name integer, intent(in), optional ::tile_count MPP_TYPE_ ::d_type type(nestSpec), pointer ::update=> set_mismatch integer ::tile update_flags
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************subroutine READ_RECORD_CORE_(unit, field, nwords, data, start, axsiz) integer, intent(in) ::unit type(fieldtype), intent(in) ::field integer, intent(in) ::nwords MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in) ::start(:), axsiz(:) integer(SHORT_KIND) ::i2vals(nwords)!rab used in conjunction with transfer intrinsic to determine size of a variable integer(KIND=1) ::one_byte(8) integer ::word_sz!#ifdef __sgi integer(INT_KIND) ::ivals(nwords) real(FLOAT_KIND) ::rvals(nwords)!#else! integer ::ivals(nwords)! real ::rvals(nwords)!#endif real(DOUBLE_KIND) ::r8vals(nwords) pointer(ptr1, i2vals) pointer(ptr2, ivals) pointer(ptr3, rvals) pointer(ptr4, r8vals) if(mpp_io_stack_size< nwords) call mpp_io_set_stack_size(nwords) call mpp_error(FATAL, 'MPP_READ currently requires use_netCDF option') end subroutine READ_RECORD_CORE_ subroutine READ_RECORD_(unit, field, nwords, data, time_level, domain, position, tile_count, start_in, axsiz_in)!routine that is finally called by all mpp_read routines to perform the read!a non-netCDF record contains:! field ID! a set of 4 coordinates(is:ie, js:je) giving the data subdomain! a timelevel and a timestamp(=NULLTIME if field is static)! 3D real data(stored as 1D)!if you are using direct access I/O, the RECL argument to OPEN must be large enough for the above!in a global direct access file, record position on PE is given by %record.!Treatment of timestamp:! We assume that static fields have been passed without a timestamp.! Here that is converted into a timestamp of NULLTIME.! For non-netCDF fields, field is treated no differently, but is written! with a timestamp of NULLTIME. There is no check in the code to prevent! the user from repeatedly writing a static field. integer, intent(in) ::unit, nwords type(fieldtype), intent(in) ::field MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in), optional ::time_level type(domain2D), intent(in), optional ::domain integer, intent(in), optional ::position, tile_count integer, intent(in), optional ::start_in(:), axsiz_in(:) integer, dimension(size(field%axes(:))) ::start, axsiz integer ::tlevel !, subdomain(4) integer ::i, error, is, ie, js, je, isg, ieg, jsg, jeg type(domain2d), pointer ::io_domain=> tlevel if(PRESENT(start_in) .AND. PRESENT(axsiz_in)) then if(size(start(! the data domain and compute domain must refer to the subdomain being passed ! In this ! since that attempts to gather all data on PE size(field%axes(:)) axsiz(i)
integer, parameter, public north
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! MPP_TRANSMIT !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! subroutine MPP_TRANSMIT_(put_data, put_len, to_pe, get_data, get_len, from_pe, block, tag, recv_request, send_request)!a message-passing routine intended to be reminiscent equally of both MPI and SHMEM!put_data and get_data are contiguous MPP_TYPE_ arrays!at each call, your put_data array is put to to_pe 's get_data! your get_data array is got from from_pe 's put_data!i.e we assume that typically(e.g updating halo regions) each PE performs a put _and_ a get!special PE designations:! NULL_PE:to disable a put or a get(e.g at boundaries)! ANY_PE:if remote PE for the put or get is to be unspecific! ALL_PES:broadcast and collect operations(collect not yet implemented)!ideally we would not pass length, but this f77-style call performs better(arrays passed by address, not descriptor)!further, this permits< length > contiguous words from an array of any rank to be passed(avoiding f90 rank conformance check)!caller is responsible for completion checks(mpp_sync_self) before and after integer, intent(in) ::put_len, to_pe, get_len, from_pe MPP_TYPE_, intent(in) ::put_data(*) MPP_TYPE_, intent(out) ::get_data(*) logical, intent(in), optional ::block integer, intent(in), optional ::tag integer, intent(out), optional ::recv_request, send_request logical ::block_comm integer ::i MPP_TYPE_, allocatable, save ::local_data(:) !local copy used by non-parallel code(no SHMEM or MPI) integer ::comm_tag integer ::rsize if(.NOT.module_is_initialized) call mpp_error(FATAL, 'MPP_TRANSMIT:You must first call mpp_init.') if(to_pe.EQ.NULL_PE .AND. from_pe.EQ.NULL_PE) return block_comm=.true. if(PRESENT(block)) block_comm=block if(debug) then call SYSTEM_CLOCK(tick) write(stdout_unit,'(a, i18, a, i6, a, 2i6, 2i8)')&'T=', tick, ' PE=', pe, ' MPP_TRANSMIT begin:to_pe, from_pe, put_len, get_len=', to_pe, from_pe, put_len, get_len end if comm_tag=DEFAULT_TAG if(present(tag)) comm_tag=tag!do put first and then get if(to_pe.GE.0 .AND. to_pe.LT.npes) then!use non-blocking sends if(debug .and.(current_clock.NE.0)) call SYSTEM_CLOCK(start_tick)!z1l:truly non-blocking send.! if(request(to_pe).NE.MPI_REQUEST_NULL) then !only one message from pe-> to_pe in queue *PE waiting for to_pe ! call error else get_len so only do gets but you cannot have a pure get with MPI call a get means do a wait to ensure put on remote PE is complete error call increase mpp_nml request_multiply call MPP_TRANSMIT get_len end if return end subroutine MPP_TRANSMIT_ ! MPP_BROADCAST ! subroutine but that doesn t allow !broadcast to a subset of PEs This version and mpp_transmit will remain !backward compatible intent(inout) a
integer, parameter, public cyclic
l_size ! loop over number of fields ke do je do ie pos
integer, parameter, public south
l_size ! loop over number of fields ke do je do ie to js
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! MPP_TRANSMIT !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! subroutine MPP_TRANSMIT_(put_data, put_len, to_pe, get_data, get_len, from_pe, block, tag, recv_request, send_request)!a message-passing routine intended to be reminiscent equally of both MPI and SHMEM!put_data and get_data are contiguous MPP_TYPE_ arrays!at each call, your put_data array is put to to_pe 's get_data! your get_data array is got from from_pe 's put_data!i.e we assume that typically(e.g updating halo regions) each PE performs a put _and_ a get!special PE designations:! NULL_PE:to disable a put or a get(e.g at boundaries)! ANY_PE:if remote PE for the put or get is to be unspecific! ALL_PES:broadcast and collect operations(collect not yet implemented)!ideally we would not pass length, but this f77-style call performs better(arrays passed by address, not descriptor)!further, this permits< length > contiguous words from an array of any rank to be passed(avoiding f90 rank conformance check)!caller is responsible for completion checks(mpp_sync_self) before and after integer, intent(in) ::put_len, to_pe, get_len, from_pe MPP_TYPE_, intent(in) ::put_data(*) MPP_TYPE_, intent(out) ::get_data(*) logical, intent(in), optional ::block integer, intent(in), optional ::tag integer, intent(out), optional ::recv_request, send_request logical ::block_comm integer ::i MPP_TYPE_, allocatable, save ::local_data(:) !local copy used by non-parallel code(no SHMEM or MPI) integer ::comm_tag integer ::rsize if(.NOT.module_is_initialized) call mpp_error(FATAL, 'MPP_TRANSMIT:You must first call mpp_init.') if(to_pe.EQ.NULL_PE .AND. from_pe.EQ.NULL_PE) return block_comm=.true. if(PRESENT(block)) block_comm=block if(debug) then call SYSTEM_CLOCK(tick) write(stdout_unit,'(a, i18, a, i6, a, 2i6, 2i8)')&'T=', tick, ' PE=', pe, ' MPP_TRANSMIT begin:to_pe, from_pe, put_len, get_len=', to_pe, from_pe, put_len, get_len end if comm_tag=DEFAULT_TAG if(present(tag)) comm_tag=tag!do put first and then get if(to_pe.GE.0 .AND. to_pe.LT.npes) then!use non-blocking sends if(debug .and.(current_clock.NE.0)) call SYSTEM_CLOCK(start_tick)!z1l:truly non-blocking send.! if(request(to_pe).NE.MPI_REQUEST_NULL) then !only one message from pe-> to_pe in queue *PE waiting for to_pe ! call error else get_len so only do gets but you cannot have a pure get with MPI call a get means do a wait to ensure put on remote PE is complete error call increase mpp_nml request_multiply call MPP_TRANSMIT get_len end if return end subroutine MPP_TRANSMIT_ ! MPP_BROADCAST ! subroutine but that doesn t allow !broadcast to a subset of PEs This version and mpp_transmit will remain !backward compatible intent(inout) MPP_BROADCAST begin