22 #include "inc_openmp.h" 65 public :: comm_horizontal_max
66 public :: comm_horizontal_min
72 module procedure comm_vars_2d
73 module procedure comm_vars_3d
74 end interface comm_vars
77 module procedure comm_vars8_2d
78 module procedure comm_vars8_3d
79 end interface comm_vars8
82 module procedure comm_wait_2d
83 module procedure comm_wait_3d
84 end interface comm_wait
86 interface comm_horizontal_max
88 module procedure comm_horizontal_max_3d
89 end interface comm_horizontal_max
91 interface comm_horizontal_min
93 module procedure comm_horizontal_min_3d
94 end interface comm_horizontal_min
99 end interface comm_gather
111 end interface comm_bcast
129 integer,
private :: comm_nreq_max
130 integer,
private :: comm_vsize_max
131 integer,
private :: comm_vsize_max_pc
133 logical,
private :: comm_isallperiodic
135 integer,
private :: comm_size2d_ns4
136 integer,
private :: comm_size2d_ns8
137 integer,
private :: comm_size2d_we
138 integer,
private :: comm_size2d_4c
140 integer,
private :: comm_vars_id = 0
142 logical,
private :: comm_use_mpi_pc = .true.
144 real(RP),
private,
allocatable :: recvpack_w2p(:,:)
145 real(RP),
private,
allocatable :: recvpack_e2p(:,:)
146 real(RP),
private,
allocatable :: sendpack_p2w(:,:)
147 real(RP),
private,
allocatable :: sendpack_p2e(:,:)
149 logical,
private,
allocatable :: use_packbuf(:)
152 integer,
private,
allocatable :: req_cnt (:)
153 integer,
private,
allocatable :: req_list(:,:)
154 integer,
private,
allocatable :: preq_cnt (:)
155 integer,
private,
allocatable :: preq_list(:,:)
156 integer,
private,
allocatable :: pseqid(:)
171 namelist / param_comm / &
176 integer :: nreq_NS, nreq_WE, nreq_4C
181 if( io_l )
write(io_fid_log,*)
182 if( io_l )
write(io_fid_log,*)
'++++++ Module[COMM] / Categ[ATMOS-RM COMM] / Origin[SCALElib]' 184 comm_vsize_max = max( 10 +
qa*2, 25 )
185 comm_vsize_max_pc = 50 +
qa*2
191 if( io_l )
write(io_fid_log,*)
'*** Not found namelist. Default used.' 192 elseif( ierr > 0 )
then 193 write(*,*)
'xxx Not appropriate names in namelist PARAM_COMM. Check!' 196 if( io_lnml )
write(io_fid_log,nml=param_comm)
202 if ( comm_use_mpi_pc )
then 203 comm_nreq_max = 2 * nreq_ns + 2 * nreq_we + 4 * nreq_4c + 1
205 comm_nreq_max = 2 * nreq_ns + 2 * nreq_we + 4 * nreq_4c
209 comm_size2d_ns8 =
imax 211 comm_size2d_4c =
ihalo 213 allocate( recvpack_w2p(comm_size2d_we*
ka,comm_vsize_max) )
214 allocate( recvpack_e2p(comm_size2d_we*
ka,comm_vsize_max) )
215 allocate( sendpack_p2w(comm_size2d_we*
ka,comm_vsize_max) )
216 allocate( sendpack_p2e(comm_size2d_we*
ka,comm_vsize_max) )
218 allocate( use_packbuf(comm_vsize_max) )
219 use_packbuf(:) = .false.
222 allocate( req_cnt( comm_vsize_max) )
223 allocate( req_list(comm_nreq_max,comm_vsize_max) )
225 req_list(:,:) = mpi_request_null
227 if ( comm_use_mpi_pc )
then 228 allocate( preq_cnt( comm_vsize_max_pc) )
229 allocate( preq_list(comm_nreq_max+1,comm_vsize_max_pc) )
231 preq_list(:,:) = mpi_request_null
233 allocate( pseqid(comm_vsize_max_pc) )
237 comm_isallperiodic = .true.
239 comm_isallperiodic = .false.
242 if (
rp == kind(0.d0) )
then 244 elseif(
rp == kind(0.0) )
then 247 write(*,*)
'xxx precision is not supportd' 254 call rdma_setup( comm_vsize_max_pc, &
270 if( io_l )
write(io_fid_log,*)
271 if( io_l )
write(io_fid_log,*)
'*** Maximum number of vars for one communication: ', &
273 if( io_l )
write(io_fid_log,*)
'*** Data size of var (3D,including halo) [byte] : ', &
275 if( io_l )
write(io_fid_log,*)
'*** Data size of halo [byte] : ', &
277 if( io_l )
write(io_fid_log,*)
'*** Ratio of halo against the whole 3D grid : ', &
278 real(2*IA*JHALO+2*JMAX*IHALO) /
real(
ia*
ja)
279 if( io_l )
write(io_fid_log,*)
280 if( io_l )
write(io_fid_log,*)
'*** All side is periodic?: ', comm_isallperiodic
290 real(RP),
intent(inout) :: var(:,:,:)
291 integer,
intent(inout) :: vid
294 if ( vid > comm_vsize_max )
then 295 write(*,*)
'xxx vid exceeds max', vid, comm_vsize_max
299 if ( comm_use_mpi_pc )
then 301 comm_vars_id = comm_vars_id + 1
302 if ( comm_vars_id > comm_vsize_max_pc )
then 303 write(*,*)
'xxx number of variable for MPI PC exceeds max', comm_vars_id, comm_vsize_max_pc
309 call set_rdma_variable(var, comm_vars_id-1)
317 vid = comm_vars_id + comm_vsize_max
330 real(RP),
intent(inout) :: var(:,:,:)
331 integer,
intent(inout) :: vid
334 if ( vid > comm_vsize_max )
then 335 write(*,*)
'xxx vid exceeds max', vid, comm_vsize_max
339 if ( comm_use_mpi_pc )
then 341 comm_vars_id = comm_vars_id + 1
342 if ( comm_vars_id > comm_vsize_max_pc )
then 343 write(*,*)
'xxx number of variable for MPI PC exceeds max', comm_vars_id, comm_vsize_max_pc
349 call set_rdma_variable(var, comm_vars_id-1)
353 call vars8_init_mpi_pc(var, comm_vars_id, vid)
357 vid = comm_vars_id + comm_vsize_max
366 subroutine comm_vars_3d(var, vid)
369 real(RP),
intent(inout) :: var(:,:,:)
370 integer,
intent(in) :: vid
373 if ( vid > comm_vsize_max )
then 376 call rdma_put(vid-comm_vsize_max-1, 1)
385 call vars_3d_mpi(var, vid)
390 end subroutine comm_vars_3d
393 subroutine comm_vars8_3d(var, vid)
396 real(RP),
intent(inout) :: var(:,:,:)
397 integer,
intent(in) :: vid
400 if ( vid > comm_vsize_max )
then 403 call rdma_put8(vid-comm_vsize_max-1,1)
417 end subroutine comm_vars8_3d
420 subroutine comm_wait_3d(var, vid, FILL_BND)
423 real(RP),
intent(inout) :: var(:,:,:)
424 integer,
intent(in) :: vid
425 logical,
intent(in),
optional :: FILL_BND
431 if (
present(fill_bnd) ) fill_bnd_ = fill_bnd
433 if ( vid > comm_vsize_max )
then 438 call wait_3d_mpi_pc(var, vid-comm_vsize_max)
448 if ( .NOT. comm_isallperiodic )
then 449 if ( fill_bnd_ )
then 450 call copy_boundary_3d(var)
455 end subroutine comm_wait_3d
458 subroutine comm_vars_2d(var, vid)
460 real(RP),
intent(inout) :: var(:,:)
461 integer,
intent(in) :: vid
469 end subroutine comm_vars_2d
472 subroutine comm_vars8_2d(var, vid)
475 real(RP),
intent(inout) :: var(:,:)
476 integer,
intent(in) :: vid
484 end subroutine comm_vars8_2d
487 subroutine comm_wait_2d(var, vid, FILL_BND)
490 real(RP),
intent(inout) :: var(:,:)
491 integer,
intent(in) :: vid
492 logical,
intent(in),
optional :: FILL_BND
498 if (
present(fill_bnd) ) fill_bnd_ = fill_bnd
501 call wait_2d_mpi(var, vid)
504 if( .NOT. comm_isallperiodic )
then 505 if ( fill_bnd_ )
then 506 call copy_boundary_2d(var)
511 end subroutine comm_wait_2d
520 real(RP),
intent(out) :: varmean(
ka)
521 real(RP),
intent(in) :: var (
ka,
ia,
ja)
523 real(RP) :: statval (
ka)
524 real(RP) :: statcnt (
ka)
525 real(RP) :: allstatval(
ka)
526 real(RP) :: allstatcnt(
ka)
539 statval(k) = statval(k) + var(k,i,j)
540 statcnt(k) = statcnt(k) + 1.d0
549 call mpi_allreduce( statval(1), &
557 call mpi_allreduce( statcnt(1), &
568 zerosw = 0.5_rp - sign(0.5_rp, allstatcnt(k) - 1.e-12_rp )
569 varmean(k) = allstatval(k) / ( allstatcnt(k) + zerosw ) * ( 1.0_rp - zerosw )
581 real(RP),
intent(out) :: varmax
582 real(RP),
intent(in) :: var(
ia,
ja)
585 real(RP) :: allstatval
595 call mpi_allreduce( statval, &
612 subroutine comm_horizontal_max_3d( varmax, var )
617 real(RP),
intent(out) :: varmax(
ka)
618 real(RP),
intent(in) :: var (
ka,
ia,
ja)
620 real(RP) :: statval (
ka)
621 real(RP) :: allstatval(
ka)
627 statval(:) = -1.e19_rp
629 statval(k) = maxval(var(k,
is:
ie,
js:
je))
635 call mpi_allreduce( statval(1), &
646 varmax(k) = allstatval(k)
652 end subroutine comm_horizontal_max_3d
659 real(RP),
intent(out) :: varmin
660 real(RP),
intent(in) :: var(
ia,
ja)
663 real(RP) :: allstatval
673 call mpi_allreduce( statval, &
690 subroutine comm_horizontal_min_3d( varmin, var )
695 real(RP),
intent(out) :: varmin(
ka)
696 real(RP),
intent(in) :: var (
ka,
ia,
ja)
698 real(RP) :: statval (
ka)
699 real(RP) :: allstatval(
ka)
705 statval(:) = -1.e19_rp
707 statval(k) = minval(var(k,
is:
ie,
js:
je))
713 call mpi_allreduce( statval(1), &
724 varmin(k) = allstatval(k)
730 end subroutine comm_horizontal_min_3d
739 real(RP),
intent(out) :: recv(:,:)
740 real(RP),
intent(in) :: send(:,:)
741 integer,
intent(in) :: gIA
742 integer,
intent(in) :: gJA
744 integer :: sendcounts, recvcounts
748 sendcounts = gia * gja
749 recvcounts = gia * gja
751 call mpi_gather( send(:,:), &
771 real(RP),
intent(out) :: recv(:,:,:)
772 real(RP),
intent(in) :: send(:,:,:)
773 integer,
intent(in) :: gIA
774 integer,
intent(in) :: gJA
775 integer,
intent(in) :: gKA
777 integer :: sendcounts, recvcounts
781 sendcounts = gia * gja * gka
782 recvcounts = gia * gja * gka
784 call mpi_gather( send(:,:,:), &
804 real(RP),
intent(inout) :: var
814 call mpi_bcast( var, &
833 real(RP),
intent(inout) :: var(:)
834 integer,
intent(in) :: gIA
844 call mpi_bcast( var(:), &
863 real(RP),
intent(inout) :: var(:,:)
864 integer,
intent(in) :: gIA
865 integer,
intent(in) :: gJA
875 call mpi_bcast( var(:,:), &
894 real(RP),
intent(inout) :: var(:,:,:)
895 integer,
intent(in) :: gIA
896 integer,
intent(in) :: gJA
897 integer,
intent(in) :: gKA
905 counts = gia * gja * gka
907 call mpi_bcast( var(:,:,:), &
926 real(RP),
intent(inout) :: var(:,:,:,:)
927 integer,
intent(in) :: gIA
928 integer,
intent(in) :: gJA
929 integer,
intent(in) :: gKA
930 integer,
intent(in) :: gTime
938 counts = gia * gja * gka * gtime
939 if ( gia>0 .AND. gja>0 .AND. gka>0 .AND. gtime>0 .AND. &
941 write(*,*)
'xxx counts overflow' 945 call mpi_bcast( var(:,:,:,:), &
964 integer,
intent(inout) :: var
974 call mpi_bcast( var, &
993 integer,
intent(inout) :: var(:)
994 integer,
intent(in) :: gIA
1004 call mpi_bcast( var(:), &
1023 integer,
intent(inout) :: var(:,:)
1024 integer,
intent(in) :: gIA
1025 integer,
intent(in) :: gJA
1035 call mpi_bcast( var(:,:), &
1054 logical,
intent(inout) :: var
1064 call mpi_bcast( var, &
1082 real(RP),
intent(inout) :: var(:,:,:)
1083 integer,
intent(in) :: vid
1084 integer,
intent(in) :: seqid
1086 integer :: ireq, tag, ierr
1100 mpi_proc_null, tag+comm_nreq_max+1,
comm_world, &
1101 preq_list(comm_nreq_max+1,vid), ierr )
1113 call mpi_recv_init( recvpack_e2p(:,seqid), comm_size2d_we*kd,
comm_datatype, &
1117 call mpi_recv_init( recvpack_w2p(:,seqid), comm_size2d_we*kd,
comm_datatype, &
1123 call mpi_send_init( sendpack_p2w(:,seqid), comm_size2d_we*kd,
comm_datatype, &
1127 call mpi_send_init( sendpack_p2e(:,seqid), comm_size2d_we*kd,
comm_datatype, &
1139 preq_cnt(vid) = ireq - 1
1144 call mpi_testall( preq_cnt(vid), preq_list(1:preq_cnt(vid),vid), &
1145 flag, mpi_statuses_ignore, ierr )
1151 subroutine vars8_init_mpi_pc(var, vid, seqid)
1154 real(RP),
intent(inout) :: var(:,:,:)
1155 integer,
intent(in) :: vid
1156 integer,
intent(in) :: seqid
1158 integer :: ireq, tag, tagc
1173 mpi_proc_null, tag+comm_nreq_max+1,
comm_world, &
1174 preq_list(comm_nreq_max+1,vid), ierr )
1177 if ( comm_isallperiodic )
then 1183 call mpi_recv_init( var(1,
ie+1,j), comm_size2d_4c*kd,
comm_datatype, &
1199 call mpi_recv_init( var(1,
ie+1,j), comm_size2d_4c*kd,
comm_datatype, &
1230 call mpi_recv_init( recvpack_e2p(:,seqid), comm_size2d_we*kd,
comm_datatype, &
1235 call mpi_recv_init( recvpack_w2p(:,seqid), comm_size2d_we*kd,
comm_datatype, &
1242 call mpi_send_init( sendpack_p2w(:,seqid), comm_size2d_we*kd,
comm_datatype, &
1247 call mpi_send_init( sendpack_p2e(:,seqid), comm_size2d_we*kd,
comm_datatype, &
1306 call mpi_recv_init( var(1,
ie+1,j), comm_size2d_4c*kd,
comm_datatype, &
1314 call mpi_recv_init( var(1,
ie+1,j), comm_size2d_4c*kd,
comm_datatype, &
1322 call mpi_recv_init( var(1,
ie+1,j), comm_size2d_4c*kd,
comm_datatype, &
1358 call mpi_recv_init( var(1,
ie+1,j), comm_size2d_4c*kd,
comm_datatype, &
1366 call mpi_recv_init( var(1,
ie+1,j), comm_size2d_4c*kd,
comm_datatype, &
1374 call mpi_recv_init( var(1,
ie+1,j), comm_size2d_4c*kd,
comm_datatype, &
1429 call mpi_recv_init( recvpack_e2p(:,seqid), comm_size2d_we*kd,
comm_datatype, &
1436 call mpi_recv_init( recvpack_w2p(:,seqid), comm_size2d_we*kd,
comm_datatype, &
1445 call mpi_send_init( sendpack_p2w(:,seqid), comm_size2d_we*kd,
comm_datatype, &
1452 call mpi_send_init( sendpack_p2e(:,seqid), comm_size2d_we*kd,
comm_datatype, &
1514 call mpi_send_init( var(1,
ie+1,j), comm_size2d_4c*kd,
comm_datatype, &
1566 call mpi_send_init( var(1,
ie+1,j), comm_size2d_4c*kd,
comm_datatype, &
1583 preq_cnt(vid) = ireq - 1
1588 call mpi_testall( preq_cnt(vid), preq_list(1:preq_cnt(vid),vid), &
1589 flag, mpi_statuses_ignore, ierr )
1593 end subroutine vars8_init_mpi_pc
1595 subroutine vars_3d_mpi(var, vid)
1600 real(RP),
intent(inout) :: var(:,:,:)
1601 integer,
intent(in) :: vid
1604 integer :: ireq, tag
1616 if ( use_packbuf(vid) )
then 1617 write(*,*)
'packing buffer is already used', vid
1620 use_packbuf(vid) = .true.
1623 if ( comm_isallperiodic )
then 1635 call mpi_irecv( recvpack_e2p(:,vid), comm_size2d_we*kd,
comm_datatype, &
1639 call mpi_irecv( recvpack_w2p(:,vid), comm_size2d_we*kd,
comm_datatype, &
1643 call pack_3d(var, vid)
1647 call mpi_isend( sendpack_p2w(:,vid), comm_size2d_we*kd,
comm_datatype, &
1651 call mpi_isend( sendpack_p2e(:,vid), comm_size2d_we*kd,
comm_datatype, &
1680 call mpi_irecv( recvpack_e2p(:,vid), comm_size2d_we*kd,
comm_datatype, &
1686 call mpi_irecv( recvpack_w2p(:,vid), comm_size2d_we*kd,
comm_datatype, &
1691 call pack_3d(var, vid)
1696 call mpi_isend( sendpack_p2w(:,vid), comm_size2d_we*kd,
comm_datatype, &
1702 call mpi_isend( sendpack_p2e(:,vid), comm_size2d_we*kd,
comm_datatype, &
1721 req_cnt(vid) = ireq - 1
1724 end subroutine vars_3d_mpi
1731 real(RP),
intent(inout) :: var(:,:,:)
1732 integer,
intent(in) :: vid
1734 integer :: ireq, tag, tagc
1748 if ( use_packbuf(vid) )
then 1749 write(*,*)
'packing buffer is already used', vid
1752 use_packbuf(vid) = .true.
1755 if ( comm_isallperiodic )
then 1808 call mpi_irecv( recvpack_e2p(:,vid), comm_size2d_we*kd,
comm_datatype, &
1813 call mpi_irecv( recvpack_w2p(:,vid), comm_size2d_we*kd,
comm_datatype, &
1817 call pack_3d(var, vid)
1823 call mpi_isend( sendpack_p2w(:,vid), comm_size2d_we*kd,
comm_datatype, &
1828 call mpi_isend( sendpack_p2e(:,vid), comm_size2d_we*kd,
comm_datatype, &
2010 call mpi_irecv( recvpack_e2p(:,vid), comm_size2d_we*kd,
comm_datatype, &
2017 call mpi_irecv( recvpack_w2p(:,vid), comm_size2d_we*kd,
comm_datatype, &
2022 call pack_3d(var, vid)
2028 call mpi_isend( sendpack_p2w(:,vid), comm_size2d_we*kd,
comm_datatype, &
2035 call mpi_isend( sendpack_p2e(:,vid), comm_size2d_we*kd,
comm_datatype, &
2071 call mpi_isend( var(1,1,j), comm_size2d_4c*kd,
comm_datatype, &
2123 call mpi_isend( var(1,1,j), comm_size2d_4c*kd,
comm_datatype, &
2166 req_cnt(vid) = ireq - 1
2176 real(RP),
intent(inout) :: var(:,:)
2177 integer,
intent(in) :: vid
2179 integer :: ireq, tag
2187 if ( use_packbuf(vid) )
then 2188 write(*,*)
'packing buffer is already used', vid
2191 use_packbuf(vid) = .true.
2194 if ( comm_isallperiodic )
then 2198 call mpi_irecv( var(:,
js-
jhalo:
js-1), comm_size2d_ns4, &
2204 call mpi_irecv( var(:,
je+1:
je+
jhalo), comm_size2d_ns4, &
2210 call mpi_irecv( recvpack_e2p(:,vid), comm_size2d_we, &
2216 call mpi_irecv( recvpack_w2p(:,vid), comm_size2d_we, &
2221 call pack_2d(var, vid)
2224 call mpi_isend( sendpack_p2w(:,vid), comm_size2d_we, &
2230 call mpi_isend( sendpack_p2e(:,vid), comm_size2d_we, &
2236 call mpi_isend( var(:,
je-
jhalo+1:
je), comm_size2d_ns4, &
2242 call mpi_isend( var(:,
js:
js+
jhalo-1), comm_size2d_ns4, &
2252 call mpi_irecv( var(:,
js-
jhalo:
js-1), comm_size2d_ns4, &
2260 call mpi_irecv( var(:,
je+1:
je+
jhalo), comm_size2d_ns4, &
2268 call mpi_irecv( recvpack_e2p(:,vid), comm_size2d_we, &
2276 call mpi_irecv( recvpack_w2p(:,vid), comm_size2d_we, &
2282 call pack_2d(var, vid)
2286 call mpi_isend( sendpack_p2w(:,vid), comm_size2d_we, &
2294 call mpi_isend( sendpack_p2e(:,vid), comm_size2d_we, &
2302 call mpi_isend( var(:,
je-
jhalo+1:
je), comm_size2d_ns4, &
2310 call mpi_isend( var(:,
js:
js+
jhalo-1), comm_size2d_ns4, &
2318 req_cnt(vid) = ireq - 1
2328 real(RP),
intent(inout) :: var(:,:)
2329 integer,
intent(in) :: vid
2331 integer :: ireq, tag, tagc
2341 if ( use_packbuf(vid) )
then 2342 write(*,*)
'packing buffer is already used', vid
2345 use_packbuf(vid) = .true.
2348 if ( comm_isallperiodic )
then 2354 call mpi_irecv( var(
ie+1,j), comm_size2d_4c, &
2363 call mpi_irecv( var(
is-
ihalo,j), comm_size2d_4c, &
2372 call mpi_irecv( var(
ie+1,j), comm_size2d_4c, &
2381 call mpi_irecv( var(
is-
ihalo,j), comm_size2d_4c, &
2390 call mpi_irecv( var(
is,j), comm_size2d_ns8, &
2399 call mpi_irecv( var(
is,j), comm_size2d_ns8, &
2406 call mpi_irecv( recvpack_e2p(:,vid), comm_size2d_we, &
2411 call mpi_irecv( recvpack_w2p(:,vid), comm_size2d_we, &
2416 call pack_2d(var, vid)
2419 call mpi_isend( sendpack_p2w(:,vid), comm_size2d_we, &
2425 call mpi_isend( sendpack_p2e(:,vid), comm_size2d_we, &
2433 call mpi_isend( var(
is,j), comm_size2d_ns8, &
2443 call mpi_isend( var(
is,j), comm_size2d_ns8, &
2453 call mpi_isend( var(
is,j), comm_size2d_4c, &
2463 call mpi_isend( var(
ie-
ihalo+1,j), comm_size2d_4c, &
2473 call mpi_isend( var(
is,j), comm_size2d_4c, &
2483 call mpi_isend( var(
ie-
ihalo+1,j), comm_size2d_4c, &
2496 call mpi_irecv( var(
ie+1,j), comm_size2d_4c, &
2505 call mpi_irecv( var(
ie+1,j), comm_size2d_4c, &
2514 call mpi_irecv( var(
ie+1,j), comm_size2d_4c, &
2526 call mpi_irecv( var(
is-
ihalo,j), comm_size2d_4c, &
2535 call mpi_irecv( var(
is-
ihalo,j), comm_size2d_4c, &
2544 call mpi_irecv( var(
is-
ihalo,j), comm_size2d_4c, &
2556 call mpi_irecv( var(
ie+1,j), comm_size2d_4c, &
2565 call mpi_irecv( var(
ie+1,j), comm_size2d_4c, &
2574 call mpi_irecv( var(
ie+1,j), comm_size2d_4c, &
2586 call mpi_irecv( var(
is-
ihalo,j), comm_size2d_4c, &
2595 call mpi_irecv( var(
is-
ihalo,j), comm_size2d_4c, &
2604 call mpi_irecv( var(
is-
ihalo,j), comm_size2d_4c, &
2616 call mpi_irecv( var(
is,j), comm_size2d_ns8, &
2628 call mpi_irecv( var(
is,j), comm_size2d_ns8, &
2638 call mpi_irecv( recvpack_e2p(:,vid), comm_size2d_we, &
2646 call mpi_irecv( recvpack_w2p(:,vid), comm_size2d_we, &
2652 call pack_2d(var, vid)
2656 call mpi_isend( sendpack_p2w(:,vid), comm_size2d_we, &
2664 call mpi_isend( sendpack_p2e(:,vid), comm_size2d_we, &
2674 call mpi_isend( var(
is,j), comm_size2d_ns8, &
2686 call mpi_isend( var(
is,j), comm_size2d_ns8, &
2698 call mpi_isend( var(
is,j), comm_size2d_4c, &
2707 call mpi_isend( var(
is,j), comm_size2d_4c, &
2716 call mpi_isend( var(
is,j), comm_size2d_4c, &
2728 call mpi_isend( var(
ie-
ihalo+1,j), comm_size2d_4c, &
2737 call mpi_isend( var(
ie-
ihalo+1,j), comm_size2d_4c, &
2746 call mpi_isend( var(
ie-
ihalo+1,j), comm_size2d_4c, &
2758 call mpi_isend( var(
is,j), comm_size2d_4c, &
2767 call mpi_isend( var(
is,j), comm_size2d_4c, &
2776 call mpi_isend( var(
is,j), comm_size2d_4c, &
2788 call mpi_isend( var(
ie-
ihalo+1,j), comm_size2d_4c, &
2797 call mpi_isend( var(
ie-
ihalo+1,j), comm_size2d_4c, &
2806 call mpi_isend( var(
ie-
ihalo+1,j), comm_size2d_4c, &
2816 req_cnt(vid) = ireq - 1
2826 real(RP),
intent(inout) :: var(:,:,:)
2827 integer,
intent(in) :: vid
2832 if ( use_packbuf(pseqid(vid)) )
then 2833 write(*,*)
'packing buffer is already used', vid, pseqid(vid)
2836 use_packbuf(pseqid(vid)) = .true.
2839 call pack_3d(var, pseqid(vid))
2841 call mpi_startall(preq_cnt(vid), preq_list(1:preq_cnt(vid),vid), ierr)
2848 real(RP),
intent(inout) :: var(:,:,:)
2849 integer,
intent(in) :: vid
2855 call mpi_waitall( req_cnt(vid), &
2856 req_list(1:req_cnt(vid),vid), &
2857 mpi_statuses_ignore, &
2859 call unpack_3d(var, vid)
2862 use_packbuf(vid) = .false.
2868 subroutine wait_2d_mpi(var, vid)
2871 real(RP),
intent(inout) :: var(:,:)
2872 integer,
intent(in) :: vid
2878 call mpi_waitall( req_cnt(vid), &
2879 req_list(1:req_cnt(vid),vid), &
2880 mpi_statuses_ignore, &
2882 call unpack_2d(var, vid)
2885 use_packbuf(vid) = .false.
2889 end subroutine wait_2d_mpi
2891 subroutine wait_3d_mpi_pc(var, vid)
2894 real(RP),
intent(inout) :: var(:,:,:)
2895 integer,
intent(in) :: vid
2900 call mpi_waitall( preq_cnt(vid), &
2901 preq_list(1:preq_cnt(vid),vid), &
2902 mpi_statuses_ignore, &
2904 call unpack_3d(var, pseqid(vid))
2907 use_packbuf(pseqid(vid)) = .false.
2911 end subroutine wait_3d_mpi_pc
2913 subroutine pack_3d(var, vid)
2916 real(RP),
intent(in) :: var(:,:,:)
2917 integer,
intent(in) :: vid
2920 integer :: k, i, j, n
2926 if ( comm_isallperiodic )
then 2937 sendpack_p2w(n,vid) = var(k,i,j)
2950 sendpack_p2e(n,vid) = var(k,i,j)
2967 sendpack_p2w(n,vid) = var(k,i,j)
2982 sendpack_p2e(n,vid) = var(k,i,j)
2993 end subroutine pack_3d
2995 subroutine pack_2d(var, vid)
2998 real(RP),
intent(in) :: var(:,:)
2999 integer,
intent(in) :: vid
3005 if ( comm_isallperiodic )
then 3015 sendpack_p2w(n,vid) = var(i,j)
3026 sendpack_p2e(n,vid) = var(i,j)
3041 sendpack_p2w(n,vid) = var(i,j)
3054 sendpack_p2e(n,vid) = var(i,j)
3064 end subroutine pack_2d
3066 subroutine unpack_3d(var, vid)
3069 real(RP),
intent(inout) :: var(:,:,:)
3070 integer,
intent(in) :: vid
3073 integer :: i, j, k, n
3080 if ( comm_isallperiodic )
then 3090 var(k,i,j) = recvpack_e2p(n,vid)
3103 var(k,i,j) = recvpack_w2p(n,vid)
3119 var(k,i,j) = recvpack_e2p(n,vid)
3134 var(k,i,j) = recvpack_w2p(n,vid)
3145 end subroutine unpack_3d
3147 subroutine unpack_2d(var, vid)
3150 real(RP),
intent(inout) :: var(:,:)
3151 integer,
intent(in) :: vid
3158 if( comm_isallperiodic )
then 3166 var(i,j) = recvpack_e2p(n,vid)
3176 var(i,j) = recvpack_w2p(n,vid)
3190 var(i,j) = recvpack_e2p(n,vid)
3203 var(i,j) = recvpack_w2p(n,vid)
3213 end subroutine unpack_2d
3215 subroutine copy_boundary_3d(var)
3218 real(RP),
intent(inout) :: var(:,:,:)
3227 var(:,i,j) = var(:,i,
je)
3236 var(:,i,j) = var(:,i,
js)
3245 var(:,i,j) = var(:,
ie,j)
3254 var(:,i,j) = var(:,
is,j)
3264 var(:,i,j) = var(:,
is,
je)
3270 var(:,i,j) = var(:,i,
je)
3276 var(:,i,j) = var(:,
is,j)
3286 var(:,i,j) = var(:,
is,
js)
3292 var(:,i,j) = var(:,i,
js)
3298 var(:,i,j) = var(:,
is,j)
3308 var(:,i,j) = var(:,
ie,
je)
3314 var(:,i,j) = var(:,i,
je)
3320 var(:,i,j) = var(:,
ie,j)
3330 var(:,i,j) = var(:,
ie,
js)
3336 var(:,i,j) = var(:,i,
js)
3342 var(:,i,j) = var(:,
ie,j)
3348 end subroutine copy_boundary_3d
3350 subroutine copy_boundary_2d(var)
3353 real(RP),
intent(inout) :: var(:,:)
3362 var(i,j) = var(i,
je)
3372 var(i,j) = var(i,
js)
3381 var(i,j) = var(
ie,j)
3390 var(i,j) = var(
is,j)
3400 var(i,j) = var(
is,
je)
3407 var(i,j) = var(i,
je)
3414 var(i,j) = var(
is,j)
3424 var(i,j) = var(
is,
js)
3431 var(i,j) = var(i,
js)
3438 var(i,j) = var(
is,j)
3448 var(i,j) = var(
ie,
je)
3455 var(i,j) = var(i,
je)
3462 var(i,j) = var(
ie,j)
3472 var(i,j) = var(
ie,
js)
3479 var(i,j) = var(i,
js)
3486 var(i,j) = var(
ie,j)
3492 end subroutine copy_boundary_2d
3498 namelist / param_comm / &
3499 comm_vsize_max_pc, &
3502 integer :: i, j, ierr
3505 deallocate( recvpack_w2p )
3506 deallocate( recvpack_e2p )
3507 deallocate( sendpack_p2w )
3508 deallocate( sendpack_p2e )
3510 deallocate( use_packbuf )
3513 deallocate( req_cnt )
3514 deallocate( req_list )
3516 if ( comm_use_mpi_pc )
then 3517 do j=1, comm_vsize_max_pc
3518 do i=1, comm_nreq_max+1
3519 if (preq_list(i,j) .NE. mpi_request_null) &
3520 call mpi_request_free(preq_list(i,j), ierr)
3523 deallocate( preq_cnt )
3524 deallocate( preq_list )
3525 deallocate( pseqid )
integer, public imax
of computational cells: x
integer, public is
start point of inner domain: x, local
integer, public comm_datatype
datatype of variable
integer, parameter, public prc_s
[node direction] south
subroutine comm_bcast_scr(var)
Broadcast data for whole process value in scalar field.
integer, public je
end point of inner domain: y, local
logical, public prc_has_n
integer, parameter, public prc_w
[node direction] west
real(rp), public const_huge
huge number
integer, public prc_local_comm_world
local communicator
subroutine, public prc_mpistop
Abort MPI.
logical, public io_l
output log or not? (this process)
subroutine wait_3d_mpi(var, vid)
logical, public prc_has_e
integer, public ke
end point of inner domain: z, local
subroutine comm_bcast_int_1d(var, gIA)
Broadcast data for whole process value in 1D field (integer)
subroutine comm_bcast_2d(var, gIA, gJA)
Broadcast data for whole process value in 2D field.
subroutine, public comm_vars_init(var, vid)
Register variables.
integer, dimension(8), public prc_next
node ID of 8 neighbour process
logical, public prc_has_s
real(rp), public const_undef
integer, parameter, public prc_n
[node direction] north
integer, public ia
of x whole cells (local, with HALO)
subroutine, public comm_horizontal_mean(varmean, var)
calculate horizontal mean (global total with communication)
subroutine, public comm_vars8_init(var, vid)
Register variables.
integer, public ka
of z whole cells (local, with HALO)
subroutine comm_gather_2d(recv, send, gIA, gJA)
Get data from whole process value in 2D field.
integer, public comm_world
communication world ID
integer, public jhalo
of halo cells: y
subroutine, public comm_cleanup
integer, parameter, public prc_nw
[node direction] northwest
integer, public js
start point of inner domain: y, local
logical, public comm_fill_bnd
switch whether fill boundary data
integer, parameter, public prc_e
[node direction] east
subroutine vars_3d_mpi_pc(var, vid)
subroutine comm_horizontal_min_2d(varmin, var)
Get minimum value in horizontal area.
subroutine comm_bcast_logical_scr(var)
Broadcast data for whole process value in scalar (logical)
subroutine vars_2d_mpi(var, vid)
subroutine vars_init_mpi_pc(var, vid, seqid)
integer, parameter, public prc_masterrank
master process in each communicator
integer, public ks
start point of inner domain: z, local
subroutine, public prof_rapstart(rapname_base, level)
Start raptime.
subroutine comm_bcast_4d(var, gIA, gJA, gKA, gTime)
Broadcast data for whole process value in 4D field.
integer, public ie
end point of inner domain: x, local
subroutine comm_horizontal_max_2d(varmax, var)
Get maximum value in horizontal area.
subroutine comm_bcast_int_2d(var, gIA, gJA)
Broadcast data for whole process value in 2D field (integer)
integer, parameter, public prc_sw
[node direction] southwest
subroutine comm_bcast_int_scr(var)
Broadcast data for whole process value in scalar (integer)
subroutine comm_bcast_3d(var, gIA, gJA, gKA)
Broadcast data for whole process value in 3D field.
integer, parameter, public prc_ne
[node direction] northeast
integer, public io_fid_conf
Config file ID.
subroutine, public comm_setup
Setup.
integer, public io_fid_log
Log file ID.
subroutine comm_gather_3d(recv, send, gIA, gJA, gKA)
Get data from whole process value in 3D field.
integer, parameter, public prc_se
[node direction] southeast
subroutine, public prof_rapend(rapname_base, level)
Save raptime.
logical, public prc_has_w
integer, parameter, public rp
subroutine vars8_2d_mpi(var, vid)
subroutine vars8_3d_mpi(var, vid)
integer, public jmax
of computational cells: y
subroutine comm_bcast_1d(var, gIA)
Broadcast data for whole process value in 1D field.
integer, public ihalo
of halo cells: x
integer, public ja
of y whole cells (local, with HALO)