30 USE iso_c_binding,
ONLY: c_f_pointer,&
53#include "../base/base_uses.f90"
57 CHARACTER(LEN=*),
PARAMETER,
PRIVATE :: moduleN =
'fft_tools'
60 LOGICAL :: fsign = .true.
61 LOGICAL :: trans_in = .false., trans_out = .false., fft_in_place = .false., &
62 valid = .false., separated_plans = .false.
63 INTEGER :: n = -1, m = -1, ldx_in = -1, ldy_in = -1, ldx_out = -1, ldy_out = -1
64 INTEGER,
DIMENSION(3) :: n_3d = -1
71 INTEGER :: nx = 0, ny = 0, nz = 0
72 INTEGER :: lmax = 0, mmax = 0, nmax = 0
73 INTEGER :: mx1 = 0, mx2 = 0, mx3 = 0
74 INTEGER :: my1 = 0, my2 = 0, my3 = 0
75 INTEGER :: mz1 = 0, mz2 = 0, mz3 = 0
76 INTEGER :: mcz1 = 0, mcz2 = 0, mcy3 = 0, mcx2 = 0
77 INTEGER :: lg = 0, mg = 0
78 INTEGER :: nbx = 0, nbz = 0
79 INTEGER :: nmray = 0, nyzray = 0
81 INTEGER,
DIMENSION(2) :: g_pos = 0, r_pos = 0, r_dim = 0
82 INTEGER :: numtask = 0
86 INTEGER :: fft_scratch_id = 0
87 INTEGER :: tf_type = -1
88 LOGICAL :: in_use = .true.
90 INTEGER,
DIMENSION(3) :: nfft = -1
93 INTEGER,
DIMENSION(2) :: dim = -1, pos = -1
95 COMPLEX(KIND=dp),
DIMENSION(:, :, :),
POINTER,
CONTIGUOUS &
96 :: ziptr => null(), zoptr => null()
98 COMPLEX(KIND=dp),
DIMENSION(:, :),
CONTIGUOUS,
POINTER &
99 :: p1buf => null(), p2buf => null(), p3buf => null(), p4buf => null(), &
100 p5buf => null(), p6buf => null(), p7buf => null()
102 COMPLEX(KIND=dp),
DIMENSION(:, :),
POINTER,
CONTIGUOUS &
103 :: r1buf => null(), r2buf => null()
104 COMPLEX(KIND=dp),
DIMENSION(:, :, :),
POINTER,
CONTIGUOUS &
107 COMPLEX(KIND=dp),
DIMENSION(:, :),
POINTER,
CONTIGUOUS &
108 :: a1buf => null(), a2buf => null(), a3buf => null(), &
109 a4buf => null(), a5buf => null(), a6buf => null()
111 INTEGER,
DIMENSION(:),
CONTIGUOUS,
POINTER :: scount => null(), rcount => null(), sdispl => null(), rdispl => null()
112 INTEGER,
DIMENSION(:, :),
CONTIGUOUS,
POINTER :: pgcube => null()
113 INTEGER,
DIMENSION(:),
CONTIGUOUS,
POINTER :: xzcount => null(), yzcount => null(), xzdispl => null(), yzdispl => null()
114 INTEGER :: in = 0, mip = -1
115 REAL(kind=
dp) :: rsratio = 1.0_dp
116 COMPLEX(KIND=dp),
DIMENSION(:),
POINTER,
CONTIGUOUS &
117 :: xzbuf => null(), yzbuf => null()
118 COMPLEX(KIND=sp),
DIMENSION(:),
POINTER,
CONTIGUOUS &
119 :: xzbuf_sgl => null(), yzbuf_sgl => null()
120 COMPLEX(KIND=dp),
DIMENSION(:, :),
POINTER,
CONTIGUOUS &
121 :: rbuf1 => null(), rbuf2 => null(), rbuf3 => null(), rbuf4 => null(), &
122 rbuf5 => null(), rbuf6 => null(), rr => null()
123 COMPLEX(KIND=sp),
DIMENSION(:, :),
POINTER,
CONTIGUOUS &
124 :: ss => null(), tt => null()
125 INTEGER,
DIMENSION(:, :),
POINTER,
CONTIGUOUS :: pgrid => null()
126 INTEGER,
DIMENSION(:),
POINTER,
CONTIGUOUS :: xcor => null(), zcor => null(), pzcoord => null()
129 INTEGER :: last_tick = -1
157 INTEGER,
PARAMETER :: fft_radix_allowed = 495, fft_radix_disallowed = 496
160 REAL(kind=
dp),
PARAMETER :: ratio_sparse_alltoall = 0.5_dp
163 LOGICAL,
SAVE :: alltoall_sgl = .false.
172 MODULE PROCEDURE fft3d_s, fft3d_ps, fft3d_pb
190 SUBROUTINE init_fft(fftlib, alltoall, pool_limit, wisdom_file, &
191 plan_style, status, use_guru_interface)
193 INTEGER,
INTENT(IN) :: fftlib
194 LOGICAL,
INTENT(IN) :: alltoall
195 INTEGER,
INTENT(IN) :: pool_limit
196 CHARACTER(LEN=*),
INTENT(IN) :: wisdom_file
197 INTEGER,
INTENT(IN) :: plan_style
198 INTEGER,
INTENT(OUT) :: status
199 LOGICAL,
INTENT(IN),
OPTIONAL :: use_guru_interface
204 IF (
PRESENT(use_guru_interface)) use_guru = use_guru_interface
206 alltoall_sgl = alltoall
209 CALL release_fft_scratch_pool()
225 CHARACTER(LEN=*),
INTENT(IN) :: wisdom_file
229 CALL release_fft_scratch_pool()
251 SUBROUTINE fft_get_lengths(DATA, max_length)
253 INTEGER,
DIMENSION(:),
INTENT(INOUT) :: data
254 INTEGER,
INTENT(INOUT) :: max_length
256 INTEGER :: h, i, j, k, m, maxn, maxn_elevens, &
257 maxn_fives, maxn_sevens, &
258 maxn_thirteens, maxn_threes, &
259 maxn_twos, ndata, nmax, number
260 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: dlocal,
idx
278 DO i = 0, maxn_threes
280 DO k = 0, maxn_sevens
281 DO m = 0, maxn_elevens
282 number = (3**i)*(5**j)*(7**k)*(11**m)
284 IF (number > nmax) cycle
287 IF (number >= maxn) cycle
296 ALLOCATE (dlocal(ndata),
idx(ndata))
302 DO i = 0, maxn_threes
304 DO k = 0, maxn_sevens
305 DO m = 0, maxn_elevens
306 number = (3**i)*(5**j)*(7**k)*(11**m)
308 IF (number > nmax) cycle
311 IF (number >= maxn) cycle
314 dlocal(ndata) = number
321 CALL sortint(dlocal, ndata,
idx)
322 ndata = min(ndata, max_length)
323 DATA(1:ndata) = dlocal(1:ndata)
326 DEALLOCATE (dlocal,
idx)
328 END SUBROUTINE fft_get_lengths
336 SUBROUTINE sortint(iarr, n, index)
338 INTEGER,
INTENT(IN) :: n
339 INTEGER,
INTENT(INOUT) :: iarr(1:n)
340 INTEGER,
INTENT(OUT) :: index(1:n)
342 INTEGER,
PARAMETER :: m = 7, nstack = 50
344 INTEGER :: a, i, ib, ir, istack(1:nstack), itemp, &
345 j, jstack, k, l, temp
362 IF (iarr(i) <= a)
EXIT
363 iarr(i + 1) = iarr(i)
364 index(i + 1) = index(i)
369 IF (jstack == 0)
RETURN
371 l = istack(jstack - 1)
376 iarr(k) = iarr(l + 1)
379 index(k) = index(l + 1)
381 IF (iarr(l + 1) > iarr(ir))
THEN
383 iarr(l + 1) = iarr(ir)
386 index(l + 1) = index(ir)
389 IF (iarr(l) > iarr(ir))
THEN
397 IF (iarr(l + 1) > iarr(l))
THEN
399 iarr(l + 1) = iarr(l)
402 index(l + 1) = index(l)
411 DO WHILE (iarr(i) < a)
415 DO WHILE (iarr(j) > a)
431 IF (jstack > nstack) cpabort(
"Nstack too small in sortint")
432 IF (ir - i + 1 >= j - l)
THEN
434 istack(jstack - 1) = i
437 istack(jstack) = j - 1
438 istack(jstack - 1) = l
445 END SUBROUTINE sortint
458 INTEGER,
INTENT(IN) :: radix_in
459 INTEGER,
INTENT(OUT) :: radix_out
460 INTEGER,
INTENT(IN) :: operation
462 INTEGER,
PARAMETER :: number_of_small_radices = 81
463 INTEGER,
DIMENSION(number_of_small_radices),
PARAMETER :: small_radices = [2, 4, 6, 8, 9, 12,&
464 15, 16, 18, 20, 24, 25, 27, 30, 32, 36, 40, 45, 48, 54, 60, 64, 72, 75, 80, 81, 90, 96, &
465 100, 108, 120, 125, 128, 135, 144, 150, 160, 162, 180, 192, 200, 216, 225, 240, 243, 256, &
466 270, 288, 300, 320, 324, 360, 375, 384, 400, 405, 432, 450, 480, 486, 500, 512, 540, 576, &
467 600, 625, 640, 648, 675, 720, 729, 750, 768, 800, 810, 864, 900, 960, 972, 1000, 1024]
469 INTEGER :: i, iloc, ldata, trial_number
470 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: data
473 ALLOCATE (
DATA(ldata))
476 DATA(1:number_of_small_radices) = small_radices(1:number_of_small_radices)
480 DO trial_number = 1, 2
481 IF (trial_number == 2)
CALL fft_get_lengths(
DATA, ldata)
484 IF (
DATA(i) == radix_in)
THEN
488 IF (operation == fft_radix_allowed)
THEN
490 ELSE IF (
DATA(i) > radix_in)
THEN
498 IF (trial_number == 1)
THEN
505 radix_out = maxval(data)
507 CALL cp_abort(__location__, &
508 "No suitable FFT lengths found! Either enable FFTW or reduce the grid size!")
515 IF (operation == fft_radix_allowed)
THEN
516 IF (
DATA(iloc) == radix_in)
THEN
517 radix_out = fft_radix_allowed
519 radix_out = fft_radix_disallowed
523 IF (
DATA(iloc) == radix_in)
THEN
524 radix_out =
DATA(iloc)
526 IF (abs(
DATA(iloc - 1) - radix_in) <= &
527 abs(
DATA(iloc) - radix_in))
THEN
528 radix_out =
DATA(iloc - 1)
530 radix_out =
DATA(iloc)
535 radix_out =
DATA(iloc)
539 IF (mod(
DATA(i), 2) == 1)
THEN
544 IF (mod(radix_out, 2) == 0)
THEN
546 IF (trial_number == 1)
THEN
549 radix_out = radix_in + 1 - mod(radix_in, 2)
576 LOGICAL,
INTENT(IN) :: fsign, trans_in, trans_out
577 INTEGER,
INTENT(IN) :: ldx_in, ldx_out, n, m
578 COMPLEX(KIND=dp),
DIMENSION(*),
INTENT(INOUT), &
582 plan%trans_in = trans_in
583 plan%trans_out = trans_out
584 IF (plan%trans_in)
THEN
591 IF (plan%trans_out)
THEN
592 plan%ldx_out = ldx_out
595 plan%ldx_out = ldx_out
622 SUBROUTINE fft_create_plan_2d(plan, fsign, trans_in, trans_out, n, m, zin, zout)
624 LOGICAL,
INTENT(IN) :: fsign, trans_in, trans_out
625 INTEGER,
INTENT(IN) :: n(2), m
626 COMPLEX(KIND=dp),
DIMENSION(*),
INTENT(INOUT), &
630 plan%trans_in = trans_in
631 plan%trans_out = trans_out
632 IF (plan%trans_in)
THEN
634 plan%ldy_in = n(1)*n(2)
636 plan%ldx_in = n(1)*n(2)
639 IF (plan%trans_out)
THEN
641 plan%ldy_out = n(1)*n(2)
643 plan%ldx_out = n(1)*n(2)
651 IF (n(1) > 0 .AND. n(2) > 0 .AND. m > 0)
THEN
658 END SUBROUTINE fft_create_plan_2d
671 LOGICAL,
INTENT(IN) :: fsign
672 INTEGER,
DIMENSION(3),
INTENT(IN) :: n
673 COMPLEX(KIND=dp),
DIMENSION(PRODUCT(n)), &
674 INTENT(INOUT),
TARGET :: zin, zout
677 plan%fft_in_place = .false.
692 SUBROUTINE fft_create_plan_3d_inplace(plan, fsign, n, zinout)
695 LOGICAL,
INTENT(IN) :: fsign
696 INTEGER,
DIMENSION(3),
INTENT(IN) :: n
697 COMPLEX(KIND=dp),
DIMENSION(PRODUCT(n)), &
698 INTENT(INOUT),
TARGET :: zinout
701 plan%fft_in_place = .true.
707 END SUBROUTINE fft_create_plan_3d_inplace
716 SUBROUTINE fft_3d(plan, scale, zin, zout)
718 REAL(kind=
dp),
INTENT(IN) :: scale
719 COMPLEX(KIND=dp),
DIMENSION(*),
INTENT(INOUT), &
722 cpassert(.NOT. plan%fft_in_place)
724 IF (all(plan%n_3d > 0))
THEN
725 CALL fft_3d_local(plan%fsign, plan%n_3d, 1, .false., .false., zin, zout)
727 zout(1:product(plan%n_3d)) = zout(1:product(plan%n_3d))*scale
737 SUBROUTINE fft_3d_inplace(plan, scale, zinout)
739 REAL(kind=
dp),
INTENT(IN) :: scale
740 COMPLEX(KIND=dp),
DIMENSION(*),
INTENT(INOUT), &
743 cpassert(plan%fft_in_place)
745 IF (all(plan%n_3d > 0))
THEN
748 zinout(1:product(plan%n_3d)) = zinout(1:product(plan%n_3d))*scale
750 END SUBROUTINE fft_3d_inplace
770 SUBROUTINE fft_1d(plan, zin, zout, scale)
772 COMPLEX(KIND=dp),
DIMENSION(*),
INTENT(INOUT), &
774 REAL(kind=
dp),
INTENT(IN) :: scale
776 IF (plan%n*plan%m > 0)
THEN
777 CALL fft_1d_local(plan%fsign, plan%n, plan%m, plan%trans_in, plan%trans_out, plan%ldx_in, plan%ldx_out, zin, zout)
778 IF (scale /= 1.0_dp) zout(1:plan%n*plan%m) = zout(1:plan%n*plan%m)*scale
790 SUBROUTINE fft_2d(plan, zin, zout, scale)
792 COMPLEX(KIND=dp),
DIMENSION(*),
INTENT(INOUT), &
794 REAL(kind=
dp),
INTENT(IN) :: scale
796 IF (plan%n_3d(1) > 0 .AND. plan%n_3d(2) > 0 .AND. plan%m > 0)
THEN
797 CALL fft_2d_local(plan%fsign, plan%n_3d(1:2), plan%m, plan%trans_in, plan%trans_out, zin, zout)
798 IF (scale /= 1.0_dp) zout(1:plan%n_3d(1)*plan%n_3d(2)*plan%m) = &
799 zout(1:plan%n_3d(1)*plan%n_3d(2)*plan%m)*scale
802 END SUBROUTINE fft_2d
815 SUBROUTINE fft3d_s(fsign, n, zin, zout, debug)
817 LOGICAL,
INTENT(IN) :: fsign
818 INTEGER,
DIMENSION(:),
INTENT(INOUT) :: n
819 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :, :), &
820 INTENT(INOUT),
TARGET :: zin
821 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :, :), &
822 INTENT(INOUT),
OPTIONAL,
TARGET :: zout
823 LOGICAL,
INTENT(IN),
OPTIONAL :: debug
825 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fft3d_s'
827 INTEGER :: handle, ld(3), lo(3), output_unit
828 LOGICAL :: fft_in_place, test
829 REAL(KIND=
dp) :: in_sum, norm, out_sum
832 CALL timeset(routinen, handle)
836 norm = 1.0_dp/real(product(n), kind=
dp)
841 IF (
PRESENT(debug))
THEN
847 IF (
PRESENT(zout))
THEN
848 fft_in_place = .false.
850 fft_in_place = .true.
854 in_sum = sum(abs(zin))
861 IF (n(1) /= ld(1) .OR. n(2) /= ld(2) .OR. n(3) /= ld(3))
THEN
862 cpabort(
"Size and dimension (zin) have to be the same.")
867 IF (fft_in_place)
THEN
869 CALL fft_3d_inplace(fft_scratch%fft_plan(1), norm, zin)
871 CALL fft_3d_inplace(fft_scratch%fft_plan(2), norm, zin)
875 CALL fft_3d(fft_scratch%fft_plan(3), norm, zin, zout)
877 CALL fft_3d(fft_scratch%fft_plan(4), norm, zin, zout)
883 IF (
PRESENT(zout))
THEN
884 lo(1) =
SIZE(zout, 1)
885 lo(2) =
SIZE(zout, 2)
886 lo(3) =
SIZE(zout, 3)
887 IF (n(1) /= lo(1) .OR. n(2) /= lo(2) .OR. n(3) /= lo(3))
THEN
888 cpabort(
"Size and dimension (zout) have to be the same.")
892 IF (test .AND. output_unit > 0)
THEN
893 IF (
PRESENT(zout))
THEN
894 out_sum = sum(abs(zout))
895 WRITE (output_unit,
'(A)')
" Out of place 3D FFT (local) : fft3d_s"
896 WRITE (output_unit,
'(A,T60,3I7)')
" Transform lengths ", n
897 WRITE (output_unit,
'(A,T60,3I7)')
" Input array dimensions ", ld
898 WRITE (output_unit,
'(A,T60,3I7)')
" Output array dimensions ", lo
899 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of input data ", in_sum
900 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of output data ", out_sum
902 out_sum = sum(abs(zin))
903 WRITE (output_unit,
'(A)')
" In place 3D FFT (local) : fft3d_s"
904 WRITE (output_unit,
'(A,T60,3I7)')
" Transform lengths ", n
905 WRITE (output_unit,
'(A,T60,3I7)')
" Input/output array dimensions ", ld
906 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of input data ", in_sum
907 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of output data ", out_sum
911 CALL timestop(handle)
913 END SUBROUTINE fft3d_s
927 SUBROUTINE fft3d_ps(fsign, n, cin, gin, rs_group, yzp, nyzray, &
930 LOGICAL,
INTENT(IN) :: fsign
931 INTEGER,
DIMENSION(:),
INTENT(IN) :: n
932 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :, :), &
934 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
937 INTEGER,
CONTIGUOUS,
DIMENSION(:, :, 0:), &
939 INTEGER,
CONTIGUOUS,
DIMENSION(0:),
INTENT(IN) :: nyzray
940 INTEGER,
CONTIGUOUS,
DIMENSION(:, :, 0:, :), &
942 LOGICAL,
INTENT(IN),
OPTIONAL :: debug
944 CHARACTER(LEN=*),
PARAMETER :: routineN =
'fft3d_ps'
946 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
947 POINTER :: pbuf, qbuf, rbuf, sbuf
948 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :, :), &
950 INTEGER :: g_pos, handle, lg, lmax, mcx2, mcz1, mcz2, mg, mmax, mx1, mx2, my1, mz2, n1, n2, &
951 nmax, numtask, nx, ny, nz, output_unit, r_dim(2), r_pos(2), rp
952 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: p2p
954 REAL(KIND=
dp) :: norm, sum_data
958 CALL timeset(routinen, handle)
961 IF (
PRESENT(debug))
THEN
967 g_pos = rs_group%mepos
968 numtask = rs_group%num_pe
969 r_dim = rs_group%num_pe_cart
970 r_pos = rs_group%mepos_cart
973 norm = 1.0_dp/real(product(n), kind=
dp)
990 lmax = max(lg, (nx*ny*nz)/mmax + 1)
992 ALLOCATE (p2p(0:numtask - 1))
994 CALL rs_group%rank_compare(rs_group, p2p)
997 mx1 = bo(2, 1, rp, 1) - bo(1, 1, rp, 1) + 1
998 my1 = bo(2, 2, rp, 1) - bo(1, 2, rp, 1) + 1
999 mx2 = bo(2, 1, rp, 2) - bo(1, 1, rp, 2) + 1
1000 mz2 = bo(2, 3, rp, 2) - bo(1, 3, rp, 2) + 1
1002 n1 = maxval(bo(2, 1, :, 1) - bo(1, 1, :, 1) + 1)
1003 n2 = maxval(bo(2, 2, :, 1) - bo(1, 2, :, 1) + 1)
1004 nmax = max((2*n2)/numtask, 2)*mx2*mz2
1005 nmax = max(nmax, n1*maxval(nyzray))
1006 n1 = maxval(bo(2, 1, :, 2))
1007 n2 = maxval(bo(2, 3, :, 2))
1009 fft_scratch_size%nx = nx
1010 fft_scratch_size%ny = ny
1011 fft_scratch_size%nz = nz
1012 fft_scratch_size%lmax = lmax
1013 fft_scratch_size%mmax = mmax
1014 fft_scratch_size%mx1 = mx1
1015 fft_scratch_size%mx2 = mx2
1016 fft_scratch_size%my1 = my1
1017 fft_scratch_size%mz2 = mz2
1018 fft_scratch_size%lg = lg
1019 fft_scratch_size%mg = mg
1020 fft_scratch_size%nbx = n1
1021 fft_scratch_size%nbz = n2
1022 mcz1 = maxval(bo(2, 3, :, 1) - bo(1, 3, :, 1) + 1)
1023 mcx2 = maxval(bo(2, 1, :, 2) - bo(1, 1, :, 2) + 1)
1024 mcz2 = maxval(bo(2, 3, :, 2) - bo(1, 3, :, 2) + 1)
1025 fft_scratch_size%mcz1 = mcz1
1026 fft_scratch_size%mcx2 = mcx2
1027 fft_scratch_size%mcz2 = mcz2
1028 fft_scratch_size%nmax = nmax
1029 fft_scratch_size%nmray = maxval(nyzray)
1030 fft_scratch_size%nyzray = nyzray(g_pos)
1031 fft_scratch_size%rs_group = rs_group
1032 fft_scratch_size%g_pos = g_pos
1033 fft_scratch_size%r_pos = r_pos
1034 fft_scratch_size%r_dim = r_dim
1035 fft_scratch_size%numtask = numtask
1038 IF (g_pos == 0 .AND. output_unit > 0)
THEN
1039 WRITE (output_unit,
'(A)')
" Parallel 3D FFT : fft3d_ps"
1040 WRITE (output_unit,
'(A,T60,3I7)')
" Transform lengths ", n
1041 WRITE (output_unit,
'(A,T67,2I7)')
" Array dimensions (gin) ", lg, mg
1042 WRITE (output_unit,
'(A,T60,3I7)')
" Array dimensions (cin) ", nx, ny, nz
1046 IF (r_dim(2) > 1)
THEN
1053 IF (r_dim(1) == 1)
THEN
1054 cpabort(
"This processor distribution is not supported.")
1056 CALL get_fft_scratch(fft_scratch, tf_type=300, n=n, fft_sizes=fft_scratch_size)
1062 sum_data = abs(sum(cin))
1063 CALL rs_group%sum(sum_data)
1064 IF (g_pos == 0 .AND. output_unit > 0)
THEN
1065 WRITE (output_unit,
'(A)')
" Two step communication algorithm "
1066 WRITE (output_unit,
'(A,T60,3I7)')
" Transform Z ", n(3), mx1*my1
1067 WRITE (output_unit,
'(A,T60,3I7)')
" Transform Y ", n(2), mx2*mz2
1068 WRITE (output_unit,
'(A,T67,2I7)')
" Transform X ", n(1), nyzray(g_pos)
1069 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(1) ", sum_data
1073 pbuf => fft_scratch%p1buf
1074 qbuf => fft_scratch%p2buf
1077 CALL fft_1d(fft_scratch%fft_plan(1), cin, qbuf, norm)
1079 rbuf => fft_scratch%p3buf
1082 sum_data = abs(sum(qbuf))
1083 CALL rs_group%sum(sum_data)
1084 IF (g_pos == 0 .AND. output_unit > 0)
THEN
1085 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(2) T", sum_data
1090 CALL cube_transpose_2(qbuf, bo(:, :, :, 1), bo(:, :, :, 2), rbuf, fft_scratch)
1093 sum_data = abs(sum(rbuf))
1094 CALL rs_group%sum(sum_data)
1095 IF (g_pos == 0 .AND. output_unit > 0)
THEN
1096 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(3) T", sum_data
1100 pbuf => fft_scratch%p4buf
1103 CALL fft_1d(fft_scratch%fft_plan(2), rbuf, pbuf, 1.0_dp)
1105 qbuf => fft_scratch%p5buf
1108 sum_data = abs(sum(pbuf))
1109 CALL rs_group%sum(sum_data)
1110 IF (g_pos == 0 .AND. output_unit > 0)
THEN
1111 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(4) TS", sum_data
1116 CALL xz_to_yz(pbuf, rs_group, r_dim, g_pos, p2p, yzp, nyzray, &
1117 bo(:, :, :, 2), qbuf, fft_scratch)
1120 sum_data = abs(sum(qbuf))
1121 CALL rs_group%sum(sum_data)
1122 IF (g_pos == 0 .AND. output_unit > 0)
THEN
1123 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(5) TS", sum_data
1128 CALL fft_1d(fft_scratch%fft_plan(3), qbuf, gin, 1.0_dp)
1131 sum_data = abs(sum(gin))
1132 CALL rs_group%sum(sum_data)
1133 IF (g_pos == 0 .AND. output_unit > 0)
THEN
1134 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(6) ", sum_data
1142 sum_data = abs(sum(gin))
1143 CALL rs_group%sum(sum_data)
1144 IF (g_pos == 0 .AND. output_unit > 0)
THEN
1145 WRITE (output_unit,
'(A)')
" Two step communication algorithm "
1146 WRITE (output_unit,
'(A,T67,2I7)')
" Transform X ", n(1), nyzray(g_pos)
1147 WRITE (output_unit,
'(A,T60,3I7)')
" Transform Y ", n(2), mx2*mz2
1148 WRITE (output_unit,
'(A,T60,3I7)')
" Transform Z ", n(3), mx1*my1
1149 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(1) ", sum_data
1153 pbuf => fft_scratch%p7buf
1156 CALL fft_1d(fft_scratch%fft_plan(4), gin, pbuf, norm)
1158 qbuf => fft_scratch%p4buf
1161 sum_data = abs(sum(pbuf))
1162 CALL rs_group%sum(sum_data)
1163 IF (g_pos == 0 .AND. output_unit > 0)
THEN
1164 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(2) TS", sum_data
1169 CALL yz_to_xz(pbuf, rs_group, r_dim, g_pos, p2p, yzp, nyzray, &
1170 bo(:, :, :, 2), qbuf, fft_scratch)
1173 sum_data = abs(sum(qbuf))
1174 CALL rs_group%sum(sum_data)
1175 IF (g_pos == 0 .AND. output_unit > 0)
THEN
1176 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(3) TS", sum_data
1180 rbuf => fft_scratch%p3buf
1183 CALL fft_1d(fft_scratch%fft_plan(5), qbuf, rbuf, 1.0_dp)
1185 pbuf => fft_scratch%p2buf
1188 sum_data = abs(sum(rbuf))
1189 CALL rs_group%sum(sum_data)
1190 IF (g_pos == 0 .AND. output_unit > 0)
THEN
1191 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(4) T", sum_data
1196 CALL cube_transpose_1(rbuf, bo(:, :, :, 2), bo(:, :, :, 1), pbuf, fft_scratch)
1199 sum_data = abs(sum(pbuf))
1200 CALL rs_group%sum(sum_data)
1201 IF (g_pos == 0 .AND. output_unit > 0)
THEN
1202 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(5) T", sum_data
1206 qbuf => fft_scratch%p1buf
1209 CALL fft_1d(fft_scratch%fft_plan(6), pbuf, cin, 1.0_dp)
1212 sum_data = abs(sum(cin))
1213 CALL rs_group%sum(sum_data)
1214 IF (g_pos == 0 .AND. output_unit > 0)
THEN
1215 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(6) ", sum_data
1230 CALL get_fft_scratch(fft_scratch, tf_type=200, n=n, fft_sizes=fft_scratch_size)
1232 sbuf => fft_scratch%r1buf
1233 tbuf => fft_scratch%tbuf
1242 sum_data = abs(sum(cin))
1243 CALL rs_group%sum(sum_data)
1244 IF (g_pos == 0 .AND. output_unit > 0)
THEN
1245 WRITE (output_unit,
'(A)')
" One step communication algorithm "
1246 WRITE (output_unit,
'(A,T60,3I7)')
" Transform YZ ", n(2), n(3), nx
1247 WRITE (output_unit,
'(A,T67,2I7)')
" Transform X ", n(1), nyzray(g_pos)
1248 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(1) ", sum_data
1253 CALL fft_2d(fft_scratch%fft_plan(1), cin, tbuf, 1._dp)
1256 sum_data = abs(sum(tbuf))
1257 CALL rs_group%sum(sum_data)
1258 IF (g_pos == 0 .AND. output_unit > 0)
THEN
1259 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(2) TS", sum_data
1264 CALL yz_to_x(tbuf, rs_group, g_pos, p2p, yzp, nyzray, &
1265 bo(:, :, :, 2), sbuf, fft_scratch)
1268 sum_data = abs(sum(sbuf))
1269 CALL rs_group%sum(sum_data)
1270 IF (g_pos == 0 .AND. output_unit > 0)
THEN
1271 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(3) TS", sum_data
1275 CALL fft_1d(fft_scratch%fft_plan(3), sbuf, gin, norm)
1278 sum_data = abs(sum(gin))
1279 CALL rs_group%sum(sum_data)
1280 IF (g_pos == 0 .AND. output_unit > 0)
THEN
1281 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(4) ", sum_data
1289 sum_data = abs(sum(gin))
1290 CALL rs_group%sum(sum_data)
1291 IF (g_pos == 0 .AND. output_unit > 0)
THEN
1292 WRITE (output_unit,
'(A)')
" One step communication algorithm "
1293 WRITE (output_unit,
'(A,T67,2I7)')
" Transform X ", n(1), nyzray(g_pos)
1294 WRITE (output_unit,
'(A,T60,3I7)')
" Transform YZ ", n(2), n(3), nx
1295 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(1) ", sum_data
1300 CALL fft_1d(fft_scratch%fft_plan(4), gin, sbuf, norm)
1303 sum_data = abs(sum(sbuf))
1304 CALL rs_group%sum(sum_data)
1305 IF (g_pos == 0 .AND. output_unit > 0)
THEN
1306 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(2) TS", sum_data
1311 CALL x_to_yz(sbuf, rs_group, g_pos, p2p, yzp, nyzray, &
1312 bo(:, :, :, 2), tbuf, fft_scratch)
1315 sum_data = abs(sum(tbuf))
1316 CALL rs_group%sum(sum_data)
1317 IF (g_pos == 0 .AND. output_unit > 0)
THEN
1318 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(3) TS", sum_data
1323 CALL fft_2d(fft_scratch%fft_plan(5), tbuf, cin, 1._dp)
1326 sum_data = abs(sum(cin))
1327 CALL rs_group%sum(sum_data)
1328 IF (g_pos == 0 .AND. output_unit > 0)
THEN
1329 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(4) ", sum_data
1340 CALL timestop(handle)
1342 END SUBROUTINE fft3d_ps
1354 SUBROUTINE fft3d_pb(fsign, n, zin, gin, group, bo, debug)
1356 LOGICAL,
INTENT(IN) :: fsign
1357 INTEGER,
DIMENSION(3),
INTENT(IN) :: n
1358 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :, :), &
1359 INTENT(INOUT) :: zin
1360 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
1361 INTENT(INOUT) :: gin
1363 INTEGER,
CONTIGUOUS,
DIMENSION(:, :, 0:, :), &
1365 LOGICAL,
INTENT(IN),
OPTIONAL :: debug
1367 CHARACTER(LEN=*),
PARAMETER :: routineN =
'fft3d_pb'
1369 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
1370 POINTER :: abuf, bbuf
1371 INTEGER :: handle, lg(2), lz(3), mcx2, mcy3, mcz1, &
1372 mcz2, mx1, mx2, mx3, my1, my2, my3, &
1373 my_pos, mz1, mz2, mz3, output_unit
1374 INTEGER,
DIMENSION(2) :: dim
1376 REAL(KIND=
dp) :: norm, sum_data
1400 CALL timeset(routinen, handle)
1403 dim = group%num_pe_cart
1404 my_pos = group%mepos
1406 IF (
PRESENT(debug))
THEN
1413 norm = 1.0_dp/real(product(n), kind=
dp)
1419 lg(1) =
SIZE(gin, 1)
1420 lg(2) =
SIZE(gin, 2)
1421 lz(1) =
SIZE(zin, 1)
1422 lz(2) =
SIZE(zin, 2)
1423 lz(3) =
SIZE(zin, 3)
1424 IF (my_pos == 0 .AND. output_unit > 0)
THEN
1425 WRITE (output_unit,
'(A)')
" Parallel 3D FFT : fft3d_pb"
1426 WRITE (output_unit,
'(A,T60,3I7)')
" Transform lengths ", n
1427 WRITE (output_unit,
'(A,T67,2I7)')
" Array dimensions (gin) ", lg
1428 WRITE (output_unit,
'(A,T60,3I7)')
" Array dimensions (cin) ", lz
1432 mx1 = bo(2, 1, my_pos, 1) - bo(1, 1, my_pos, 1) + 1
1433 my1 = bo(2, 2, my_pos, 1) - bo(1, 2, my_pos, 1) + 1
1434 mz1 = bo(2, 3, my_pos, 1) - bo(1, 3, my_pos, 1) + 1
1435 mx2 = bo(2, 1, my_pos, 2) - bo(1, 1, my_pos, 2) + 1
1436 my2 = bo(2, 2, my_pos, 2) - bo(1, 2, my_pos, 2) + 1
1437 mz2 = bo(2, 3, my_pos, 2) - bo(1, 3, my_pos, 2) + 1
1438 mx3 = bo(2, 1, my_pos, 3) - bo(1, 1, my_pos, 3) + 1
1439 my3 = bo(2, 2, my_pos, 3) - bo(1, 2, my_pos, 3) + 1
1440 mz3 = bo(2, 3, my_pos, 3) - bo(1, 3, my_pos, 3) + 1
1441 fft_scratch_size%mx1 = mx1
1442 fft_scratch_size%mx2 = mx2
1443 fft_scratch_size%mx3 = mx3
1444 fft_scratch_size%my1 = my1
1445 fft_scratch_size%my2 = my2
1446 fft_scratch_size%my3 = my3
1447 fft_scratch_size%mz1 = mz1
1448 fft_scratch_size%mz2 = mz2
1449 fft_scratch_size%mz3 = mz3
1450 mcz1 = maxval(bo(2, 3, :, 1) - bo(1, 3, :, 1) + 1)
1451 mcx2 = maxval(bo(2, 1, :, 2) - bo(1, 1, :, 2) + 1)
1452 mcz2 = maxval(bo(2, 3, :, 2) - bo(1, 3, :, 2) + 1)
1453 mcy3 = maxval(bo(2, 2, :, 3) - bo(1, 2, :, 3) + 1)
1454 fft_scratch_size%mcz1 = mcz1
1455 fft_scratch_size%mcx2 = mcx2
1456 fft_scratch_size%mcz2 = mcz2
1457 fft_scratch_size%mcy3 = mcy3
1458 fft_scratch_size%rs_group = group
1459 fft_scratch_size%g_pos = my_pos
1460 fft_scratch_size%numtask = dim(1)*dim(2)
1462 IF (dim(1) > 1 .AND. dim(2) > 1)
THEN
1468 CALL get_fft_scratch(fft_scratch, tf_type=100, n=n, fft_sizes=fft_scratch_size)
1473 bbuf => fft_scratch%a2buf
1476 sum_data = abs(sum(zin))
1477 CALL group%sum(sum_data)
1478 IF (my_pos == 0 .AND. output_unit > 0)
THEN
1479 WRITE (output_unit,
'(A)')
" Two step communication algorithm "
1480 WRITE (output_unit,
'(A,T67,2I7)')
" Transform Z ", n(3), mx1*my1
1481 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(1) ", sum_data
1486 CALL fft_1d(fft_scratch%fft_plan(1), zin, bbuf, norm)
1488 abuf => fft_scratch%a3buf
1491 sum_data = abs(sum(bbuf))
1492 CALL group%sum(sum_data)
1493 IF (my_pos == 0 .AND. output_unit > 0)
THEN
1494 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(2) T", sum_data
1498 CALL cube_transpose_2(bbuf, bo(:, :, :, 1), bo(:, :, :, 2), abuf, fft_scratch)
1500 bbuf => fft_scratch%a4buf
1503 sum_data = abs(sum(abuf))
1504 CALL group%sum(sum_data)
1505 IF (my_pos == 0 .AND. output_unit > 0)
THEN
1506 WRITE (output_unit,
'(A,T67,2I7)')
" Transform Y ", n(2), mx2*mz2
1507 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(3) ", sum_data
1512 CALL fft_1d(fft_scratch%fft_plan(2), abuf, bbuf, 1.0_dp)
1514 abuf => fft_scratch%a5buf
1517 sum_data = abs(sum(bbuf))
1518 CALL group%sum(sum_data)
1519 IF (my_pos == 0 .AND. output_unit > 0)
THEN
1520 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(4) T", sum_data
1524 CALL cube_transpose_4(bbuf, bo(:, :, :, 2), bo(:, :, :, 3), abuf, fft_scratch)
1527 sum_data = abs(sum(abuf))
1528 CALL group%sum(sum_data)
1529 IF (my_pos == 0 .AND. output_unit > 0)
THEN
1530 WRITE (output_unit,
'(A,T67,2I7)')
" Transform X ", n(1), my3*mz3
1531 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(5) ", sum_data
1536 CALL fft_1d(fft_scratch%fft_plan(3), abuf, gin, 1.0_dp)
1539 sum_data = abs(sum(gin))
1540 CALL group%sum(sum_data)
1541 IF (my_pos == 0 .AND. output_unit > 0)
THEN
1542 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(6) ", sum_data
1549 bbuf => fft_scratch%a5buf
1552 sum_data = abs(sum(gin))
1553 CALL group%sum(sum_data)
1554 IF (my_pos == 0 .AND. output_unit > 0)
THEN
1555 WRITE (output_unit,
'(A)')
" Two step communication algorithm "
1556 WRITE (output_unit,
'(A,T67,2I7)')
" Transform X ", n(1), my3*mz3
1557 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(1) ", sum_data
1562 CALL fft_1d(fft_scratch%fft_plan(4), gin, bbuf, 1.0_dp)
1564 abuf => fft_scratch%a4buf
1567 sum_data = abs(sum(bbuf))
1568 CALL group%sum(sum_data)
1569 IF (my_pos == 0 .AND. output_unit > 0)
THEN
1570 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(2) T", sum_data
1574 CALL cube_transpose_3(bbuf, bo(:, :, :, 3), bo(:, :, :, 2), abuf, fft_scratch)
1576 bbuf => fft_scratch%a3buf
1579 sum_data = abs(sum(abuf))
1580 CALL group%sum(sum_data)
1581 IF (my_pos == 0 .AND. output_unit > 0)
THEN
1582 WRITE (output_unit,
'(A,T67,2I7)')
" Transform Y ", n(2), mx2*mz2
1583 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(3) ", sum_data
1588 CALL fft_1d(fft_scratch%fft_plan(5), abuf, bbuf, 1.0_dp)
1590 abuf => fft_scratch%a2buf
1593 sum_data = abs(sum(bbuf))
1594 CALL group%sum(sum_data)
1595 IF (my_pos == 0 .AND. output_unit > 0)
THEN
1596 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(4) T", sum_data
1600 CALL cube_transpose_1(bbuf, bo(:, :, :, 2), bo(:, :, :, 1), abuf, fft_scratch)
1603 sum_data = abs(sum(abuf))
1604 CALL group%sum(sum_data)
1605 IF (my_pos == 0 .AND. output_unit > 0)
THEN
1606 WRITE (output_unit,
'(A,T67,2I7)')
" Transform Z ", n(3), mx1*my1
1607 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(5) ", sum_data
1612 CALL fft_1d(fft_scratch%fft_plan(6), abuf, zin, norm)
1615 sum_data = abs(sum(zin))
1616 CALL group%sum(sum_data)
1617 IF (my_pos == 0 .AND. output_unit > 0)
THEN
1618 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(6) ", sum_data
1625 ELSE IF (dim(2) == 1)
THEN
1631 CALL get_fft_scratch(fft_scratch, tf_type=101, n=n, fft_sizes=fft_scratch_size)
1637 sum_data = abs(sum(zin))
1638 CALL group%sum(sum_data)
1639 IF (my_pos == 0 .AND. output_unit > 0)
THEN
1640 WRITE (output_unit,
'(A)')
" one step communication algorithm "
1641 WRITE (output_unit,
'(A,T67,2I7)')
" Transform Z ", n(3), mx1*my1
1642 WRITE (output_unit,
'(A,T67,2I7)')
" Transform Y ", n(2), mx1*mz1
1643 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(1) ", sum_data
1647 bbuf => fft_scratch%a4buf
1649 CALL fft_2d(fft_scratch%fft_plan(1), zin, bbuf, norm)
1651 abuf => fft_scratch%a5buf
1654 sum_data = abs(sum(bbuf))
1655 CALL group%sum(sum_data)
1656 IF (my_pos == 0 .AND. output_unit > 0)
THEN
1657 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(2) T", sum_data
1661 CALL cube_transpose_6(bbuf, group, bo(:, :, :, 1), bo(:, :, :, 3), abuf, fft_scratch)
1664 sum_data = abs(sum(abuf))
1665 CALL group%sum(sum_data)
1666 IF (my_pos == 0 .AND. output_unit > 0)
THEN
1667 WRITE (output_unit,
'(A,T67,2I7)')
" Transform X ", n(1), my3*mz3
1668 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(3) ", sum_data
1673 CALL fft_1d(fft_scratch%fft_plan(3), abuf, gin, 1.0_dp)
1676 sum_data = abs(sum(gin))
1677 CALL group%sum(sum_data)
1678 IF (my_pos == 0 .AND. output_unit > 0)
THEN
1679 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(4) ", sum_data
1687 sum_data = abs(sum(gin))
1688 CALL group%sum(sum_data)
1689 IF (my_pos == 0 .AND. output_unit > 0)
THEN
1690 WRITE (output_unit,
'(A)')
" one step communication algorithm "
1691 WRITE (output_unit,
'(A,T67,2I7)')
" Transform X ", n(1), my3*mz3
1692 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(1) ", sum_data
1696 bbuf => fft_scratch%a5buf
1699 CALL fft_1d(fft_scratch%fft_plan(4), gin, bbuf, 1.0_dp)
1701 abuf => fft_scratch%a4buf
1704 sum_data = abs(sum(bbuf))
1705 CALL group%sum(sum_data)
1706 IF (my_pos == 0 .AND. output_unit > 0)
THEN
1707 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(2) T", sum_data
1711 CALL cube_transpose_5(bbuf, group, bo(:, :, :, 3), bo(:, :, :, 1), abuf, fft_scratch)
1714 sum_data = abs(sum(abuf))
1715 CALL group%sum(sum_data)
1716 IF (my_pos == 0 .AND. output_unit > 0)
THEN
1717 WRITE (output_unit,
'(A,T67,2I7)')
" Transform Y ", n(2), mx1*mz1
1718 WRITE (output_unit,
'(A,T67,2I7)')
" Transform Z ", n(3), mx1*my1
1719 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(3) ", sum_data
1724 CALL fft_2d(fft_scratch%fft_plan(5), abuf, zin, norm)
1727 sum_data = abs(sum(zin))
1728 CALL group%sum(sum_data)
1729 IF (my_pos == 0 .AND. output_unit > 0)
THEN
1730 WRITE (output_unit,
'(A,T61,E20.14)')
" Sum of data(4) ", sum_data
1739 cpabort(
"Partition not implemented.")
1743 CALL timestop(handle)
1745 END SUBROUTINE fft3d_pb
1762 SUBROUTINE x_to_yz(sb, group, my_pos, p2p, yzp, nray, bo, tb, fft_scratch)
1764 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
1767 INTEGER,
INTENT(IN) :: my_pos
1768 INTEGER,
CONTIGUOUS,
DIMENSION(0:),
INTENT(IN) :: p2p
1769 INTEGER,
CONTIGUOUS,
DIMENSION(:, :, 0:), &
1771 INTEGER,
CONTIGUOUS,
DIMENSION(0:),
INTENT(IN) :: nray
1772 INTEGER,
CONTIGUOUS,
DIMENSION(:, :, 0:), &
1774 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :, :), &
1778 CHARACTER(LEN=*),
PARAMETER :: routinen =
'x_to_yz'
1780 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
1782 COMPLEX(KIND=sp),
CONTIGUOUS,
DIMENSION(:, :), &
1784 INTEGER :: handle, ip, ir, ix, ixx, iy, iz, mpr, &
1786 INTEGER,
CONTIGUOUS,
DIMENSION(:),
POINTER :: rcount, rdispl, scount, sdispl
1788 CALL timeset(routinen, handle)
1791 scount => fft_scratch%scount
1792 rcount => fft_scratch%rcount
1793 sdispl => fft_scratch%sdispl
1794 rdispl => fft_scratch%rdispl
1796 IF (alltoall_sgl)
THEN
1797 ss => fft_scratch%ss
1798 tt => fft_scratch%tt
1799 ss(:, :) = cmplx(sb(:, :), kind=
sp)
1802 rr => fft_scratch%rr
1806 nm = maxval(nray(0:np - 1))
1813 nx = bo(2, 1, ix) - bo(1, 1, ix) + 1
1815 sdispl(ip) = nr*(bo(1, 1, ix) - 1)
1818 nx = bo(2, 1, mpr) - bo(1, 1, mpr) + 1
1825 rdispl(ip) = nm*nx*ip
1828 IF (alltoall_sgl)
THEN
1829 CALL group%alltoall(ss, scount, sdispl, tt, rcount, rdispl)
1831 CALL group%alltoall(sb, scount, sdispl, rr, rcount, rdispl)
1834 nx = bo(2, 1, mpr) - bo(1, 1, mpr) + 1
1840 ixx = nray(ip)*(ix - 1)
1841 IF (alltoall_sgl)
THEN
1845 tb(iy, iz, ix) = tt(ir + ixx, ip)
1851 tb(iy, iz, ix) = rr(ir + ixx, ip)
1858 CALL timestop(handle)
1877 SUBROUTINE yz_to_x(tb, group, my_pos, p2p, yzp, nray, bo, sb, fft_scratch)
1879 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :, :), &
1882 INTEGER,
INTENT(IN) :: my_pos
1883 INTEGER,
CONTIGUOUS,
DIMENSION(0:),
INTENT(IN) :: p2p
1884 INTEGER,
CONTIGUOUS,
DIMENSION(:, :, 0:), &
1886 INTEGER,
CONTIGUOUS,
DIMENSION(0:),
INTENT(IN) :: nray
1887 INTEGER,
DIMENSION(:, :, 0:),
INTENT(IN) :: bo
1888 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
1892 CHARACTER(LEN=*),
PARAMETER :: routinen =
'yz_to_x'
1894 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
1896 COMPLEX(KIND=sp),
CONTIGUOUS,
DIMENSION(:, :), &
1898 INTEGER :: handle, ip, ir, ix, ixx, iy, iz, mpr, &
1900 INTEGER,
CONTIGUOUS,
DIMENSION(:),
POINTER :: rcount, rdispl, scount, sdispl
1902 CALL timeset(routinen, handle)
1906 scount => fft_scratch%scount
1907 rcount => fft_scratch%rcount
1908 sdispl => fft_scratch%sdispl
1909 rdispl => fft_scratch%rdispl
1911 IF (alltoall_sgl)
THEN
1912 ss => fft_scratch%ss
1913 tt => fft_scratch%tt
1917 rr => fft_scratch%rr
1920 nx = bo(2, 1, mpr) - bo(1, 1, mpr) + 1
1926 ixx = nray(ip)*(ix - 1)
1927 IF (alltoall_sgl)
THEN
1931 tt(ir + ixx, ip) = cmplx(tb(iy, iz, ix), kind=
sp)
1937 rr(ir + ixx, ip) = tb(iy, iz, ix)
1943 nm = maxval(nray(0:np - 1))
1950 nx = bo(2, 1, ix) - bo(1, 1, ix) + 1
1952 rdispl(ip) = nr*(bo(1, 1, ix) - 1)
1955 nx = bo(2, 1, mpr) - bo(1, 1, mpr) + 1
1962 sdispl(ip) = nm*nx*ip
1966 IF (alltoall_sgl)
THEN
1967 CALL group%alltoall(tt, scount, sdispl, ss, rcount, rdispl)
1970 CALL group%alltoall(rr, scount, sdispl, sb, rcount, rdispl)
1973 CALL timestop(handle)
1993 SUBROUTINE yz_to_xz(sb, group, dims, my_pos, p2p, yzp, nray, bo, tb, fft_scratch)
1995 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
1998 INTEGER,
DIMENSION(2),
INTENT(IN) :: dims
1999 INTEGER,
INTENT(IN) :: my_pos
2000 INTEGER,
CONTIGUOUS,
DIMENSION(0:),
INTENT(IN) :: p2p
2001 INTEGER,
CONTIGUOUS,
DIMENSION(:, :, 0:), &
2003 INTEGER,
CONTIGUOUS,
DIMENSION(0:),
INTENT(IN) :: nray
2004 INTEGER,
CONTIGUOUS,
DIMENSION(:, :, 0:), &
2006 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
2010 CHARACTER(LEN=*),
PARAMETER :: routinen =
'yz_to_xz'
2012 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:), &
2013 POINTER :: xzbuf, yzbuf
2014 COMPLEX(KIND=sp),
CONTIGUOUS,
DIMENSION(:), &
2015 POINTER :: xzbuf_sgl, yzbuf_sgl
2016 INTEGER :: handle, icrs, ip, ipl, ipr, ir, ix, iz, &
2017 jj, jx, jy, jz, myx, myz, np, npx, &
2019 INTEGER,
CONTIGUOUS,
DIMENSION(:),
POINTER :: pzcoord, rcount, rdispl, scount, sdispl, &
2021 INTEGER,
CONTIGUOUS,
DIMENSION(:, :),
POINTER :: pgrid
2023 CALL timeset(routinen, handle)
2027 rs_pos = p2p(my_pos)
2029 IF (alltoall_sgl)
THEN
2030 yzbuf_sgl => fft_scratch%yzbuf_sgl
2031 xzbuf_sgl => fft_scratch%xzbuf_sgl
2033 yzbuf => fft_scratch%yzbuf
2034 xzbuf => fft_scratch%xzbuf
2038 pgrid => fft_scratch%pgrid
2039 xcor => fft_scratch%xcor
2040 zcor => fft_scratch%zcor
2041 pzcoord => fft_scratch%pzcoord
2042 scount => fft_scratch%scount
2043 rcount => fft_scratch%rcount
2044 sdispl => fft_scratch%sdispl
2045 rdispl => fft_scratch%rdispl
2051 IF (fft_scratch%in == 0)
THEN
2057 xcor(bo(1, 1, ip):bo(2, 1, ip)) = ix
2061 zcor(bo(1, 3, ip):bo(2, 3, ip)) = iz
2064 IF (alltoall_sgl)
THEN
2065 DO ir = 1, nray(my_pos)
2066 jy = yzp(1, ir, my_pos)
2067 jz = yzp(2, ir, my_pos)
2068 ip = pgrid(xcor(jx), zcor(jz))
2069 scount(ip) = scount(ip) + 1
2072 DO ir = 1, nray(my_pos)
2073 jy = yzp(1, ir, my_pos)
2074 jz = yzp(2, ir, my_pos)
2075 ip = pgrid(xcor(jx), zcor(jz))
2076 scount(ip) = scount(ip) + 1
2081 CALL group%alltoall(scount, rcount, 1)
2082 fft_scratch%yzcount = scount
2083 fft_scratch%xzcount = rcount
2089 sdispl(ip) = sdispl(ip - 1) + scount(ip - 1)
2090 rdispl(ip) = rdispl(ip - 1) + rcount(ip - 1)
2093 fft_scratch%yzdispl = sdispl
2094 fft_scratch%xzdispl = rdispl
2098 IF (scount(ip) /= 0) icrs = icrs + 1
2099 IF (rcount(ip) /= 0) icrs = icrs + 1
2101 CALL group%sum(icrs)
2102 fft_scratch%rsratio = real(icrs, kind=
dp)/(real(2*np, kind=
dp)*real(np, kind=
dp))
2106 scount = fft_scratch%yzcount
2107 rcount = fft_scratch%xzcount
2108 sdispl = fft_scratch%yzdispl
2109 rdispl = fft_scratch%xzdispl
2119 IF (scount(ip) == 0) cycle
2122 nx = bo(2, 1, ipl) - bo(1, 1, ipl) + 1
2123 DO ir = 1, nray(my_pos)
2124 jz = yzp(2, ir, my_pos)
2125 IF (zcor(jz) == pzcoord(ipl))
THEN
2127 jy = yzp(1, ir, my_pos)
2128 IF (alltoall_sgl)
THEN
2130 yzbuf_sgl(sdispl(ip) + jj + jx*scount(ip)/nx) = cmplx(sb(ir, jx + bo(1, 1, ipl)), kind=
sp)
2134 yzbuf(sdispl(ip) + jj + jx*scount(ip)/nx) = sb(ir, jx + bo(1, 1, ipl))
2142 IF (alltoall_sgl)
THEN
2143 CALL group%alltoall(yzbuf_sgl, scount, sdispl, xzbuf_sgl, rcount, rdispl)
2145 IF (fft_scratch%rsratio < ratio_sparse_alltoall)
THEN
2146 CALL sparse_alltoall(yzbuf, scount, sdispl, xzbuf, rcount, rdispl, group)
2148 CALL group%alltoall(yzbuf, scount, sdispl, xzbuf, rcount, rdispl)
2152 myx = fft_scratch%sizes%r_pos(1)
2153 myz = fft_scratch%sizes%r_pos(2)
2154 nz = bo(2, 3, rs_pos) - bo(1, 3, rs_pos) + 1
2164 DO jx = 0, bo(2, 1, rs_pos) - bo(1, 1, rs_pos)
2167 IF (alltoall_sgl)
THEN
2168 IF (zcor(jz) == myz)
THEN
2171 jz = jz - bo(1, 3, rs_pos) + 1
2172 tb(jy, jz + jx*nz) = xzbuf_sgl(jj + rdispl(ipr))
2175 IF (zcor(jz) == myz)
THEN
2178 jz = jz - bo(1, 3, rs_pos) + 1
2179 tb(jy, jz + jx*nz) = xzbuf(jj + rdispl(ipr))
2187 CALL timestop(handle)
2207 SUBROUTINE xz_to_yz(sb, group, dims, my_pos, p2p, yzp, nray, bo, tb, fft_scratch)
2209 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
2212 INTEGER,
DIMENSION(2),
INTENT(IN) :: dims
2213 INTEGER,
INTENT(IN) :: my_pos
2214 INTEGER,
CONTIGUOUS,
DIMENSION(0:),
INTENT(IN) :: p2p
2215 INTEGER,
CONTIGUOUS,
DIMENSION(:, :, 0:), &
2217 INTEGER,
CONTIGUOUS,
DIMENSION(0:),
INTENT(IN) :: nray
2218 INTEGER,
CONTIGUOUS,
DIMENSION(:, :, 0:), &
2220 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
2224 CHARACTER(LEN=*),
PARAMETER :: routinen =
'xz_to_yz'
2226 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:), &
2227 POINTER :: xzbuf, yzbuf
2228 COMPLEX(KIND=sp),
CONTIGUOUS,
DIMENSION(:), &
2229 POINTER :: xzbuf_sgl, yzbuf_sgl
2230 INTEGER :: handle, icrs, ip, ipl, ir, ix, ixx, iz, &
2231 jj, jx, jy, jz, mp, myx, myz, np, npx, &
2233 INTEGER,
CONTIGUOUS,
DIMENSION(:),
POINTER :: pzcoord, rcount, rdispl, scount, sdispl, &
2235 INTEGER,
CONTIGUOUS,
DIMENSION(:, :),
POINTER :: pgrid
2237 CALL timeset(routinen, handle)
2241 IF (alltoall_sgl)
THEN
2242 yzbuf_sgl => fft_scratch%yzbuf_sgl
2243 xzbuf_sgl => fft_scratch%xzbuf_sgl
2245 yzbuf => fft_scratch%yzbuf
2246 xzbuf => fft_scratch%xzbuf
2250 pgrid => fft_scratch%pgrid
2251 xcor => fft_scratch%xcor
2252 zcor => fft_scratch%zcor
2253 pzcoord => fft_scratch%pzcoord
2254 scount => fft_scratch%scount
2255 rcount => fft_scratch%rcount
2256 sdispl => fft_scratch%sdispl
2257 rdispl => fft_scratch%rdispl
2261 IF (fft_scratch%in == 0)
THEN
2264 nx = maxval(bo(2, 1, :))
2268 xcor(bo(1, 1, ip):bo(2, 1, ip)) = ix
2272 zcor(bo(1, 3, ip):bo(2, 3, ip)) = iz
2275 DO ir = 1, nray(my_pos)
2276 jy = yzp(1, ir, my_pos)
2277 jz = yzp(2, ir, my_pos)
2278 ip = pgrid(xcor(jx), zcor(jz))
2279 rcount(ip) = rcount(ip) + 1
2283 CALL group%alltoall(rcount, scount, 1)
2284 fft_scratch%xzcount = scount
2285 fft_scratch%yzcount = rcount
2291 sdispl(ip) = sdispl(ip - 1) + scount(ip - 1)
2292 rdispl(ip) = rdispl(ip - 1) + rcount(ip - 1)
2295 fft_scratch%xzdispl = sdispl
2296 fft_scratch%yzdispl = rdispl
2300 IF (scount(ip) /= 0) icrs = icrs + 1
2301 IF (rcount(ip) /= 0) icrs = icrs + 1
2303 CALL group%sum(icrs)
2304 fft_scratch%rsratio = real(icrs, kind=
dp)/(real(2*np, kind=
dp)*real(np, kind=
dp))
2308 scount = fft_scratch%xzcount
2309 rcount = fft_scratch%yzcount
2310 sdispl = fft_scratch%xzdispl
2311 rdispl = fft_scratch%yzdispl
2315 myx = fft_scratch%sizes%r_pos(1)
2316 myz = fft_scratch%sizes%r_pos(2)
2318 nz = bo(2, 3, mp) - bo(1, 3, mp) + 1
2319 nx = bo(2, 1, mp) - bo(1, 1, mp) + 1
2331 IF (zcor(jz) == myz)
THEN
2334 jz = yzp(2, ir, ip) - bo(1, 3, mp) + 1
2335 IF (alltoall_sgl)
THEN
2337 ixx = jj + jx*scount(ipl)/nx
2338 xzbuf_sgl(ixx + sdispl(ipl)) = cmplx(sb(jy, jz + jx*nz), kind=
sp)
2342 ixx = jj + jx*scount(ipl)/nx
2343 xzbuf(ixx + sdispl(ipl)) = sb(jy, jz + jx*nz)
2351 IF (alltoall_sgl)
THEN
2352 CALL group%alltoall(xzbuf_sgl, scount, sdispl, yzbuf_sgl, rcount, rdispl)
2354 IF (fft_scratch%rsratio < ratio_sparse_alltoall)
THEN
2355 CALL sparse_alltoall(xzbuf, scount, sdispl, yzbuf, rcount, rdispl, group)
2357 CALL group%alltoall(xzbuf, scount, sdispl, yzbuf, rcount, rdispl)
2367 IF (rcount(ip) == 0) cycle
2370 nx = bo(2, 1, ipl) - bo(1, 1, ipl) + 1
2371 DO ir = 1, nray(my_pos)
2372 jz = yzp(2, ir, my_pos)
2373 IF (zcor(jz) == pzcoord(ipl))
THEN
2375 jy = yzp(1, ir, my_pos)
2376 IF (alltoall_sgl)
THEN
2378 tb(ir, jx + bo(1, 1, ipl)) = yzbuf_sgl(rdispl(ip) + jj + jx*rcount(ip)/nx)
2382 tb(ir, jx + bo(1, 1, ipl)) = yzbuf(rdispl(ip) + jj + jx*rcount(ip)/nx)
2390 CALL timestop(handle)
2407 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
2409 INTEGER,
CONTIGUOUS,
DIMENSION(:, :, 0:), &
2410 INTENT(IN) :: boin, boout
2411 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
2415 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cube_transpose_1'
2417 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
2419 INTEGER :: handle, ip, ipl, ir, is, ixy, iz, mip, &
2421 INTEGER,
CONTIGUOUS,
DIMENSION(:),
POINTER :: rcount, rdispl, scount, sdispl
2422 INTEGER,
CONTIGUOUS,
DIMENSION(:, :),
POINTER :: pgrid
2423 INTEGER,
DIMENSION(2) :: dim, pos
2425 CALL timeset(routinen, handle)
2427 mip = fft_scratch%mip
2428 dim = fft_scratch%dim
2429 pos = fft_scratch%pos
2430 scount => fft_scratch%scount
2431 rcount => fft_scratch%rcount
2432 sdispl => fft_scratch%sdispl
2433 rdispl => fft_scratch%rdispl
2434 pgrid => fft_scratch%pgcube
2437 nx = boin(2, 1, mip) - boin(1, 1, mip) + 1
2438 nz = boin(2, 3, mip) - boin(1, 3, mip) + 1
2445 ny = boout(2, 2, ipl) - boout(1, 2, ipl) + 1
2446 scount(ip) = nx*nz*ny
2447 sdispl(ip) = nx*nz*(boout(1, 2, ipl) - 1)
2450 ny = boout(2, 2, mip) - boout(1, 2, mip) + 1
2451 mz = maxval(boin(2, 3, :) - boin(1, 3, :) + 1)
2457 nz = boin(2, 3, ipl) - boin(1, 3, ipl) + 1
2458 rcount(ip) = nx*nz*ny
2459 rdispl(ip) = nx*ny*mz*ip
2463 rbuf => fft_scratch%rbuf1
2465 CALL fft_scratch%cart_sub_comm(2)%alltoall(cin, scount, sdispl, rbuf, rcount, rdispl)
2473 nz = boin(2, 3, ipl) - boin(1, 3, ipl) + 1
2475 is = boin(1, 3, ipl) + iz - 1
2476 ir = iz + nz*(ixy - 1)
2477 sout(is, ixy) = rbuf(ir, ip)
2483 CALL timestop(handle)
2497 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
2499 INTEGER,
CONTIGUOUS,
DIMENSION(:, :, 0:), &
2500 INTENT(IN) :: boin, boout
2501 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
2505 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cube_transpose_2'
2507 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
2509 INTEGER :: handle, ip, ipl, ir, ixy, iz, mip, mz, &
2511 INTEGER,
CONTIGUOUS,
DIMENSION(:),
POINTER :: rcount, rdispl, scount, sdispl
2512 INTEGER,
CONTIGUOUS,
DIMENSION(:, :),
POINTER :: pgrid
2513 INTEGER,
DIMENSION(2) :: dim, pos
2516 CALL timeset(routinen, handle)
2518 sub_group = fft_scratch%cart_sub_comm(2)
2519 mip = fft_scratch%mip
2520 dim = fft_scratch%dim
2521 pos = fft_scratch%pos
2522 scount => fft_scratch%scount
2523 rcount => fft_scratch%rcount
2524 sdispl => fft_scratch%sdispl
2525 rdispl => fft_scratch%rdispl
2526 pgrid => fft_scratch%pgcube
2529 nx = boin(2, 1, mip) - boin(1, 1, mip) + 1
2530 ny = boin(2, 2, mip) - boin(1, 2, mip) + 1
2531 mz = maxval(boout(2, 3, :) - boout(1, 3, :) + 1)
2533 rbuf => fft_scratch%rbuf2
2542 nz = boout(2, 3, ipl) - boout(1, 3, ipl) + 1
2543 DO iz = boout(1, 3, ipl), boout(2, 3, ipl)
2544 ir = iz - boout(1, 3, ipl) + 1 + (ixy - 1)*nz
2545 rbuf(ir, ip) = cin(iz, ixy)
2553 nz = boout(2, 3, ipl) - boout(1, 3, ipl) + 1
2554 scount(ip) = nx*ny*nz
2555 sdispl(ip) = nx*ny*mz*ip
2559 nz = boout(2, 3, mip) - boout(1, 3, mip) + 1
2565 ny = boin(2, 2, ipl) - boin(1, 2, ipl) + 1
2566 rcount(ip) = nx*ny*nz
2567 rdispl(ip) = nx*nz*(boin(1, 2, ipl) - 1)
2571 CALL sub_group%alltoall(rbuf, scount, sdispl, sout, rcount, rdispl)
2573 CALL timestop(handle)
2585 SUBROUTINE cube_transpose_3(cin, boin, boout, sout, fft_scratch)
2587 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
2589 INTEGER,
CONTIGUOUS,
DIMENSION(:, :, 0:), &
2590 INTENT(IN) :: boin, boout
2591 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
2595 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cube_transpose_3'
2597 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
2599 INTEGER :: handle, ip, ipl, ir, is, ixz, iy, lb, &
2600 mip, my, my_id, np, num_threads, nx, &
2602 INTEGER,
CONTIGUOUS,
DIMENSION(:),
POINTER :: rcount, rdispl, scount, sdispl
2603 INTEGER,
CONTIGUOUS,
DIMENSION(:, :),
POINTER :: pgrid
2604 INTEGER,
DIMENSION(2) :: dim, pos
2607 CALL timeset(routinen, handle)
2609 sub_group = fft_scratch%cart_sub_comm(1)
2610 mip = fft_scratch%mip
2611 dim = fft_scratch%dim
2612 pos = fft_scratch%pos
2614 scount => fft_scratch%scount
2615 rcount => fft_scratch%rcount
2616 sdispl => fft_scratch%sdispl
2617 rdispl => fft_scratch%rdispl
2618 pgrid => fft_scratch%pgcube
2620 ny = boin(2, 2, mip) - boin(1, 2, mip) + 1
2621 nz = boin(2, 3, mip) - boin(1, 3, mip) + 1
2627 nx = boout(2, 1, ipl) - boout(1, 1, ipl) + 1
2628 scount(ip) = nx*nz*ny
2629 sdispl(ip) = ny*nz*(boout(1, 1, ipl) - 1)
2632 nx = boout(2, 1, mip) - boout(1, 1, mip) + 1
2633 my = maxval(boin(2, 2, :) - boin(1, 2, :) + 1)
2639 ny = boin(2, 2, ipl) - boin(1, 2, ipl) + 1
2640 rcount(ip) = nx*nz*ny
2641 rdispl(ip) = nx*my*nz*ip
2645 rbuf => fft_scratch%rbuf3
2653 IF (my_id < num_threads)
THEN
2654 lb = (
SIZE(rbuf, 2)*my_id)/num_threads
2655 ub = (
SIZE(rbuf, 2)*(my_id + 1))/num_threads - 1
2656 rbuf(:, lb:ub) = 0.0_dp
2660 CALL sub_group%alltoall(cin, scount, sdispl, rbuf, rcount, rdispl)
2668 ny = boin(2, 2, ipl) - boin(1, 2, ipl) + 1
2670 is = boin(1, 2, ipl) + iy - 1
2671 ir = iy + ny*(ixz - 1)
2672 sout(is, ixz) = rbuf(ir, ip)
2678 CALL timestop(handle)
2680 END SUBROUTINE cube_transpose_3
2690 SUBROUTINE cube_transpose_4(cin, boin, boout, sout, fft_scratch)
2692 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
2694 INTEGER,
CONTIGUOUS,
DIMENSION(:, :, 0:), &
2695 INTENT(IN) :: boin, boout
2696 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
2700 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cube_transpose_4'
2702 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
2704 INTEGER :: handle, ip, ipl, ir, iy, izx, lb, mip, &
2705 my, my_id, np, num_threads, nx, ny, &
2707 INTEGER,
CONTIGUOUS,
DIMENSION(:),
POINTER :: rcount, rdispl, scount, sdispl
2708 INTEGER,
CONTIGUOUS,
DIMENSION(:, :),
POINTER :: pgrid
2709 INTEGER,
DIMENSION(2) :: dim, pos
2712 CALL timeset(routinen, handle)
2714 sub_group = fft_scratch%cart_sub_comm(1)
2715 mip = fft_scratch%mip
2716 dim = fft_scratch%dim
2717 pos = fft_scratch%pos
2719 scount => fft_scratch%scount
2720 rcount => fft_scratch%rcount
2721 sdispl => fft_scratch%sdispl
2722 rdispl => fft_scratch%rdispl
2723 pgrid => fft_scratch%pgcube
2725 nx = boin(2, 1, mip) - boin(1, 1, mip) + 1
2726 nz = boin(2, 3, mip) - boin(1, 3, mip) + 1
2727 my = maxval(boout(2, 2, :) - boout(1, 2, :) + 1)
2729 rbuf => fft_scratch%rbuf4
2737 IF (my_id < num_threads)
THEN
2738 lb = (
SIZE(rbuf, 2)*my_id)/num_threads
2739 ub = (
SIZE(rbuf, 2)*(my_id + 1))/num_threads - 1
2740 rbuf(:, lb:ub) = 0.0_dp
2748 ny = boout(2, 2, ipl) - boout(1, 2, ipl) + 1
2749 DO iy = boout(1, 2, ipl), boout(2, 2, ipl)
2750 ir = iy - boout(1, 2, ipl) + 1 + (izx - 1)*ny
2751 rbuf(ir, ip) = cin(iy, izx)
2759 ny = boout(2, 2, ipl) - boout(1, 2, ipl) + 1
2760 scount(ip) = nx*ny*nz
2761 sdispl(ip) = nx*nz*my*ip
2765 ny = boout(2, 2, mip) - boout(1, 2, mip) + 1
2771 nx = boin(2, 1, ipl) - boin(1, 1, ipl) + 1
2772 rcount(ip) = nx*ny*nz
2773 rdispl(ip) = ny*nz*(boin(1, 1, ipl) - 1)
2777 CALL sub_group%alltoall(rbuf, scount, sdispl, sout, rcount, rdispl)
2779 CALL timestop(handle)
2781 END SUBROUTINE cube_transpose_4
2792 SUBROUTINE cube_transpose_5(cin, group, boin, boout, sout, fft_scratch)
2794 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
2797 INTEGER,
CONTIGUOUS,
DIMENSION(:, :, 0:), &
2798 INTENT(IN) :: boin, boout
2799 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
2803 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cube_transpose_5'
2805 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
2807 INTEGER :: handle, ip, ir, is, ixz, iy, lb, mip, &
2808 my, my_id, np, num_threads, nx, ny, &
2810 INTEGER,
CONTIGUOUS,
DIMENSION(:),
POINTER :: rcount, rdispl, scount, sdispl
2812 CALL timeset(routinen, handle)
2814 np = fft_scratch%sizes%numtask
2815 mip = fft_scratch%mip
2816 scount => fft_scratch%scount
2817 rcount => fft_scratch%rcount
2818 sdispl => fft_scratch%sdispl
2819 rdispl => fft_scratch%rdispl
2821 ny = boin(2, 2, mip) - boin(1, 2, mip) + 1
2822 nz = boin(2, 3, mip) - boin(1, 3, mip) + 1
2827 nx = boout(2, 1, ip) - boout(1, 1, ip) + 1
2828 scount(ip) = nx*nz*ny
2829 sdispl(ip) = ny*nz*(boout(1, 1, ip) - 1)
2832 nx = boout(2, 1, mip) - boout(1, 1, mip) + 1
2833 my = maxval(boin(2, 2, :) - boin(1, 2, :) + 1)
2838 ny = boin(2, 2, ip) - boin(1, 2, ip) + 1
2839 rcount(ip) = nx*nz*ny
2840 rdispl(ip) = nx*my*nz*ip
2844 rbuf => fft_scratch%rbuf5
2852 IF (my_id < num_threads)
THEN
2853 lb = (
SIZE(rbuf, 2)*my_id)/num_threads
2854 ub = (
SIZE(rbuf, 2)*(my_id + 1))/num_threads - 1
2855 rbuf(:, lb:ub) = 0.0_dp
2859 CALL group%alltoall(cin, scount, sdispl, rbuf, rcount, rdispl)
2866 ny = boin(2, 2, ip) - boin(1, 2, ip) + 1
2868 is = boin(1, 2, ip) + iy - 1
2869 ir = iy + ny*(ixz - 1)
2870 sout(is, ixz) = rbuf(ir, ip)
2876 CALL timestop(handle)
2878 END SUBROUTINE cube_transpose_5
2889 SUBROUTINE cube_transpose_6(cin, group, boin, boout, sout, fft_scratch)
2891 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
2894 INTEGER,
CONTIGUOUS,
DIMENSION(:, :, 0:), &
2895 INTENT(IN) :: boin, boout
2896 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
2900 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cube_transpose_6'
2902 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
2904 INTEGER :: handle, ip, ir, iy, izx, lb, mip, my, &
2905 my_id, np, num_threads, nx, ny, nz, ub
2906 INTEGER,
CONTIGUOUS,
DIMENSION(:),
POINTER :: rcount, rdispl, scount, sdispl
2908 CALL timeset(routinen, handle)
2910 np = fft_scratch%sizes%numtask
2911 mip = fft_scratch%mip
2912 scount => fft_scratch%scount
2913 rcount => fft_scratch%rcount
2914 sdispl => fft_scratch%sdispl
2915 rdispl => fft_scratch%rdispl
2917 nx = boin(2, 1, mip) - boin(1, 1, mip) + 1
2918 nz = boin(2, 3, mip) - boin(1, 3, mip) + 1
2919 my = maxval(boout(2, 2, :) - boout(1, 2, :) + 1)
2921 rbuf => fft_scratch%rbuf5
2929 IF (my_id < num_threads)
THEN
2930 lb = (
SIZE(rbuf, 2)*my_id)/num_threads
2931 ub = (
SIZE(rbuf, 2)*(my_id + 1))/num_threads - 1
2932 rbuf(:, lb:ub) = 0.0_dp
2939 ny = boout(2, 2, ip) - boout(1, 2, ip) + 1
2940 DO iy = boout(1, 2, ip), boout(2, 2, ip)
2941 ir = iy - boout(1, 2, ip) + 1 + (izx - 1)*ny
2942 rbuf(ir, ip) = cin(iy, izx)
2949 ny = boout(2, 2, ip) - boout(1, 2, ip) + 1
2950 scount(ip) = nx*ny*nz
2951 sdispl(ip) = nx*nz*my*ip
2955 ny = boout(2, 2, mip) - boout(1, 2, mip) + 1
2960 nx = boin(2, 1, ip) - boin(1, 1, ip) + 1
2961 rcount(ip) = nx*ny*nz
2962 rdispl(ip) = ny*nz*(boin(1, 1, ip) - 1)
2966 CALL group%alltoall(rbuf, scount, sdispl, sout, rcount, rdispl)
2968 CALL timestop(handle)
2970 END SUBROUTINE cube_transpose_6
2977 CALL release_fft_scratch_pool()
2993 SUBROUTINE deallocate_fft_scratch_type(fft_scratch)
2996#if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_FFT)
2998 COMPLEX(KIND=dp),
POINTER :: dummy_ptr_z
3002 IF (
ASSOCIATED(fft_scratch%ziptr))
THEN
3005 IF (
ASSOCIATED(fft_scratch%zoptr))
THEN
3008 IF (
ASSOCIATED(fft_scratch%p1buf))
THEN
3011 IF (
ASSOCIATED(fft_scratch%p2buf))
THEN
3012#if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_FFT)
3013 dummy_ptr_z => fft_scratch%p2buf(1, 1)
3019 IF (
ASSOCIATED(fft_scratch%p3buf))
THEN
3020#if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_FFT)
3021 dummy_ptr_z => fft_scratch%p3buf(1, 1)
3027 IF (
ASSOCIATED(fft_scratch%p4buf))
THEN
3028#if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_FFT)
3029 dummy_ptr_z => fft_scratch%p4buf(1, 1)
3035 IF (
ASSOCIATED(fft_scratch%p5buf))
THEN
3036#if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_FFT)
3037 dummy_ptr_z => fft_scratch%p5buf(1, 1)
3043 IF (
ASSOCIATED(fft_scratch%p6buf))
THEN
3046 IF (
ASSOCIATED(fft_scratch%p7buf))
THEN
3047#if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_FFT)
3048 dummy_ptr_z => fft_scratch%p7buf(1, 1)
3054 IF (
ASSOCIATED(fft_scratch%r1buf))
THEN
3055#if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_FFT)
3056 dummy_ptr_z => fft_scratch%r1buf(1, 1)
3062 IF (
ASSOCIATED(fft_scratch%r2buf))
THEN
3065 IF (
ASSOCIATED(fft_scratch%tbuf))
THEN
3066#if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_FFT)
3067 dummy_ptr_z => fft_scratch%tbuf(1, 1, 1)
3073 IF (
ASSOCIATED(fft_scratch%a1buf))
THEN
3076 IF (
ASSOCIATED(fft_scratch%a2buf))
THEN
3079 IF (
ASSOCIATED(fft_scratch%a3buf))
THEN
3082 IF (
ASSOCIATED(fft_scratch%a4buf))
THEN
3085 IF (
ASSOCIATED(fft_scratch%a5buf))
THEN
3088 IF (
ASSOCIATED(fft_scratch%a6buf))
THEN
3091 IF (
ASSOCIATED(fft_scratch%scount))
THEN
3092 DEALLOCATE (fft_scratch%scount, fft_scratch%rcount, &
3093 fft_scratch%sdispl, fft_scratch%rdispl)
3095 IF (
ASSOCIATED(fft_scratch%rr))
THEN
3096 DEALLOCATE (fft_scratch%rr)
3098 IF (
ASSOCIATED(fft_scratch%xzbuf))
THEN
3099 DEALLOCATE (fft_scratch%xzbuf)
3101 IF (
ASSOCIATED(fft_scratch%yzbuf))
THEN
3102 DEALLOCATE (fft_scratch%yzbuf)
3104 IF (
ASSOCIATED(fft_scratch%xzbuf_sgl))
THEN
3105 DEALLOCATE (fft_scratch%xzbuf_sgl)
3107 IF (
ASSOCIATED(fft_scratch%yzbuf_sgl))
THEN
3108 DEALLOCATE (fft_scratch%yzbuf_sgl)
3110 IF (
ASSOCIATED(fft_scratch%ss))
THEN
3111 DEALLOCATE (fft_scratch%ss)
3113 IF (
ASSOCIATED(fft_scratch%tt))
THEN
3114 DEALLOCATE (fft_scratch%tt)
3116 IF (
ASSOCIATED(fft_scratch%pgrid))
THEN
3117 DEALLOCATE (fft_scratch%pgrid)
3119 IF (
ASSOCIATED(fft_scratch%pgcube))
THEN
3120 DEALLOCATE (fft_scratch%pgcube)
3122 IF (
ASSOCIATED(fft_scratch%xcor))
THEN
3123 DEALLOCATE (fft_scratch%xcor, fft_scratch%zcor)
3125 IF (
ASSOCIATED(fft_scratch%pzcoord))
THEN
3126 DEALLOCATE (fft_scratch%pzcoord)
3128 IF (
ASSOCIATED(fft_scratch%xzcount))
THEN
3129 DEALLOCATE (fft_scratch%xzcount, fft_scratch%yzcount)
3130 DEALLOCATE (fft_scratch%xzdispl, fft_scratch%yzdispl)
3132 fft_scratch%rsratio = 1._dp
3134 IF (
ASSOCIATED(fft_scratch%rbuf1))
THEN
3135 DEALLOCATE (fft_scratch%rbuf1)
3137 IF (
ASSOCIATED(fft_scratch%rbuf2))
THEN
3138 DEALLOCATE (fft_scratch%rbuf2)
3140 IF (
ASSOCIATED(fft_scratch%rbuf3))
THEN
3141 DEALLOCATE (fft_scratch%rbuf3)
3143 IF (
ASSOCIATED(fft_scratch%rbuf4))
THEN
3144 DEALLOCATE (fft_scratch%rbuf4)
3146 IF (
ASSOCIATED(fft_scratch%rbuf5))
THEN
3147 DEALLOCATE (fft_scratch%rbuf5)
3149 IF (
ASSOCIATED(fft_scratch%rbuf6))
THEN
3150 DEALLOCATE (fft_scratch%rbuf6)
3154 CALL fft_scratch%cart_sub_comm(1)%free()
3157 CALL fft_scratch%cart_sub_comm(2)%free()
3167 END SUBROUTINE deallocate_fft_scratch_type
3172 SUBROUTINE release_fft_scratch_pool()
3181 IF (
ASSOCIATED(fft_scratch))
THEN
3182 fft_scratch_current => fft_scratch
3183 fft_scratch => fft_scratch_current%fft_scratch_next
3184 NULLIFY (fft_scratch_current%fft_scratch_next)
3186 CALL deallocate_fft_scratch_type(fft_scratch_current%fft_scratch)
3188 DEALLOCATE (fft_scratch_current%fft_scratch)
3189 DEALLOCATE (fft_scratch_current)
3197 END SUBROUTINE release_fft_scratch_pool
3202 SUBROUTINE resize_fft_scratch_pool()
3204 INTEGER :: last_tick, nscratch
3209 last_tick = huge(last_tick)
3210 NULLIFY (fft_scratch_old)
3215 IF (
ASSOCIATED(fft_scratch_current))
THEN
3216 nscratch = nscratch + 1
3218 IF (.NOT. fft_scratch_current%fft_scratch%in_use)
THEN
3219 IF (fft_scratch_current%fft_scratch%last_tick < last_tick)
THEN
3220 last_tick = fft_scratch_current%fft_scratch%last_tick
3221 fft_scratch_old => fft_scratch_current
3224 fft_scratch_current => fft_scratch_current%fft_scratch_next
3233 IF (
ASSOCIATED(fft_scratch_old))
THEN
3236 IF (
ASSOCIATED(fft_scratch_current))
THEN
3238 IF (
ASSOCIATED(fft_scratch_current%fft_scratch_next, fft_scratch_old))
THEN
3240 fft_scratch_current%fft_scratch_next => fft_scratch_old%fft_scratch_next
3243 CALL deallocate_fft_scratch_type(fft_scratch_old%fft_scratch)
3244 DEALLOCATE (fft_scratch_old%fft_scratch)
3245 DEALLOCATE (fft_scratch_old)
3248 fft_scratch_current => fft_scratch_current%fft_scratch_next
3256 cpwarn(
"The number of the scratches exceeded the limit, but none could be deallocated")
3260 END SUBROUTINE resize_fft_scratch_pool
3271 INTEGER,
INTENT(IN) :: tf_type
3272 INTEGER,
DIMENSION(:),
INTENT(IN) :: n
3274 OPTIONAL :: fft_sizes
3276 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_fft_scratch'
3278 INTEGER :: coord(2), dim(2), handle, i, ix, iz, lg, lmax, m1, m2, &
3279 mcx2, mcy3, mcz1, mcz2, mg, mmax, mx1, mx2, my1, my3, mz1, mz2, mz3, &
3280 nbx, nbz, nm, nmax, nmray, np, nx, ny, nyzray, nz, pos(2)
3281 INTEGER,
DIMENSION(3) :: pcoord
3283 LOGICAL,
DIMENSION(2) :: dims
3287#if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_FFT)
3289 INTEGER(KIND=C_SIZE_T) :: length
3290 TYPE(c_ptr) :: cptr_r1buf, cptr_tbuf, &
3291 cptr_p2buf, cptr_p3buf, cptr_p4buf, cptr_p5buf, cptr_p7buf
3293 CALL timeset(routinen, handle)
3297 CALL resize_fft_scratch_pool()
3304 IF (
ASSOCIATED(fft_scratch_current))
THEN
3305 IF (fft_scratch_current%fft_scratch%in_use)
THEN
3306 fft_scratch_last => fft_scratch_current
3307 fft_scratch_current => fft_scratch_current%fft_scratch_next
3310 IF (tf_type /= fft_scratch_current%fft_scratch%tf_type)
THEN
3311 fft_scratch_last => fft_scratch_current
3312 fft_scratch_current => fft_scratch_current%fft_scratch_next
3315 IF (.NOT. all(n == fft_scratch_current%fft_scratch%nfft))
THEN
3316 fft_scratch_last => fft_scratch_current
3317 fft_scratch_current => fft_scratch_current%fft_scratch_next
3320 IF (
PRESENT(fft_sizes))
THEN
3321 IF (fft_sizes%rs_group /= fft_scratch_current%fft_scratch%group)
THEN
3322 fft_scratch_last => fft_scratch_current
3323 fft_scratch_current => fft_scratch_current%fft_scratch_next
3326 CALL is_equal(fft_sizes, fft_scratch_current%fft_scratch%sizes, equal)
3327 IF (.NOT. equal)
THEN
3328 fft_scratch_last => fft_scratch_current
3329 fft_scratch_current => fft_scratch_current%fft_scratch_next
3334 fft_scratch => fft_scratch_current%fft_scratch
3335 fft_scratch_current%fft_scratch%in_use = .true.
3340 ALLOCATE (fft_scratch_new)
3341 ALLOCATE (fft_scratch_new%fft_scratch)
3343 IF (tf_type /= 400)
THEN
3344 fft_scratch_new%fft_scratch%sizes = fft_sizes
3345 np = fft_sizes%numtask
3346 ALLOCATE (fft_scratch_new%fft_scratch%scount(0:np - 1), fft_scratch_new%fft_scratch%rcount(0:np - 1), &
3347 fft_scratch_new%fft_scratch%sdispl(0:np - 1), fft_scratch_new%fft_scratch%rdispl(0:np - 1), &
3348 fft_scratch_new%fft_scratch%pgcube(0:np - 1, 2))
3351 SELECT CASE (tf_type)
3353 cpabort(
"Invalid scratch type.")
3355 cpassert(
PRESENT(fft_sizes))
3362 CALL fft_allocate(fft_scratch_new%fft_scratch%a1buf, [mx1*my1, n(3)])
3363 CALL fft_allocate(fft_scratch_new%fft_scratch%a2buf, [n(3), mx1*my1])
3364 CALL fft_allocate(fft_scratch_new%fft_scratch%a3buf, [mx2*mz2, n(2)])
3365 CALL fft_allocate(fft_scratch_new%fft_scratch%a4buf, [n(2), mx2*mz2])
3366 CALL fft_allocate(fft_scratch_new%fft_scratch%a5buf, [my3*mz3, n(1)])
3367 CALL fft_allocate(fft_scratch_new%fft_scratch%a6buf, [n(1), my3*mz3])
3368 fft_scratch_new%fft_scratch%group = fft_sizes%rs_group
3370 dim = fft_sizes%rs_group%num_pe_cart
3371 pos = fft_sizes%rs_group%mepos_cart
3372 fft_scratch_new%fft_scratch%mip = fft_sizes%rs_group%mepos
3373 fft_scratch_new%fft_scratch%dim = dim
3374 fft_scratch_new%fft_scratch%pos = pos
3375 mcz1 = fft_sizes%mcz1
3376 mcx2 = fft_sizes%mcx2
3377 mcz2 = fft_sizes%mcz2
3378 mcy3 = fft_sizes%mcy3
3379 ALLOCATE (fft_scratch_new%fft_scratch%rbuf1(mx2*my1*mcz2, 0:dim(2) - 1))
3380 ALLOCATE (fft_scratch_new%fft_scratch%rbuf2(mx1*my1*mcz2, 0:dim(2) - 1))
3381 ALLOCATE (fft_scratch_new%fft_scratch%rbuf3(mx2*mz3*mcy3, 0:dim(1) - 1))
3382 ALLOCATE (fft_scratch_new%fft_scratch%rbuf4(mx2*mz2*mcy3, 0:dim(1) - 1))
3384 dims = [.true., .false.]
3385 CALL fft_scratch_new%fft_scratch%cart_sub_comm(1)%from_sub(fft_sizes%rs_group, dims)
3386 dims = [.false., .true.]
3387 CALL fft_scratch_new%fft_scratch%cart_sub_comm(2)%from_sub(fft_sizes%rs_group, dims)
3390 DO i = 0, dim(1) - 1
3392 CALL fft_sizes%rs_group%rank_cart(coord, fft_scratch_new%fft_scratch%pgcube(i, 1))
3394 DO i = 0, dim(2) - 1
3396 CALL fft_sizes%rs_group%rank_cart(coord, fft_scratch_new%fft_scratch%pgcube(i, 2))
3401 mx1*my1, n(3), n(3), mx1*my1, &
3402 fft_scratch_new%fft_scratch%a1buf, fft_scratch_new%fft_scratch%a2buf)
3404 mx2*mz2, n(2), n(2), mx2*mz2, &
3405 fft_scratch_new%fft_scratch%a3buf, fft_scratch_new%fft_scratch%a4buf)
3407 my3*mz3, n(1), n(1), my3*mz3, &
3408 fft_scratch_new%fft_scratch%a5buf, fft_scratch_new%fft_scratch%a6buf)
3410 n(1), my3*mz3, n(1), my3*mz3, &
3411 fft_scratch_new%fft_scratch%a6buf, fft_scratch_new%fft_scratch%a5buf)
3413 n(2), mx2*mz2, n(2), mx2*mz2, &
3414 fft_scratch_new%fft_scratch%a4buf, fft_scratch_new%fft_scratch%a3buf)
3416 n(3), mx1*my1, n(3), mx1*my1, &
3417 fft_scratch_new%fft_scratch%a2buf, fft_scratch_new%fft_scratch%a1buf)
3420 cpassert(
PRESENT(fft_sizes))
3426 CALL fft_allocate(fft_scratch_new%fft_scratch%a1buf, [mx1*my1, n(3)])
3427 CALL fft_allocate(fft_scratch_new%fft_scratch%a2buf, [n(3), mx1*my1])
3428 fft_scratch_new%fft_scratch%group = fft_sizes%rs_group
3429 CALL fft_allocate(fft_scratch_new%fft_scratch%a4buf, [n(2), mx1*mz1])
3430 CALL fft_allocate(fft_scratch_new%fft_scratch%a5buf, [my3*mz3, n(1)])
3431 CALL fft_allocate(fft_scratch_new%fft_scratch%a6buf, [n(1), my3*mz3])
3433 dim = fft_sizes%rs_group%num_pe_cart
3434 pos = fft_sizes%rs_group%mepos_cart
3435 fft_scratch_new%fft_scratch%mip = fft_sizes%rs_group%mepos
3436 fft_scratch_new%fft_scratch%dim = dim
3437 fft_scratch_new%fft_scratch%pos = pos
3438 mcy3 = fft_sizes%mcy3
3439 ALLOCATE (fft_scratch_new%fft_scratch%rbuf5(mx1*mz3*mcy3, 0:dim(1) - 1))
3440 ALLOCATE (fft_scratch_new%fft_scratch%rbuf6(mx1*mz1*mcy3, 0:dim(1) - 1))
3443 CALL fft_create_plan_2d(fft_scratch_new%fft_scratch%fft_plan(1),
fwfft, .true., .false., &
3444 [n(2), n(3)], mx1, &
3445 fft_scratch_new%fft_scratch%a1buf, fft_scratch_new%fft_scratch%a4buf)
3447 my3*mz3, n(1), n(1), my3*mz3, &
3448 fft_scratch_new%fft_scratch%a5buf, fft_scratch_new%fft_scratch%a6buf)
3450 n(1), my3*mz3, n(1), my3*mz3, &
3451 fft_scratch_new%fft_scratch%a6buf, fft_scratch_new%fft_scratch%a5buf)
3452 CALL fft_create_plan_2d(fft_scratch_new%fft_scratch%fft_plan(5),
bwfft, .false., .true., &
3453 [n(2), n(3)], mx1, fft_scratch_new%fft_scratch%a4buf, fft_scratch_new%fft_scratch%a1buf)
3456 cpassert(
PRESENT(fft_sizes))
3461 lmax = fft_sizes%lmax
3462 mmax = fft_sizes%mmax
3465 np = fft_sizes%numtask
3466 nmray = fft_sizes%nmray
3467 nyzray = fft_sizes%nyzray
3468#if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_FFT)
3469 length = int(2*
dp_size*max(mmax, 1)*max(lmax, 1), kind=c_size_t)
3472 CALL c_f_pointer(cptr_r1buf, fft_scratch_new%fft_scratch%r1buf, [max(mmax, 1), max(lmax, 1)])
3473 length = int(2*
dp_size*max(ny, 1)*max(nz, 1)*max(nx, 1), kind=c_size_t)
3476 CALL c_f_pointer(cptr_tbuf, fft_scratch_new%fft_scratch%tbuf, [max(ny, 1), max(nz, 1), max(nx, 1)])
3478 CALL fft_allocate(fft_scratch_new%fft_scratch%r1buf, [mmax, lmax])
3479 CALL fft_allocate(fft_scratch_new%fft_scratch%tbuf, [ny, nz, nx])
3481 fft_scratch_new%fft_scratch%group = fft_sizes%rs_group
3482 CALL fft_allocate(fft_scratch_new%fft_scratch%r2buf, [lg, mg])
3484 IF (alltoall_sgl)
THEN
3485 ALLOCATE (fft_scratch_new%fft_scratch%ss(mmax, lmax))
3486 ALLOCATE (fft_scratch_new%fft_scratch%tt(nm, 0:np - 1))
3488 ALLOCATE (fft_scratch_new%fft_scratch%rr(nm, 0:np - 1))
3492 CALL fft_create_plan_2d(fft_scratch_new%fft_scratch%fft_plan(1),
fwfft, .true., .false., &
3493 [ny, nz], nx, fft_scratch_new%fft_scratch%r1buf, fft_scratch_new%fft_scratch%tbuf)
3495 nyzray, n(1), n(1), nyzray, &
3496 fft_scratch_new%fft_scratch%r1buf, fft_scratch_new%fft_scratch%r2buf)
3498 n(1), nyzray, n(1), nyzray, &
3499 fft_scratch_new%fft_scratch%r2buf, fft_scratch_new%fft_scratch%r1buf)
3500 CALL fft_create_plan_2d(fft_scratch_new%fft_scratch%fft_plan(5),
bwfft, .false., .true., &
3502 fft_scratch_new%fft_scratch%tbuf, fft_scratch_new%fft_scratch%r1buf)
3505 cpassert(
PRESENT(fft_sizes))
3510 mcx2 = fft_sizes%mcx2
3513 nmax = fft_sizes%nmax
3514 nmray = fft_sizes%nmray
3515 nyzray = fft_sizes%nyzray
3516 m1 = fft_sizes%r_dim(1)
3517 m2 = fft_sizes%r_dim(2)
3520 CALL fft_allocate(fft_scratch_new%fft_scratch%p1buf, [mx1*my1, n(3)])
3521 CALL fft_allocate(fft_scratch_new%fft_scratch%p6buf, [lg, mg])
3522#if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_FFT)
3523 length = int(2*
dp_size*max(n(3), 1)*max(mx1*my1, 1), kind=c_size_t)
3526 CALL c_f_pointer(cptr_p2buf, fft_scratch_new%fft_scratch%p2buf, [max(n(3), 1), max(mx1*my1, 1)])
3527 length = int(2*
dp_size*max(mx2*mz2, 1)*max(n(2), 1), kind=c_size_t)
3530 CALL c_f_pointer(cptr_p3buf, fft_scratch_new%fft_scratch%p3buf, [max(mx2*mz2, 1), max(n(2), 1)])
3531 length = int(2*
dp_size*max(n(2), 1)*max(mx2*mz2, 1), kind=c_size_t)
3534 CALL c_f_pointer(cptr_p4buf, fft_scratch_new%fft_scratch%p4buf, [max(n(2), 1), max(mx2*mz2, 1)])
3535 length = int(2*
dp_size*max(nyzray, 1)*max(n(1), 1), kind=c_size_t)
3538 CALL c_f_pointer(cptr_p5buf, fft_scratch_new%fft_scratch%p5buf, [max(nyzray, 1), max(n(1), 1)])
3539 length = int(2*
dp_size*max(mg, 1)*max(lg, 1), kind=c_size_t)
3542 CALL c_f_pointer(cptr_p7buf, fft_scratch_new%fft_scratch%p7buf, [max(mg, 1), max(lg, 1)])
3544 CALL fft_allocate(fft_scratch_new%fft_scratch%p2buf, [n(3), mx1*my1])
3545 CALL fft_allocate(fft_scratch_new%fft_scratch%p3buf, [mx2*mz2, n(2)])
3546 CALL fft_allocate(fft_scratch_new%fft_scratch%p4buf, [n(2), mx2*mz2])
3547 CALL fft_allocate(fft_scratch_new%fft_scratch%p5buf, [nyzray, n(1)])
3548 CALL fft_allocate(fft_scratch_new%fft_scratch%p7buf, [mg, lg])
3550 IF (alltoall_sgl)
THEN
3551 ALLOCATE (fft_scratch_new%fft_scratch%yzbuf_sgl(mg*lg))
3552 ALLOCATE (fft_scratch_new%fft_scratch%xzbuf_sgl(n(2)*mx2*mz2))
3554 ALLOCATE (fft_scratch_new%fft_scratch%yzbuf(mg*lg))
3555 ALLOCATE (fft_scratch_new%fft_scratch%xzbuf(n(2)*mx2*mz2))
3557 ALLOCATE (fft_scratch_new%fft_scratch%pgrid(0:m1 - 1, 0:m2 - 1))
3558 ALLOCATE (fft_scratch_new%fft_scratch%xcor(nbx))
3559 ALLOCATE (fft_scratch_new%fft_scratch%zcor(nbz))
3560 ALLOCATE (fft_scratch_new%fft_scratch%pzcoord(0:np - 1))
3561 ALLOCATE (fft_scratch_new%fft_scratch%xzcount(0:np - 1), &
3562 fft_scratch_new%fft_scratch%yzcount(0:np - 1))
3563 ALLOCATE (fft_scratch_new%fft_scratch%xzdispl(0:np - 1), &
3564 fft_scratch_new%fft_scratch%yzdispl(0:np - 1))
3565 fft_scratch_new%fft_scratch%group = fft_sizes%rs_group
3567 dim = fft_sizes%rs_group%num_pe_cart
3568 pos = fft_sizes%rs_group%mepos_cart
3569 fft_scratch_new%fft_scratch%mip = fft_sizes%rs_group%mepos
3570 fft_scratch_new%fft_scratch%dim = dim
3571 fft_scratch_new%fft_scratch%pos = pos
3572 mcz1 = fft_sizes%mcz1
3573 mcz2 = fft_sizes%mcz2
3574 ALLOCATE (fft_scratch_new%fft_scratch%rbuf1(mx2*my1*mcz2, 0:dim(2) - 1))
3575 ALLOCATE (fft_scratch_new%fft_scratch%rbuf2(mx1*my1*mcz2, 0:dim(2) - 1))
3577 dims = [.false., .true.]
3578 CALL fft_scratch_new%fft_scratch%cart_sub_comm(2)%from_sub(fft_sizes%rs_group, dims)
3581 DO i = 0, dim(2) - 1
3583 CALL fft_sizes%rs_group%rank_cart(coord, fft_scratch_new%fft_scratch%pgcube(i, 2))
3590 CALL fft_sizes%rs_group%rank_cart(coord, fft_scratch_new%fft_scratch%pgrid(ix, iz))
3596 CALL fft_sizes%rs_group%coords(i, pcoord)
3597 fft_scratch_new%fft_scratch%pzcoord(i) = pcoord(2)
3605 cpassert(
SIZE(fft_scratch_new%fft_scratch%p1buf) >= mx1*my1*n(3))
3607 mx1*my1, n(3), n(3), mx1*my1, &
3608 fft_scratch_new%fft_scratch%p1buf, fft_scratch_new%fft_scratch%p2buf)
3609 cpassert(
SIZE(fft_scratch_new%fft_scratch%p3buf) >= mx2*mz2*n(2))
3611 mx2*mz2, n(2), n(2), mx2*mz2, &
3612 fft_scratch_new%fft_scratch%p3buf, fft_scratch_new%fft_scratch%p4buf)
3613 cpassert(
SIZE(fft_scratch_new%fft_scratch%p5buf) >= nyzray*n(1))
3615 nyzray, n(1), n(1), nyzray, &
3616 fft_scratch_new%fft_scratch%p5buf, fft_scratch_new%fft_scratch%p6buf)
3617 cpassert(
SIZE(fft_scratch_new%fft_scratch%p6buf) >= n(1)*nyzray)
3619 n(1), nyzray, n(1), nyzray, &
3620 fft_scratch_new%fft_scratch%p6buf, fft_scratch_new%fft_scratch%p7buf)
3621 cpassert(
SIZE(fft_scratch_new%fft_scratch%p4buf) >= n(2)*mx2*mz2)
3623 n(2), mx2*mz2, n(2), mx2*mz2, &
3624 fft_scratch_new%fft_scratch%p4buf, fft_scratch_new%fft_scratch%p3buf)
3625 cpassert(
SIZE(fft_scratch_new%fft_scratch%p2buf) >= n(3)*mx1*my1)
3627 n(3), mx1*my1, n(3), mx1*my1, &
3628 fft_scratch_new%fft_scratch%p2buf, fft_scratch_new%fft_scratch%p1buf)
3632 CALL fft_allocate(fft_scratch_new%fft_scratch%ziptr, n)
3633 CALL fft_allocate(fft_scratch_new%fft_scratch%zoptr, n)
3636 CALL fft_create_plan_3d_inplace(fft_scratch_new%fft_scratch%fft_plan(1),
fwfft, n, &
3637 fft_scratch_new%fft_scratch%ziptr)
3638 CALL fft_create_plan_3d_inplace(fft_scratch_new%fft_scratch%fft_plan(2),
bwfft, n, &
3639 fft_scratch_new%fft_scratch%ziptr)
3642 fft_scratch_new%fft_scratch%ziptr, fft_scratch_new%fft_scratch%zoptr)
3644 fft_scratch_new%fft_scratch%ziptr, fft_scratch_new%fft_scratch%zoptr)
3648 NULLIFY (fft_scratch_new%fft_scratch_next)
3649 fft_scratch_new%fft_scratch%fft_scratch_id = &
3650 fft_scratch_last%fft_scratch%fft_scratch_id + 1
3651 fft_scratch_new%fft_scratch%in_use = .true.
3652 fft_scratch_new%fft_scratch%nfft = n
3653 fft_scratch_last%fft_scratch_next => fft_scratch_new
3654 fft_scratch_new%fft_scratch%tf_type = tf_type
3655 fft_scratch => fft_scratch_new%fft_scratch
3664 CALL timestop(handle)
3676 INTEGER :: scratch_id
3679 scratch_id = fft_scratch%fft_scratch_id
3683 IF (
ASSOCIATED(fft_scratch_current))
THEN
3684 IF (scratch_id == fft_scratch_current%fft_scratch%fft_scratch_id)
THEN
3685 fft_scratch%in_use = .false.
3686 NULLIFY (fft_scratch)
3689 fft_scratch_current => fft_scratch_current%fft_scratch_next
3692 cpabort(
"Invalid scratch type.")
3709 SUBROUTINE sparse_alltoall(rs, scount, sdispl, rq, rcount, rdispl, group)
3710 COMPLEX(KIND=dp),
DIMENSION(:),
POINTER :: rs
3711 INTEGER,
DIMENSION(:),
POINTER :: scount, sdispl
3712 COMPLEX(KIND=dp),
DIMENSION(:),
POINTER :: rq
3713 INTEGER,
DIMENSION(:),
POINTER :: rcount, rdispl
3716 COMPLEX(KIND=dp),
DIMENSION(:),
POINTER :: msgin, msgout
3717 INTEGER :: ip, n, nr, ns, pos
3723 ALLOCATE (sreq(0:n - 1))
3724 ALLOCATE (rreq(0:n - 1))
3727 IF (rcount(ip) == 0) cycle
3728 IF (ip == pos) cycle
3729 msgout => rq(rdispl(ip) + 1:rdispl(ip) + rcount(ip))
3730 CALL group%irecv(msgout, ip, rreq(nr))
3735 IF (scount(ip) == 0) cycle
3736 IF (ip == pos) cycle
3737 msgin => rs(sdispl(ip) + 1:sdispl(ip) + scount(ip))
3738 CALL group%isend(msgin, ip, sreq(ns))
3741 IF (rcount(pos) /= 0)
THEN
3742 IF (rcount(pos) /= scount(pos)) cpabort(
"Invalid count.")
3743 rq(rdispl(pos) + 1:rdispl(pos) + rcount(pos)) = rs(sdispl(pos) + 1:sdispl(pos) + scount(pos))
3751 END SUBROUTINE sparse_alltoall
3760 SUBROUTINE is_equal(fft_size_1, fft_size_2, equal)
3766 equal = equal .AND. fft_size_1%nx == fft_size_2%nx
3767 equal = equal .AND. fft_size_1%ny == fft_size_2%ny
3768 equal = equal .AND. fft_size_1%nz == fft_size_2%nz
3770 equal = equal .AND. fft_size_1%lmax == fft_size_2%lmax
3771 equal = equal .AND. fft_size_1%mmax == fft_size_2%mmax
3772 equal = equal .AND. fft_size_1%nmax == fft_size_2%nmax
3774 equal = equal .AND. fft_size_1%mx1 == fft_size_2%mx1
3775 equal = equal .AND. fft_size_1%mx2 == fft_size_2%mx2
3776 equal = equal .AND. fft_size_1%mx3 == fft_size_2%mx3
3778 equal = equal .AND. fft_size_1%my1 == fft_size_2%my1
3779 equal = equal .AND. fft_size_1%my2 == fft_size_2%my2
3780 equal = equal .AND. fft_size_1%my3 == fft_size_2%my3
3782 equal = equal .AND. fft_size_1%mcz1 == fft_size_2%mcz1
3783 equal = equal .AND. fft_size_1%mcx2 == fft_size_2%mcx2
3784 equal = equal .AND. fft_size_1%mcz2 == fft_size_2%mcz2
3785 equal = equal .AND. fft_size_1%mcy3 == fft_size_2%mcy3
3787 equal = equal .AND. fft_size_1%lg == fft_size_2%lg
3788 equal = equal .AND. fft_size_1%mg == fft_size_2%mg
3790 equal = equal .AND. fft_size_1%nbx == fft_size_2%nbx
3791 equal = equal .AND. fft_size_1%nbz == fft_size_2%nbz
3793 equal = equal .AND. fft_size_1%nmray == fft_size_2%nmray
3794 equal = equal .AND. fft_size_1%nyzray == fft_size_2%nyzray
3796 equal = equal .AND. fft_size_1%rs_group == fft_size_2%rs_group
3798 equal = equal .AND. all(fft_size_1%g_pos == fft_size_2%g_pos)
3799 equal = equal .AND. all(fft_size_1%r_pos == fft_size_2%r_pos)
3800 equal = equal .AND. all(fft_size_1%r_dim == fft_size_2%r_dim)
3802 equal = equal .AND. fft_size_1%numtask == fft_size_2%numtask
3804 END SUBROUTINE is_equal
static GRID_HOST_DEVICE int idx(const orbital a)
Return coset index of given orbital angular momentum.
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
Fortran API for the FFT package, which is written in C.
subroutine, public fft_register_3d_local_inplace(direction, fft_size, number_of_ffts, transpose, grid)
Registers a complex-to-complex 3D FFT.
subroutine, public fft_2d_local(direction, fft_size, number_of_ffts, transpose_in, transpose_out, grid_in, grid_out)
Performs a complex-to-complex 2D FFT.
subroutine, public fft_register_3d_local(direction, fft_size, number_of_ffts, transpose_in, transpose_out, grid_in, grid_out)
Registers a complex-to-complex 3D FFT.
subroutine, public fft_register_2d_local(direction, fft_size, number_of_ffts, transpose_in, transpose_out, grid_in, grid_out)
Registers a complex-to-complex 2D FFT.
subroutine, public fft_3d_local(direction, fft_size, number_of_ffts, transpose_in, transpose_out, grid_in, grid_out)
Performs a complex-to-complex 3D FFT.
subroutine, public fft_1d_local(direction, fft_size, number_of_ffts, transpose_in, transpose_out, leading_dimension_in, leading_dimension_out, grid_in, grid_out)
Performs a complex-to-complex 1D FFT.
subroutine, public fft_library_init(backend, planning_mode, use_guru_interface, wisdom_file, status)
Initialize FFT library.
subroutine, public fft_3d_local_inplace(direction, fft_size, number_of_ffts, transpose, grid)
Performs a complex-to-complex 3D FFT.
subroutine, public fft_library_finalize(wisdom_file)
Finalize FFT library.
subroutine, public fft_register_1d_local(direction, fft_size, number_of_ffts, transpose_in, transpose_out, leading_dimension_in, leading_dimension_out, grid_in, grid_out)
Registers a complex-to-complex 1D FFT.
Defines the basic variable types.
integer, parameter, public dp_size
integer, parameter, public dp
integer, parameter, public sp
Definition of mathematical constants and functions.
complex(kind=dp), parameter, public z_zero
Interface to the message passing library MPI.
type(mp_comm_type), parameter, public mp_comm_null
Fortran API for the offload package, which is written in C.
integer function, public offload_free_pinned_mem(buffer)
free pinned memory
integer function, public offload_malloc_pinned_mem(buffer, length)
allocate pinned memory.