28 public :: comm_data_transfer
32 interface comm_data_transfer
35 end interface comm_data_transfer
40 end interface comm_var
42 public :: comm_stat_sum
43 public :: comm_stat_sum_eachlayer
44 public :: comm_stat_avg
45 public :: comm_stat_max
46 public :: comm_stat_min
48 interface comm_stat_sum
51 end interface comm_stat_sum
53 interface comm_stat_sum_eachlayer
56 end interface comm_stat_sum_eachlayer
58 interface comm_stat_avg
61 end interface comm_stat_avg
63 interface comm_stat_max
66 end interface comm_stat_max
68 interface comm_stat_min
71 end interface comm_stat_min
132 private :: comm_list_generate
133 private :: comm_sortdest
134 private :: comm_sortdest_pl
135 private :: comm_sortdest_singular
137 private :: comm_debugtest
143 logical,
private :: comm_apply_barrier = .false.
144 integer,
private :: comm_varmax = 50
145 logical,
private :: debug = .false.
146 logical,
private :: testonly = .false.
149 integer,
private,
parameter :: rellist_vindex = 6
150 integer,
private,
parameter :: i_recv_grid = 1
151 integer,
private,
parameter :: i_recv_rgn = 2
152 integer,
private,
parameter :: i_recv_prc = 3
153 integer,
private,
parameter :: i_send_grid = 4
154 integer,
private,
parameter :: i_send_rgn = 5
155 integer,
private,
parameter :: i_send_prc = 6
157 integer,
private,
allocatable :: rellist(:,:)
158 integer,
private :: rellist_nmax
161 integer,
private,
parameter :: recv_nlim = 20
162 integer,
private,
parameter :: send_nlim = 20
164 integer,
private :: copy_nmax_r2r = 0
165 integer,
private :: recv_nmax_r2r = 0
166 integer,
private :: send_nmax_r2r = 0
168 integer,
private :: copy_nmax_p2r = 0
169 integer,
private :: recv_nmax_p2r = 0
170 integer,
private :: send_nmax_p2r = 0
172 integer,
private :: copy_nmax_r2p = 0
173 integer,
private :: recv_nmax_r2p = 0
174 integer,
private :: send_nmax_r2p = 0
176 integer,
private :: singular_nmax = 0
178 integer,
private,
parameter :: info_vindex = 3
179 integer,
private,
parameter :: i_size = 1
180 integer,
private,
parameter :: i_prc_from = 2
181 integer,
private,
parameter :: i_prc_to = 3
184 integer,
private,
parameter :: list_vindex = 4
185 integer,
private,
parameter :: i_grid_from = 1
186 integer,
private,
parameter :: i_l_from = 2
187 integer,
private,
parameter :: i_grid_to = 3
188 integer,
private,
parameter :: i_l_to = 4
191 integer,
private :: req_count
206 namelist / param_comm_icoa / &
207 comm_apply_barrier, &
217 if(
io_l )
write(
io_fid_log,*)
'+++ Module[comm]/Category[common share]'
221 if(
io_l )
write(
io_fid_log,*)
'*** PARAM_COMM_ICOA is not specified. use default.'
222 elseif( ierr > 0 )
then
223 write(*,*)
'xxx Not appropriate names in namelist PARAM_COMM_ICOA. STOP.'
230 elseif(
rp ==
sp )
then
233 write(*,*)
'xxx precision is not supportd'
243 if(
io_l )
write(
io_fid_log,*)
'====== communication information ======'
245 call comm_list_generate
248 call comm_sortdest_pl
249 call comm_sortdest_singular
251 allocate(
req_list( recv_nmax_r2r + send_nmax_r2r &
252 + recv_nmax_p2r + send_nmax_p2r &
253 + recv_nmax_r2p + send_nmax_r2p ) )
255 if( testonly )
call comm_debugtest
262 subroutine comm_list_generate
290 integer :: prc, prc_rmt
291 integer :: rgnid, rgnid_rmt
292 integer :: i, j, i_rmt, j_rmt
321 rellist(i_recv_grid,cnt) =
suf(i,j)
322 rellist(i_recv_rgn, cnt) = rgnid
323 rellist(i_recv_prc, cnt) = prc
324 rellist(i_send_grid,cnt) =
suf(i_rmt,j_rmt)
325 rellist(i_send_rgn, cnt) = rgnid_rmt
326 rellist(i_send_prc, cnt) = prc_rmt
343 rellist(i_recv_grid,cnt) =
suf(i,j)
344 rellist(i_recv_rgn, cnt) = rgnid
345 rellist(i_recv_prc, cnt) = prc
346 rellist(i_send_grid,cnt) =
suf(i_rmt,j_rmt)
347 rellist(i_send_rgn, cnt) = rgnid_rmt
348 rellist(i_send_prc, cnt) = prc_rmt
367 rellist(i_recv_grid,cnt) =
suf(i,j)
368 rellist(i_recv_rgn, cnt) = rgnid
369 rellist(i_recv_prc, cnt) = prc
370 rellist(i_send_grid,cnt) =
suf(i_rmt,j_rmt)
371 rellist(i_send_rgn, cnt) = rgnid_rmt
372 rellist(i_send_prc, cnt) = prc_rmt
389 rellist(i_recv_grid,cnt) =
suf(i,j)
390 rellist(i_recv_rgn, cnt) = rgnid
391 rellist(i_recv_prc, cnt) = prc
392 rellist(i_send_grid,cnt) =
suf(i_rmt,j_rmt)
393 rellist(i_send_rgn, cnt) = rgnid_rmt
394 rellist(i_send_prc, cnt) = prc_rmt
413 rellist(i_recv_grid,cnt) =
suf(i,j)
414 rellist(i_recv_rgn, cnt) = rgnid
415 rellist(i_recv_prc, cnt) = prc
416 rellist(i_send_grid,cnt) =
suf(i_rmt,j_rmt)
417 rellist(i_send_rgn, cnt) = rgnid_rmt
418 rellist(i_send_prc, cnt) = prc_rmt
435 rellist(i_recv_grid,cnt) =
suf(i,j)
436 rellist(i_recv_rgn, cnt) = rgnid
437 rellist(i_recv_prc, cnt) = prc
438 rellist(i_send_grid,cnt) =
suf(i_rmt,j_rmt)
439 rellist(i_send_rgn, cnt) = rgnid_rmt
440 rellist(i_send_prc, cnt) = prc_rmt
459 rellist(i_recv_grid,cnt) =
suf(i,j)
460 rellist(i_recv_rgn, cnt) = rgnid
461 rellist(i_recv_prc, cnt) = prc
462 rellist(i_send_grid,cnt) =
suf(i_rmt,j_rmt)
463 rellist(i_send_rgn, cnt) = rgnid_rmt
464 rellist(i_send_prc, cnt) = prc_rmt
481 rellist(i_recv_grid,cnt) =
suf(i,j)
482 rellist(i_recv_rgn, cnt) = rgnid
483 rellist(i_recv_prc, cnt) = prc
484 rellist(i_send_grid,cnt) =
suf(i_rmt,j_rmt)
485 rellist(i_send_rgn, cnt) = rgnid_rmt
486 rellist(i_send_prc, cnt) = prc_rmt
513 rellist(i_recv_grid,cnt) =
suf(i,j)
514 rellist(i_recv_rgn, cnt) = rgnid
515 rellist(i_recv_prc, cnt) = prc
516 rellist(i_send_grid,cnt) =
suf(i_rmt,j_rmt)
517 rellist(i_send_rgn, cnt) = rgnid_rmt
518 rellist(i_send_prc, cnt) = prc_rmt
535 rellist(i_recv_grid,cnt) =
suf(i,j)
536 rellist(i_recv_rgn, cnt) = rgnid
537 rellist(i_recv_prc, cnt) = prc
538 rellist(i_send_grid,cnt) =
suf(i_rmt,j_rmt)
539 rellist(i_send_rgn, cnt) = rgnid_rmt
540 rellist(i_send_prc, cnt) = prc_rmt
563 rellist(i_recv_grid,cnt) =
suf(i,j)
564 rellist(i_recv_rgn, cnt) = rgnid
565 rellist(i_recv_prc, cnt) = prc
566 rellist(i_send_grid,cnt) =
suf(i_rmt,j_rmt)
567 rellist(i_send_rgn, cnt) = rgnid_rmt
568 rellist(i_send_prc, cnt) = prc_rmt
584 rellist(i_recv_grid,cnt) =
suf(i,j)
585 rellist(i_recv_rgn, cnt) = rgnid
586 rellist(i_recv_prc, cnt) = prc
587 rellist(i_send_grid,cnt) =
suf(i_rmt,j_rmt)
588 rellist(i_send_rgn, cnt) = rgnid_rmt
589 rellist(i_send_prc, cnt) = prc_rmt
607 rellist(i_recv_grid,cnt) =
suf(i,j)
608 rellist(i_recv_rgn, cnt) = rgnid
609 rellist(i_recv_prc, cnt) = prc
610 rellist(i_send_grid,cnt) =
suf(i_rmt,j_rmt)
611 rellist(i_send_rgn, cnt) = rgnid_rmt
612 rellist(i_send_prc, cnt) = prc_rmt
635 rellist(i_recv_grid,cnt) =
suf(i,j)
636 rellist(i_recv_rgn, cnt) = rgnid
637 rellist(i_recv_prc, cnt) = prc
638 rellist(i_send_grid,cnt) =
suf(i_rmt,j_rmt)
639 rellist(i_send_rgn, cnt) = rgnid_rmt
640 rellist(i_send_prc, cnt) = prc_rmt
651 if(
io_l )
write(
io_fid_log,
'(7(A10))')
'Count',
'|recv_grid',
'| recv_rgn',
'| recv_prc', &
652 '|send_grid',
'| send_rgn',
'| send_prc'
653 do cnt = 1, rellist_nmax
659 end subroutine comm_list_generate
663 subroutine comm_sortdest
674 integer :: sendbuf1(1)
675 integer :: recvbuf1(1)
677 integer,
allocatable :: sendbuf_info(:)
678 integer,
allocatable :: recvbuf_info(:)
679 integer,
allocatable :: sendbuf_list(:,:,:)
680 integer,
allocatable :: recvbuf_list(:,:,:)
681 integer,
allocatable :: req_list_r2r(:)
683 integer :: recv_nglobal_r2r
684 integer :: send_size_nglobal
686 integer :: cnt, irank, ipos
687 integer :: totalsize, rank, tag
689 integer :: i_from, j_from, r_from, g_from, l_from, p_from
690 integer :: i_to, j_to, r_to, g_to, l_to, p_to
707 allocate(
recv_list_r2r(list_vindex,rellist_nmax,recv_nlim) )
708 allocate(
send_list_r2r(list_vindex,rellist_nmax,send_nlim) )
714 do cnt = 1, rellist_nmax
716 if ( rellist(i_recv_prc,cnt) == rellist(i_send_prc,cnt) )
then
727 do n = 1, recv_nmax_r2r
728 if (
recv_info_r2r(i_prc_from,n) == rellist(i_send_prc,cnt) )
then
734 if ( irank < 0 )
then
735 recv_nmax_r2r = recv_nmax_r2r + 1
736 irank = recv_nmax_r2r
745 recv_list_r2r(i_grid_from,ipos,irank) = rellist(i_send_grid,cnt)
747 recv_list_r2r(i_grid_to ,ipos,irank) = rellist(i_recv_grid,cnt)
761 sendbuf1(1) = recv_nmax_r2r
763 call mpi_allreduce( sendbuf1(1), &
771 recv_nglobal_r2r = recvbuf1(1)
774 allocate( sendbuf_info(info_vindex*recv_nglobal_r2r) )
775 allocate( recvbuf_info(info_vindex*recv_nglobal_r2r*
prc_nprocs) )
778 do irank = 1, recv_nmax_r2r
779 n = (irank-1) * info_vindex
786 totalsize = info_vindex * recv_nglobal_r2r
788 if ( totalsize > 0 )
then
789 call mpi_allgather( sendbuf_info(1), &
799 send_size_nglobal = 0
803 n = (p-1) * info_vindex
805 if ( recvbuf_info(n+i_prc_from) ==
prc_myrank )
then
806 send_nmax_r2r = send_nmax_r2r + 1
807 irank = send_nmax_r2r
814 send_size_nglobal = max( send_size_nglobal, recvbuf_info(n+i_size) )
818 if(
io_l )
write(
io_fid_log,*)
'*** Recv_nmax_r2r(global) = ', recv_nglobal_r2r
819 if(
io_l )
write(
io_fid_log,*)
'*** Recv_nmax_r2r(local) = ', recv_nmax_r2r
820 if(
io_l )
write(
io_fid_log,*)
'*** Send_nmax_r2r(local) = ', send_nmax_r2r
821 if(
io_l )
write(
io_fid_log,*)
'*** Send_size_r2r(global) = ', send_size_nglobal
823 if(
io_l )
write(
io_fid_log,
'(A)')
'|---------------------------------------'
826 do irank = 1, recv_nmax_r2r
829 do irank = 1, send_nmax_r2r
834 allocate( req_list_r2r(recv_nmax_r2r+send_nmax_r2r) )
836 allocate( sendbuf_list(list_vindex,send_size_nglobal,recv_nmax_r2r) )
837 allocate( recvbuf_list(list_vindex,send_size_nglobal,send_nmax_r2r) )
838 sendbuf_list(:,:,:) = -1
842 do irank = 1, send_nmax_r2r
843 req_count = req_count + 1
848 call mpi_irecv( recvbuf_list(1,1,irank), &
854 req_list_r2r(req_count), &
858 do irank = 1, recv_nmax_r2r
863 req_count = req_count + 1
868 call mpi_isend( sendbuf_list(1,1,irank), &
874 req_list_r2r(req_count), &
879 if ( recv_nmax_r2r+send_nmax_r2r > 0 )
then
880 call mpi_waitall( recv_nmax_r2r+send_nmax_r2r, &
882 mpi_statuses_ignore, &
886 do irank = 1, send_nmax_r2r
897 '|ifrom',
'|jfrom',
'|rfrom',
'|gfrom',
'|lfrom',
'|pfrom', &
898 '| ito',
'| jto',
'| rto',
'| gto',
'| lto',
'| pto'
913 if(
io_l )
write(
io_fid_log,
'(13(I6))') ipos, i_from, j_from, r_from, g_from, l_from, p_from, &
914 i_to , j_to , r_to , g_to , l_to , p_to
919 do irank = 1, recv_nmax_r2r
921 '|ifrom',
'|jfrom',
'|rfrom',
'|gfrom',
'|lfrom',
'|pfrom', &
922 '| ito',
'| jto',
'| rto',
'| gto',
'| lto',
'| pto'
937 if(
io_l )
write(
io_fid_log,
'(13(I6))') ipos, i_from, j_from, r_from, g_from, l_from, p_from, &
938 i_to , j_to , r_to , g_to , l_to , p_to
944 do irank = 1, send_nmax_r2r
946 '|ifrom',
'|jfrom',
'|rfrom',
'|gfrom',
'|lfrom',
'|pfrom', &
947 '| ito',
'| jto',
'| rto',
'| gto',
'| lto',
'| pto'
962 if(
io_l )
write(
io_fid_log,
'(13(I6))') ipos, i_from, j_from, r_from, g_from, l_from, p_from, &
963 i_to , j_to , r_to , g_to , l_to , p_to
974 end subroutine comm_sortdest
978 subroutine comm_sortdest_pl
999 integer :: prc, prc_rmt
1000 integer :: rgnid, rgnid_rmt
1001 logical :: check_vert_pl
1004 integer :: irank, ipos
1006 integer,
parameter :: send_size_nglobal_pl = 10
1008 integer :: l, l_pl, n, v, vv
1009 integer :: i_from, j_from, r_from, g_from, l_from, p_from
1010 integer :: i_to, j_to, r_to, g_to, l_to, p_to
1024 allocate(
recv_list_p2r(list_vindex,send_size_nglobal_pl,recv_nlim) )
1025 allocate(
send_list_p2r(list_vindex,send_size_nglobal_pl,send_nlim) )
1041 allocate(
recv_list_r2p(list_vindex,send_size_nglobal_pl,recv_nlim) )
1042 allocate(
send_list_r2p(list_vindex,send_size_nglobal_pl,send_nlim) )
1056 if ( rgnid_rmt ==
i_npl )
then
1062 elseif( rgnid_rmt ==
i_spl )
then
1070 if ( check_vert_pl )
then
1081 if ( prc == prc_rmt )
then
1093 do n = 1, recv_nmax_p2r
1100 if ( irank < 0 )
then
1101 recv_nmax_p2r = recv_nmax_p2r + 1
1102 irank = recv_nmax_p2r
1118 do n = 1, send_nmax_r2p
1125 if ( irank < 0 )
then
1126 send_nmax_r2p = send_nmax_r2p + 1
1127 irank = send_nmax_r2p
1160 if ( rgnid ==
i_npl )
then
1165 elseif( rgnid ==
i_spl )
then
1175 if ( prc == prc_rmt )
then
1187 do n = 1, recv_nmax_r2p
1194 if ( irank < 0 )
then
1195 recv_nmax_r2p = recv_nmax_r2p + 1
1196 irank = recv_nmax_r2p
1212 do n = 1, send_nmax_p2r
1219 if ( irank < 0 )
then
1220 send_nmax_p2r = send_nmax_p2r + 1
1221 irank = send_nmax_p2r
1255 if(
io_l )
write(
io_fid_log,*)
'*** Recv_nmax_p2r(local) = ', recv_nmax_p2r
1256 if(
io_l )
write(
io_fid_log,*)
'*** Send_nmax_p2r(local) = ', send_nmax_p2r
1258 if(
io_l )
write(
io_fid_log,
'(A)')
'|---------------------------------------'
1261 do irank = 1, recv_nmax_p2r
1264 do irank = 1, send_nmax_p2r
1273 '|rfrom',
'|gfrom',
'|lfrom',
'|pfrom', &
1274 '| ito',
'| jto',
'| rto',
'| gto',
'| lto',
'| pto'
1287 if(
io_l )
write(
io_fid_log,
'(11(I6))') ipos, r_from, g_from, l_from, p_from, &
1288 i_to , j_to , r_to , g_to , l_to , p_to
1293 do irank = 1, recv_nmax_p2r
1295 '|rfrom',
'|gfrom',
'|lfrom',
'|pfrom', &
1296 '| ito',
'| jto',
'| rto',
'| gto',
'| lto',
'| pto'
1309 if(
io_l )
write(
io_fid_log,
'(11(I6))') ipos, r_from, g_from, l_from, p_from, &
1310 i_to , j_to , r_to , g_to , l_to , p_to
1316 do irank = 1, send_nmax_p2r
1318 '|rfrom',
'|gfrom',
'|lfrom',
'|pfrom', &
1319 '| ito',
'| jto',
'| rto',
'| gto',
'| lto',
'| pto'
1332 if(
io_l )
write(
io_fid_log,
'(11(I6))') ipos, r_from, g_from, l_from, p_from, &
1333 i_to , j_to , r_to , g_to , l_to , p_to
1339 if(
io_l )
write(
io_fid_log,*)
'*** Recv_nmax_r2p(local) = ', recv_nmax_r2p
1340 if(
io_l )
write(
io_fid_log,*)
'*** Send_nmax_r2p(local) = ', send_nmax_r2p
1342 if(
io_l )
write(
io_fid_log,
'(A)')
'|---------------------------------------'
1345 do irank = 1, recv_nmax_r2p
1348 do irank = 1, send_nmax_r2p
1357 '|ifrom',
'|jfrom',
'|rfrom',
'|gfrom',
'|lfrom',
'|pfrom', &
1358 '| rto',
'| gto',
'| lto',
'| pto'
1371 if(
io_l )
write(
io_fid_log,
'(11(I6))') ipos, i_from, j_from, r_from, g_from, l_from, p_from, &
1372 r_to , g_to , l_to , p_to
1377 do irank = 1, recv_nmax_r2p
1379 '|ifrom',
'|jfrom',
'|rfrom',
'|gfrom',
'|lfrom',
'|pfrom', &
1380 '| rto',
'| gto',
'| lto',
'| pto'
1393 if(
io_l )
write(
io_fid_log,
'(11(I6))') ipos, i_from, j_from, r_from, g_from, l_from, p_from, &
1394 r_to , g_to , l_to , p_to
1400 do irank = 1, send_nmax_r2p
1402 '|ifrom',
'|jfrom',
'|rfrom',
'|gfrom',
'|lfrom',
'|pfrom', &
1403 '| rto',
'| gto',
'| lto',
'| pto'
1416 if(
io_l )
write(
io_fid_log,
'(11(I6))') ipos, i_from, j_from, r_from, g_from, l_from, p_from, &
1417 r_to , g_to , l_to , p_to
1422 if(
io_l )
write(
io_fid_log,*)
'*** Send_size_p2r,r2p = ', send_size_nglobal_pl
1434 end subroutine comm_sortdest_pl
1438 subroutine comm_sortdest_singular
1455 integer :: i, j, i_rmt, j_rmt
1458 integer :: i_from, j_from, r_from, g_from, l_from, p_from
1459 integer :: i_to, j_to, r_to, g_to, l_to, p_to
1526 if(
io_l )
write(
io_fid_log,
'(A)')
'|---------------------------------------'
1535 '|ifrom',
'|jfrom',
'|rfrom',
'|gfrom',
'|lfrom',
'|pfrom', &
1536 '| ito',
'| jto',
'| rto',
'| gto',
'| lto',
'| pto'
1551 if(
io_l )
write(
io_fid_log,
'(13(I6))') ipos, i_from, j_from, r_from, g_from, l_from, p_from, &
1552 i_to , j_to , r_to , g_to , l_to , p_to
1557 end subroutine comm_sortdest_singular
1569 real(SP),
intent(inout) :: var (:,:,:,:)
1570 real(SP),
intent(inout) :: var_pl(:,:,:,:)
1572 integer :: shp(4), kmax, vmax
1573 integer :: totalsize, rank, tag
1574 integer :: irank, ipos, imax
1575 integer :: ij_from, l_from, ij_to, l_to
1577 integer :: k, v, ikv
1584 if ( comm_apply_barrier )
then
1598 if ( kmax * vmax >
adm_kall * comm_varmax )
then
1599 write(*,*)
'xxx [COMM_data_transfer] kmax * vmax exceeds ADM_kall * COMM_varmax, stop!'
1600 write(*,*)
'xxx kmax * vmax = ', kmax * vmax
1601 write(*,*)
'xxx ADM_kall * COMM_varmax = ',
adm_kall * comm_varmax
1625 do irank = 1, recv_nmax_r2r
1626 req_count = req_count + 1
1642 do irank = 1, recv_nmax_p2r
1643 req_count = req_count + 1
1659 do irank = 1, recv_nmax_r2p
1660 req_count = req_count + 1
1680 do irank = 1, send_nmax_r2r
1696 ikv = (v-1) * imax * kmax &
1707 req_count = req_count + 1
1708 totalsize = imax * kmax * vmax
1724 do irank = 1, send_nmax_p2r
1740 ikv = (v-1) * imax * kmax &
1751 req_count = req_count + 1
1752 totalsize = imax * kmax * vmax
1768 do irank = 1, send_nmax_r2p
1784 ikv = (v-1) * imax * kmax &
1795 req_count = req_count + 1
1796 totalsize = imax * kmax * vmax
1823 do irank = 1, copy_nmax_r2r
1839 var(ij_to,k,l_to,v) = var(ij_from,k,l_from,v)
1848 do irank = 1, copy_nmax_p2r
1864 var(ij_to,k,l_to,v) = var_pl(ij_from,k,l_from,v)
1873 do irank = 1, copy_nmax_r2p
1889 var_pl(ij_to,k,l_to,v) = var(ij_from,k,l_from,v)
1900 if ( req_count > 0 )
then
1901 call mpi_waitall( req_count, &
1903 mpi_statuses_ignore, &
1920 do irank = 1, recv_nmax_r2r
1934 ikv = (v-1) * imax * kmax &
1947 do irank = 1, recv_nmax_p2r
1961 ikv = (v-1) * imax * kmax &
1974 do irank = 1, recv_nmax_r2p
1988 ikv = (v-1) * imax * kmax &
2004 do irank = 1, singular_nmax
2020 var(ij_to,k,l_to,v) = var(ij_from,k,l_from,v)
2048 real(DP),
intent(inout) :: var (:,:,:,:)
2049 real(DP),
intent(inout) :: var_pl(:,:,:,:)
2051 integer :: shp(4), kmax, vmax
2052 integer :: totalsize, rank, tag
2053 integer :: irank, ipos, imax
2054 integer :: ij_from, l_from, ij_to, l_to
2056 integer :: k, v, ikv
2063 if ( comm_apply_barrier )
then
2077 if ( kmax * vmax >
adm_kall * comm_varmax )
then
2078 write(*,*)
'xxx [COMM_data_transfer] kmax * vmax exceeds ADM_kall * COMM_varmax, stop!'
2079 write(*,*)
'xxx kmax * vmax = ', kmax * vmax
2080 write(*,*)
'xxx ADM_kall * COMM_varmax = ',
adm_kall * comm_varmax
2104 do irank = 1, recv_nmax_r2r
2105 req_count = req_count + 1
2112 mpi_double_precision, &
2121 do irank = 1, recv_nmax_p2r
2122 req_count = req_count + 1
2129 mpi_double_precision, &
2138 do irank = 1, recv_nmax_r2p
2139 req_count = req_count + 1
2146 mpi_double_precision, &
2159 do irank = 1, send_nmax_r2r
2175 ikv = (v-1) * imax * kmax &
2186 req_count = req_count + 1
2187 totalsize = imax * kmax * vmax
2194 mpi_double_precision, &
2203 do irank = 1, send_nmax_p2r
2219 ikv = (v-1) * imax * kmax &
2230 req_count = req_count + 1
2231 totalsize = imax * kmax * vmax
2238 mpi_double_precision, &
2247 do irank = 1, send_nmax_r2p
2263 ikv = (v-1) * imax * kmax &
2274 req_count = req_count + 1
2275 totalsize = imax * kmax * vmax
2282 mpi_double_precision, &
2302 do irank = 1, copy_nmax_r2r
2318 var(ij_to,k,l_to,v) = var(ij_from,k,l_from,v)
2327 do irank = 1, copy_nmax_p2r
2343 var(ij_to,k,l_to,v) = var_pl(ij_from,k,l_from,v)
2352 do irank = 1, copy_nmax_r2p
2368 var_pl(ij_to,k,l_to,v) = var(ij_from,k,l_from,v)
2379 if ( req_count > 0 )
then
2380 call mpi_waitall( req_count, &
2382 mpi_statuses_ignore, &
2399 do irank = 1, recv_nmax_r2r
2413 ikv = (v-1) * imax * kmax &
2426 do irank = 1, recv_nmax_p2r
2440 ikv = (v-1) * imax * kmax &
2453 do irank = 1, recv_nmax_r2p
2467 ikv = (v-1) * imax * kmax &
2483 do irank = 1, singular_nmax
2499 var(ij_to,k,l_to,v) = var(ij_from,k,l_from,v)
2526 real(
dp),
intent(inout) :: var (:,:,:,:)
2528 integer :: shp(4), kmax, vmax
2529 integer :: totalsize, rank, tag
2530 integer :: irank, ipos,
imax
2531 integer :: ij_from, l_from, ij_to, l_to
2533 integer :: k, v, ikv
2537 if ( comm_apply_barrier )
then
2549 if ( kmax * vmax >
adm_kall * comm_varmax )
then
2550 write(*,*)
'xxx [COMM_data_transfer_nopl] kmax * vmax exceeds ADM_kall * COMM_varmax, stop!'
2551 write(*,*)
'xxx kmax * vmax = ', kmax * vmax
2552 write(*,*)
'xxx ADM_kall * COMM_varmax = ',
adm_kall * comm_varmax
2567 do irank = 1, recv_nmax_r2r
2568 req_count = req_count + 1
2575 mpi_double_precision, &
2584 do irank = 1, send_nmax_r2r
2595 ikv = (v-1) *
imax * kmax &
2605 req_count = req_count + 1
2606 totalsize =
imax * kmax * vmax
2612 mpi_double_precision, &
2623 do irank = 1, copy_nmax_r2r
2634 var(ij_to,k,l_to,v) = var(ij_from,k,l_from,v)
2642 if ( req_count > 0 )
then
2643 call mpi_waitall( req_count, &
2645 mpi_statuses_ignore, &
2652 do irank = 1, recv_nmax_r2r
2661 ikv = (v-1) *
imax * kmax &
2673 do irank = 1, singular_nmax
2684 var(ij_to,k,l_to,v) = var(ij_from,k,l_from,v)
2712 integer,
intent(in) :: kmax
2713 integer,
intent(in) :: vmax
2714 real(SP),
intent(inout) :: var (ADM_gall, kmax,ADM_lall, vmax)
2715 real(SP),
intent(inout) :: var_pl(ADM_gall_pl,kmax,ADM_lall_pl,vmax)
2717 real(SP) :: sendbuf_h2p_SP(kmax*vmax,PRC_RGN_total_pl)
2718 real(SP) :: recvbuf_h2p_SP(kmax*vmax,PRC_RGN_total_pl)
2720 integer :: totalsize, rank, tag
2721 integer :: irank, ipos
2722 integer :: ij_from, l_from, ij_to, l_to
2723 integer :: r_from, r_to
2729 if ( comm_apply_barrier )
then
2742 do irank = 1, send_nmax_p2r
2748 req_count = req_count + 1
2749 totalsize = kmax * vmax
2753 call mpi_irecv( recvbuf_h2p_sp(1,
i_npl), &
2764 req_count = req_count + 1
2765 totalsize = kmax * vmax
2769 call mpi_irecv( recvbuf_h2p_sp(1,
i_spl), &
2782 do irank = 1, recv_nmax_p2r
2791 kk = (v-1) * kmax + k
2792 sendbuf_h2p_sp(kk,
i_npl) = var(ij_from,k,l_from,v)
2796 req_count = req_count + 1
2797 totalsize = kmax * vmax
2801 call mpi_isend( sendbuf_h2p_sp(1,
i_npl), &
2814 kk = (v-1) * kmax + k
2815 sendbuf_h2p_sp(kk,
i_spl) = var(ij_from,k,l_from,v)
2819 req_count = req_count + 1
2820 totalsize = kmax * vmax
2824 call mpi_isend( sendbuf_h2p_sp(1,
i_spl), &
2837 do irank = 1, copy_nmax_p2r
2850 var_pl(ij_to,k,l_to,v) = var(ij_from,k,l_from,v)
2858 if ( req_count > 0 )
then
2859 call mpi_waitall( req_count, &
2861 mpi_statuses_ignore, &
2866 do irank = 1, send_nmax_p2r
2877 kk = (v-1) * kmax + k
2878 var_pl(ij_to,k,l_to,v) = recvbuf_h2p_sp(kk,
i_npl)
2886 kk = (v-1) * kmax + k
2887 var_pl(ij_to,k,l_to,v) = recvbuf_h2p_sp(kk,
i_spl)
2920 integer,
intent(in) :: kmax
2921 integer,
intent(in) :: vmax
2922 real(DP),
intent(inout) :: var (ADM_gall, kmax,ADM_lall, vmax)
2923 real(DP),
intent(inout) :: var_pl(ADM_gall_pl,kmax,ADM_lall_pl,vmax)
2925 real(DP) :: sendbuf_h2p_DP(kmax*vmax,PRC_RGN_total_pl)
2926 real(DP) :: recvbuf_h2p_DP(kmax*vmax,PRC_RGN_total_pl)
2928 integer :: totalsize, rank, tag
2929 integer :: irank, ipos
2930 integer :: ij_from, l_from, ij_to, l_to
2931 integer :: r_from, r_to
2937 if ( comm_apply_barrier )
then
2950 do irank = 1, send_nmax_p2r
2956 req_count = req_count + 1
2957 totalsize = kmax * vmax
2961 call mpi_irecv( recvbuf_h2p_dp(1,
i_npl), &
2963 mpi_double_precision, &
2972 req_count = req_count + 1
2973 totalsize = kmax * vmax
2977 call mpi_irecv( recvbuf_h2p_dp(1,
i_spl), &
2979 mpi_double_precision, &
2990 do irank = 1, recv_nmax_p2r
2999 kk = (v-1) * kmax + k
3000 sendbuf_h2p_dp(kk,
i_npl) = var(ij_from,k,l_from,v)
3004 req_count = req_count + 1
3005 totalsize = kmax * vmax
3009 call mpi_isend( sendbuf_h2p_dp(1,
i_npl), &
3011 mpi_double_precision, &
3022 kk = (v-1) * kmax + k
3023 sendbuf_h2p_dp(kk,
i_spl) = var(ij_from,k,l_from,v)
3027 req_count = req_count + 1
3028 totalsize = kmax * vmax
3032 call mpi_isend( sendbuf_h2p_dp(1,
i_spl), &
3034 mpi_double_precision, &
3045 do irank = 1, copy_nmax_p2r
3058 var_pl(ij_to,k,l_to,v) = var(ij_from,k,l_from,v)
3066 if ( req_count > 0 )
then
3067 call mpi_waitall( req_count, &
3069 mpi_statuses_ignore, &
3074 do irank = 1, send_nmax_p2r
3085 kk = (v-1) * kmax + k
3086 var_pl(ij_to,k,l_to,v) = recvbuf_h2p_dp(kk,
i_npl)
3094 kk = (v-1) * kmax + k
3095 var_pl(ij_to,k,l_to,v) = recvbuf_h2p_dp(kk,
i_spl)
3114 function suf(i,j)
result(suffix)
3126 subroutine comm_debugtest
3143 integer :: i, j, k, l, ij, rgnid, prc
3149 var(:,:,:,:) = -999.0_rp
3150 var_pl(:,:,:,:) = -999.0_rp
3161 var(ij,k,l,1) = real(prc, kind=
rp)
3162 var(ij,k,l,2) = real(rgnid,kind=
rp)
3163 var(ij,k,l,3) = real(i, kind=
rp)
3164 var(ij,k,l,4) = real(j, kind=
rp)
3171 var(1,k,l,:) = -1.0_rp
3182 var_pl(ij,k,l,1) = real(-prc, kind=
rp)
3183 var_pl(ij,k,l,2) = real(-rgnid,kind=
rp)
3184 var_pl(ij,k,l,3) = real(-ij, kind=
rp)
3185 var_pl(ij,k,l,4) = real(-ij, kind=
rp)
3205 '(',int(var(ij,k,l,1)),
',',int(var(ij,k,l,2)),
')'
3224 '(',int(var_pl(ij,k,l,1)),
',',int(var_pl(ij,k,l,2)),
')'
3245 '(',int(var(ij,k,l,3)),
',',int(var(ij,k,l,4)),
')'
3264 '(',int(var_pl(ij,k,l,3)),
',',int(var_pl(ij,k,l,4)),
')'
3275 call comm_data_transfer( var(:,:,:,:), var_pl(:,:,:,:) )
3292 '(',int(var(ij,k,l,1)),
',',int(var(ij,k,l,2)),
')'
3311 '(',int(var_pl(ij,k,l,1)),
',',int(var_pl(ij,k,l,2)),
')'
3332 '(',int(var(ij,k,l,3)),
',',int(var(ij,k,l,4)),
')'
3351 '(',int(var_pl(ij,k,l,3)),
',',int(var_pl(ij,k,l,4)),
')'
3369 var(ij,k,l,1) = real(prc, kind=
rp)
3370 var(ij,k,l,2) = real(rgnid,kind=
rp)
3371 var(ij,k,l,3) = real(i, kind=
rp)
3372 var(ij,k,l,4) = real(j, kind=
rp)
3382 var(ij,k,l,1) = real(prc, kind=
rp)
3383 var(ij,k,l,2) = real(rgnid,kind=
rp)
3384 var(ij,k,l,3) = real(i, kind=
rp)
3385 var(ij,k,l,4) = real(j, kind=
rp)
3394 call comm_var( var(:,:,:,:), var_pl(:,:,:,:),
adm_kall, 4 )
3411 '(',int(var(ij,k,l,1)),
',',int(var(ij,k,l,2)),
')'
3430 '(',int(var_pl(ij,k,l,1)),
',',int(var_pl(ij,k,l,2)),
')'
3451 '(',int(var(ij,k,l,3)),
',',int(var(ij,k,l,4)),
')'
3470 '(',int(var_pl(ij,k,l,3)),
',',int(var_pl(ij,k,l,4)),
')'
3479 end subroutine comm_debugtest
3488 real(SP),
intent(in) :: localsum
3489 real(SP),
intent(out) :: globalsum
3491 real(SP) :: sendbuf(1)
3492 real(SP) :: recvbuf(PRC_nprocs)
3498 sendbuf(1) = localsum
3500 call mpi_allgather( sendbuf, &
3509 globalsum = sum( recvbuf(:) )
3511 globalsum = localsum
3524 real(DP),
intent(in) :: localsum
3525 real(DP),
intent(out) :: globalsum
3527 real(DP) :: sendbuf(1)
3528 real(DP) :: recvbuf(PRC_nprocs)
3534 sendbuf(1) = localsum
3536 call mpi_allgather( sendbuf, &
3538 mpi_double_precision, &
3541 mpi_double_precision, &
3545 globalsum = sum( recvbuf(:) )
3547 globalsum = localsum
3560 integer,
intent(in) :: kall
3561 real(SP),
intent(in) :: localsum (kall)
3562 real(SP),
intent(out) :: globalsum(kall)
3564 real(SP) :: sendbuf(kall)
3565 integer :: displs (PRC_nprocs)
3566 integer :: counts (PRC_nprocs)
3567 real(SP) :: recvbuf(kall,PRC_nprocs)
3573 do p = 1, prc_nprocs
3574 displs(p) = (p-1) * kall
3579 sendbuf(:) = localsum(:)
3581 call mpi_allgatherv( sendbuf, &
3592 globalsum(k) = sum( recvbuf(k,:) )
3596 globalsum(k) = localsum(k)
3610 integer,
intent(in) :: kall
3611 real(DP),
intent(in) :: localsum (kall)
3612 real(DP),
intent(out) :: globalsum(kall)
3614 real(DP) :: sendbuf(kall)
3615 integer :: displs (PRC_nprocs)
3616 integer :: counts (PRC_nprocs)
3617 real(DP) :: recvbuf(kall,PRC_nprocs)
3623 do p = 1, prc_nprocs
3624 displs(p) = (p-1) * kall
3629 sendbuf(:) = localsum(:)
3631 call mpi_allgatherv( sendbuf, &
3633 mpi_double_precision, &
3637 mpi_double_precision, &
3642 globalsum(k) = sum( recvbuf(k,:) )
3646 globalsum(k) = localsum(k)
3660 real(SP),
intent(in) :: localavg
3661 real(SP),
intent(out) :: globalavg
3663 real(SP) :: sendbuf(1)
3664 real(SP) :: recvbuf(PRC_nprocs)
3670 sendbuf(1) = localavg
3672 call mpi_allgather( sendbuf, &
3681 globalavg = sum( recvbuf(:) ) / real(prc_nprocs,kind=sp)
3683 globalavg = localavg
3696 real(DP),
intent(in) :: localavg
3697 real(DP),
intent(out) :: globalavg
3699 real(DP) :: sendbuf(1)
3700 real(DP) :: recvbuf(PRC_nprocs)
3706 sendbuf(1) = localavg
3708 call mpi_allgather( sendbuf, &
3710 mpi_double_precision, &
3713 mpi_double_precision, &
3717 globalavg = sum( recvbuf(:) ) / real(prc_nprocs,kind=dp)
3719 globalavg = localavg
3732 real(SP),
intent(in) :: localmax
3733 real(SP),
intent(out) :: globalmax
3735 real(SP) :: sendbuf(1)
3736 real(SP) :: recvbuf(PRC_nprocs)
3741 sendbuf(1) = localmax
3743 call mpi_allgather( sendbuf, &
3752 globalmax = maxval( recvbuf(:) )
3764 real(DP),
intent(in) :: localmax
3765 real(DP),
intent(out) :: globalmax
3767 real(DP) :: sendbuf(1)
3768 real(DP) :: recvbuf(PRC_nprocs)
3773 sendbuf(1) = localmax
3775 call mpi_allgather( sendbuf, &
3777 mpi_double_precision, &
3780 mpi_double_precision, &
3784 globalmax = maxval( recvbuf(:) )
3796 real(SP),
intent(in) :: localmin
3797 real(SP),
intent(out) :: globalmin
3799 real(SP) :: sendbuf(1)
3800 real(SP) :: recvbuf(PRC_nprocs)
3805 sendbuf(1) = localmin
3807 call mpi_allgather( sendbuf, &
3816 globalmin = minval( recvbuf(:) )
3828 real(DP),
intent(in) :: localmin
3829 real(DP),
intent(out) :: globalmin
3831 real(DP) :: sendbuf(1)
3832 real(DP) :: recvbuf(PRC_nprocs)
3837 sendbuf(1) = localmin
3839 call mpi_allgather( sendbuf, &
3841 mpi_double_precision, &
3844 mpi_double_precision, &
3848 globalmin = minval( recvbuf(:) )