65 end interface comm_vars
70 end interface comm_vars8
75 end interface comm_wait
80 end interface comm_gather
99 end interface comm_bcast
116 integer,
private :: comm_vsize_max
117 integer,
private :: comm_vsize_max_pc
119 logical,
private :: comm_isallperiodic
121 logical,
private :: comm_use_mpi_pc = .true.
123 logical,
private :: comm_use_mpi_onesided = .true.
125 logical,
private :: comm_use_mpi_onesided = .false.
129 integer,
private :: comm_datatype_t
130 integer,
private :: comm_world_t
132 type(mpi_datatype),
private :: comm_datatype_t
133 type(mpi_comm),
private :: comm_world_t
138 real(
rp),
pointer :: ptr(:,:,:)
143 integer :: ia, is, ie, ihalo
144 integer :: ja, js, je, jhalo
146 integer :: size2d_ns4
147 integer :: size2d_ns8
150 integer :: vars_num = 0
151 real(
rp),
pointer :: recvpack_we2p(:,:,:)
152 real(
rp),
pointer :: sendpack_p2we(:,:,:)
153 type(c_ptr),
allocatable :: recvbuf_we(:)
154 type(c_ptr),
allocatable :: recvbuf_ns(:)
155 integer,
allocatable :: req_cnt (:)
156 integer,
allocatable :: preq_cnt (:)
157 integer,
allocatable :: packid(:)
159 integer,
allocatable :: req_list(:,:)
160 integer,
allocatable :: preq_list(:,:)
161 integer,
allocatable :: win_packwe(:)
162 integer,
allocatable :: win_packns(:)
164 type(mpi_request),
allocatable :: req_list(:,:)
165 type(mpi_request),
allocatable :: preq_list(:,:)
166 type(mpi_win),
allocatable :: win_packwe(:)
167 type(mpi_win),
allocatable :: win_packns(:)
170 logical,
allocatable :: use_packbuf(:)
173 logical,
allocatable :: device_alloc(:)
174 type(ptr_t),
allocatable :: device_ptr(:)
178 integer,
private,
parameter :: comm_gid_max = 20
179 integer,
private :: comm_gid
180 type(ginfo_t),
private :: ginfo(comm_gid_max)
183 integer,
private :: group_packwe
184 integer,
private :: group_packns
186 type(mpi_group),
private :: group_packwe
187 type(mpi_group),
private :: group_packns
189 logical,
private :: group_packwe_created = .false.
190 logical,
private :: group_packns_created = .false.
192 logical,
private :: initialized = .false.
207 namelist / param_comm_cartesc / &
211 comm_use_mpi_onesided
217 type(mpi_group) :: group
224 if ( initialized )
return
227 log_info(
"COMM_setup",*)
'Setup'
229 comm_vsize_max = max( 10 +
qa*2, 25 )
230 comm_vsize_max_pc = 50 +
qa*2
233 comm_use_mpi_onesided = .false.
238 read(
io_fid_conf,nml=param_comm_cartesc,iostat=ierr)
240 log_info(
"COMM_setup",*)
'Not found namelist. Default used.'
241 elseif( ierr > 0 )
then
242 log_error(
"COMM_setup",*)
'Not appropriate names in namelist PARAM_COMM_CARTESC. Check!'
245 log_nml(param_comm_cartesc)
247 if ( prc_has_n .AND. prc_has_s .AND. prc_has_w .AND. prc_has_e )
then
248 comm_isallperiodic = .true.
250 comm_isallperiodic = .false.
255 if (
rp == kind(0.d0) )
then
256 comm_datatype_t = mpi_double_precision
257 elseif(
rp == kind(0.0) )
then
258 comm_datatype_t = mpi_real
260 log_error(
"COMM_setup",*)
'precision is not supportd'
275 if ( comm_use_mpi_onesided )
then
276 log_warn(
"COMM_setup",*)
"Open MPI does not support one-sided APIs with CUDA-aware UCX"
280 if ( comm_use_mpi_onesided )
then
282 comm_use_mpi_pc = .false.
284 call mpi_comm_group( comm_world_t, group, ierr )
287 if ( prc_has_s )
then
289 ranks(n) = prc_next(prc_s)
291 if ( prc_has_n )
then
293 if ( ranks(m) == prc_next(prc_n) )
exit
295 if ( m == n + 1 )
then
297 ranks(n) = prc_next(prc_n)
300 if ( prc_has_n .and. prc_has_w )
then
302 if ( ranks(m) == prc_next(prc_nw) )
exit
304 if ( m == n + 1 )
then
306 ranks(n) = prc_next(prc_nw)
308 else if ( prc_has_n )
then
310 if ( ranks(m) == prc_next(prc_n) )
exit
312 if ( m == n + 1 )
then
314 ranks(n) = prc_next(prc_n)
316 else if ( prc_has_w )
then
318 if ( ranks(m) == prc_next(prc_w) )
exit
320 if ( m == n + 1 )
then
322 ranks(n) = prc_next(prc_w)
325 if ( prc_has_n .and. prc_has_e )
then
327 if ( ranks(m) == prc_next(prc_ne) )
exit
329 if ( m == n + 1 )
then
331 ranks(n) = prc_next(prc_ne)
333 else if ( prc_has_n )
then
335 if ( ranks(m) == prc_next(prc_n) )
exit
337 if ( m == n + 1 )
then
339 ranks(n) = prc_next(prc_n)
341 else if ( prc_has_e )
then
343 if ( ranks(m) == prc_next(prc_e) )
exit
345 if ( m == n + 1 )
then
347 ranks(n) = prc_next(prc_e)
350 if ( prc_has_s .and. prc_has_w )
then
352 if ( ranks(m) == prc_next(prc_sw) )
exit
354 if ( m == n + 1 )
then
356 ranks(n) = prc_next(prc_sw)
358 else if ( prc_has_s )
then
360 if ( ranks(m) == prc_next(prc_s) )
exit
362 if ( m == n + 1 )
then
364 ranks(n) = prc_next(prc_s)
366 else if ( prc_has_w )
then
368 if ( ranks(m) == prc_next(prc_w) )
exit
370 if ( m == n + 1 )
then
372 ranks(n) = prc_next(prc_w)
375 if ( prc_has_s .and. prc_has_e )
then
377 if ( ranks(m) == prc_next(prc_se) )
exit
379 if ( m == n + 1 )
then
381 ranks(n) = prc_next(prc_se)
383 else if ( prc_has_s )
then
385 if ( ranks(m) == prc_next(prc_s) )
exit
387 if ( m == n + 1 )
then
389 ranks(n) = prc_next(prc_s)
391 else if ( prc_has_e )
then
393 if ( ranks(m) == prc_next(prc_e) )
exit
395 if ( m == n + 1 )
then
397 ranks(n) = prc_next(prc_e)
401 call mpi_group_incl( group, n, ranks, group_packns, ierr )
402 group_packns_created = .true.
404 group_packns_created = .false.
409 if ( prc_has_w )
then
411 ranks(n) = prc_next(prc_w)
413 if ( prc_has_e )
then
414 if ( n == 0 .or. ranks(1) .ne. prc_next(prc_e) )
then
416 ranks(n) = prc_next(prc_e)
421 call mpi_group_incl( group, n, ranks, group_packwe, ierr )
422 group_packwe_created = .true.
424 group_packwe_created = .false.
427 call mpi_group_free( group, ierr )
431 log_info(
"COMM_setup",*)
'Communication information'
432 log_info_cont(*)
'Maximum number of vars for one communication: ', comm_vsize_max
433 log_info_cont(*)
'All side is periodic? : ', comm_isallperiodic
444 KA, IA, JA, IHALO, JHALO, &
450 integer,
intent(in) :: ka, ia, ja, ihalo, jhalo
451 integer,
intent(out) :: gid
453 integer :: imax, jmax
454 integer :: nreq_ns, nreq_we, nreq_4c
459 type(mpi_info) :: win_info
462 integer(kind=MPI_ADDRESS_KIND) :: size
467 if ( .not. initialized )
then
468 log_error(
"COMM_regist",*)
'COMM_setup must be called before calling COMM_regist'
472 comm_gid = comm_gid + 1
473 if ( comm_gid > comm_gid_max )
then
474 log_error(
"COMM_regist",*)
'number of registed grid size exceeds the limit'
479 if ( ia < ihalo * 3 )
then
480 log_error(
"COMM_regist",*)
'IA must be >= IHALO * 3'
483 if ( ja < jhalo * 3 )
then
484 log_error(
"COMM_regist",*)
'JA must be >= JHALO * 3'
488 imax = ia - ihalo * 2
489 jmax = ja - jhalo * 2
493 ginfo(gid)%IS = ihalo + 1
494 ginfo(gid)%IE = ia - ihalo
495 ginfo(gid)%IHALO = ihalo
497 ginfo(gid)%JS = jhalo + 1
498 ginfo(gid)%JE = ja - jhalo
499 ginfo(gid)%JHALO = jhalo
505 if ( comm_use_mpi_pc )
then
506 ginfo(gid)%nreq_MAX = 2 * nreq_ns + 2 * nreq_we + 4 * nreq_4c + 1
508 ginfo(gid)%nreq_MAX = 2 * nreq_ns + 2 * nreq_we + 4 * nreq_4c
511 ginfo(gid)%size2D_NS4 = ia * jhalo
512 ginfo(gid)%size2D_NS8 = imax
513 ginfo(gid)%size2D_WE = jmax * ihalo
514 ginfo(gid)%size2D_4C = ihalo
516 allocate( ginfo(gid)%sendpack_P2WE(ginfo(gid)%size2D_WE * ka, 2, comm_vsize_max) )
520 allocate( ginfo(gid)%use_packbuf(comm_vsize_max) )
521 ginfo(gid)%use_packbuf(:) = .false.
525 allocate( ginfo(gid)%device_alloc(comm_vsize_max+comm_vsize_max_pc) )
526 allocate( ginfo(gid)%device_ptr(comm_vsize_max+1:comm_vsize_max_pc) )
527 ginfo(gid)%device_alloc(:) = .false.
530 if ( comm_use_mpi_onesided )
then
532 allocate( ginfo(gid)%recvbuf_WE(comm_vsize_max) )
533 allocate( ginfo(gid)%recvbuf_NS(comm_vsize_max) )
535 allocate( ginfo(gid)%win_packWE(comm_vsize_max) )
536 allocate( ginfo(gid)%win_packNS(comm_vsize_max) )
538 call mpi_info_create(win_info, ierr)
539 call mpi_info_set(win_info,
"no_locks",
"true", ierr)
540 call mpi_info_set(win_info,
"same_size",
"true", ierr)
541 call mpi_info_set(win_info,
"same_disp_unit",
"true", ierr)
543 do n = 1, comm_vsize_max
544 size = ginfo(gid)%size2D_WE * ka * 2 *
rp
547 real(
rp),
pointer :: pack(:)
548 call mpi_alloc_mem(
size, mpi_info_null, ginfo(gid)%recvbuf_WE(n), ierr)
549 call c_f_pointer(ginfo(gid)%recvbuf_WE(n), pack, (/ size/
rp /))
552 call mpi_win_create(pack,
size, ginfo(gid)%size2D_WE*ka*
rp, &
553 win_info, comm_world_t, &
554 ginfo(gid)%win_packWE(n), ierr)
558 call mpi_win_allocate(
size, ginfo(gid)%size2D_WE*ka*
rp, &
559 win_info, comm_world_t, &
560 ginfo(gid)%recvbuf_WE(n), ginfo(gid)%win_packWE(n), ierr)
562 size = ginfo(gid)%size2D_NS4 * ka * 2 *
rp
565 real(
rp),
pointer :: pack(:)
566 call mpi_alloc_mem(
size, mpi_info_null, ginfo(gid)%recvbuf_NS(n), ierr)
567 call c_f_pointer(ginfo(gid)%recvbuf_NS(n), pack, (/ size/
rp /))
570 call mpi_win_create(pack,
size,
rp, &
571 win_info, comm_world_t, &
572 ginfo(gid)%win_packNS(n), ierr)
576 call mpi_win_allocate(
size, rp, &
577 win_info, comm_world_t, &
578 ginfo(gid)%recvbuf_NS(n), ginfo(gid)%win_packNS(n), ierr)
582 call mpi_info_free(win_info, ierr)
584 do n = 1, comm_vsize_max
585 call mpi_win_post( group_packwe, mpi_mode_nostore, ginfo(gid)%win_packWE(n), ierr )
586 call mpi_win_post( group_packns, mpi_mode_nostore, ginfo(gid)%win_packNS(n), ierr )
589 ginfo(gid)%vars_num = 0
590 allocate( ginfo(gid)%packid(comm_vsize_max_pc) )
594 allocate( ginfo(gid)%recvpack_WE2P(ginfo(gid)%size2D_WE * ka, 2, comm_vsize_max) )
597 allocate( ginfo(gid)%req_cnt ( comm_vsize_max) )
598 allocate( ginfo(gid)%req_list(ginfo(gid)%nreq_MAX, comm_vsize_max) )
599 ginfo(gid)%req_cnt (:) = -1
600 ginfo(gid)%req_list(:,:) = mpi_request_null
602 if ( comm_use_mpi_pc )
then
603 ginfo(gid)%vars_num = 0
604 allocate( ginfo(gid)%packid(comm_vsize_max_pc) )
605 allocate( ginfo(gid)%preq_cnt ( comm_vsize_max_pc) )
606 allocate( ginfo(gid)%preq_list(ginfo(gid)%nreq_MAX+1,comm_vsize_max_pc) )
607 ginfo(gid)%preq_cnt (:) = -1
608 ginfo(gid)%preq_list(:,:) = mpi_request_null
615 log_info(
"COMM_regist",*)
'Register grid: id=', gid
616 log_info_cont(*)
'Data size of var (3D,including halo) [byte] : ', rp*ka*ia*ja
617 log_info_cont(*)
'Data size of halo [byte] : ', rp*ka*(2*ia*jhalo+2*jmax*ihalo)
618 log_info_cont(*)
'Ratio of halo against the whole 3D grid : ', real(2*ia*jhalo+2*jmax*ihalo) / real(ia*ja)
629 integer :: i, j, ierr
634 if ( comm_use_mpi_onesided )
then
636 do i = 1, comm_vsize_max
637 call mpi_win_start( group_packwe, 0, ginfo(gid)%win_packWE(i), ierr )
638 call mpi_win_start( group_packns, 0, ginfo(gid)%win_packNS(i), ierr )
641 do i = 1, comm_vsize_max
642 call mpi_win_complete( ginfo(gid)%win_packWE(i), ierr )
643 call mpi_win_complete( ginfo(gid)%win_packNS(i), ierr )
646 do i = 1, comm_vsize_max
647 call mpi_win_wait( ginfo(gid)%win_packWE(i), ierr )
648 call mpi_win_wait( ginfo(gid)%win_packNS(i), ierr )
651 do i = 1, comm_vsize_max
652 call mpi_win_free(ginfo(gid)%win_packWE(i), ierr)
653 call mpi_win_free(ginfo(gid)%win_packNS(i), ierr)
656 real(rp),
pointer :: pack(:)
659 call c_f_pointer( ginfo(gid)%recvbuf_WE(i), pack, (/ginfo(gid)%size2D_WE*ka*2/) )
661 call c_f_pointer( ginfo(gid)%recvbuf_NS(i), pack, (/ginfo(gid)%size2D_NS4*ka*2/) )
664 call mpi_free_mem(ginfo(gid)%recvbuf_WE(i), ierr)
665 call mpi_free_mem(ginfo(gid)%recvbuf_NS(i), ierr)
669 deallocate( ginfo(gid)%packid )
670 ginfo(gid)%vars_num = 0
672 deallocate( ginfo(gid)%win_packWE )
673 deallocate( ginfo(gid)%win_packNS )
675 deallocate( ginfo(gid)%recvbuf_WE )
676 deallocate( ginfo(gid)%recvbuf_NS )
680 if ( comm_use_mpi_pc )
then
682 do j = 1, comm_vsize_max_pc
683 do i = 1, ginfo(gid)%nreq_MAX+1
684 if (ginfo(gid)%preq_list(i,j) .NE. mpi_request_null) &
685 call mpi_request_free(ginfo(gid)%preq_list(i,j), ierr)
688 if ( ginfo(gid)%device_alloc(j+comm_vsize_max) )
then
693 deallocate( ginfo(gid)%preq_cnt )
694 deallocate( ginfo(gid)%preq_list )
695 deallocate( ginfo(gid)%packid )
696 ginfo(gid)%vars_num = 0
700 deallocate( ginfo(gid)%req_cnt )
701 deallocate( ginfo(gid)%req_list )
704 deallocate( ginfo(gid)%recvpack_WE2P )
709 deallocate( ginfo(gid)%sendpack_P2WE )
711 deallocate( ginfo(gid)%use_packbuf )
716 if ( comm_use_mpi_onesided )
then
717 if ( group_packwe_created )
then
718 call mpi_group_free(group_packwe, ierr)
719 group_packwe_created = .false.
721 if ( group_packns_created )
then
722 call mpi_group_free(group_packns, ierr)
723 group_packns_created = .false.
730 initialized = .false.
746 character(len=*),
intent(in) :: varname
747 real(rp),
target,
intent(inout) :: var(:,:,:)
748 integer,
intent(inout) :: vid
750 integer,
intent(in),
optional :: gid
756 if ( .not. comm_use_mpi_pc )
return
758 if ( .not. acc_is_present(var) )
return
761 call prof_rapstart(
'COMM_init_pers', 2)
764 if (
present(gid) ) gid_ = gid
765 if ( gid_ > comm_gid_max )
then
766 log_error(
"COMM_vars_init",*)
'gid is invalid', gid_, comm_gid_max
770 if ( vid > comm_vsize_max )
then
771 log_error(
"COMM_vars_init",*)
'vid exceeds max', vid, comm_vsize_max, gid
775 ginfo(gid_)%vars_num = ginfo(gid_)%vars_num + 1
776 if ( ginfo(gid_)%vars_num > comm_vsize_max_pc )
then
777 log_error(
"COMM_vars_init",*)
'number of variable for MPI PC exceeds max', ginfo(gid_)%vars_num, comm_vsize_max_pc
781 vars_id = ginfo(gid_)%vars_num
782 ginfo(gid_)%packid(vars_id) = vid
785 if ( .not. acc_is_present(var) )
then
786 ginfo(gid_)%device_alloc(vars_id+comm_vsize_max) = .true.
787 ginfo(gid_)%device_ptr(vars_id*comm_vsize_max)%ptr => var
794 vid = vars_id + comm_vsize_max
796 log_info(
"COMM_vars_init",
'(1x,A,I3.3,A,I3.3,2A)')
'Initialize variable (grid ID = ', gid_,
'): ID = ', vid, &
797 ', name = ', trim(varname)
799 call prof_rapend (
'COMM_init_pers', 2)
815 character(len=*),
intent(in) :: varname
817 real(rp),
target,
intent(inout) :: var(:,:,:)
818 integer,
intent(inout) :: vid
820 integer,
intent(in),
optional :: gid
826 if ( .not. comm_use_mpi_pc )
return
828 if ( .not. acc_is_present(var) )
return
831 call prof_rapstart(
'COMM_init_pers', 2)
834 if (
present(gid) ) gid_ = gid
835 if ( gid_ > comm_gid_max )
then
836 log_error(
"COMM_vars8_init",*)
'gid is invalid', gid_, comm_gid_max
840 if ( vid > comm_vsize_max )
then
841 log_error(
"COMM_vars8_init",*)
'vid exceeds max', vid, comm_vsize_max
845 ginfo(gid_)%vars_num = ginfo(gid_)%vars_num + 1
846 if ( ginfo(gid_)%vars_num > comm_vsize_max_pc )
then
847 log_error(
"COMM_vars8_init",*)
'number of variable for MPI PC exceeds max', ginfo(gid_)%vars_num, comm_vsize_max_pc
851 vars_id = ginfo(gid_)%vars_num
852 ginfo(gid_)%packid(vars_id) = vid
855 if ( .not. acc_is_present(var) )
then
856 ginfo(gid_)%device_alloc(vars_id+comm_vsize_max) = .true.
857 ginfo(gid_)%device_ptr(vars_id+comm_vsize_max)%ptr => var
864 vid = vars_id + comm_vsize_max
866 log_info(
"COMM_vars8_init",
'(1x,A,I3.3,A,I3.3,2A)')
'Initialize variable (grid ID = ', gid_,
'): ID = ', vid, &
867 ', name = ', trim(varname)
869 call prof_rapend (
'COMM_init_pers', 2)
880 real(RP),
intent(inout) :: var(:,:,:)
882 integer,
intent(in) :: vid
884 integer,
intent(in),
optional :: gid
890 if (
present(gid) ) gid_ = gid
891 if ( gid_ > comm_gid_max )
then
892 log_error(
"COMM_vars_3D",*)
'gid is invalid', gid_, comm_gid_max
896 if ( vid > comm_vsize_max )
then
897 call prof_rapstart(
'COMM_vars_pers', 2)
899 call prof_rapend (
'COMM_vars_pers', 2)
901 call prof_rapstart(
'COMM_vars', 2)
902 if ( comm_use_mpi_onesided )
then
907 call prof_rapend (
'COMM_vars', 2)
919 real(RP),
intent(inout) :: var(:,:,:)
921 integer,
intent(in) :: vid
923 integer,
intent(in),
optional :: gid
929 if (
present(gid) ) gid_ = gid
930 if ( gid_ > comm_gid_max )
then
931 log_error(
"COMM_vars8_3D",*)
'gid is invalid', gid_, comm_gid_max
935 if ( vid > comm_vsize_max )
then
936 call prof_rapstart(
'COMM_vars_pers', 2)
938 call prof_rapend (
'COMM_vars_pers', 2)
940 call prof_rapstart(
'COMM_vars', 2)
941 if ( comm_use_mpi_onesided )
then
946 call prof_rapend (
'COMM_vars', 2)
958 real(RP),
intent(inout) :: var(:,:,:)
960 integer,
intent(in) :: vid
962 logical,
intent(in),
optional :: FILL_BND
963 integer,
intent(in),
optional :: gid
970 if (
present(fill_bnd) ) fill_bnd_ = fill_bnd
973 if (
present(gid) ) gid_ = gid
974 if ( gid_ > comm_gid_max )
then
975 log_error(
"COMM_wait_3D",*)
'gid is invalid', gid_, comm_gid_max
979 if ( vid > comm_vsize_max )
then
980 call prof_rapstart(
'COMM_wait_pers', 2)
982 call prof_rapend (
'COMM_wait_pers', 2)
984 call prof_rapstart(
'COMM_wait', 2)
985 if ( comm_use_mpi_onesided )
then
990 call prof_rapend (
'COMM_wait', 2)
994 if ( .NOT. comm_isallperiodic )
then
995 if ( fill_bnd_ )
then
996 call copy_boundary_3d(var, gid_)
1009 real(RP),
intent(inout) :: var(:,:)
1011 integer,
intent(in) :: vid
1013 integer,
intent(in),
optional :: gid
1019 if (
present(gid) ) gid_ = gid
1020 if ( gid_ > comm_gid_max )
then
1021 log_error(
"COMM_vars_2D",*)
'gid is invalid', gid_, comm_gid_max
1025 call prof_rapstart(
'COMM_vars', 2)
1026 if ( comm_use_mpi_onesided )
then
1031 call prof_rapend (
'COMM_vars', 2)
1042 real(RP),
intent(inout) :: var(:,:)
1044 integer,
intent(in) :: vid
1046 integer,
intent(in),
optional :: gid
1052 if (
present(gid) ) gid_ = gid
1053 if ( gid_ > comm_gid_max )
then
1054 log_error(
"COMM_vars8_2D",*)
'gid is invalid', gid_, comm_gid_max
1058 call prof_rapstart(
'COMM_vars', 2)
1059 if ( comm_use_mpi_onesided )
then
1064 call prof_rapend (
'COMM_vars', 2)
1075 real(RP),
intent(inout) :: var(:,:)
1077 integer,
intent(in) :: vid
1079 logical,
intent(in),
optional :: FILL_BND
1080 integer,
intent(in),
optional :: gid
1082 logical :: FILL_BND_
1087 if (
present(fill_bnd) ) fill_bnd_ = fill_bnd
1090 if (
present(gid) ) gid_ = gid
1091 if ( gid_ > comm_gid_max )
then
1092 log_error(
"COMM_wait_2D",*)
'gid is invalid', gid_, comm_gid_max
1096 call prof_rapstart(
'COMM_wait', 2)
1097 if ( comm_use_mpi_onesided )
then
1102 call prof_rapend (
'COMM_wait', 2)
1104 if( .NOT. comm_isallperiodic )
then
1105 if ( fill_bnd_ )
then
1116 IA, IS, IE, JA, JS, JE, &
1123 integer,
intent(in) :: IA, IS, IE
1124 integer,
intent(in) :: JA, JS, JE
1125 real(RP),
intent(in) :: var(IA,JA)
1127 real(RP),
intent(out) :: varmean
1130 real(DP) :: stat1, stat2
1131 real(DP) :: allstat(2)
1147 stat1 = stat1 + var(i,j)
1148 stat2 = stat2 + 1.0_dp
1154 stat(:) = (/stat1, stat2/)
1158 call prof_rapstart(
'COMM_Allreduce', 2)
1159 call mpi_allreduce( stat, &
1162 mpi_double_precision, &
1166 call prof_rapend (
'COMM_Allreduce', 2)
1168 zerosw = 0.5_dp - sign(0.5_dp, allstat(1) - 1.e-12_dp )
1169 varmean = allstat(1) / ( allstat(2) + zerosw ) * ( 1.0_dp - zerosw )
1178 KA, IA, IS, IE, JA, JS, JE, &
1185 integer,
intent(in) :: KA
1186 integer,
intent(in) :: IA, IS, IE
1187 integer,
intent(in) :: JA, JS, JE
1188 real(RP),
intent(in) :: var(KA,IA,JA)
1190 real(RP),
intent(out) :: varmean(KA)
1192 real(DP) :: stat (KA,2)
1193 real(DP) :: allstat(KA,2)
1199 logical :: flag_device
1204 flag_device = acc_is_present(var)
1220 stat(k,1) = stat(k,1) + var(k,i,j)
1223 stat(k,2) = stat(k,2) + 1.0_dp
1234 call prof_rapstart(
'COMM_Allreduce', 2)
1236 call mpi_allreduce( stat, &
1239 mpi_double_precision, &
1244 call prof_rapend (
'COMM_Allreduce', 2)
1248 zerosw = 0.5_dp - sign(0.5_dp, allstat(k,2) - 1.e-12_dp )
1249 varmean(k) = allstat(k,1) / ( allstat(k,2) + zerosw ) * ( 1.0_dp - zerosw )
1269 integer,
intent(in) :: IA, JA
1270 real(RP),
intent(in) :: send(IA,JA)
1272 real(RP),
intent(out) :: recv(:,:,:)
1274 integer :: sendcounts, recvcounts
1278 sendcounts = ia * ja
1279 recvcounts = ia * ja
1282 call mpi_gather( send(:,:), &
1306 integer,
intent(in) :: KA, IA, JA
1307 real(RP),
intent(in) :: send(KA,IA,JA)
1309 real(RP),
intent(out) :: recv(:,:,:,:)
1311 integer :: sendcounts, recvcounts
1315 sendcounts = ka * ia * ja
1316 recvcounts = ka * ia * ja
1319 call mpi_gather( send(:,:,:), &
1340 real(SP),
intent(inout) :: var
1346 call prof_rapstart(
'COMM_Bcast', 2)
1350 call mpi_bcast( var, &
1357 call prof_rapend(
'COMM_Bcast', 2)
1366 real(DP),
intent(inout) :: var
1372 call prof_rapstart(
'COMM_Bcast', 2)
1376 call mpi_bcast( var, &
1378 mpi_double_precision, &
1383 call prof_rapend(
'COMM_Bcast', 2)
1395 integer,
intent(in) :: IA
1397 real(SP),
intent(inout) :: var(IA)
1403 call prof_rapstart(
'COMM_Bcast', 2)
1408 call mpi_bcast( var(:), &
1416 call prof_rapend(
'COMM_Bcast', 2)
1425 integer,
intent(in) :: IA
1427 real(DP),
intent(inout) :: var(IA)
1433 call prof_rapstart(
'COMM_Bcast', 2)
1438 call mpi_bcast( var(:), &
1440 mpi_double_precision, &
1446 call prof_rapend(
'COMM_Bcast', 2)
1458 integer,
intent(in) :: IA, JA
1460 real(SP),
intent(inout) :: var(IA,JA)
1466 call prof_rapstart(
'COMM_Bcast', 2)
1471 call mpi_bcast( var(:,:), &
1479 call prof_rapend(
'COMM_Bcast', 2)
1488 integer,
intent(in) :: IA, JA
1490 real(DP),
intent(inout) :: var(IA,JA)
1496 call prof_rapstart(
'COMM_Bcast', 2)
1501 call mpi_bcast( var(:,:), &
1503 mpi_double_precision, &
1509 call prof_rapend(
'COMM_Bcast', 2)
1521 integer,
intent(in) :: KA, IA, JA
1523 real(SP),
intent(inout) :: var(KA,IA,JA)
1529 call prof_rapstart(
'COMM_Bcast', 2)
1531 counts = ka * ia * ja
1534 call mpi_bcast( var(:,:,:), &
1542 call prof_rapend(
'COMM_Bcast', 2)
1551 integer,
intent(in) :: KA, IA, JA
1553 real(DP),
intent(inout) :: var(KA,IA,JA)
1559 call prof_rapstart(
'COMM_Bcast', 2)
1561 counts = ka * ia * ja
1564 call mpi_bcast( var(:,:,:), &
1566 mpi_double_precision, &
1572 call prof_rapend(
'COMM_Bcast', 2)
1585 integer,
intent(in) :: KA, IA, JA, NT
1587 real(SP),
intent(inout) :: var(KA,IA,JA,NT)
1593 call prof_rapstart(
'COMM_Bcast', 2)
1595 counts = ka * ia * ja * nt
1596 if ( ka>0 .AND. ia>0 .AND. ja>0 .AND. nt>0 .AND. &
1598 log_error(
"COMM_bcast_4D",*)
'counts overflow'
1603 call mpi_bcast( var(:,:,:,:), &
1611 call prof_rapend(
'COMM_Bcast', 2)
1621 integer,
intent(in) :: KA, IA, JA, NT
1623 real(DP),
intent(inout) :: var(KA,IA,JA,NT)
1629 call prof_rapstart(
'COMM_Bcast', 2)
1631 counts = ka * ia * ja * nt
1632 if ( ka>0 .AND. ia>0 .AND. ja>0 .AND. nt>0 .AND. &
1634 log_error(
"COMM_bcast_4D",*)
'counts overflow'
1639 call mpi_bcast( var(:,:,:,:), &
1641 mpi_double_precision, &
1647 call prof_rapend(
'COMM_Bcast', 2)
1659 integer,
intent(inout) :: var
1665 call prof_rapstart(
'COMM_Bcast', 2)
1669 call mpi_bcast( var, &
1676 call prof_rapend(
'COMM_Bcast', 2)
1688 integer,
intent(in) :: IA
1689 integer,
intent(inout) :: var(IA)
1695 call prof_rapstart(
'COMM_Bcast', 2)
1699 call mpi_bcast( var(:), &
1706 call prof_rapend(
'COMM_Bcast', 2)
1718 integer,
intent(in) :: IA, JA
1720 integer,
intent(inout) :: var(IA,JA)
1726 call prof_rapstart(
'COMM_Bcast', 2)
1731 call mpi_bcast( var(:,:), &
1739 call prof_rapend(
'COMM_Bcast', 2)
1751 logical,
intent(inout) :: var
1757 call prof_rapstart(
'COMM_Bcast', 2)
1761 call mpi_bcast( var, &
1768 call prof_rapend(
'COMM_Bcast', 2)
1780 integer,
intent(in) :: IA
1781 logical,
intent(inout) :: var(IA)
1787 call prof_rapstart(
'COMM_Bcast', 2)
1792 call mpi_bcast( var(:), &
1800 call prof_rapend(
'COMM_Bcast', 2)
1812 character(len=*),
intent(inout) :: var
1818 call prof_rapstart(
'COMM_Bcast', 2)
1822 call mpi_bcast( var, &
1829 call prof_rapend(
'COMM_Bcast', 2)
1842 real(RP),
intent(inout) :: var(:,:,:)
1843 integer,
intent(in) :: gid
1844 integer,
intent(in) :: vid
1845 integer,
intent(in) :: seqid
1847 integer :: ireq, tag, ierr
1851 integer :: JA, JS, JE, JHALO
1857 real(RP),
pointer :: ptr(:,:)
1860 tag = ( (gid - 1) * comm_vsize_max + vid ) * 100
1867 jhalo = ginfo(gid)%JHALO
1873 call mpi_send_init( var(:,:,:),
size(var), comm_datatype_t, &
1874 mpi_proc_null, tag+ginfo(gid)%nreq_max+1, comm_world_t, &
1875 ginfo(gid)%preq_list(ginfo(gid)%nreq_max+1,vid), ierr )
1879 if ( prc_has_s )
then
1880 call mpi_recv_init( var(:,:,1:js-1), ginfo(gid)%size2D_NS4*ka, comm_datatype_t, &
1881 prc_next(prc_s), tag+1, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
1885 if ( prc_has_n )
then
1886 call mpi_recv_init( var(:,:,je+1:ja), ginfo(gid)%size2D_NS4*ka, comm_datatype_t, &
1887 prc_next(prc_n), tag+2, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
1892 ptr => ginfo(gid)%recvpack_WE2P(:,:,seqid)
1897 if ( prc_has_e )
then
1899 call mpi_recv_init( ptr(:,2), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
1901 call mpi_recv_init( ginfo(gid)%recvpack_WE2P(:,2,seqid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
1903 prc_next(prc_e), tag+3, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
1907 if ( prc_has_w )
then
1909 call mpi_recv_init( ptr(:,1), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
1911 call mpi_recv_init( ginfo(gid)%recvpack_WE2P(:,1,seqid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
1913 prc_next(prc_w), tag+4, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
1922 ptr => ginfo(gid)%sendpack_P2WE(:,:,seqid)
1926 if ( prc_has_w )
then
1928 call mpi_send_init( ptr(:,1), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
1930 call mpi_send_init( ginfo(gid)%sendpack_P2WE(:,1,seqid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
1932 prc_next(prc_w), tag+3, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
1936 if ( prc_has_e )
then
1938 call mpi_send_init( ptr(:,2), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
1940 call mpi_send_init( ginfo(gid)%sendpack_P2WE(:,2,seqid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
1942 prc_next(prc_e), tag+4, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
1948 if ( prc_has_n )
then
1949 call mpi_send_init( var(:,:,je-jhalo+1:je), ginfo(gid)%size2D_NS4*ka, comm_datatype_t, &
1950 prc_next(prc_n), tag+1, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
1954 if ( prc_has_s )
then
1955 call mpi_send_init( var(:,:,js:js+jhalo-1), ginfo(gid)%size2D_NS4*ka, comm_datatype_t, &
1956 prc_next(prc_s), tag+2, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
1960 ginfo(gid)%preq_cnt(vid) = ireq - 1
1963 nreq = ginfo(gid)%preq_cnt(vid)
1965 call mpi_testall( nreq, ginfo(gid)%preq_list(1:nreq,vid), &
1966 flag, mpi_statuses_ignore, ierr )
1979 real(RP),
intent(inout) :: var(:,:,:)
1980 integer,
intent(in) :: gid
1981 integer,
intent(in) :: vid
1982 integer,
intent(in) :: seqid
1984 integer :: ireq, tag, tagc
1989 integer :: IS, IE, IHALO
1990 integer :: JA, JS, JE, JHALO
1996 real(RP),
pointer :: ptr(:,:)
2002 ihalo = ginfo(gid)%IHALO
2006 jhalo = ginfo(gid)%JHALO
2008 tag = ( (gid - 1) * comm_vsize_max + vid ) * 100
2015 call mpi_send_init( var(:,:,:),
size(var), comm_datatype_t, &
2016 mpi_proc_null, tag+ginfo(gid)%nreq_max+1, comm_world_t, &
2017 ginfo(gid)%preq_list(ginfo(gid)%nreq_max+1,vid), ierr )
2020 if ( comm_isallperiodic )
then
2027 call mpi_recv_init( var(1,ie+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2028 prc_next(prc_se), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2035 call mpi_recv_init( var(1,1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2036 prc_next(prc_sw), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2043 call mpi_recv_init( var(1,ie+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2044 prc_next(prc_ne), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2050 do j = je+1, je+jhalo
2051 call mpi_recv_init( var(1,1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2052 prc_next(prc_nw), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2059 ptr => ginfo(gid)%recvpack_WE2P(:,:,seqid)
2061 call mpi_recv_init( ptr(:,2), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2063 call mpi_recv_init( ginfo(gid)%recvpack_WE2P(:,2,seqid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2065 prc_next(prc_e), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2070 call mpi_recv_init( ptr(:,1), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2072 call mpi_recv_init( ginfo(gid)%recvpack_WE2P(:,1,seqid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2074 prc_next(prc_w), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2081 call mpi_recv_init( var(1,is,j), ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
2082 prc_next(prc_s), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2089 call mpi_recv_init( var(1,is,j), ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
2090 prc_next(prc_n), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2098 do j = je-jhalo+1, je
2099 call mpi_send_init( var(1,is,j), ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
2100 prc_next(prc_n), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2106 do j = js, js+jhalo-1
2107 call mpi_send_init( var(1,is,j), ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
2108 prc_next(prc_s), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2116 ptr => ginfo(gid)%sendpack_P2WE(:,:,seqid)
2118 call mpi_send_init( ptr(:,1), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2120 call mpi_send_init( ginfo(gid)%sendpack_P2WE(:,1,seqid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2122 prc_next(prc_w), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2127 call mpi_send_init( ptr(:,2), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2129 call mpi_send_init( ginfo(gid)%sendpack_P2WE(:,2,seqid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2131 prc_next(prc_e), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2136 do j = je-jhalo+1, je
2137 call mpi_send_init( var(1,is,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2138 prc_next(prc_nw), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2144 do j = je-jhalo+1, je
2145 call mpi_send_init( var(1,ie-ihalo+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2146 prc_next(prc_ne), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2152 do j = js, js+jhalo-1
2153 call mpi_send_init( var(1,is,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2154 prc_next(prc_sw), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2160 do j = js, js+jhalo-1
2161 call mpi_send_init( var(1,ie-ihalo+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2162 prc_next(prc_se), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2173 if ( prc_has_s .AND. prc_has_e )
then
2176 call mpi_recv_init( var(1,ie+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2177 prc_next(prc_se), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2181 else if ( prc_has_s )
then
2184 call mpi_recv_init( var(1,ie+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2185 prc_next(prc_s), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2189 else if ( prc_has_e )
then
2192 call mpi_recv_init( var(1,ie+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2193 prc_next(prc_e), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2199 if ( prc_has_s .AND. prc_has_w )
then
2202 call mpi_recv_init( var(1,1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2203 prc_next(prc_sw), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2207 else if ( prc_has_s )
then
2210 call mpi_recv_init( var(1,1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2211 prc_next(prc_s), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2215 else if ( prc_has_w )
then
2218 call mpi_recv_init( var(1,1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2219 prc_next(prc_w), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2225 if ( prc_has_n .AND. prc_has_e )
then
2228 call mpi_recv_init( var(1,ie+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2229 prc_next(prc_ne), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2233 else if ( prc_has_n )
then
2236 call mpi_recv_init( var(1,ie+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2237 prc_next(prc_n), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2241 else if ( prc_has_e )
then
2244 call mpi_recv_init( var(1,ie+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2245 prc_next(prc_e), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2251 if ( prc_has_n .AND. prc_has_w )
then
2254 call mpi_recv_init( var(1,1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2255 prc_next(prc_nw), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2259 else if ( prc_has_n )
then
2262 call mpi_recv_init( var(1,1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2263 prc_next(prc_n), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2267 else if ( prc_has_w )
then
2270 call mpi_recv_init( var(1,1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2271 prc_next(prc_w), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2277 ptr => ginfo(gid)%recvpack_WE2P(:,:,seqid)
2281 if ( prc_has_e )
then
2284 call mpi_recv_init( ptr(:,2), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2286 call mpi_recv_init( ginfo(gid)%recvpack_WE2P(:,2,seqid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2288 prc_next(prc_e), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2292 if ( prc_has_w )
then
2295 call mpi_recv_init( ptr(:,1), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2297 call mpi_recv_init( ginfo(gid)%recvpack_WE2P(:,1,seqid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2299 prc_next(prc_w), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2305 if ( prc_has_s )
then
2308 call mpi_recv_init( var(1,is,j), ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
2309 prc_next(prc_s), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2315 if ( prc_has_n )
then
2318 call mpi_recv_init( var(1,is,j), ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
2319 prc_next(prc_n), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2327 if ( prc_has_n )
then
2329 do j = je-jhalo+1, je
2330 call mpi_send_init( var(1,is,j), ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
2331 prc_next(prc_n), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2337 if ( prc_has_s )
then
2339 do j = js, js+jhalo-1
2340 call mpi_send_init( var(1,is,j), ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
2341 prc_next(prc_s), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2348 ptr => ginfo(gid)%sendpack_P2WE(:,:,seqid)
2352 if ( prc_has_w )
then
2355 call mpi_send_init( ptr(:,1), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2357 call mpi_send_init( ginfo(gid)%sendpack_P2WE(:,1,seqid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2359 prc_next(prc_w), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2363 if ( prc_has_e )
then
2366 call mpi_send_init( ptr(:,2), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2368 call mpi_send_init( ginfo(gid)%sendpack_P2WE(:,2,seqid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2370 prc_next(prc_e), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2375 if ( prc_has_n .AND. prc_has_w )
then
2377 do j = je-jhalo+1, je
2378 call mpi_send_init( var(1,is,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2379 prc_next(prc_nw), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2383 else if ( prc_has_n )
then
2385 do j = je-jhalo+1, je
2386 call mpi_send_init( var(1,1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2387 prc_next(prc_n), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2391 else if ( prc_has_w )
then
2394 call mpi_send_init( var(1,is,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2395 prc_next(prc_w), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2401 if ( prc_has_n .AND. prc_has_e )
then
2403 do j = je-jhalo+1, je
2404 call mpi_send_init( var(1,ie-ihalo+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2405 prc_next(prc_ne), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2409 else if ( prc_has_n )
then
2411 do j = je-jhalo+1, je
2412 call mpi_send_init( var(1,ie+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2413 prc_next(prc_n), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2417 else if ( prc_has_e )
then
2420 call mpi_send_init( var(1,ie-ihalo+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2421 prc_next(prc_e), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2427 if ( prc_has_s .AND. prc_has_w )
then
2429 do j = js, js+jhalo-1
2430 call mpi_send_init( var(1,is,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2431 prc_next(prc_sw), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2435 else if ( prc_has_s )
then
2437 do j = js, js+jhalo-1
2438 call mpi_send_init( var(1,1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2439 prc_next(prc_s), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2443 else if ( prc_has_w )
then
2446 call mpi_send_init( var(1,is,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2447 prc_next(prc_w), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2453 if ( prc_has_s .AND. prc_has_e )
then
2455 do j = js, js+jhalo-1
2456 call mpi_send_init( var(1,ie-ihalo+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2457 prc_next(prc_se), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2461 else if ( prc_has_s )
then
2463 do j = js, js+jhalo-1
2464 call mpi_send_init( var(1,ie+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2465 prc_next(prc_s), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2469 else if ( prc_has_e )
then
2472 call mpi_send_init( var(1,ie-ihalo+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2473 prc_next(prc_e), tag+tagc, comm_world_t, ginfo(gid)%preq_list(ireq,vid), ierr )
2482 ginfo(gid)%preq_cnt(vid) = ireq - 1
2485 nreq = ginfo(gid)%preq_cnt(vid)
2487 call mpi_testall( nreq, ginfo(gid)%preq_list(1:nreq,vid), &
2488 flag, mpi_statuses_ignore, ierr )
2503 real(RP),
intent(inout) :: var(:,:,:)
2504 integer,
intent(in) :: gid
2505 integer,
intent(in) :: vid
2508 integer :: ireq, tag
2511 integer :: IA, IS, IE
2512 integer :: JA, JS, JE
2513 integer :: IHALO, JHALO
2517 real(RP),
pointer :: ptr(:,:)
2518 logical :: flag_device
2522 tag = ( (gid - 1) * comm_vsize_max + vid ) * 100
2532 ihalo = ginfo(gid)%IHALO
2533 jhalo = ginfo(gid)%JHALO
2536 if ( ginfo(gid)%use_packbuf(vid) )
then
2537 log_error(
"vars_3D_mpi",*)
'packing buffer is already used', vid
2540 ginfo(gid)%use_packbuf(vid) = .true.
2544 flag_device = acc_is_present(var)
2551 if ( prc_has_s )
then
2552 call mpi_irecv( var(:,:,1:js-1), ginfo(gid)%size2D_NS4*ka, comm_datatype_t, &
2553 prc_next(prc_s), tag+1, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2557 if ( prc_has_n )
then
2558 call mpi_irecv( var(:,:,je+1:ja), ginfo(gid)%size2D_NS4*ka, comm_datatype_t, &
2559 prc_next(prc_n), tag+2, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2564 ptr => ginfo(gid)%recvpack_WE2P(:,:,vid)
2568 if ( prc_has_e )
then
2570 call mpi_irecv( ptr(:,2), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2572 call mpi_irecv( ginfo(gid)%recvpack_WE2P(:,2,vid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2574 prc_next(prc_e), tag+3, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2578 if ( prc_has_w )
then
2580 call mpi_irecv( ptr(:,1), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2582 call mpi_irecv( ginfo(gid)%recvpack_WE2P(:,1,vid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2584 prc_next(prc_w), tag+4, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2594 call packwe_3d( ka, ia, is, ie, ja, js, je, &
2602 if ( prc_has_n )
then
2603 call mpi_isend( var(:,:,je-jhalo+1:je), ginfo(gid)%size2D_NS4*ka, comm_datatype_t, &
2604 prc_next(prc_n), tag+1, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2608 if ( prc_has_s )
then
2609 call mpi_isend( var(:,:,js:js+jhalo-1), ginfo(gid)%size2D_NS4*ka, comm_datatype_t, &
2610 prc_next(prc_s), tag+2, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2618 ptr => ginfo(gid)%sendpack_P2WE(:,:,vid)
2623 if ( prc_has_w )
then
2625 call mpi_isend( ptr(:,1), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2627 call mpi_isend( ginfo(gid)%sendpack_P2WE(:,1,vid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2629 prc_next(prc_w), tag+3, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2633 if ( prc_has_e )
then
2635 call mpi_isend( ptr(:,2), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2637 call mpi_isend( ginfo(gid)%sendpack_P2WE(:,2,vid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2639 prc_next(prc_e), tag+4, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2646 ginfo(gid)%req_cnt(vid) = ireq - 1
2656 real(RP),
intent(inout) :: var(:,:,:)
2657 integer,
intent(in) :: gid
2658 integer,
intent(in) :: vid
2661 integer :: IA, IS, IE
2662 integer :: JA, JS, JE
2663 integer :: IHALO, JHALO
2665 integer(kind=MPI_ADDRESS_KIND) :: disp
2669 real(RP),
pointer :: ptr(:,:)
2680 ihalo = ginfo(gid)%IHALO
2681 jhalo = ginfo(gid)%JHALO
2685 call mpi_win_start( group_packwe, 0, ginfo(gid)%win_packWE(vid), ierr )
2686 call mpi_win_start( group_packns, 0, ginfo(gid)%win_packNS(vid), ierr )
2690 call packwe_3d( ka, ia, is, ie, ja, js, je, &
2698 if ( prc_has_n )
then
2700 call mpi_put( var(:,:,je-jhalo+1:je), ginfo(gid)%size2D_NS4*ka, comm_datatype_t, &
2701 prc_next(prc_n), disp, ginfo(gid)%size2D_NS4*ka, comm_datatype_t, &
2702 ginfo(gid)%win_packNS(vid), ierr )
2705 if ( prc_has_s )
then
2706 disp = ka * ia * jhalo
2707 call mpi_put( var(:,:,js:js+jhalo-1), ginfo(gid)%size2D_NS4*ka, comm_datatype_t, &
2708 prc_next(prc_s), disp, ginfo(gid)%size2D_NS4*ka, comm_datatype_t, &
2709 ginfo(gid)%win_packNS(vid), ierr )
2716 ptr => ginfo(gid)%sendpack_P2WE(:,:,vid)
2722 if ( prc_has_w )
then
2725 call mpi_put( ptr(:,1), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2727 call mpi_put( ginfo(gid)%sendpack_P2WE(:,1,vid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2729 prc_next(prc_w), disp, ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2730 ginfo(gid)%win_packWE(vid), ierr )
2733 if ( prc_has_e )
then
2736 call mpi_put( ptr(:,2), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2738 call mpi_put( ginfo(gid)%sendpack_P2WE(:,2,vid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2740 prc_next(prc_e), disp, ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2741 ginfo(gid)%win_packWE(vid), ierr )
2747 call mpi_win_complete( ginfo(gid)%win_packWE(vid), ierr )
2748 call mpi_win_complete( ginfo(gid)%win_packNS(vid), ierr )
2762 real(RP),
intent(inout) :: var(:,:,:)
2763 integer,
intent(in) :: gid
2764 integer,
intent(in) :: vid
2766 integer :: ireq, tag, tagc
2769 integer :: IA, IS, IE
2770 integer :: JA, JS, JE
2771 integer :: IHALO, JHALO
2776 real(RP),
pointer :: ptr(:,:)
2777 logical :: flag_device
2781 tag = ( (gid - 1) * comm_vsize_max + vid ) * 100
2792 ihalo = ginfo(gid)%IHALO
2793 jhalo = ginfo(gid)%JHALO
2796 if ( ginfo(gid)%use_packbuf(vid) )
then
2797 log_error(
"vars8_3D_mpi",*)
'packing buffer is already used', vid
2800 ginfo(gid)%use_packbuf(vid) = .true.
2804 flag_device = acc_is_present(var)
2807 if ( comm_isallperiodic )
then
2816 call mpi_irecv( var(1,ie+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2817 prc_next(prc_se), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2824 call mpi_irecv( var(1,1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2825 prc_next(prc_sw), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2832 call mpi_irecv( var(1,ie+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2833 prc_next(prc_ne), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2840 call mpi_irecv( var(1,1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2841 prc_next(prc_nw), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2846 ptr => ginfo(gid)%recvpack_WE2P(:,:,vid)
2852 call mpi_irecv( ptr(:,2), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2854 call mpi_irecv( ginfo(gid)%recvpack_WE2P(:,2,vid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2856 prc_next(prc_e), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2861 call mpi_irecv( ptr(:,1), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2863 call mpi_irecv( ginfo(gid)%recvpack_WE2P(:,1,vid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2865 prc_next(prc_w), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2872 call mpi_irecv( var(1,is,j), ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
2873 prc_next(prc_s), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2880 call mpi_irecv( var(1,is,j), ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
2881 prc_next(prc_n), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2889 do j = je-jhalo+1, je
2890 call mpi_isend( var(1,is,j), ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
2891 prc_next(prc_n), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2897 do j = js, js+jhalo-1
2898 call mpi_isend( var(1,is,j), ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
2899 prc_next(prc_s), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2908 call packwe_3d( ka, ia, is, ie, ja, js, je, &
2916 do j = je-jhalo+1, je
2917 call mpi_isend( var(1,is,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2918 prc_next(prc_nw), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2924 do j = je-jhalo+1, je
2925 call mpi_isend( var(1,ie-ihalo+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2926 prc_next(prc_ne), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2932 do j = js, js+jhalo-1
2933 call mpi_isend( var(1,is,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2934 prc_next(prc_sw), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2940 do j = js, js+jhalo-1
2941 call mpi_isend( var(1,ie-ihalo+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2942 prc_next(prc_se), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2950 ptr => ginfo(gid)%sendpack_P2WE(:,:,vid)
2957 call mpi_isend( ptr(:,1), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2959 call mpi_isend( ginfo(gid)%sendpack_P2WE(:,1,vid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2961 prc_next(prc_w), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2966 call mpi_isend( ptr(:,2), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2968 call mpi_isend( ginfo(gid)%sendpack_P2WE(:,2,vid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
2970 prc_next(prc_e), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2983 if ( prc_has_s .AND. prc_has_e )
then
2986 call mpi_irecv( var(1,ie+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2987 prc_next(prc_se), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2991 else if ( prc_has_s )
then
2994 call mpi_irecv( var(1,ie+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
2995 prc_next(prc_s), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
2999 else if ( prc_has_e )
then
3002 call mpi_irecv( var(1,ie+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3003 prc_next(prc_e), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3009 if ( prc_has_s .AND. prc_has_w )
then
3012 call mpi_irecv( var(1,1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3013 prc_next(prc_sw), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3017 else if ( prc_has_s )
then
3020 call mpi_irecv( var(1,1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3021 prc_next(prc_s), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3025 else if ( prc_has_w )
then
3028 call mpi_irecv( var(1,1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3029 prc_next(prc_w), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3035 if ( prc_has_n .AND. prc_has_e )
then
3038 call mpi_irecv( var(1,ie+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3039 prc_next(prc_ne), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3043 else if ( prc_has_n )
then
3046 call mpi_irecv( var(1,ie+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3047 prc_next(prc_n), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3051 else if ( prc_has_e )
then
3054 call mpi_irecv( var(1,ie+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3055 prc_next(prc_e), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3061 if ( prc_has_n .AND. prc_has_w )
then
3064 call mpi_irecv( var(1,1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3065 prc_next(prc_nw), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3069 else if ( prc_has_n )
then
3072 call mpi_irecv( var(1,1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3073 prc_next(prc_n), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3077 else if ( prc_has_w )
then
3080 call mpi_irecv( var(1,1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3081 prc_next(prc_w), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3087 ptr => ginfo(gid)%recvpack_WE2P(:,:,vid)
3091 if ( prc_has_e )
then
3094 call mpi_irecv( ptr(:,2), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
3096 call mpi_irecv( ginfo(gid)%recvpack_WE2P(:,2,vid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
3098 prc_next(prc_e), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3102 if ( prc_has_w )
then
3105 call mpi_irecv( ptr(:,1), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
3107 call mpi_irecv( ginfo(gid)%recvpack_WE2P(:,1,vid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
3109 prc_next(prc_w), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3115 if ( prc_has_s )
then
3118 call mpi_irecv( var(1,is,j), ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
3119 prc_next(prc_s), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3125 if ( prc_has_n )
then
3128 call mpi_irecv( var(1,is,j), ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
3129 prc_next(prc_n), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3137 if ( prc_has_n )
then
3139 do j = je-jhalo+1, je
3140 call mpi_isend( var(1,is,j), ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
3141 prc_next(prc_n), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3147 if ( prc_has_s )
then
3149 do j = js, js+jhalo-1
3150 call mpi_isend( var(1,is,j), ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
3151 prc_next(prc_s), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3161 call packwe_3d( ka, ia, is, ie, ja, js, je, &
3168 if ( prc_has_n .AND. prc_has_w )
then
3170 do j = je-jhalo+1, je
3171 call mpi_isend( var(1,is,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3172 prc_next(prc_nw), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3176 else if ( prc_has_n )
then
3178 do j = je-jhalo+1, je
3179 call mpi_isend( var(1,1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3180 prc_next(prc_n), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3184 else if ( prc_has_w )
then
3187 call mpi_isend( var(1,is,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3188 prc_next(prc_w), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3194 if ( prc_has_n .AND. prc_has_e )
then
3196 do j = je-jhalo+1, je
3197 call mpi_isend( var(1,ie-ihalo+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3198 prc_next(prc_ne), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3202 else if ( prc_has_n )
then
3204 do j = je-jhalo+1, je
3205 call mpi_isend( var(1,ie+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3206 prc_next(prc_n), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3210 else if ( prc_has_e )
then
3213 call mpi_isend( var(1,ie-ihalo+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3214 prc_next(prc_e), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3220 if ( prc_has_s .AND. prc_has_w )
then
3222 do j = js, js+jhalo-1
3223 call mpi_isend( var(1,is,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3224 prc_next(prc_sw), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3228 else if ( prc_has_s )
then
3230 do j = js, js+jhalo-1
3231 call mpi_isend( var(1,1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3232 prc_next(prc_s), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3236 else if ( prc_has_w )
then
3239 call mpi_isend( var(1,is,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3240 prc_next(prc_w), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3246 if ( prc_has_s .AND. prc_has_e )
then
3248 do j = js, js+jhalo-1
3249 call mpi_isend( var(1,ie-ihalo+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3250 prc_next(prc_se), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3254 else if ( prc_has_s )
then
3256 do j = js, js+jhalo-1
3257 call mpi_isend( var(1,ie+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3258 prc_next(prc_s), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3262 else if ( prc_has_e )
then
3265 call mpi_isend( var(1,ie-ihalo+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3266 prc_next(prc_e), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3275 ptr => ginfo(gid)%sendpack_P2WE(:,:,vid)
3281 if ( prc_has_w )
then
3284 call mpi_isend( ptr(:,1), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
3286 call mpi_isend( ginfo(gid)%sendpack_P2WE(:,1,vid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
3288 prc_next(prc_w), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3292 if ( prc_has_e )
then
3295 call mpi_isend( ptr(:,2), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
3297 call mpi_isend( ginfo(gid)%sendpack_P2WE(:,2,vid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
3299 prc_next(prc_e), tag+tagc, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3308 ginfo(gid)%req_cnt(vid) = ireq - 1
3318 real(RP),
intent(inout) :: var(:,:,:)
3319 integer,
intent(in) :: gid
3320 integer,
intent(in) :: vid
3323 integer :: IA, IS, IE
3324 integer :: JA, JS, JE
3325 integer :: IHALO, JHALO
3327 integer(kind=MPI_ADDRESS_KIND) :: disp
3332 real(RP),
pointer :: ptr(:,:)
3343 ihalo = ginfo(gid)%IHALO
3344 jhalo = ginfo(gid)%JHALO
3347 call mpi_win_start( group_packwe, 0, ginfo(gid)%win_packWE(vid), ierr )
3348 call mpi_win_start( group_packns, 0, ginfo(gid)%win_packNS(vid), ierr )
3350 if ( comm_isallperiodic )
then
3356 do j = je-jhalo+1, je
3357 disp = ka * ( ihalo + ia * ( j - je+jhalo-1 ) )
3358 call mpi_put( var(1,is,j), ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
3359 prc_next(prc_n), disp, ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
3360 ginfo(gid)%win_packNS(vid), ierr )
3363 do j = js, js+jhalo-1
3364 disp = ka * ( ihalo + ia * ( j - js + jhalo ) )
3365 call mpi_put( var(1,is,j), ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
3366 prc_next(prc_s), disp, ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
3367 ginfo(gid)%win_packNS(vid), ierr )
3374 call packwe_3d( ka, ia, is, ie, ja, js, je, &
3380 do j = je-jhalo+1, je
3381 disp = ka * ( ie + ia * ( j - je+jhalo-1 ) )
3382 call mpi_put( var(1,is,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3383 prc_next(prc_nw), disp, ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3384 ginfo(gid)%win_packNS(vid), ierr )
3387 do j = je-jhalo+1, je
3388 disp = ka * ( ia * ( j - je+jhalo-1 ) )
3389 call mpi_put( var(1,ie-ihalo+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3390 prc_next(prc_ne), disp, ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3391 ginfo(gid)%win_packNS(vid), ierr )
3394 do j = js, js+jhalo-1
3395 disp = ka * ( ie + ia * ( j - js + jhalo ) )
3396 call mpi_put( var(1,is,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3397 prc_next(prc_sw), disp, ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3398 ginfo(gid)%win_packNS(vid), ierr )
3401 do j = js, js+jhalo-1
3402 disp = ka * ( ia * ( j - js + jhalo ) )
3403 call mpi_put( var(1,ie-ihalo+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3404 prc_next(prc_se), disp, ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3405 ginfo(gid)%win_packNS(vid), ierr )
3411 ptr => ginfo(gid)%sendpack_P2WE(:,:,vid)
3418 call mpi_put( ptr(:,1), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
3420 call mpi_put( ginfo(gid)%sendpack_P2WE(:,1,vid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
3422 prc_next(prc_w), disp, ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
3423 ginfo(gid)%win_packWE(vid), ierr )
3427 call mpi_put( ptr(:,2), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
3429 call mpi_put( ginfo(gid)%sendpack_P2WE(:,2,vid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
3431 prc_next(prc_e), disp, ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
3432 ginfo(gid)%win_packWE(vid), ierr )
3443 if ( prc_has_n )
then
3444 do j = je-jhalo+1, je
3445 disp = ka * ( ihalo + ia * ( j - je+jhalo-1 ) )
3446 call mpi_put( var(1,is,j), ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
3447 prc_next(prc_n), disp, ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
3448 ginfo(gid)%win_packNS(vid), ierr )
3452 if ( prc_has_s )
then
3453 do j = js, js+jhalo-1
3454 disp = ka * ( ihalo + ia * ( j - js + jhalo ) )
3455 call mpi_put( var(1,is,j), ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
3456 prc_next(prc_s), disp, ginfo(gid)%size2D_NS8*ka, comm_datatype_t, &
3457 ginfo(gid)%win_packNS(vid), ierr )
3465 call packwe_3d( ka, ia, is, ie, ja, js, je, &
3472 if ( prc_has_n .AND. prc_has_w )
then
3473 do j = je-jhalo+1, je
3474 disp = ka * ( ie + ia * ( j - je+jhalo-1 ) )
3475 call mpi_put( var(1,is,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3476 prc_next(prc_nw), disp, ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3477 ginfo(gid)%win_packNS(vid), ierr )
3479 else if ( prc_has_n )
then
3480 do j = je-jhalo+1, je
3481 disp = ka * ( ia * ( j - je+jhalo-1 ) )
3482 call mpi_put( var(1,1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3483 prc_next(prc_n), disp, ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3484 ginfo(gid)%win_packNS(vid), ierr )
3486 else if ( prc_has_w )
then
3488 disp = ka * ( ie + ia * ( j - je-1 + jhalo ) )
3489 call mpi_put( var(1,is,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3490 prc_next(prc_w), disp, ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3491 ginfo(gid)%win_packNS(vid), ierr )
3495 if ( prc_has_n .AND. prc_has_e )
then
3496 do j = je-jhalo+1, je
3497 disp = ka * ( ia * ( j - je+jhalo-1 ) )
3498 call mpi_put( var(1,ie-ihalo+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3499 prc_next(prc_ne), disp, ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3500 ginfo(gid)%win_packNS(vid), ierr )
3502 else if ( prc_has_n )
then
3503 do j = je-jhalo+1, je
3504 disp = ka * ( ie + ia * ( j - je+jhalo-1 ) )
3505 call mpi_put( var(1,ie+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3506 prc_next(prc_n), disp, ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3507 ginfo(gid)%win_packNS(vid), ierr )
3509 else if ( prc_has_e )
then
3511 disp = ka * ia * ( j - je-1 + jhalo )
3512 call mpi_put( var(1,ie-ihalo+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3513 prc_next(prc_e), disp, ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3514 ginfo(gid)%win_packNS(vid), ierr )
3518 if ( prc_has_s .AND. prc_has_w )
then
3519 do j = js, js+jhalo-1
3520 disp = ka * ( ie + ia * ( j - js + jhalo ) )
3521 call mpi_put( var(1,is,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3522 prc_next(prc_sw), disp, ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3523 ginfo(gid)%win_packNS(vid), ierr )
3525 else if ( prc_has_s )
then
3526 do j = js, js+jhalo-1
3527 disp = ka * ( ia * ( j - js + jhalo ) )
3528 call mpi_put( var(1,1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3529 prc_next(prc_s), disp, ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3530 ginfo(gid)%win_packNS(vid), ierr )
3532 else if ( prc_has_w )
then
3534 disp = ka * ( ie + ia * (j-1) )
3535 call mpi_put( var(1,is,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3536 prc_next(prc_w), disp, ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3537 ginfo(gid)%win_packNS(vid), ierr )
3541 if ( prc_has_s .AND. prc_has_e )
then
3542 do j = js, js+jhalo-1
3543 disp = ka * ( ia * ( j - js + jhalo ) )
3544 call mpi_put( var(1,ie-ihalo+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3545 prc_next(prc_se), disp, ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3546 ginfo(gid)%win_packNS(vid), ierr )
3548 else if ( prc_has_s )
then
3549 do j = js, js+jhalo-1
3550 disp = ka * ( ie + ia * ( j - js + jhalo ) )
3551 call mpi_put( var(1,ie+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3552 prc_next(prc_s), disp, ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3553 ginfo(gid)%win_packNS(vid), ierr )
3555 else if ( prc_has_e )
then
3557 disp = ka * ( ia * ( j - 1 ) )
3558 call mpi_put( var(1,ie-ihalo+1,j), ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3559 prc_next(prc_e), disp, ginfo(gid)%size2D_4C*ka, comm_datatype_t, &
3560 ginfo(gid)%win_packNS(vid), ierr )
3567 ptr => ginfo(gid)%sendpack_P2WE(:,:,vid)
3573 if ( prc_has_w )
then
3576 call mpi_put( ptr(:,1), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
3578 call mpi_put( ginfo(gid)%sendpack_P2WE(:,1,vid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
3580 prc_next(prc_w), disp, ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
3581 ginfo(gid)%win_packWE(vid), ierr )
3584 if ( prc_has_e )
then
3587 call mpi_put( ptr(:,2), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
3589 call mpi_put( ginfo(gid)%sendpack_P2WE(:,2,vid), ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
3591 prc_next(prc_e), disp, ginfo(gid)%size2D_WE*ka, comm_datatype_t, &
3592 ginfo(gid)%win_packWE(vid), ierr )
3600 call mpi_win_complete( ginfo(gid)%win_packWE(vid), ierr )
3601 call mpi_win_complete( ginfo(gid)%win_packNS(vid), ierr )
3615 real(RP),
intent(inout) :: var(:,:)
3616 integer,
intent(in) :: gid
3617 integer,
intent(in) :: vid
3619 integer :: IA, IS, IE
3620 integer :: JA, JS, JE
3621 integer :: IHALO, JHALO
3623 integer :: ireq, tag
3626 real(RP),
pointer :: ptr(:,:)
3627 logical :: flag_device
3637 ihalo = ginfo(gid)%IHALO
3638 jhalo = ginfo(gid)%JHALO
3640 tag = ( (gid - 1) * comm_vsize_max + vid ) * 100
3644 if ( ginfo(gid)%use_packbuf(vid) )
then
3645 log_error(
"vars_2D_mpi",*)
'packing buffer is already used', vid
3648 ginfo(gid)%use_packbuf(vid) = .true.
3652 flag_device = acc_is_present(var)
3659 if ( prc_has_s )
then
3660 call mpi_irecv( var(:,1:js-1), ginfo(gid)%size2D_NS4, comm_datatype_t, &
3661 prc_next(prc_s), tag+1, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3665 if ( prc_has_n )
then
3666 call mpi_irecv( var(:,je+1:ja), ginfo(gid)%size2D_NS4, comm_datatype_t, &
3667 prc_next(prc_n), tag+2, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3673 ptr => ginfo(gid)%recvpack_WE2P(:,:,vid)
3677 if ( prc_has_e )
then
3679 call mpi_irecv( ptr(:,2), ginfo(gid)%size2D_WE, comm_datatype_t, &
3681 call mpi_irecv( ginfo(gid)%recvpack_WE2P(:,2,vid), ginfo(gid)%size2D_WE, comm_datatype_t, &
3683 prc_next(prc_e), tag+3, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3687 if ( prc_has_w )
then
3689 call mpi_irecv( ptr(:,1), ginfo(gid)%size2D_WE, comm_datatype_t, &
3691 call mpi_irecv( ginfo(gid)%recvpack_WE2P(:,1,vid), ginfo(gid)%size2D_WE, comm_datatype_t, &
3693 prc_next(prc_w), tag+4, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3704 call packwe_2d( ia, is, ie, ja, js, je, &
3709 ptr => ginfo(gid)%sendpack_P2WE(:,:,vid)
3714 if ( prc_has_w )
then
3716 call mpi_isend( ptr(:,1), ginfo(gid)%size2D_WE, comm_datatype_t, &
3718 call mpi_isend( ginfo(gid)%sendpack_P2WE(:,1,vid), ginfo(gid)%size2D_WE, comm_datatype_t, &
3720 prc_next(prc_w), tag+3, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3724 if ( prc_has_e )
then
3726 call mpi_isend( ptr(:,2), ginfo(gid)%size2D_WE, comm_datatype_t, &
3728 call mpi_isend( ginfo(gid)%sendpack_P2WE(:,2,vid), ginfo(gid)%size2D_WE, comm_datatype_t, &
3730 prc_next(prc_e), tag+4, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3741 if ( prc_has_n )
then
3742 call mpi_isend( var(:,je-jhalo+1:je), ginfo(gid)%size2D_NS4, comm_datatype_t, &
3743 prc_next(prc_n), tag+1, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3747 if ( prc_has_s )
then
3748 call mpi_isend( var(:,js:js+jhalo-1), ginfo(gid)%size2D_NS4, comm_datatype_t, &
3749 prc_next(prc_s), tag+2, comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3755 ginfo(gid)%req_cnt(vid) = ireq - 1
3765 real(RP),
intent(inout) :: var(:,:)
3766 integer,
intent(in) :: gid
3767 integer,
intent(in) :: vid
3769 integer :: IA, IS, IE
3770 integer :: JA, JS, JE
3771 integer :: IHALO, JHALO
3773 integer(kind=MPI_ADDRESS_KIND) :: disp
3777 real(RP),
pointer :: ptr(:,:)
3787 ihalo = ginfo(gid)%IHALO
3788 jhalo = ginfo(gid)%JHALO
3792 call mpi_win_start( group_packwe, 0, ginfo(gid)%win_packWE(vid), ierr )
3793 call mpi_win_start( group_packns, 0, ginfo(gid)%win_packNS(vid), ierr )
3799 call packwe_2d( ia, is, ie, ja, js, je, &
3804 ptr => ginfo(gid)%sendpack_P2WE(:,:,vid)
3809 if ( prc_has_w )
then
3812 call mpi_put( ptr(:,1), ginfo(gid)%size2D_WE, comm_datatype_t, &
3814 call mpi_put( ginfo(gid)%sendpack_P2WE(:,1,vid), ginfo(gid)%size2D_WE, comm_datatype_t, &
3816 prc_next(prc_w), disp, ginfo(gid)%size2D_WE, comm_datatype_t, &
3817 ginfo(gid)%win_packWE(vid), ierr )
3820 if ( prc_has_e )
then
3823 call mpi_put( ptr(:,2), ginfo(gid)%size2D_WE, comm_datatype_t, &
3825 call mpi_put( ginfo(gid)%sendpack_P2WE(:,2,vid), ginfo(gid)%size2D_WE, comm_datatype_t, &
3827 prc_next(prc_e), disp, ginfo(gid)%size2D_WE, comm_datatype_t, &
3828 ginfo(gid)%win_packWE(vid), ierr )
3838 if ( prc_has_n )
then
3840 call mpi_put( var(:,je-jhalo+1:je), ginfo(gid)%size2D_NS4, comm_datatype_t, &
3841 prc_next(prc_n), disp, ginfo(gid)%size2D_NS4, comm_datatype_t, &
3842 ginfo(gid)%win_packNS(vid), ierr )
3845 if ( prc_has_s )
then
3847 call mpi_put( var(:,js:js+jhalo-1), ginfo(gid)%size2D_NS4, comm_datatype_t, &
3848 prc_next(prc_s), disp, ginfo(gid)%size2D_NS4, comm_datatype_t, &
3849 ginfo(gid)%win_packNS(vid), ierr )
3854 call mpi_win_complete( ginfo(gid)%win_packWE(vid), ierr )
3855 call mpi_win_complete( ginfo(gid)%win_packNS(vid), ierr )
3869 real(RP),
intent(inout) :: var(:,:)
3870 integer,
intent(in) :: gid
3871 integer,
intent(in) :: vid
3873 integer :: IA, IS, IE
3874 integer :: JA, JS, JE
3875 integer :: IHALO, JHALO
3877 integer :: ireq, tag, tagc
3882 real(RP),
pointer :: ptr(:,:)
3883 logical :: flag_device
3893 ihalo = ginfo(gid)%IHALO
3894 jhalo = ginfo(gid)%JHALO
3896 tag = ( (gid - 1) * comm_vsize_max + vid ) * 100
3900 if ( ginfo(gid)%use_packbuf(vid) )
then
3901 log_error(
"vars8_2D_mpi",*)
'packing buffer is already used', vid
3904 ginfo(gid)%use_packbuf(vid) = .true.
3908 flag_device = acc_is_present(var)
3911 if ( comm_isallperiodic )
then
3920 call mpi_irecv( var(ie+1,j), ginfo(gid)%size2D_4C, &
3921 comm_datatype_t, prc_next(prc_se), tag+tagc, &
3922 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3929 call mpi_irecv( var(1,j), ginfo(gid)%size2D_4C, &
3930 comm_datatype_t, prc_next(prc_sw), tag+tagc, &
3931 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3938 call mpi_irecv( var(ie+1,j), ginfo(gid)%size2D_4C, &
3939 comm_datatype_t, prc_next(prc_ne), tag+tagc, &
3940 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3947 call mpi_irecv( var(1,j), ginfo(gid)%size2D_4C, &
3948 comm_datatype_t, prc_next(prc_nw), tag+tagc, &
3949 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3954 ptr => ginfo(gid)%recvpack_WE2P(:,:,vid)
3959 call mpi_irecv( ptr(:,2), ginfo(gid)%size2D_WE, &
3961 call mpi_irecv( ginfo(gid)%recvpack_WE2P(:,2,vid), ginfo(gid)%size2D_WE, &
3963 comm_datatype_t, prc_next(prc_e), tag+60, &
3964 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3968 call mpi_irecv( ptr(:,1), ginfo(gid)%size2D_WE, &
3970 call mpi_irecv( ginfo(gid)%recvpack_WE2P(:,1,vid), ginfo(gid)%size2D_WE, &
3972 comm_datatype_t, prc_next(prc_w), tag+70, &
3973 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3980 call mpi_irecv( var(is,j), ginfo(gid)%size2D_NS8, &
3981 comm_datatype_t, prc_next(prc_s), tag+tagc, &
3982 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
3989 call mpi_irecv( var(is,j), ginfo(gid)%size2D_NS8, &
3990 comm_datatype_t, prc_next(prc_n), tag+tagc, &
3991 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4001 do j = je-jhalo+1, je
4002 call mpi_isend( var(is,j), ginfo(gid)%size2D_NS8, &
4003 comm_datatype_t, prc_next(prc_n), tag+tagc, &
4004 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4011 do j = js, js+jhalo-1
4012 call mpi_isend( var(is,j), ginfo(gid)%size2D_NS8, &
4013 comm_datatype_t, prc_next(prc_s), tag+tagc, &
4014 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4023 call packwe_2d( ia, is, ie, ja, js, je, &
4029 ptr => ginfo(gid)%sendpack_P2WE(:,:,vid)
4035 call mpi_isend( ptr(:,1), ginfo(gid)%size2D_WE, &
4037 call mpi_isend( ginfo(gid)%sendpack_P2WE(:,1,vid), ginfo(gid)%size2D_WE, &
4039 comm_datatype_t, prc_next(prc_w), tag+60, &
4040 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4045 call mpi_isend( ptr(:,2), ginfo(gid)%size2D_WE, &
4047 call mpi_isend( ginfo(gid)%sendpack_P2WE(:,2,vid), ginfo(gid)%size2D_WE, &
4049 comm_datatype_t, prc_next(prc_e), tag+70, &
4050 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4056 do j = je-jhalo+1, je
4057 call mpi_isend( var(is,j), ginfo(gid)%size2D_4C, &
4058 comm_datatype_t, prc_next(prc_nw), tag+tagc, &
4059 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4066 do j = je-jhalo+1, je
4067 call mpi_isend( var(ie-ihalo+1,j), ginfo(gid)%size2D_4C, &
4068 comm_datatype_t, prc_next(prc_ne), tag+tagc, &
4069 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4076 do j = js, js+jhalo-1
4077 call mpi_isend( var(is,j), ginfo(gid)%size2D_4C, &
4078 comm_datatype_t, prc_next(prc_sw), tag+tagc, &
4079 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4086 do j = js, js+jhalo-1
4087 call mpi_isend( var(ie-ihalo+1,j), ginfo(gid)%size2D_4C, &
4088 comm_datatype_t, prc_next(prc_se), tag+tagc, &
4089 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4106 if ( prc_has_s .AND. prc_has_e )
then
4109 call mpi_irecv( var(ie+1,j), ginfo(gid)%size2D_4C, &
4110 comm_datatype_t, prc_next(prc_se), tag+tagc, &
4111 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4115 else if ( prc_has_s )
then
4118 call mpi_irecv( var(ie+1,j), ginfo(gid)%size2D_4C, &
4119 comm_datatype_t, prc_next(prc_s), tag+tagc, &
4120 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4124 else if ( prc_has_e )
then
4127 call mpi_irecv( var(ie+1,j), ginfo(gid)%size2D_4C, &
4128 comm_datatype_t, prc_next(prc_e), tag+tagc, &
4129 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4136 if ( prc_has_s .AND. prc_has_w )
then
4139 call mpi_irecv( var(1,j), ginfo(gid)%size2D_4C, &
4140 comm_datatype_t, prc_next(prc_sw), tag+tagc, &
4141 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4145 else if ( prc_has_s )
then
4148 call mpi_irecv( var(1,j), ginfo(gid)%size2D_4C, &
4149 comm_datatype_t, prc_next(prc_s), tag+tagc, &
4150 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4154 else if ( prc_has_w )
then
4157 call mpi_irecv( var(1,j), ginfo(gid)%size2D_4C, &
4158 comm_datatype_t, prc_next(prc_w), tag+tagc, &
4159 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4166 if ( prc_has_n .AND. prc_has_e )
then
4168 do j = je+1, je+jhalo
4169 call mpi_irecv( var(ie+1,j), ginfo(gid)%size2D_4C, &
4170 comm_datatype_t, prc_next(prc_ne), tag+tagc, &
4171 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4175 else if ( prc_has_n )
then
4178 call mpi_irecv( var(ie+1,j), ginfo(gid)%size2D_4C, &
4179 comm_datatype_t, prc_next(prc_n), tag+tagc, &
4180 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4184 else if ( prc_has_e )
then
4187 call mpi_irecv( var(ie+1,j), ginfo(gid)%size2D_4C, &
4188 comm_datatype_t, prc_next(prc_e), tag+tagc, &
4189 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4196 if ( prc_has_n .AND. prc_has_w )
then
4199 call mpi_irecv( var(1,j), ginfo(gid)%size2D_4C, &
4200 comm_datatype_t, prc_next(prc_nw), tag+tagc, &
4201 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4205 else if ( prc_has_n )
then
4208 call mpi_irecv( var(1,j), ginfo(gid)%size2D_4C, &
4209 comm_datatype_t, prc_next(prc_n), tag+tagc, &
4210 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4214 else if ( prc_has_w )
then
4217 call mpi_irecv( var(1,j), ginfo(gid)%size2D_4C, &
4218 comm_datatype_t, prc_next(prc_w), tag+tagc, &
4219 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4226 ptr => ginfo(gid)%recvpack_WE2P(:,:,vid)
4230 if ( prc_has_e )
then
4232 call mpi_irecv( ptr(:,2), ginfo(gid)%size2D_WE, &
4234 call mpi_irecv( ginfo(gid)%recvpack_WE2P(:,2,vid), ginfo(gid)%size2D_WE, &
4236 comm_datatype_t, prc_next(prc_e), tag+60, &
4237 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4242 if ( prc_has_w )
then
4244 call mpi_irecv( ptr(:,1), ginfo(gid)%size2D_WE, &
4246 call mpi_irecv( ginfo(gid)%recvpack_WE2P(:,1,vid), ginfo(gid)%size2D_WE, &
4248 comm_datatype_t, prc_next(prc_w), tag+70, &
4249 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4257 if ( prc_has_s )
then
4260 call mpi_irecv( var(is,j), ginfo(gid)%size2D_NS8, &
4261 comm_datatype_t, prc_next(prc_s), tag+tagc, &
4262 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4269 if ( prc_has_n )
then
4272 call mpi_irecv( var(is,j), ginfo(gid)%size2D_NS8, &
4273 comm_datatype_t, prc_next(prc_n), tag+tagc, &
4274 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4284 if ( prc_has_n )
then
4286 do j = je-jhalo+1, je
4287 call mpi_isend( var(is,j), ginfo(gid)%size2D_NS8, &
4288 comm_datatype_t, prc_next(prc_n), tag+tagc, &
4289 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4296 if ( prc_has_s )
then
4298 do j = js, js+jhalo-1
4299 call mpi_isend( var(is,j), ginfo(gid)%size2D_NS8, &
4300 comm_datatype_t, prc_next(prc_s), tag+tagc, &
4301 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4311 call packwe_2d( ia, is, ie, ja, js, je, &
4317 ptr => ginfo(gid)%sendpack_P2WE(:,:,vid)
4322 if ( prc_has_w )
then
4324 call mpi_isend( ptr(:,1), ginfo(gid)%size2D_WE, &
4326 call mpi_isend( ginfo(gid)%sendpack_P2WE(:,1,vid), ginfo(gid)%size2D_WE, &
4328 comm_datatype_t, prc_next(prc_w), tag+60, &
4329 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4334 if ( prc_has_e )
then
4336 call mpi_isend( ptr(:,2), ginfo(gid)%size2D_WE, &
4338 call mpi_isend( ginfo(gid)%sendpack_P2WE(:,2,vid), ginfo(gid)%size2D_WE, &
4340 comm_datatype_t, prc_next(prc_e), tag+70, &
4341 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4347 if ( prc_has_n .AND. prc_has_w )
then
4349 do j = je-jhalo+1, je
4350 call mpi_isend( var(is,j), ginfo(gid)%size2D_4C, &
4351 comm_datatype_t, prc_next(prc_nw), tag+tagc, &
4352 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4356 else if ( prc_has_n )
then
4358 do j = je-jhalo+1, je
4359 call mpi_isend( var(1,j), ginfo(gid)%size2D_4C, &
4360 comm_datatype_t, prc_next(prc_n), tag+tagc, &
4361 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4365 else if ( prc_has_w )
then
4368 call mpi_isend( var(is,j), ginfo(gid)%size2D_4C, &
4369 comm_datatype_t, prc_next(prc_w), tag+tagc, &
4370 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4377 if ( prc_has_n .AND. prc_has_e )
then
4379 do j = je-jhalo+1, je
4380 call mpi_isend( var(ie-ihalo+1,j), ginfo(gid)%size2D_4C, &
4381 comm_datatype_t, prc_next(prc_ne), tag+tagc, &
4382 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4386 else if ( prc_has_n )
then
4388 do j = je-jhalo+1, je
4389 call mpi_isend( var(ie+1,j), ginfo(gid)%size2D_4C, &
4390 comm_datatype_t, prc_next(prc_n), tag+tagc, &
4391 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4395 else if ( prc_has_e )
then
4398 call mpi_isend( var(ie-ihalo+1,j), ginfo(gid)%size2D_4C, &
4399 comm_datatype_t, prc_next(prc_e), tag+tagc, &
4400 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4407 if ( prc_has_s .AND. prc_has_w )
then
4409 do j = js, js+jhalo-1
4410 call mpi_isend( var(is,j), ginfo(gid)%size2D_4C, &
4411 comm_datatype_t, prc_next(prc_sw), tag+tagc, &
4412 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4416 else if ( prc_has_s )
then
4418 do j = js, js+jhalo-1
4419 call mpi_isend( var(1,j), ginfo(gid)%size2D_4C, &
4420 comm_datatype_t, prc_next(prc_s), tag+tagc, &
4421 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4425 else if ( prc_has_w )
then
4428 call mpi_isend( var(is,j), ginfo(gid)%size2D_4C, &
4429 comm_datatype_t, prc_next(prc_w), tag+tagc, &
4430 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4437 if ( prc_has_s .AND. prc_has_e )
then
4439 do j = js, js+jhalo-1
4440 call mpi_isend( var(ie-ihalo+1,j), ginfo(gid)%size2D_4C, &
4441 comm_datatype_t, prc_next(prc_se), tag+tagc, &
4442 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4446 else if ( prc_has_s )
then
4448 do j = js, js+jhalo-1
4449 call mpi_isend( var(ie+1,j), ginfo(gid)%size2D_4C, &
4450 comm_datatype_t, prc_next(prc_s), tag+tagc, &
4451 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4455 else if ( prc_has_e )
then
4458 call mpi_isend( var(ie-ihalo+1,j), ginfo(gid)%size2D_4C, &
4459 comm_datatype_t, prc_next(prc_e), tag+tagc, &
4460 comm_world_t, ginfo(gid)%req_list(ireq,vid), ierr )
4472 ginfo(gid)%req_cnt(vid) = ireq - 1
4482 real(RP),
intent(inout) :: var(:,:)
4483 integer,
intent(in) :: gid
4484 integer,
intent(in) :: vid
4486 integer :: IA, IS, IE, IHALO
4487 integer :: JA, JS, JE, JHALO
4489 integer(kind=MPI_ADDRESS_KIND) :: disp
4494 real(RP),
pointer :: ptr(:,:)
4501 ihalo = ginfo(gid)%IHALO
4505 jhalo = ginfo(gid)%JHALO
4509 call mpi_win_start( group_packwe, 0, ginfo(gid)%win_packWE(vid), ierr )
4510 call mpi_win_start( group_packns, 0, ginfo(gid)%win_packNS(vid), ierr )
4512 if ( comm_isallperiodic )
then
4520 do j = je-jhalo+1, je
4521 disp = ihalo + ia * ( j - je+jhalo-1 )
4522 call mpi_put( var(is,j), ginfo(gid)%size2D_NS8, comm_datatype_t, &
4523 prc_next(prc_n), disp, ginfo(gid)%size2D_NS8, comm_datatype_t, &
4524 ginfo(gid)%win_packNS(vid), ierr )
4527 do j = js, js+jhalo-1
4528 disp = ihalo + ia * ( j - js + jhalo )
4529 call mpi_put( var(is,j), ginfo(gid)%size2D_NS8, comm_datatype_t, &
4530 prc_next(prc_s), disp, ginfo(gid)%size2D_NS8, comm_datatype_t, &
4531 ginfo(gid)%win_packNS(vid), ierr )
4538 call packwe_2d( ia, is, ie, ja, js, je, &
4544 ptr => ginfo(gid)%sendpack_P2WE(:,:,vid)
4551 call mpi_put( ptr(:,1), ginfo(gid)%size2D_WE, comm_datatype_t, &
4553 call mpi_put( ginfo(gid)%sendpack_P2WE(:,1,vid), ginfo(gid)%size2D_WE, comm_datatype_t, &
4555 prc_next(prc_w), disp, ginfo(gid)%size2D_WE, comm_datatype_t, &
4556 ginfo(gid)%win_packWE(vid), ierr )
4560 call mpi_put( ptr(:,2), ginfo(gid)%size2D_WE, comm_datatype_t, &
4562 call mpi_put( ginfo(gid)%sendpack_P2WE(:,2,vid), ginfo(gid)%size2D_WE, comm_datatype_t, &
4564 prc_next(prc_e), disp, ginfo(gid)%size2D_WE, comm_datatype_t, &
4565 ginfo(gid)%win_packWE(vid), ierr )
4568 do j = je-jhalo+1, je
4569 disp = ie + ia * ( j - je+jhalo-1 )
4570 call mpi_put( var(is,j), ginfo(gid)%size2D_4C, comm_datatype_t, &
4571 prc_next(prc_nw), disp, ginfo(gid)%size2D_4C, comm_datatype_t, &
4572 ginfo(gid)%win_packNS(vid), ierr )
4575 do j = je-jhalo+1, je
4576 disp = ia * ( j - je+jhalo-1 )
4577 call mpi_put( var(ie-ihalo+1,j), ginfo(gid)%size2D_4C, comm_datatype_t, &
4578 prc_next(prc_ne), disp, ginfo(gid)%size2D_4C, comm_datatype_t, &
4579 ginfo(gid)%win_packNS(vid), ierr )
4582 do j = js, js+jhalo-1
4583 disp = ie + ia * ( j - js + jhalo )
4584 call mpi_put( var(is,j), ginfo(gid)%size2D_4C, comm_datatype_t, &
4585 prc_next(prc_sw), disp, ginfo(gid)%size2D_4C, comm_datatype_t, &
4586 ginfo(gid)%win_packNS(vid), ierr )
4589 do j = js, js+jhalo-1
4590 disp = ia * ( j - js + jhalo )
4591 call mpi_put( var(ie-ihalo+1,j), ginfo(gid)%size2D_4C, comm_datatype_t, &
4592 prc_next(prc_se), disp, ginfo(gid)%size2D_4C, comm_datatype_t, &
4593 ginfo(gid)%win_packNS(vid), ierr )
4605 if ( prc_has_n )
then
4606 do j = je-jhalo+1, je
4607 disp = ihalo + ia * ( j - je+jhalo-1 )
4608 call mpi_put( var(is,j), ginfo(gid)%size2D_NS8, comm_datatype_t, &
4609 prc_next(prc_n), disp, ginfo(gid)%size2D_NS8, comm_datatype_t, &
4610 ginfo(gid)%win_packNS(vid), ierr )
4614 if ( prc_has_s )
then
4615 do j = js, js+jhalo-1
4616 disp = ihalo + ia * ( j - js + jhalo )
4617 call mpi_put( var(is,j), ginfo(gid)%size2D_NS8, comm_datatype_t, &
4618 prc_next(prc_s), disp, ginfo(gid)%size2D_NS8, comm_datatype_t, &
4619 ginfo(gid)%win_packNS(vid), ierr )
4627 call packwe_2d( ia, is, ie, ja, js, je, &
4633 ptr => ginfo(gid)%sendpack_P2WE(:,:,vid)
4638 if ( prc_has_w )
then
4641 call mpi_put( ptr(:,1), ginfo(gid)%size2D_WE, comm_datatype_t, &
4643 call mpi_put( ginfo(gid)%sendpack_P2WE(:,1,vid), ginfo(gid)%size2D_WE, comm_datatype_t, &
4645 prc_next(prc_w), disp, ginfo(gid)%size2D_WE, comm_datatype_t, &
4646 ginfo(gid)%win_packWE(vid), ierr )
4649 if ( prc_has_e )
then
4652 call mpi_put( ptr(:,2), ginfo(gid)%size2D_WE, comm_datatype_t, &
4654 call mpi_put( ginfo(gid)%sendpack_P2WE(:,2,vid), ginfo(gid)%size2D_WE, comm_datatype_t, &
4656 prc_next(prc_e), disp, ginfo(gid)%size2D_WE, comm_datatype_t, &
4657 ginfo(gid)%win_packWE(vid), ierr )
4661 if ( prc_has_n .AND. prc_has_w )
then
4662 do j = je-jhalo+1, je
4663 disp = ie + ia * ( j - je+jhalo-1 )
4664 call mpi_put( var(is,j), ginfo(gid)%size2D_4C, comm_datatype_t, &
4665 prc_next(prc_nw), disp, ginfo(gid)%size2D_4C, comm_datatype_t, &
4666 ginfo(gid)%win_packNS(vid), ierr )
4668 else if ( prc_has_n )
then
4669 do j = je-jhalo+1, je
4670 disp = ia * ( j - je+jhalo-1 )
4671 call mpi_put( var(1,j), ginfo(gid)%size2D_4C, comm_datatype_t, &
4672 prc_next(prc_n), disp, ginfo(gid)%size2D_4C, comm_datatype_t, &
4673 ginfo(gid)%win_packNS(vid), ierr )
4675 else if ( prc_has_w )
then
4677 disp = ie + ia * ( j - je-1 + jhalo )
4678 call mpi_put( var(is,j), ginfo(gid)%size2D_4C, comm_datatype_t, &
4679 prc_next(prc_w), disp, ginfo(gid)%size2D_4C, comm_datatype_t, &
4680 ginfo(gid)%win_packNS(vid), ierr )
4684 if ( prc_has_n .AND. prc_has_e )
then
4685 do j = je-jhalo+1, je
4686 disp = ia * ( j - je+jhalo-1 )
4687 call mpi_put( var(ie-ihalo+1,j), ginfo(gid)%size2D_4C, comm_datatype_t, &
4688 prc_next(prc_ne), disp, ginfo(gid)%size2D_4C, comm_datatype_t, &
4689 ginfo(gid)%win_packNS(vid), ierr )
4691 else if ( prc_has_n )
then
4692 do j = je-jhalo+1, je
4693 disp = ie + ia * ( j - je+jhalo-1 )
4694 call mpi_put( var(ie+1,j), ginfo(gid)%size2D_4C, comm_datatype_t, &
4695 prc_next(prc_n), disp, ginfo(gid)%size2D_4C, comm_datatype_t, &
4696 ginfo(gid)%win_packNS(vid), ierr )
4698 else if ( prc_has_e )
then
4700 disp = ia * ( j - je-1 + jhalo )
4701 call mpi_put( var(ie-ihalo+1,j), ginfo(gid)%size2D_4C, comm_datatype_t, &
4702 prc_next(prc_e), disp, ginfo(gid)%size2D_4C, comm_datatype_t, &
4703 ginfo(gid)%win_packNS(vid), ierr )
4707 if ( prc_has_s .AND. prc_has_w )
then
4708 do j = js, js+jhalo-1
4709 disp = ie + ia * ( j - js + jhalo )
4710 call mpi_put( var(is,j), ginfo(gid)%size2D_4C, comm_datatype_t, &
4711 prc_next(prc_sw), disp, ginfo(gid)%size2D_4C, comm_datatype_t, &
4712 ginfo(gid)%win_packNS(vid), ierr )
4714 else if ( prc_has_s )
then
4715 do j = js, js+jhalo-1
4716 disp = ia * ( j - js + jhalo )
4717 call mpi_put( var(1,j), ginfo(gid)%size2D_4C, comm_datatype_t, &
4718 prc_next(prc_s), disp, ginfo(gid)%size2D_4C, comm_datatype_t, &
4719 ginfo(gid)%win_packNS(vid), ierr )
4721 else if ( prc_has_w )
then
4723 disp = ie + ia * ( j - 1 )
4724 call mpi_put( var(is,j), ginfo(gid)%size2D_4C, comm_datatype_t, &
4725 prc_next(prc_w), disp, ginfo(gid)%size2D_4C, comm_datatype_t, &
4726 ginfo(gid)%win_packNS(vid), ierr )
4730 if ( prc_has_s .AND. prc_has_e )
then
4731 do j = js, js+jhalo-1
4732 disp = ia * ( j - js + jhalo )
4733 call mpi_put( var(ie-ihalo+1,j), ginfo(gid)%size2D_4C, comm_datatype_t, &
4734 prc_next(prc_se), disp, ginfo(gid)%size2D_4C, comm_datatype_t, &
4735 ginfo(gid)%win_packNS(vid), ierr )
4737 else if ( prc_has_s )
then
4738 do j = js, js+jhalo-1
4739 disp = ie + ia * ( j - js + jhalo )
4740 call mpi_put( var(ie+1,j), ginfo(gid)%size2D_4C, comm_datatype_t, &
4741 prc_next(prc_s), disp, ginfo(gid)%size2D_4C, comm_datatype_t, &
4742 ginfo(gid)%win_packNS(vid), ierr )
4744 else if ( prc_has_e )
then
4746 disp = ia * ( j - 1 )
4747 call mpi_put( var(ie-ihalo+1,j), ginfo(gid)%size2D_4C, comm_datatype_t, &
4748 prc_next(prc_e), disp, ginfo(gid)%size2D_4C, comm_datatype_t, &
4749 ginfo(gid)%win_packNS(vid), ierr )
4758 call mpi_win_complete( ginfo(gid)%win_packWE(vid), ierr )
4759 call mpi_win_complete( ginfo(gid)%win_packNS(vid), ierr )
4772 real(RP),
intent(inout) :: var(:,:,:)
4773 integer,
intent(in) :: gid
4774 integer,
intent(in) :: vid
4777 integer :: IA, IS, IE
4778 integer :: JA, JS, JE
4785 if ( ginfo(gid)%use_packbuf(ginfo(gid)%packid(vid)) )
then
4786 log_error(
"vars_3D_mpi_pc",*)
'packing buffer is already used', vid, ginfo(gid)%packid(vid)
4789 ginfo(gid)%use_packbuf(ginfo(gid)%packid(vid)) = .true.
4793 if ( ginfo(gid)%device_alloc(vid+comm_vsize_max) )
then
4806 ihalo = ginfo(gid)%IHALO
4807 call packwe_3d( ka, ia, is, ie, ja, js, je, &
4809 var, gid, ginfo(gid)%packid(vid))
4813 call mpi_startall(ginfo(gid)%preq_cnt(vid), ginfo(gid)%preq_list(1:ginfo(gid)%preq_cnt(vid),vid), ierr)
4822 real(RP),
intent(inout) :: var(:,:,:)
4823 integer,
intent(in) :: gid
4824 integer,
intent(in) :: vid
4827 integer :: IA, IS, IE
4828 integer :: JA, JS, JE
4835 call mpi_waitall( ginfo(gid)%req_cnt (vid), &
4836 ginfo(gid)%req_list(1:ginfo(gid)%req_cnt(vid),vid), &
4837 mpi_statuses_ignore, &
4847 ihalo = ginfo(gid)%IHALO
4848 call unpackwe_3d( ka, ia, is, ie, ja, js, je, &
4850 var, ginfo(gid)%recvpack_WE2P(:,:,vid) )
4855 ginfo(gid)%use_packbuf(vid) = .false.
4865 real(RP),
intent(inout) :: var(:,:,:)
4866 integer,
intent(in) :: gid
4867 integer,
intent(in) :: vid
4870 integer :: IA, IS, IE
4871 integer :: JA, JS, JE
4872 integer :: IHALO, JHALO
4874 real(RP),
pointer :: pack(:)
4886 ihalo = ginfo(gid)%IHALO
4887 jhalo = ginfo(gid)%JHALO
4889 call mpi_win_wait( ginfo(gid)%win_packWE(vid), ierr )
4891 call c_f_pointer( ginfo(gid)%recvbuf_WE(vid), pack, (/ginfo(gid)%size2D_WE*ka*2/) )
4892 call unpackwe_3d( ka, ia, is, ie, ja, js, je, &
4897 call mpi_win_wait( ginfo(gid)%win_packNS(vid), ierr )
4898 call c_f_pointer( ginfo(gid)%recvbuf_NS(vid), pack, (/ginfo(gid)%size2D_NS4*ka*2/) )
4899 call unpackns_3d( ka, ia, is, ie, ja, js, je, &
4905 call mpi_win_post( group_packwe, mpi_mode_nostore, ginfo(gid)%win_packWE(vid), ierr )
4906 call mpi_win_post( group_packns, mpi_mode_nostore, ginfo(gid)%win_packNS(vid), ierr )
4915 real(RP),
intent(inout) :: var(:,:)
4916 integer,
intent(in) :: gid
4917 integer,
intent(in) :: vid
4920 integer :: IA, IS, IE
4921 integer :: JA, JS, JE
4928 call mpi_waitall( ginfo(gid)%req_cnt(vid), &
4929 ginfo(gid)%req_list(1:ginfo(gid)%req_cnt(vid),vid), &
4930 mpi_statuses_ignore, &
4940 ihalo = ginfo(gid)%IHALO
4941 call unpackwe_2d( ka, ia, is, ie, ja, js, je, &
4943 var, ginfo(gid)%recvpack_WE2P(:,:,vid) )
4947 ginfo(gid)%use_packbuf(vid) = .false.
4957 real(RP),
intent(inout) :: var(:,:)
4958 integer,
intent(in) :: gid
4959 integer,
intent(in) :: vid
4962 integer :: IA, IS, IE
4963 integer :: JA, JS, JE
4964 integer :: IHALO, JHALO
4966 real(RP),
pointer :: pack(:)
4978 ihalo = ginfo(gid)%IHALO
4979 jhalo = ginfo(gid)%JHALO
4981 call mpi_win_wait( ginfo(gid)%win_packWE(vid), ierr )
4983 call c_f_pointer( ginfo(gid)%recvbuf_WE(vid), pack, (/ginfo(gid)%size2D_WE*ka*2/) )
4984 call unpackwe_2d( ka, ia, is, ie, ja, js, je, &
4989 call mpi_win_wait( ginfo(gid)%win_packNS(vid), ierr )
4990 call c_f_pointer( ginfo(gid)%recvbuf_NS(vid), pack, (/ginfo(gid)%size2D_NS4*ka*2/) )
4991 call unpackns_2d( ia, is, ie, ja, js, je, &
4995 call mpi_win_post( group_packwe, mpi_mode_nostore, ginfo(gid)%win_packWE(vid), ierr )
4996 call mpi_win_post( group_packns, mpi_mode_nostore, ginfo(gid)%win_packNS(vid), ierr )
5005 real(RP),
intent(inout) :: var(:,:,:)
5006 integer,
intent(in) :: gid
5007 integer,
intent(in) :: vid
5010 integer :: IA, IS, IE
5011 integer :: JA, JS, JE
5018 call mpi_waitall( ginfo(gid)%preq_cnt (vid), &
5019 ginfo(gid)%preq_list(1:ginfo(gid)%preq_cnt(vid),vid), &
5020 mpi_statuses_ignore, &
5030 ihalo = ginfo(gid)%IHALO
5031 pid = ginfo(gid)%packid(vid)
5032 call unpackwe_3d( ka, ia, is, ie, ja, js, je, &
5034 var, ginfo(gid)%recvpack_WE2P(:,:,pid) )
5039 ginfo(gid)%use_packbuf(ginfo(gid)%packid(vid)) = .false.
5043 if ( ginfo(gid)%device_alloc(vid+comm_vsize_max) )
then
5051 subroutine packwe_3d( KA, IA, IS, IE, JA, JS, JE, &
5055 integer,
intent(in) :: KA
5056 integer,
intent(in) :: IA, IS, IE
5057 integer,
intent(in) :: JA, JS, JE
5058 integer,
intent(in) :: IHALO
5059 real(RP),
intent(in) :: var(KA,IA,JA)
5060 integer,
intent(in) :: gid
5061 integer,
intent(in) :: vid
5063 integer :: k, i, j, n
5066 real(RP),
pointer :: ptr(:,:,:)
5067 ptr => ginfo(gid)%sendpack_P2WE
5072 call prof_rapstart(
'COMM_pack', 3)
5074 if ( prc_has_w )
then
5080 do i = is, is+ihalo-1
5083 n = (j-js) * ka * ihalo &
5087 ptr(n,1,vid) = var(k,i,j)
5089 ginfo(gid)%sendpack_P2WE(n,1,vid) = var(k,i,j)
5097 if ( prc_has_e )
then
5103 do i = ie-ihalo+1, ie
5106 n = (j-js) * ka * ihalo &
5107 + (i-ie+ihalo-1) * ka &
5110 ptr(n,2,vid) = var(k,i,j)
5112 ginfo(gid)%sendpack_P2WE(n,2,vid) = var(k,i,j)
5120 call prof_rapend(
'COMM_pack', 3)
5127 subroutine packwe_2d( IA, IS, IE, JA, JS, JE, &
5131 integer,
intent(in) :: IA, IS, IE
5132 integer,
intent(in) :: JA, JS, JE
5133 integer,
intent(in) :: IHALO
5134 real(RP),
intent(in) :: var(IA,JA)
5135 integer,
intent(in) :: vid
5136 integer,
intent(in) :: gid
5141 real(RP),
pointer :: ptr(:,:,:)
5142 ptr => ginfo(gid)%sendpack_P2WE
5146 call prof_rapstart(
'COMM_pack', 3)
5148 if ( prc_has_w )
then
5156 do i = is, is+ihalo-1
5157 n = (j-js) * ihalo &
5160 ptr(n,1,vid) = var(i,j)
5162 ginfo(gid)%sendpack_P2WE(n,1,vid) = var(i,j)
5169 if ( prc_has_e )
then
5176 do i = ie-ihalo+1, ie
5177 n = (j-js) * ihalo &
5178 + (i-ie+ihalo-1) + 1
5180 ptr(n,2,vid) = var(i,j)
5182 ginfo(gid)%sendpack_P2WE(n,2,vid) = var(i,j)
5191 call prof_rapend(
'COMM_pack', 3)
5196 end subroutine packwe_2d
5198 subroutine unpackwe_3d( KA, IA, IS, IE, JA, JS, JE, &
5202 integer,
intent(in) :: KA
5203 integer,
intent(in) :: IA, IS, IE
5204 integer,
intent(in) :: JA, JS, JE
5205 integer,
intent(in) :: IHALO
5206 real(RP),
intent(inout) :: var(KA,IA,JA)
5207 real(RP),
intent(in) :: buf(KA,IHALO,JS:JE,2)
5214 call prof_rapstart(
'COMM_unpack', 3)
5216 if ( prc_has_e )
then
5225 var(k,i,j) = buf(k,i-ie,j,2)
5232 if ( prc_has_w )
then
5241 var(k,i,j) = buf(k,i,j,1)
5248 call prof_rapend(
'COMM_unpack', 3)
5253 end subroutine unpackwe_3d
5255 subroutine unpackwe_2d( KA, IA, IS, IE, JA, JS, JE, &
5259 integer,
intent(in) :: KA
5260 integer,
intent(in) :: IA, IS, IE
5261 integer,
intent(in) :: JA, JS, JE
5262 integer,
intent(in) :: IHALO
5263 real(RP),
intent(inout) :: var(IA,JA)
5264 real(RP),
intent(in) :: buf(IHALO,JS:JE,KA,2)
5271 call prof_rapstart(
'COMM_unpack', 3)
5273 if( prc_has_e )
then
5278 do i = ie+1, ie+ihalo
5279 var(i,j) = buf(i-ie,j,1,2)
5285 if( prc_has_w )
then
5290 do i = is-ihalo, is-1
5291 var(i,j) = buf(i,j,1,1)
5299 call prof_rapend(
'COMM_unpack', 3)
5304 end subroutine unpackwe_2d
5306 subroutine unpackns_3d( KA, IA, IS, IE, JA, JS, JE, &
5310 integer,
intent(in) :: KA
5311 integer,
intent(in) :: IA, IS, IE
5312 integer,
intent(in) :: JA, JS, JE
5313 integer,
intent(in) :: JHALO
5314 real(RP),
intent(inout) :: var(KA,IA,JA)
5315 real(RP),
intent(in) :: buf(KA,IA,JHALO,2)
5322 call prof_rapstart(
'COMM_unpack', 3)
5324 if ( prc_has_s )
then
5331 var(k,i,j) = buf(k,i,j,1)
5337 if ( prc_has_w )
then
5344 var(k,i,j) = buf(k,i,j,1)
5350 if ( prc_has_e )
then
5357 var(k,i,j) = buf(k,i,j,1)
5365 if ( prc_has_n )
then
5372 var(k,i,j) = buf(k,i,j-je,2)
5378 if ( prc_has_w )
then
5385 var(k,i,j) = buf(k,i,j-je,2)
5391 if ( prc_has_e )
then
5398 var(k,i,j) = buf(k,i,j-je,2)
5408 call prof_rapend(
'COMM_unpack', 3)
5413 end subroutine unpackns_3d
5415 subroutine unpackns_2d( IA, IS, IE, JA, JS, JE, &
5419 integer,
intent(in) :: IA, IS, IE
5420 integer,
intent(in) :: JA, JS, JE
5421 integer,
intent(in) :: JHALO
5422 real(RP),
intent(inout) :: var(IA,JA)
5423 real(RP),
intent(in) :: buf(IA,JHALO,2)
5430 call prof_rapstart(
'COMM_unpack', 3)
5432 if ( prc_has_s )
then
5438 var(i,j) = buf(i,j,1)
5443 if ( prc_has_w )
then
5449 var(i,j) = buf(i,j,1)
5454 if ( prc_has_e )
then
5460 var(i,j) = buf(i,j,1)
5467 if ( prc_has_n )
then
5473 var(i,j) = buf(i,j-je,2)
5478 if ( prc_has_w )
then
5484 var(i,j) = buf(i,j-je,2)
5489 if ( prc_has_e )
then
5495 var(i,j) = buf(i,j-je,2)
5504 call prof_rapend(
'COMM_unpack', 3)
5509 end subroutine unpackns_2d
5511 subroutine copy_boundary_3d(var, gid)
5516 real(RP),
intent(inout) :: var(:,:,:)
5517 integer,
intent(in) :: gid
5520 integer :: IS, IE, IHALO
5521 integer :: JS, JE, JHALO
5531 ihalo = ginfo(gid)%IHALO
5534 jhalo = ginfo(gid)%JHALO
5539 if ( .NOT. prc_has_n )
then
5541 do j = je+1, je+jhalo
5545 var(k,i,j) = var(k,i,je)
5554 if ( .NOT. prc_has_s )
then
5557 do j = js-jhalo, js-1
5561 var(k,i,j) = var(k,i,js)
5572 if ( .NOT. prc_has_e )
then
5576 do i = ie+1, ie+ihalo
5578 var(k,i,j) = var(k,ie,j)
5587 if ( .NOT. prc_has_w )
then
5592 do i = is-ihalo, is-1
5593 var(:,i,j) = var(:,is,j)
5601 if ( .NOT. prc_has_n .AND. &
5602 .NOT. prc_has_w )
then
5604 do j = je+1, je+jhalo
5606 do i = is-ihalo, is-1
5608 var(k,i,j) = var(k,is,je)
5613 elseif( .NOT. prc_has_n )
then
5615 do j = je+1, je+jhalo
5616 do i = is-ihalo, is-1
5618 var(k,i,j) = var(k,i,je)
5623 elseif( .NOT. prc_has_w )
then
5625 do j = je+1, je+jhalo
5627 do i = is-ihalo, is-1
5629 var(k,i,j) = var(k,is,j)
5637 if ( .NOT. prc_has_s .AND. &
5638 .NOT. prc_has_w )
then
5641 do j = js-jhalo, js-1
5643 do i = is-ihalo, is-1
5645 var(k,i,j) = var(k,is,js)
5650 elseif( .NOT. prc_has_s )
then
5653 do j = js-jhalo, js-1
5654 do i = is-ihalo, is-1
5656 var(k,i,j) = var(k,i,js)
5661 elseif( .NOT. prc_has_w )
then
5663 do j = js-jhalo, js-1
5665 do i = is-ihalo, is-1
5667 var(k,i,j) = var(k,is,j)
5675 if ( .NOT. prc_has_n .AND. &
5676 .NOT. prc_has_e )
then
5678 do j = je+1, je+jhalo
5679 do i = ie+1, ie+ihalo
5681 var(k,i,j) = var(k,ie,je)
5686 elseif( .NOT. prc_has_n )
then
5688 do j = je+1, je+jhalo
5689 do i = ie+1, ie+ihalo
5691 var(k,i,j) = var(k,i,je)
5696 elseif( .NOT. prc_has_e )
then
5698 do j = je+1, je+jhalo
5699 do i = ie+1, ie+ihalo
5701 var(k,i,j) = var(k,ie,j)
5709 if ( .NOT. prc_has_s .AND. &
5710 .NOT. prc_has_e )
then
5712 do j = js-jhalo, js-1
5713 do i = ie+1, ie+ihalo
5715 var(k,i,j) = var(k,ie,js)
5720 elseif( .NOT. prc_has_s )
then
5723 do j = js-jhalo, js-1
5724 do i = ie+1, ie+ihalo
5726 var(k,i,j) = var(k,i,js)
5731 elseif( .NOT. prc_has_e )
then
5733 do j = js-jhalo, js-1
5734 do i = ie+1, ie+ihalo
5736 var(k,i,j) = var(k,ie,j)
5752 end subroutine copy_boundary_3d
5759 real(RP),
intent(inout) :: var(:,:)
5760 integer,
intent(in) :: gid
5762 integer :: IS, IE, IHALO
5763 integer :: JS, JE, JHALO
5772 ihalo = ginfo(gid)%IHALO
5775 jhalo = ginfo(gid)%JHALO
5780 if( .NOT. prc_has_n )
then
5782 do j = je+1, je+jhalo
5785 var(i,j) = var(i,je)
5793 if( .NOT. prc_has_s )
then
5796 do j = js-jhalo, js-1
5799 var(i,j) = var(i,js)
5808 if( .NOT. prc_has_e )
then
5812 do i = ie+1, ie+ihalo
5813 var(i,j) = var(ie,j)
5820 if( .NOT. prc_has_w )
then
5825 do i = is-ihalo, is-1
5826 var(i,j) = var(is,j)
5834 if( .NOT. prc_has_n .AND. .NOT. prc_has_w )
then
5836 do j = je+1, je+jhalo
5838 do i = is-ihalo, is-1
5839 var(i,j) = var(is,je)
5843 elseif( .NOT. prc_has_n )
then
5845 do j = je+1, je+jhalo
5846 do i = is-ihalo, is-1
5847 var(i,j) = var(i,je)
5851 elseif( .NOT. prc_has_w )
then
5853 do j = je+1, je+jhalo
5855 do i = is-ihalo, is-1
5856 var(i,j) = var(is,j)
5863 if( .NOT. prc_has_s .AND. .NOT. prc_has_w )
then
5866 do j = js-jhalo, js-1
5868 do i = is-ihalo, is-1
5869 var(i,j) = var(is,js)
5873 elseif( .NOT. prc_has_s )
then
5876 do j = js-jhalo, js-1
5877 do i = is-ihalo, is-1
5878 var(i,j) = var(i,js)
5882 elseif( .NOT. prc_has_w )
then
5884 do j = js-jhalo, js-1
5886 do i = is-ihalo, is-1
5887 var(i,j) = var(is,j)
5894 if( .NOT. prc_has_n .AND. .NOT. prc_has_e )
then
5896 do j = je+1, je+jhalo
5897 do i = ie+1, ie+ihalo
5898 var(i,j) = var(ie,je)
5902 elseif( .NOT. prc_has_n )
then
5904 do j = je+1, je+jhalo
5905 do i = ie+1, ie+ihalo
5906 var(i,j) = var(i,je)
5910 elseif( .NOT. prc_has_e )
then
5912 do j = je+1, je+jhalo
5913 do i = ie+1, ie+ihalo
5914 var(i,j) = var(ie,j)
5921 if( .NOT. prc_has_s .AND. .NOT. prc_has_e )
then
5923 do j = js-jhalo, js-1
5924 do i = ie+1, ie+ihalo
5925 var(i,j) = var(ie,js)
5929 elseif( .NOT. prc_has_s )
then
5932 do j = js-jhalo, js-1
5933 do i = ie+1, ie+ihalo
5934 var(i,j) = var(i,js)
5938 elseif( .NOT. prc_has_e )
then
5940 do j = js-jhalo, js-1
5941 do i = ie+1, ie+ihalo
5942 var(i,j) = var(ie,j)