27 #include "../base/base_uses.f90"
31 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'dct'
34 INTEGER,
DIMENSION(:),
POINTER :: dests_expand => null()
35 INTEGER,
DIMENSION(:),
POINTER :: srcs_expand => null()
36 INTEGER,
DIMENSION(:),
POINTER :: flipg_stat => null()
37 INTEGER,
DIMENSION(:),
POINTER :: dests_shrink => null()
38 INTEGER :: srcs_shrink = 0
39 INTEGER,
DIMENSION(:, :, :),
POINTER :: recv_msgs_bnds => null()
40 INTEGER,
DIMENSION(2, 3) :: dct_bounds = 0
41 INTEGER,
DIMENSION(2, 3) :: dct_bounds_local = 0
42 INTEGER,
DIMENSION(2, 3) :: bounds_shftd = 0
43 INTEGER,
DIMENSION(2, 3) :: bounds_local_shftd = 0
48 REAL(dp),
DIMENSION(:, :, :),
ALLOCATABLE :: msg
58 INTEGER,
PARAMETER,
PRIVATE :: NOT_FLIPPED = 0, &
85 TYPE(pw_grid_type),
INTENT(IN),
POINTER :: pw_grid
86 INTEGER,
INTENT(IN) :: neumann_directions
87 TYPE(dct_type),
INTENT(INOUT) :: dct_env
89 CHARACTER(len=*),
PARAMETER :: routinen =
'dct_type_init'
91 INTEGER :: handle, maxn_sendrecv
93 CALL timeset(routinen, handle)
95 SELECT CASE (neumann_directions)
103 cpabort(
"Invalid combination of Neumann and periodic conditions.")
106 ALLOCATE (dct_env%flipg_stat(maxn_sendrecv))
107 ALLOCATE (dct_env%dests_expand(maxn_sendrecv), dct_env%srcs_expand(maxn_sendrecv))
108 ALLOCATE (dct_env%dests_shrink(maxn_sendrecv))
109 ALLOCATE (dct_env%recv_msgs_bnds(2, 3, maxn_sendrecv))
111 CALL set_dests_srcs_pid(pw_grid, neumann_directions, &
112 dct_env%dests_expand, dct_env%srcs_expand, dct_env%flipg_stat, &
113 dct_env%dests_shrink, dct_env%srcs_shrink)
114 CALL expansion_bounds(pw_grid, neumann_directions, &
115 dct_env%srcs_expand, dct_env%flipg_stat, &
116 dct_env%bounds_shftd, dct_env%bounds_local_shftd, &
117 dct_env%recv_msgs_bnds, dct_env%dct_bounds, &
118 dct_env%dct_bounds_local)
120 CALL timestop(handle)
133 TYPE(dct_type),
INTENT(INOUT) :: dct_env
135 CHARACTER(len=*),
PARAMETER :: routinen =
'dct_type_release'
139 CALL timeset(routinen, handle)
141 IF (
ASSOCIATED(dct_env%dests_shrink))
DEALLOCATE (dct_env%dests_shrink)
142 IF (
ASSOCIATED(dct_env%dests_expand))
DEALLOCATE (dct_env%dests_expand)
143 IF (
ASSOCIATED(dct_env%srcs_expand))
DEALLOCATE (dct_env%srcs_expand)
144 IF (
ASSOCIATED(dct_env%flipg_stat))
DEALLOCATE (dct_env%flipg_stat)
145 IF (
ASSOCIATED(dct_env%recv_msgs_bnds))
DEALLOCATE (dct_env%recv_msgs_bnds)
147 CALL timestop(handle)
164 TYPE(pw_grid_type),
INTENT(IN),
POINTER :: pw_grid
165 REAL(
dp),
DIMENSION(3, 3),
INTENT(IN) :: cell_hmat
166 INTEGER,
INTENT(IN) :: neumann_directions
167 TYPE(pw_grid_type),
INTENT(INOUT),
POINTER :: dct_pw_grid
169 CHARACTER(LEN=*),
PARAMETER :: routinen =
'setup_dct_pw_grids'
171 INTEGER :: blocked, handle, maxn_sendrecv, &
173 INTEGER,
DIMENSION(2, 3) :: bounds_local_new, bounds_local_shftd, &
174 bounds_new, bounds_shftd
175 INTEGER,
DIMENSION(:),
POINTER :: dests_expand, dests_shrink, flipg_stat, &
177 INTEGER,
DIMENSION(:, :, :),
POINTER :: recv_msgs_bnds
178 REAL(kind=
dp),
DIMENSION(3) :: scfac
179 REAL(kind=
dp),
DIMENSION(3, 3) :: hmat2
181 CALL timeset(routinen, handle)
183 SELECT CASE (neumann_directions)
186 scfac = (/2.0_dp, 2.0_dp, 2.0_dp/)
189 scfac = (/2.0_dp, 2.0_dp, 1.0_dp/)
192 scfac = (/2.0_dp, 1.0_dp, 2.0_dp/)
195 scfac = (/1.0_dp, 2.0_dp, 2.0_dp/)
198 scfac = (/2.0_dp, 1.0_dp, 1.0_dp/)
201 scfac = (/1.0_dp, 2.0_dp, 1.0_dp/)
204 scfac = (/1.0_dp, 1.0_dp, 2.0_dp/)
206 cpabort(
"Invalid combination of Neumann and periodic conditions.")
209 ALLOCATE (flipg_stat(maxn_sendrecv))
210 ALLOCATE (dests_expand(maxn_sendrecv), srcs_expand(maxn_sendrecv), dests_shrink(maxn_sendrecv))
211 ALLOCATE (recv_msgs_bnds(2, 3, maxn_sendrecv))
213 CALL set_dests_srcs_pid(pw_grid, neumann_directions, dests_expand, srcs_expand, flipg_stat, &
214 dests_shrink, srcs_shrink)
215 CALL expansion_bounds(pw_grid, neumann_directions, srcs_expand, flipg_stat, &
216 bounds_shftd, bounds_local_shftd, recv_msgs_bnds, bounds_new, bounds_local_new)
217 CALL pw_grid_create(dct_pw_grid, pw_grid%para%rs_group, local=.false.)
220 hmat2(1, 1) = scfac(1)*cell_hmat(1, 1)
221 hmat2(2, 2) = scfac(2)*cell_hmat(2, 2)
222 hmat2(3, 3) = scfac(3)*cell_hmat(3, 3)
227 IF (pw_grid%para%blocked)
THEN
229 ELSE IF (pw_grid%para%ray_distribution)
THEN
235 rs_dims=pw_grid%para%rs_dims, &
237 bounds_local=bounds_local_new)
239 DEALLOCATE (flipg_stat, dests_expand, srcs_expand, dests_shrink, recv_msgs_bnds)
241 CALL timestop(handle)
259 SUBROUTINE set_dests_srcs_pid(pw_grid, neumann_directions, dests_expand, srcs_expand, &
260 flipg_stat, dests_shrink, srcs_shrink)
262 TYPE(pw_grid_type),
INTENT(IN),
POINTER :: pw_grid
263 INTEGER,
INTENT(IN) :: neumann_directions
264 INTEGER,
DIMENSION(:),
INTENT(INOUT),
POINTER :: dests_expand, srcs_expand, flipg_stat, &
266 INTEGER,
INTENT(OUT) :: srcs_shrink
268 CHARACTER(LEN=*),
PARAMETER :: routinen =
'set_dests_srcs_pid'
270 INTEGER :: group_size, handle, i, j, k, &
271 maxn_sendrecv, rs_dim1, rs_dim2, &
272 rs_mpo, tmp_size1, tmp_size2
273 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: src_pos1_onesdd, src_pos2_onesdd, &
275 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: dests_shrink_all, src_pos1, src_pos2, &
276 srcs_coord, srcs_expand_all
277 INTEGER,
DIMENSION(2) :: rs_dims, rs_pos
278 TYPE(mp_comm_type) :: rs_group
280 CALL timeset(routinen, handle)
325 rs_group = pw_grid%para%rs_group
326 rs_mpo = pw_grid%para%rs_mpo
327 group_size = pw_grid%para%group_size
328 rs_dims = pw_grid%para%rs_dims
330 rs_pos = pw_grid%para%rs_pos
331 rs_dim1 = rs_dims(1); rs_dim2 = rs_dims(2)
334 SELECT CASE (neumann_directions)
337 ALLOCATE (srcs_coord(2, maxn_sendrecv))
339 IF (mod(rs_dim1, 2) .EQ. 0)
THEN
342 tmp_size1 = rs_dim1 + 1
344 ALLOCATE (tmp1_arr(tmp_size1), src_pos1(2, 0:rs_dim1 - 1))
346 IF (mod(rs_dim1, 2) .EQ. 0)
THEN
347 tmp1_arr(:) = (/(i, i=1, rs_dim1)/)
348 src_pos1(:, :) = reshape((/tmp1_arr, -tmp1_arr(tmp_size1:1:-1)/), (/2, rs_dim1/))
350 tmp1_arr(:) = (/(i, i=1, rs_dim1), -rs_dim1/)
351 src_pos1(:, :) = reshape((/tmp1_arr, -tmp1_arr(tmp_size1 - 2:1:-1)/), (/2, rs_dim1/))
354 IF (mod(rs_dim2, 2) .EQ. 0)
THEN
357 tmp_size2 = rs_dim2 + 1
359 ALLOCATE (tmp2_arr(tmp_size2), src_pos2(2, 0:rs_dim2 - 1))
361 IF (mod(rs_dim2, 2) .EQ. 0)
THEN
362 tmp2_arr(:) = (/(i, i=1, rs_dim2)/)
363 src_pos2(:, :) = reshape((/tmp2_arr, -tmp2_arr(tmp_size2:1:-1)/), (/2, rs_dim2/))
365 tmp2_arr(:) = (/(i, i=1, rs_dim2), -rs_dim2/)
366 src_pos2(:, :) = reshape((/tmp2_arr, -tmp2_arr(tmp_size2 - 2:1:-1)/), (/2, rs_dim2/))
369 srcs_coord(:, 1) = (/src_pos1(1, rs_pos(1)), src_pos2(1, rs_pos(2))/)
370 srcs_coord(:, 2) = (/src_pos1(1, rs_pos(1)), src_pos2(2, rs_pos(2))/)
371 srcs_coord(:, 3) = (/src_pos1(2, rs_pos(1)), src_pos2(1, rs_pos(2))/)
372 srcs_coord(:, 4) = (/src_pos1(2, rs_pos(1)), src_pos2(2, rs_pos(2))/)
375 ALLOCATE (srcs_coord(2, maxn_sendrecv))
377 IF (mod(rs_dim1, 2) .EQ. 0)
THEN
380 tmp_size1 = rs_dim1 + 1
382 ALLOCATE (tmp1_arr(tmp_size1), src_pos1(2, 0:rs_dim1 - 1))
384 IF (mod(rs_dim1, 2) .EQ. 0)
THEN
385 tmp1_arr(:) = (/(i, i=1, rs_dim1)/)
386 src_pos1(:, :) = reshape((/tmp1_arr, -tmp1_arr(tmp_size1:1:-1)/), (/2, rs_dim1/))
388 tmp1_arr(:) = (/(i, i=1, rs_dim1), -rs_dim1/)
389 src_pos1(:, :) = reshape((/tmp1_arr, -tmp1_arr(tmp_size1 - 2:1:-1)/), (/2, rs_dim1/))
392 ALLOCATE (src_pos2_onesdd(0:rs_dim2 - 1))
393 src_pos2_onesdd(:) = (/(i, i=1, rs_dim2)/)
395 srcs_coord(:, 1) = (/src_pos1(1, rs_pos(1)), src_pos2_onesdd(rs_pos(2))/)
396 srcs_coord(:, 2) = (/src_pos1(2, rs_pos(1)), src_pos2_onesdd(rs_pos(2))/)
399 ALLOCATE (srcs_coord(2, maxn_sendrecv))
401 ALLOCATE (src_pos1_onesdd(0:rs_dim1 - 1))
402 src_pos1_onesdd(:) = (/(i, i=1, rs_dim1)/)
404 IF (mod(rs_dim2, 2) .EQ. 0)
THEN
407 tmp_size2 = rs_dim2 + 1
409 ALLOCATE (tmp2_arr(tmp_size2), src_pos2(2, 0:rs_dim2 - 1))
411 IF (mod(rs_dim2, 2) .EQ. 0)
THEN
412 tmp2_arr(:) = (/(i, i=1, rs_dim2)/)
413 src_pos2(:, :) = reshape((/tmp2_arr, -tmp2_arr(tmp_size2:1:-1)/), (/2, rs_dim2/))
415 tmp2_arr(:) = (/(i, i=1, rs_dim2), -rs_dim2/)
416 src_pos2(:, :) = reshape((/tmp2_arr, -tmp2_arr(tmp_size2 - 2:1:-1)/), (/2, rs_dim2/))
419 srcs_coord(:, 1) = (/src_pos1_onesdd(rs_pos(1)), src_pos2(1, rs_pos(2))/)
420 srcs_coord(:, 2) = (/src_pos1_onesdd(rs_pos(1)), src_pos2(2, rs_pos(2))/)
423 ALLOCATE (srcs_coord(2, maxn_sendrecv))
424 ALLOCATE (src_pos1_onesdd(0:rs_dim1 - 1))
425 ALLOCATE (src_pos2_onesdd(0:rs_dim2 - 1))
427 src_pos1_onesdd(:) = (/(i, i=1, rs_dim1)/)
429 src_pos2_onesdd(:) = (/(i, i=1, rs_dim2)/)
431 srcs_coord(:, 1) = (/src_pos1_onesdd(rs_pos(1)), src_pos2_onesdd(rs_pos(2))/)
435 flipg_stat = not_flipped
437 DO k = 1, maxn_sendrecv
439 CALL pw_grid%para%rs_group%rank_cart(abs(srcs_coord(:, k)) - 1, srcs_expand(k))
441 IF ((srcs_coord(1, k) .GT. 0) .AND. (srcs_coord(2, k) .GT. 0))
THEN
442 flipg_stat(k) = not_flipped
443 ELSE IF ((srcs_coord(1, k) .LT. 0) .AND. (srcs_coord(2, k) .GT. 0))
THEN
444 flipg_stat(k) = ud_flipped
445 ELSE IF ((srcs_coord(1, k) .GT. 0) .AND. (srcs_coord(2, k) .LT. 0))
THEN
446 flipg_stat(k) = lr_flipped
448 flipg_stat(k) = rotated
453 ALLOCATE (srcs_expand_all(maxn_sendrecv, group_size))
454 CALL rs_group%allgather(srcs_expand, srcs_expand_all)
459 DO j = 1, maxn_sendrecv
460 IF (srcs_expand_all(j, i) .EQ. rs_mpo)
THEN
461 dests_expand(k) = i - 1
474 DO i = 1, maxn_sendrecv
475 IF (flipg_stat(i) .EQ. not_flipped) dests_shrink(i) = srcs_expand(i)
479 ALLOCATE (dests_shrink_all(maxn_sendrecv, group_size))
480 CALL rs_group%allgather(dests_shrink, dests_shrink_all)
485 DO j = 1, maxn_sendrecv
486 IF (dests_shrink_all(j, i) .EQ. rs_mpo)
THEN
493 CALL timestop(handle)
495 END SUBROUTINE set_dests_srcs_pid
516 SUBROUTINE pw_expand(neumann_directions, recv_msgs_bnds, dests_expand, srcs_expand, &
517 flipg_stat, bounds_shftd, pw_in, pw_expanded)
519 INTEGER,
INTENT(IN) :: neumann_directions
520 INTEGER,
DIMENSION(:, :, :),
INTENT(IN),
POINTER :: recv_msgs_bnds
521 INTEGER,
DIMENSION(:),
INTENT(IN),
POINTER :: dests_expand, srcs_expand, flipg_stat
522 INTEGER,
DIMENSION(2, 3),
INTENT(IN) :: bounds_shftd
523 TYPE(pw_r3d_rs_type),
INTENT(IN) :: pw_in
524 TYPE(pw_r3d_rs_type),
INTENT(INOUT) :: pw_expanded
526 CHARACTER(LEN=*),
PARAMETER :: routinen =
'pw_expand'
528 INTEGER :: group_size, handle, i, ind, lb1, lb1_loc, lb1_new, lb2, lb2_loc, lb2_new, lb3, &
529 lb3_loc, lb3_new, loc, maxn_sendrecv, rs_mpo, ub1, ub1_loc, ub1_new, ub2, ub2_loc, &
530 ub2_new, ub3, ub3_loc, ub3_new
531 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: dest_hist, src_hist
532 INTEGER,
ALLOCATABLE,
DIMENSION(:, :, :) :: pcs_bnds
533 INTEGER,
DIMENSION(2, 3) :: bounds_local_new
534 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: catd, catd_flipdbf, cr3d_xpndd
535 TYPE(dct_msg_type),
ALLOCATABLE,
DIMENSION(:) :: pcs, recv_msgs
536 TYPE(mp_comm_type) :: rs_group
537 TYPE(mp_request_type),
ALLOCATABLE,
DIMENSION(:) :: recv_reqs, send_reqs
538 TYPE(pw_grid_type),
POINTER :: pw_grid
540 CALL timeset(routinen, handle)
542 pw_grid => pw_in%pw_grid
543 rs_group = pw_grid%para%rs_group
544 rs_mpo = pw_grid%para%my_pos
545 group_size = pw_grid%para%group_size
547 bounds_local_new = pw_expanded%pw_grid%bounds_local
549 SELECT CASE (neumann_directions)
558 ALLOCATE (recv_reqs(maxn_sendrecv), send_reqs(maxn_sendrecv))
559 ALLOCATE (dest_hist(maxn_sendrecv), src_hist(maxn_sendrecv))
560 ALLOCATE (pcs_bnds(2, 3, maxn_sendrecv))
562 ALLOCATE (pcs(maxn_sendrecv), recv_msgs(maxn_sendrecv))
570 DO i = 1, maxn_sendrecv
572 IF ((dests_expand(i) .NE. rs_mpo) .AND. .NOT. any(dest_hist .EQ. dests_expand(i)))
THEN
573 CALL rs_group%isend(pw_in%array, dests_expand(i), send_reqs(i))
575 dest_hist(i) = dests_expand(i)
578 DO i = 1, maxn_sendrecv
579 lb1 = recv_msgs_bnds(1, 1, i)
580 ub1 = recv_msgs_bnds(2, 1, i)
581 lb2 = recv_msgs_bnds(1, 2, i)
582 ub2 = recv_msgs_bnds(2, 2, i)
583 lb3 = recv_msgs_bnds(1, 3, i)
584 ub3 = recv_msgs_bnds(2, 3, i)
586 IF (srcs_expand(i) .EQ. rs_mpo)
THEN
587 ALLOCATE (recv_msgs(i)%msg(lb1:ub1, lb2:ub2, lb3:ub3))
588 recv_msgs(i)%msg(:, :, :) = pw_in%array
590 ELSE IF (any(src_hist .EQ. srcs_expand(i)))
THEN
591 loc = minloc(abs(src_hist - srcs_expand(i)), 1)
592 lb1_loc = recv_msgs_bnds(1, 1, loc)
593 ub1_loc = recv_msgs_bnds(2, 1, loc)
594 lb2_loc = recv_msgs_bnds(1, 2, loc)
595 ub2_loc = recv_msgs_bnds(2, 2, loc)
596 lb3_loc = recv_msgs_bnds(1, 3, loc)
597 ub3_loc = recv_msgs_bnds(2, 3, loc)
598 ALLOCATE (recv_msgs(i)%msg(lb1_loc:ub1_loc, lb2_loc:ub2_loc, lb3_loc:ub3_loc))
599 recv_msgs(i)%msg(:, :, :) = recv_msgs(loc)%msg
601 ALLOCATE (recv_msgs(i)%msg(lb1:ub1, lb2:ub2, lb3:ub3))
602 CALL rs_group%irecv(recv_msgs(i)%msg, srcs_expand(i), recv_reqs(i))
603 CALL recv_reqs(i)%wait()
605 src_hist(i) = srcs_expand(i)
608 CALL mp_waitall(send_reqs(:))
611 DO i = 1, maxn_sendrecv
612 SELECT CASE (flipg_stat(i))
614 lb1 = recv_msgs_bnds(1, 1, i)
615 ub1 = recv_msgs_bnds(2, 1, i)
616 lb2 = recv_msgs_bnds(1, 2, i)
617 ub2 = recv_msgs_bnds(2, 2, i)
618 lb3 = recv_msgs_bnds(1, 3, i)
619 ub3 = recv_msgs_bnds(2, 3, i)
620 ALLOCATE (pcs(i)%msg(lb1:ub1, lb2:ub2, lb3:ub3))
621 pcs(i)%msg(:, :, :) = recv_msgs(i)%msg
623 CALL flipud(recv_msgs(i)%msg, pcs(i)%msg, bounds_shftd)
625 CALL fliplr(recv_msgs(i)%msg, pcs(i)%msg, bounds_shftd)
627 CALL flipbf(recv_msgs(i)%msg, pcs(i)%msg, bounds_shftd)
629 CALL rot180(recv_msgs(i)%msg, pcs(i)%msg, bounds_shftd)
634 DO i = 1, maxn_sendrecv
635 pcs_bnds(1, 1, i) = lbound(pcs(i)%msg, 1)
636 pcs_bnds(2, 1, i) = ubound(pcs(i)%msg, 1)
637 pcs_bnds(1, 2, i) = lbound(pcs(i)%msg, 2)
638 pcs_bnds(2, 2, i) = ubound(pcs(i)%msg, 2)
639 pcs_bnds(1, 3, i) = lbound(pcs(i)%msg, 3)
640 pcs_bnds(2, 3, i) = ubound(pcs(i)%msg, 3)
643 lb1_new = bounds_local_new(1, 1); ub1_new = bounds_local_new(2, 1)
644 lb2_new = bounds_local_new(1, 2); ub2_new = bounds_local_new(2, 2)
645 lb3_new = bounds_local_new(1, 3); ub3_new = bounds_local_new(2, 3)
647 SELECT CASE (neumann_directions)
649 ind = int(0.5*(ub3_new + lb3_new + 1))
650 ALLOCATE (catd(lb1_new:ub1_new, lb2_new:ub2_new, lb3_new:ind - 1))
652 ALLOCATE (catd(lb1_new:ub1_new, lb2_new:ub2_new, lb3_new:ub3_new))
655 DO i = 1, maxn_sendrecv
656 catd(pcs_bnds(1, 1, i):pcs_bnds(2, 1, i), &
657 pcs_bnds(1, 2, i):pcs_bnds(2, 2, i), &
658 pcs_bnds(1, 3, i):pcs_bnds(2, 3, i)) = pcs(i)%msg
662 CALL flipbf(catd, catd_flipdbf, bounds_shftd)
664 ALLOCATE (cr3d_xpndd(lb1_new:ub1_new, lb2_new:ub2_new, lb3_new:ub3_new))
665 SELECT CASE (neumann_directions)
667 cr3d_xpndd(:, :, lb3_new:ind - 1) = catd
668 cr3d_xpndd(:, :, ind:ub3_new) = catd_flipdbf
670 cr3d_xpndd(:, :, :) = catd
673 pw_expanded%array = cr3d_xpndd
675 DO i = 1, maxn_sendrecv
676 DEALLOCATE (pcs(i)%msg)
677 DEALLOCATE (recv_msgs(i)%msg)
679 DEALLOCATE (pcs, recv_msgs)
680 DEALLOCATE (catd, catd_flipdbf, cr3d_xpndd)
682 CALL timestop(handle)
700 SUBROUTINE pw_shrink(neumann_directions, dests_shrink, srcs_shrink, bounds_local_shftd, &
703 INTEGER,
INTENT(IN) :: neumann_directions
704 INTEGER,
DIMENSION(:),
INTENT(IN),
POINTER :: dests_shrink
705 INTEGER,
INTENT(INOUT) :: srcs_shrink
706 INTEGER,
DIMENSION(2, 3),
INTENT(IN) :: bounds_local_shftd
707 TYPE(pw_r3d_rs_type),
INTENT(IN) :: pw_in
708 TYPE(pw_r3d_rs_type),
INTENT(INOUT) :: pw_shrinked
710 CHARACTER(LEN=*),
PARAMETER :: routinen =
'pw_shrink'
712 INTEGER :: group_size, handle, i, lb1_orig, lb1_xpnd, lb2_orig, lb2_xpnd, lb3_orig, &
713 lb3_xpnd, maxn_sendrecv, rs_mpo, send_lb1, send_lb2, send_lb3, send_ub1, send_ub2, &
714 send_ub3, tag, ub1_orig, ub1_xpnd, ub2_orig, ub2_xpnd, ub3_orig, ub3_xpnd
715 INTEGER,
ALLOCATABLE,
DIMENSION(:, :, :) :: bounds_local_all
716 INTEGER,
DIMENSION(2, 3) :: bounds_local_xpnd
717 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: cr3d, send_crmsg
718 TYPE(mp_comm_type) :: rs_group
719 TYPE(pw_grid_type),
POINTER :: pw_grid_orig
721 CALL timeset(routinen, handle)
723 pw_grid_orig => pw_shrinked%pw_grid
724 rs_group = pw_grid_orig%para%rs_group
725 rs_mpo = pw_grid_orig%para%my_pos
726 group_size = pw_grid_orig%para%group_size
727 bounds_local_xpnd = pw_in%pw_grid%bounds_local
730 SELECT CASE (neumann_directions)
740 lb1_xpnd = bounds_local_xpnd(1, 1)
741 ub1_xpnd = bounds_local_xpnd(2, 1)
742 lb2_xpnd = bounds_local_xpnd(1, 2)
743 ub2_xpnd = bounds_local_xpnd(2, 2)
744 lb3_xpnd = bounds_local_xpnd(1, 3)
745 ub3_xpnd = bounds_local_xpnd(2, 3)
746 ALLOCATE (cr3d(lb1_xpnd:ub1_xpnd, lb2_xpnd:ub2_xpnd, lb3_xpnd:ub3_xpnd))
747 cr3d(:, :, :) = pw_in%array
750 ALLOCATE (bounds_local_all(2, 3, group_size))
751 CALL rs_group%allgather(bounds_local_shftd, bounds_local_all)
753 DO i = 1, maxn_sendrecv
755 IF ((dests_shrink(i) .NE. rs_mpo) .AND. (dests_shrink(i) .NE. -1))
THEN
756 send_lb1 = bounds_local_all(1, 1, dests_shrink(i) + 1)
757 send_ub1 = bounds_local_all(2, 1, dests_shrink(i) + 1)
758 send_lb2 = bounds_local_all(1, 2, dests_shrink(i) + 1)
759 send_ub2 = bounds_local_all(2, 2, dests_shrink(i) + 1)
760 send_lb3 = bounds_local_all(1, 3, dests_shrink(i) + 1)
761 send_ub3 = bounds_local_all(2, 3, dests_shrink(i) + 1)
763 ALLOCATE (send_crmsg(send_lb1:send_ub1, send_lb2:send_ub2, send_lb3:send_ub3))
764 send_crmsg(:, :, :) = cr3d(send_lb1:send_ub1, send_lb2:send_ub2, send_lb3:send_ub3)
765 CALL rs_group%send(send_crmsg, dests_shrink(i), tag)
766 DEALLOCATE (send_crmsg)
770 lb1_orig = bounds_local_shftd(1, 1)
771 ub1_orig = bounds_local_shftd(2, 1)
772 lb2_orig = bounds_local_shftd(1, 2)
773 ub2_orig = bounds_local_shftd(2, 2)
774 lb3_orig = bounds_local_shftd(1, 3)
775 ub3_orig = bounds_local_shftd(2, 3)
778 IF (srcs_shrink .EQ. rs_mpo)
THEN
779 pw_shrinked%array = cr3d(lb1_orig:ub1_orig, lb2_orig:ub2_orig, lb3_orig:ub3_orig)
780 ELSE IF (srcs_shrink .EQ. -1)
THEN
783 CALL rs_group%recv(pw_shrinked%array, srcs_shrink, tag)
786 DEALLOCATE (bounds_local_all)
788 CALL timestop(handle)
802 SUBROUTINE flipud(cr3d_in, cr3d_out, bounds)
804 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :), &
805 INTENT(IN) :: cr3d_in
806 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :), &
807 INTENT(INOUT) :: cr3d_out
808 INTEGER,
DIMENSION(2, 3),
INTENT(IN) :: bounds
810 CHARACTER(LEN=*),
PARAMETER :: routinen =
'flipud'
812 INTEGER :: handle, i, lb1, lb1_glbl, lb1_new, lb2, lb2_glbl, lb2_new, lb3, lb3_glbl, &
813 lb3_new, ub1, ub1_glbl, ub1_new, ub2, ub2_glbl, ub2_new, ub3, ub3_glbl, ub3_new
814 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: indx
815 INTEGER,
DIMENSION(2, 3) :: bndsl, bndsl_new
817 CALL timeset(routinen, handle)
819 lb1 = lbound(cr3d_in, 1); ub1 = ubound(cr3d_in, 1)
820 lb2 = lbound(cr3d_in, 2); ub2 = ubound(cr3d_in, 2)
821 lb3 = lbound(cr3d_in, 3); ub3 = ubound(cr3d_in, 3)
823 lb1_glbl = bounds(1, 1); ub1_glbl = bounds(2, 1)
824 lb2_glbl = bounds(1, 2); ub2_glbl = bounds(2, 2)
825 lb3_glbl = bounds(1, 3); ub3_glbl = bounds(2, 3)
827 bndsl = reshape((/lb1, ub1, lb2, ub2, lb3, ub3/), (/2, 3/))
828 bndsl_new = flipud_bounds_local(bndsl, bounds)
830 lb1_new = bndsl_new(1, 1); ub1_new = bndsl_new(2, 1)
831 lb2_new = bndsl_new(1, 2); ub2_new = bndsl_new(2, 2)
832 lb3_new = bndsl_new(1, 3); ub3_new = bndsl_new(2, 3)
834 ALLOCATE (cr3d_out(lb1_new:ub1_new, lb2_new:ub2_new, lb3_new:ub3_new))
839 ALLOCATE (indx(ub1_new - lb1_new + 1))
840 indx(:) = (/(i, i=2*(ub1_glbl + 1) - lb1_new, 2*(ub1_glbl + 1) - ub1_new, -1)/)
841 IF (lb1_new .EQ. ub1_glbl + 1) indx(1) = indx(2)
842 cr3d_out(lb1_new:ub1_new, lb2_new:ub2_new, lb3_new:ub3_new) = cr3d_in(indx, :, :)
844 CALL timestop(handle)
846 END SUBROUTINE flipud
858 SUBROUTINE fliplr(cr3d_in, cr3d_out, bounds)
860 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :), &
861 INTENT(IN) :: cr3d_in
862 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :), &
863 INTENT(INOUT) :: cr3d_out
864 INTEGER,
DIMENSION(2, 3),
INTENT(IN) :: bounds
866 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fliplr'
868 INTEGER :: handle, i, lb1, lb1_glbl, lb1_new, lb2, lb2_glbl, lb2_new, lb3, lb3_glbl, &
869 lb3_new, ub1, ub1_glbl, ub1_new, ub2, ub2_glbl, ub2_new, ub3, ub3_glbl, ub3_new
870 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: indy
871 INTEGER,
DIMENSION(2, 3) :: bndsl, bndsl_new
873 CALL timeset(routinen, handle)
875 lb1 = lbound(cr3d_in, 1); ub1 = ubound(cr3d_in, 1)
876 lb2 = lbound(cr3d_in, 2); ub2 = ubound(cr3d_in, 2)
877 lb3 = lbound(cr3d_in, 3); ub3 = ubound(cr3d_in, 3)
879 lb1_glbl = bounds(1, 1); ub1_glbl = bounds(2, 1)
880 lb2_glbl = bounds(1, 2); ub2_glbl = bounds(2, 2)
881 lb3_glbl = bounds(1, 3); ub3_glbl = bounds(2, 3)
883 bndsl = reshape((/lb1, ub1, lb2, ub2, lb3, ub3/), (/2, 3/))
884 bndsl_new = fliplr_bounds_local(bndsl, bounds)
886 lb1_new = bndsl_new(1, 1); ub1_new = bndsl_new(2, 1)
887 lb2_new = bndsl_new(1, 2); ub2_new = bndsl_new(2, 2)
888 lb3_new = bndsl_new(1, 3); ub3_new = bndsl_new(2, 3)
890 ALLOCATE (cr3d_out(lb1_new:ub1_new, lb2_new:ub2_new, lb3_new:ub3_new))
895 ALLOCATE (indy(ub2_new - lb2_new + 1))
896 indy(:) = (/(i, i=2*(ub2_glbl + 1) - lb2_new, 2*(ub2_glbl + 1) - ub2_new, -1)/)
897 IF (lb2_new .EQ. ub2_glbl + 1) indy(1) = indy(2)
898 cr3d_out(lb1_new:ub1_new, lb2_new:ub2_new, lb3_new:ub3_new) = cr3d_in(:, indy, :)
900 CALL timestop(handle)
902 END SUBROUTINE fliplr
914 SUBROUTINE flipbf(cr3d_in, cr3d_out, bounds)
916 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :), &
917 INTENT(IN) :: cr3d_in
918 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :), &
919 INTENT(INOUT) :: cr3d_out
920 INTEGER,
DIMENSION(2, 3),
INTENT(IN) :: bounds
922 CHARACTER(LEN=*),
PARAMETER :: routinen =
'flipbf'
924 INTEGER :: handle, i, lb1, lb1_glbl, lb1_new, lb2, lb2_glbl, lb2_new, lb3, lb3_glbl, &
925 lb3_new, ub1, ub1_glbl, ub1_new, ub2, ub2_glbl, ub2_new, ub3, ub3_glbl, ub3_new
926 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: indz
927 INTEGER,
DIMENSION(2, 3) :: bndsl, bndsl_new
929 CALL timeset(routinen, handle)
931 lb1 = lbound(cr3d_in, 1); ub1 = ubound(cr3d_in, 1)
932 lb2 = lbound(cr3d_in, 2); ub2 = ubound(cr3d_in, 2)
933 lb3 = lbound(cr3d_in, 3); ub3 = ubound(cr3d_in, 3)
935 lb1_glbl = bounds(1, 1); ub1_glbl = bounds(2, 1)
936 lb2_glbl = bounds(1, 2); ub2_glbl = bounds(2, 2)
937 lb3_glbl = bounds(1, 3); ub3_glbl = bounds(2, 3)
939 bndsl = reshape((/lb1, ub1, lb2, ub2, lb3, ub3/), (/2, 3/))
940 bndsl_new = flipbf_bounds_local(bndsl, bounds)
942 lb1_new = bndsl_new(1, 1); ub1_new = bndsl_new(2, 1)
943 lb2_new = bndsl_new(1, 2); ub2_new = bndsl_new(2, 2)
944 lb3_new = bndsl_new(1, 3); ub3_new = bndsl_new(2, 3)
946 ALLOCATE (cr3d_out(lb1_new:ub1_new, lb2_new:ub2_new, lb3_new:ub3_new))
951 ALLOCATE (indz(ub3_new - lb3_new + 1))
952 indz(:) = (/(i, i=2*(ub3_glbl + 1) - lb3_new, 2*(ub3_glbl + 1) - ub3_new, -1)/)
953 IF (lb3_new .EQ. ub3_glbl + 1) indz(1) = indz(2)
954 cr3d_out(lb1_new:ub1_new, lb2_new:ub2_new, lb3_new:ub3_new) = cr3d_in(:, :, indz)
956 CALL timestop(handle)
958 END SUBROUTINE flipbf
970 SUBROUTINE rot180(cr3d_in, cr3d_out, bounds)
972 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :), &
973 INTENT(IN) :: cr3d_in
974 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :), &
975 INTENT(INOUT) :: cr3d_out
976 INTEGER,
DIMENSION(2, 3),
INTENT(IN) :: bounds
978 CHARACTER(LEN=*),
PARAMETER :: routinen =
'rot180'
980 INTEGER :: handle, i, lb1, lb1_glbl, lb1_new, lb2, lb2_glbl, lb2_new, lb3, lb3_glbl, &
981 lb3_new, ub1, ub1_glbl, ub1_new, ub2, ub2_glbl, ub2_new, ub3, ub3_glbl, ub3_new
982 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: indx, indy
983 INTEGER,
DIMENSION(2, 3) :: bndsl, bndsl_new
985 CALL timeset(routinen, handle)
987 lb1 = lbound(cr3d_in, 1); ub1 = ubound(cr3d_in, 1)
988 lb2 = lbound(cr3d_in, 2); ub2 = ubound(cr3d_in, 2)
989 lb3 = lbound(cr3d_in, 3); ub3 = ubound(cr3d_in, 3)
991 lb1_glbl = bounds(1, 1); ub1_glbl = bounds(2, 1)
992 lb2_glbl = bounds(1, 2); ub2_glbl = bounds(2, 2)
993 lb3_glbl = bounds(1, 3); ub3_glbl = bounds(2, 3)
995 bndsl = reshape((/lb1, ub1, lb2, ub2, lb3, ub3/), (/2, 3/))
996 bndsl_new = rot180_bounds_local(bndsl, bounds)
998 lb1_new = bndsl_new(1, 1); ub1_new = bndsl_new(2, 1)
999 lb2_new = bndsl_new(1, 2); ub2_new = bndsl_new(2, 2)
1000 lb3_new = bndsl_new(1, 3); ub3_new = bndsl_new(2, 3)
1002 ALLOCATE (cr3d_out(lb1_new:ub1_new, lb2_new:ub2_new, lb3_new:ub3_new))
1007 ALLOCATE (indx(ub1_new - lb1_new + 1), indy(ub2_new - lb2_new + 1))
1008 indx(:) = (/(i, i=2*(ub1_glbl + 1) - lb1_new, 2*(ub1_glbl + 1) - ub1_new, -1)/)
1009 indy(:) = (/(i, i=2*(ub2_glbl + 1) - lb2_new, 2*(ub2_glbl + 1) - ub2_new, -1)/)
1010 IF (lb1_new .EQ. ub1_glbl + 1) indx(1) = indx(2)
1011 IF (lb2_new .EQ. ub2_glbl + 1) indy(1) = indy(2)
1012 cr3d_out(lb1_new:ub1_new, lb2_new:ub2_new, lb3_new:ub3_new) = cr3d_in(indx, indy, :)
1014 CALL timestop(handle)
1016 END SUBROUTINE rot180
1033 SUBROUTINE expansion_bounds(pw_grid, neumann_directions, srcs_expand, flipg_stat, &
1034 bounds_shftd, bounds_local_shftd, &
1035 recv_msgs_bnds, bounds_new, bounds_local_new)
1037 TYPE(pw_grid_type),
INTENT(IN),
POINTER :: pw_grid
1038 INTEGER,
INTENT(IN) :: neumann_directions
1039 INTEGER,
DIMENSION(:),
INTENT(IN),
POINTER :: srcs_expand, flipg_stat
1040 INTEGER,
DIMENSION(2, 3),
INTENT(OUT) :: bounds_shftd, bounds_local_shftd
1041 INTEGER,
DIMENSION(:, :, :),
INTENT(INOUT), &
1042 POINTER :: recv_msgs_bnds
1043 INTEGER,
DIMENSION(2, 3),
INTENT(OUT) :: bounds_new, bounds_local_new
1045 CHARACTER(LEN=*),
PARAMETER :: routinen =
'expansion_bounds'
1047 INTEGER :: group_size, handle, i, lb1_new, lb2_new, &
1048 lb3_new, loc, maxn_sendrecv, rs_mpo, &
1049 ub1_new, ub2_new, ub3_new
1050 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: src_hist
1051 INTEGER,
ALLOCATABLE,
DIMENSION(:, :, :) :: bounds_local_all, bounds_local_new_all, &
1053 INTEGER,
DIMENSION(2, 3) :: bounds, bounds_local
1054 INTEGER,
DIMENSION(3) :: npts_new, shf_yesno, shift
1055 TYPE(mp_comm_type) :: rs_group
1057 CALL timeset(routinen, handle)
1059 rs_group = pw_grid%para%rs_group
1060 rs_mpo = pw_grid%para%my_pos
1061 group_size = pw_grid%para%group_size
1062 bounds = pw_grid%bounds
1063 bounds_local = pw_grid%bounds_local
1065 SELECT CASE (neumann_directions)
1068 shf_yesno = (/1, 1, 1/)
1071 shf_yesno = (/1, 1, 0/)
1074 shf_yesno = (/1, 0, 1/)
1077 shf_yesno = (/0, 1, 1/)
1080 shf_yesno = (/1, 0, 0/)
1083 shf_yesno = (/0, 1, 0/)
1086 shf_yesno = (/0, 0, 1/)
1088 cpabort(
"Unknown neumann direction")
1089 shf_yesno = (/0, 0, 0/)
1092 ALLOCATE (pcs_bnds(2, 3, maxn_sendrecv))
1093 ALLOCATE (src_hist(maxn_sendrecv))
1096 npts_new = 2*pw_grid%npts
1098 shift = shift - bounds(1, :)
1099 bounds_shftd(:, 1) = bounds(:, 1) + shf_yesno(1)*shift(1)
1100 bounds_shftd(:, 2) = bounds(:, 2) + shf_yesno(2)*shift(2)
1101 bounds_shftd(:, 3) = bounds(:, 3) + shf_yesno(3)*shift(3)
1102 bounds_local_shftd(:, 1) = bounds_local(:, 1) + shf_yesno(1)*shift(1)
1103 bounds_local_shftd(:, 2) = bounds_local(:, 2) + shf_yesno(2)*shift(2)
1104 bounds_local_shftd(:, 3) = bounds_local(:, 3) + shf_yesno(3)*shift(3)
1107 ALLOCATE (bounds_local_all(2, 3, group_size))
1108 CALL rs_group%allgather(bounds_local_shftd, bounds_local_all)
1112 DO i = 1, maxn_sendrecv
1114 IF (srcs_expand(i) .EQ. rs_mpo)
THEN
1115 recv_msgs_bnds(1, 1, i) = bounds_local_shftd(1, 1)
1116 recv_msgs_bnds(2, 1, i) = bounds_local_shftd(2, 1)
1117 recv_msgs_bnds(1, 2, i) = bounds_local_shftd(1, 2)
1118 recv_msgs_bnds(2, 2, i) = bounds_local_shftd(2, 2)
1119 recv_msgs_bnds(1, 3, i) = bounds_local_shftd(1, 3)
1120 recv_msgs_bnds(2, 3, i) = bounds_local_shftd(2, 3)
1122 ELSE IF (any(src_hist .EQ. srcs_expand(i)))
THEN
1123 loc = minloc(abs(src_hist - srcs_expand(i)), 1)
1124 recv_msgs_bnds(1, 1, i) = bounds_local_all(1, 1, srcs_expand(loc) + 1)
1125 recv_msgs_bnds(2, 1, i) = bounds_local_all(2, 1, srcs_expand(loc) + 1)
1126 recv_msgs_bnds(1, 2, i) = bounds_local_all(1, 2, srcs_expand(loc) + 1)
1127 recv_msgs_bnds(2, 2, i) = bounds_local_all(2, 2, srcs_expand(loc) + 1)
1128 recv_msgs_bnds(1, 3, i) = bounds_local_all(1, 3, srcs_expand(loc) + 1)
1129 recv_msgs_bnds(2, 3, i) = bounds_local_all(2, 3, srcs_expand(loc) + 1)
1131 recv_msgs_bnds(1, 1, i) = bounds_local_all(1, 1, srcs_expand(i) + 1)
1132 recv_msgs_bnds(2, 1, i) = bounds_local_all(2, 1, srcs_expand(i) + 1)
1133 recv_msgs_bnds(1, 2, i) = bounds_local_all(1, 2, srcs_expand(i) + 1)
1134 recv_msgs_bnds(2, 2, i) = bounds_local_all(2, 2, srcs_expand(i) + 1)
1135 recv_msgs_bnds(1, 3, i) = bounds_local_all(1, 3, srcs_expand(i) + 1)
1136 recv_msgs_bnds(2, 3, i) = bounds_local_all(2, 3, srcs_expand(i) + 1)
1138 src_hist(i) = srcs_expand(i)
1142 DO i = 1, maxn_sendrecv
1143 SELECT CASE (flipg_stat(i))
1145 pcs_bnds(:, :, i) = recv_msgs_bnds(:, :, i)
1147 pcs_bnds(:, :, i) = flipud_bounds_local(recv_msgs_bnds(:, :, i), bounds_shftd)
1149 pcs_bnds(:, :, i) = fliplr_bounds_local(recv_msgs_bnds(:, :, i), bounds_shftd)
1151 pcs_bnds(:, :, i) = flipbf_bounds_local(recv_msgs_bnds(:, :, i), bounds_shftd)
1153 pcs_bnds(:, :, i) = rot180_bounds_local(recv_msgs_bnds(:, :, i), bounds_shftd)
1157 lb1_new = minval(pcs_bnds(1, 1, :)); ub1_new = maxval(pcs_bnds(2, 1, :))
1158 lb2_new = minval(pcs_bnds(1, 2, :)); ub2_new = maxval(pcs_bnds(2, 2, :))
1159 lb3_new = minval(pcs_bnds(1, 3, :)); ub3_new = maxval(pcs_bnds(2, 3, :))
1162 bounds_local_new(1, 1) = minval(pcs_bnds(1, 1, :))
1163 bounds_local_new(2, 1) = maxval(pcs_bnds(2, 1, :))
1164 bounds_local_new(1, 2) = minval(pcs_bnds(1, 2, :))
1165 bounds_local_new(2, 2) = maxval(pcs_bnds(2, 2, :))
1166 bounds_local_new(1, 3) = minval(pcs_bnds(1, 3, :))
1167 SELECT CASE (neumann_directions)
1169 bounds_local_new(2, 3) = 2*(maxval(pcs_bnds(2, 3, :)) + 1) - bounds_local_new(1, 3) - 1
1171 bounds_local_new(2, 3) = maxval(pcs_bnds(2, 3, :))
1174 ALLOCATE (bounds_local_new_all(2, 3, group_size))
1175 CALL rs_group%allgather(bounds_local_new, bounds_local_new_all)
1176 bounds_new(1, 1) = minval(bounds_local_new_all(1, 1, :))
1177 bounds_new(2, 1) = maxval(bounds_local_new_all(2, 1, :))
1178 bounds_new(1, 2) = minval(bounds_local_new_all(1, 2, :))
1179 bounds_new(2, 2) = maxval(bounds_local_new_all(2, 2, :))
1180 bounds_new(1, 3) = minval(bounds_local_new_all(1, 3, :))
1181 bounds_new(2, 3) = maxval(bounds_local_new_all(2, 3, :))
1183 DEALLOCATE (bounds_local_all, bounds_local_new_all)
1185 CALL timestop(handle)
1187 END SUBROUTINE expansion_bounds
1198 PURE FUNCTION flipud_bounds_local(bndsl_in, bounds)
RESULT(bndsl_out)
1200 INTEGER,
DIMENSION(2, 3),
INTENT(IN) :: bndsl_in, bounds
1201 INTEGER,
DIMENSION(2, 3) :: bndsl_out
1203 bndsl_out(1, 1) = 2*(bounds(2, 1) + 1) - bndsl_in(2, 1)
1204 bndsl_out(2, 1) = 2*(bounds(2, 1) + 1) - bndsl_in(1, 1)
1205 IF (bndsl_out(1, 1) .EQ. bounds(2, 1) + 2) bndsl_out(1, 1) = bndsl_out(1, 1) - 1
1206 IF (bndsl_out(2, 1) .EQ. 2*(bounds(2, 1) + 1) - bounds(1, 1)) bndsl_out(2, 1) = bndsl_out(2, 1) - 1
1208 bndsl_out(1, 2) = bndsl_in(1, 2)
1209 bndsl_out(2, 2) = bndsl_in(2, 2)
1211 bndsl_out(1, 3) = bndsl_in(1, 3)
1212 bndsl_out(2, 3) = bndsl_in(2, 3)
1214 END FUNCTION flipud_bounds_local
1225 PURE FUNCTION fliplr_bounds_local(bndsl_in, bounds)
RESULT(bndsl_out)
1227 INTEGER,
DIMENSION(2, 3),
INTENT(IN) :: bndsl_in, bounds
1228 INTEGER,
DIMENSION(2, 3) :: bndsl_out
1230 bndsl_out(1, 1) = bndsl_in(1, 1)
1231 bndsl_out(2, 1) = bndsl_in(2, 1)
1233 bndsl_out(1, 2) = 2*(bounds(2, 2) + 1) - bndsl_in(2, 2)
1234 bndsl_out(2, 2) = 2*(bounds(2, 2) + 1) - bndsl_in(1, 2)
1235 IF (bndsl_out(1, 2) .EQ. bounds(2, 2) + 2) bndsl_out(1, 2) = bndsl_out(1, 2) - 1
1236 IF (bndsl_out(2, 2) .EQ. 2*(bounds(2, 2) + 1) - bounds(1, 2)) bndsl_out(2, 2) = bndsl_out(2, 2) - 1
1238 bndsl_out(1, 3) = bndsl_in(1, 3)
1239 bndsl_out(2, 3) = bndsl_in(2, 3)
1241 END FUNCTION fliplr_bounds_local
1252 PURE FUNCTION flipbf_bounds_local(bndsl_in, bounds)
RESULT(bndsl_out)
1254 INTEGER,
DIMENSION(2, 3),
INTENT(IN) :: bndsl_in, bounds
1255 INTEGER,
DIMENSION(2, 3) :: bndsl_out
1257 bndsl_out(1, 1) = bndsl_in(1, 1)
1258 bndsl_out(2, 1) = bndsl_in(2, 1)
1260 bndsl_out(1, 2) = bndsl_in(1, 2)
1261 bndsl_out(2, 2) = bndsl_in(2, 2)
1263 bndsl_out(1, 3) = 2*(bounds(2, 3) + 1) - bndsl_in(2, 3)
1264 bndsl_out(2, 3) = 2*(bounds(2, 3) + 1) - bndsl_in(1, 3)
1265 IF (bndsl_out(1, 3) .EQ. bounds(2, 3) + 2) bndsl_out(1, 3) = bndsl_out(1, 3) - 1
1266 IF (bndsl_out(2, 3) .EQ. 2*(bounds(2, 3) + 1) - bounds(1, 3)) bndsl_out(2, 3) = bndsl_out(2, 3) - 1
1268 END FUNCTION flipbf_bounds_local
1279 PURE FUNCTION rot180_bounds_local(bndsl_in, bounds)
RESULT(bndsl_out)
1281 INTEGER,
DIMENSION(2, 3),
INTENT(IN) :: bndsl_in, bounds
1282 INTEGER,
DIMENSION(2, 3) :: bndsl_out
1284 bndsl_out(1, 1) = 2*(bounds(2, 1) + 1) - bndsl_in(2, 1)
1285 bndsl_out(2, 1) = 2*(bounds(2, 1) + 1) - bndsl_in(1, 1)
1286 IF (bndsl_out(1, 1) .EQ. bounds(2, 1) + 2) bndsl_out(1, 1) = bndsl_out(1, 1) - 1
1287 IF (bndsl_out(2, 1) .EQ. 2*(bounds(2, 1) + 1) - bounds(1, 1)) bndsl_out(2, 1) = bndsl_out(2, 1) - 1
1289 bndsl_out(1, 2) = 2*(bounds(2, 2) + 1) - bndsl_in(2, 2)
1290 bndsl_out(2, 2) = 2*(bounds(2, 2) + 1) - bndsl_in(1, 2)
1291 IF (bndsl_out(1, 2) .EQ. bounds(2, 2) + 2) bndsl_out(1, 2) = bndsl_out(1, 2) - 1
1292 IF (bndsl_out(2, 2) .EQ. 2*(bounds(2, 2) + 1) - bounds(1, 2)) bndsl_out(2, 2) = bndsl_out(2, 2) - 1
1294 bndsl_out(1, 3) = bndsl_in(1, 3)
1295 bndsl_out(2, 3) = bndsl_in(2, 3)
1297 END FUNCTION rot180_bounds_local
the type I Discrete Cosine Transform (DCT-I)
subroutine, public dct_type_release(dct_env)
Releases a dct_type.
integer, parameter, public neumannx
integer, parameter, public neumannxy
subroutine, public dct_type_init(pw_grid, neumann_directions, dct_env)
Initializes a dct_type.
integer, parameter, public neumannxz
subroutine, public pw_shrink(neumann_directions, dests_shrink, srcs_shrink, bounds_local_shftd, pw_in, pw_shrinked)
shrinks an evenly symmetric pw_r3d_rs_type data to a pw_r3d_rs_type data that is 8 times smaller (the...
integer, parameter, public neumannxyz
integer, parameter, public neumannz
integer, parameter, public neumannyz
subroutine, public setup_dct_pw_grids(pw_grid, cell_hmat, neumann_directions, dct_pw_grid)
sets up an extended pw_grid for Discrete Cosine Transform (DCT) calculations
integer, parameter, public neumanny
subroutine, public pw_expand(neumann_directions, recv_msgs_bnds, dests_expand, srcs_expand, flipg_stat, bounds_shftd, pw_in, pw_expanded)
expands a pw_r3d_rs_type data to an evenly symmetric pw_r3d_rs_type data that is 8 times larger than ...
Defines the basic variable types.
integer, parameter, public dp
Interface to the message passing library MPI.
type(mp_request_type), parameter, public mp_request_null
This module defines the grid data type and some basic operations on it.
subroutine, public pw_grid_setup(cell_hmat, pw_grid, grid_span, cutoff, bounds, bounds_local, npts, spherical, odd, fft_usage, ncommensurate, icommensurate, blocked, ref_grid, rs_dims, iounit)
sets up a pw_grid
subroutine, public pw_grid_create(pw_grid, pe_group, local)
Initialize a PW grid with all defaults.