3 #include "sll_memory.h"
4 #include "sll_working_precision.h"
53 sll_real64,
intent(in) :: r_min
54 sll_real64,
intent(in) :: r_max
55 sll_int32,
intent(in) :: num_cells_r
56 sll_int32,
intent(in) :: num_cells_theta
57 sll_real64,
dimension(:),
intent(in) :: rho
58 sll_real64,
dimension(:, :),
intent(in) :: points
59 sll_int32,
intent(in) :: n_points
60 sll_int32,
dimension(:),
intent(out) :: pre_compute_n
61 sll_int32,
intent(out) :: size_pre_compute
62 sll_int32,
dimension(:, :),
allocatable :: buf
63 sll_int32 ::i, k, ell_1, ell_2, ii(2), s, nb, ind(2)
64 sll_real64::eta_star(2), eta(2), delta_eta(2), x(2)
65 sll_int32 ::error, max_nb
66 sll_real64 :: eta_min(2), eta_max(2)
69 delta_eta(1) = (r_max - r_min)/real(num_cells_r, f64)
70 delta_eta(2) = 2._f64*
sll_p_pi/real(num_cells_theta, f64)
73 nc(2) = num_cells_theta
80 sll_allocate(buf(0:num_cells_r + 2, 0:num_cells_theta - 1), error)
88 eta(1) = eta_min(1) + real(i - 1, f64)*delta_eta(1)
91 x(1) = eta(1)*cos(eta(2)) + rho(i)*points(1, k)
92 x(2) = eta(1)*sin(eta(2)) + rho(i)*points(2, k)
101 ind(2) = modulo(ii(2) + ell_2, nc(2))
103 ind(1) = ii(1) + 1 + ell_1
104 if (buf(ind(1), ind(2)) .ne. i)
then
106 buf(ind(1), ind(2)) = i
114 max_nb = max(max_nb, nb)
116 size_pre_compute = max_nb
118 sll_deallocate_array(buf, error)
132 pre_compute_coeff_spl)
133 sll_real64,
intent(in) :: r_min
134 sll_real64,
intent(in) :: r_max
135 sll_int32,
intent(in) :: num_cells_r
136 sll_int32,
intent(in) :: num_cells_theta
137 sll_real64,
dimension(:),
intent(in) :: rho
138 sll_real64,
dimension(:, :),
intent(in) :: points
139 sll_int32,
intent(in) :: n_points
140 sll_int32,
intent(in) :: size_pre_compute
141 sll_int32,
dimension(:, :),
intent(out) :: pre_compute_index
142 sll_real,
dimension(:),
intent(out) :: pre_compute_coeff_spl
143 sll_int32,
dimension(:, :),
allocatable :: buf
144 sll_int32 ::i, j, k, ell_1, ell_2, ii(2), s, nb, ind(2)
145 sll_real64::val(-1:2, -1:2), eta_star(2), eta(2), delta_eta(2), x(2)
147 sll_real64 :: eta_min(2), eta_max(2)
150 delta_eta(1) = (r_max - r_min)/real(num_cells_r, f64)
151 delta_eta(2) = 2._f64*
sll_p_pi/real(num_cells_theta, f64)
154 nc(2) = num_cells_theta
161 sll_allocate(buf(0:num_cells_r + 2, 0:num_cells_theta - 1), error)
171 eta(1) = eta_min(1) + real(i - 1, f64)*delta_eta(1)
173 x(1) = eta(1)*cos(eta(2)) + rho(i)*points(1, k)
174 x(2) = eta(1)*sin(eta(2)) + rho(i)*points(2, k)
179 val = val*points(3, k)
182 ind(2) = modulo(ii(2) + ell_2, nc(2))
184 ind(1) = ii(1) + 1 + ell_1
185 j = buf(ind(1), ind(2))
188 buf(ind(1), ind(2)) = s
189 pre_compute_coeff_spl(s) = val(ell_1, ell_2)
190 pre_compute_index(1, s) = ind(1)
191 pre_compute_index(2, s) = ind(2)
193 pre_compute_coeff_spl(j) = pre_compute_coeff_spl(j) + val(ell_1, ell_2)
201 sll_deallocate_array(buf, error)
203 print *, size_pre_compute
212 pre_compute_coeff_spl, &
214 pointer_mat_contribution_circ)
215 sll_int32,
intent(in) :: num_cells_r
216 sll_int32,
intent(in) :: num_cells_theta
217 sll_int32,
dimension(:),
intent(in) :: pre_compute_n
218 sll_int32,
dimension(:, :),
intent(in) :: pre_compute_index
219 sll_real64,
dimension(:),
intent(in) :: pre_compute_coeff_spl
220 sll_int32,
intent(in) :: size_pre_compute
221 sll_real64,
dimension(:, :, :),
intent(out) :: pointer_mat_contribution_circ
226 pointer_mat_contribution_circ = 0._f64
228 do i = 1, num_cells_r + 1
229 do k = 1, pre_compute_n(i)
231 ii(1) = pre_compute_index(1, s) + 1
232 ii(2) = modulo(pre_compute_index(2, s), num_cells_theta) + 1
233 pointer_mat_contribution_circ(ii(2), i, ii(1)) = &
234 pointer_mat_contribution_circ(ii(2), i, ii(1)) + &
235 pre_compute_coeff_spl(s)
239 print *, size_pre_compute
246 sll_int32,
intent(in) :: num_cells_r
247 sll_int32,
intent(in) :: num_cells_theta
251 sll_comp64,
dimension(:, :, :),
intent(out) :: d_spl2d
252 sll_real64,
dimension(:),
allocatable,
target::dnat, lnat, dper, lper, mper
253 sll_real64,
dimension(:),
pointer::pointer_dnat, pointer_lnat
254 sll_real64,
dimension(:),
pointer::pointer_dper, pointer_lper, pointer_mper
255 sll_real64,
dimension(:, :),
allocatable,
target::mat_nat, mat_per
256 sll_real64,
dimension(:, :),
pointer::pointer_mat_nat, pointer_mat_per
257 sll_real64,
dimension(:, :, :),
allocatable,
target::mat_spl2d_circ
258 sll_real64,
dimension(:, :, :),
pointer::pointer_mat_spl2d_circ
263 sll_comp64,
dimension(:),
allocatable :: fft_array
264 sll_real64,
dimension(:),
allocatable :: buf_fft
268 ntheta = num_cells_theta
270 sll_allocate(dnat(0:nr + 2), ierr)
271 sll_allocate(lnat(0:nr + 2), ierr)
272 sll_allocate(dper(0:ntheta - 1), ierr)
273 sll_allocate(lper(0:ntheta - 1), ierr)
274 sll_allocate(mper(0:ntheta - 1), ierr)
275 sll_allocate(mat_nat(0:nr + 2, 0:nr), ierr)
276 sll_allocate(mat_per(0:ntheta - 1, 0:ntheta - 1), ierr)
277 sll_allocate(mat_spl2d_circ(0:ntheta - 1, 0:nr + 2, 0:nr), ierr)
279 sll_allocate(buf_fft(4*ntheta + 15), ierr)
280 sll_allocate(fft_array(ntheta), ierr)
287 pointer_mat_nat => mat_nat
288 pointer_mat_per => mat_per
289 pointer_mat_spl2d_circ => mat_spl2d_circ
297 pointer_mat_spl2d_circ(j, :, :) = pointer_mat_per(0, j)*pointer_mat_nat
300 call zffti(ntheta, buf_fft)
304 fft_array(1:ntheta) = pointer_mat_spl2d_circ(0:ntheta - 1, j, k)*(1._f64, 0._f64)
305 call zfftf(ntheta, fft_array(1:ntheta), buf_fft)
306 d_spl2d(1:ntheta, j + 1, k + 1) = fft_array(1:ntheta)
324 pointer_mat_contribution_circ, &
326 sll_int32,
intent(in) :: num_cells_r
327 sll_int32,
intent(in) :: num_cells_theta
328 sll_real64,
dimension(:, :, :),
intent(in) :: pointer_mat_contribution_circ
332 sll_comp64,
dimension(:, :, :),
intent(out) :: d_contr
337 sll_comp64,
dimension(:),
allocatable :: fft_array
338 sll_real64,
dimension(:),
allocatable :: buf_fft
342 ntheta = num_cells_theta
344 sll_allocate(buf_fft(4*ntheta + 15), ierr)
345 sll_allocate(fft_array(ntheta), ierr)
347 call zffti(ntheta, buf_fft)
351 fft_array(1:ntheta) = pointer_mat_contribution_circ(1:ntheta, j + 1, k + 1)*(1._f64, 0._f64)
352 call zfftf(ntheta, fft_array(1:ntheta), buf_fft)
353 d_contr(1:ntheta, j + 1, k + 1) = fft_array(1:ntheta)
374 sll_comp64,
dimension(:, :, :),
intent(in) :: d_spl2d
375 sll_comp64,
dimension(:, :, :),
intent(in) :: d_contr
376 sll_int32,
intent(in) :: num_cells_r
377 sll_int32,
intent(in) :: num_cells_theta
378 sll_comp64,
dimension(:, :, :),
intent(out) :: mat
383 sll_comp64,
dimension(:, :),
allocatable :: mat_stock1
384 sll_comp64,
dimension(:, :),
allocatable :: mat_stock2
385 sll_comp64,
dimension(:, :),
allocatable :: mat_stock3
389 ntheta = num_cells_theta
391 sll_allocate(mat_stock1(nr + 1, nr + 1), ierr)
392 sll_allocate(mat_stock2(nr + 1, nr + 1), ierr)
393 sll_allocate(mat_stock3(nr + 1, nr + 1), ierr)
395 mat = (0._f64, 0._f64)
397 mat_stock1 = (0._f64, 0._f64)
398 mat_stock2 = (0._f64, 0._f64)
420 mat_stock3 = mat_stock1
434 mat_stock2(i, i) = mat_stock2(i, i) - (1._f64, 0._f64)
438 mat(m, :, :) = -mat_stock2
454 sll_comp64,
dimension(:, :, :),
intent(in) :: d_spl2d
455 sll_comp64,
dimension(:, :, :),
intent(in) :: d_contr
456 sll_int32,
intent(in) :: num_cells_r
457 sll_int32,
intent(in) :: num_cells_theta
458 sll_comp64,
dimension(:, :, :),
intent(out) :: mat
463 sll_comp64,
dimension(:, :),
allocatable :: mat_stock1
464 sll_comp64,
dimension(:, :),
allocatable :: mat_stock2
466 sll_comp64,
dimension(:, :),
allocatable :: mat_a
467 sll_comp64,
dimension(:, :),
allocatable :: mat_b
468 sll_comp64,
dimension(:, :),
allocatable :: mat_c
473 ntheta = num_cells_theta
475 sll_allocate(mat_stock1(nr + 1, nr + 1), ierr)
476 sll_allocate(mat_stock2(nr + 1, nr + 1), ierr)
477 sll_allocate(mat_a(nr + 1, nr + 3), ierr)
478 sll_allocate(mat_b(nr + 3, nr + 1), ierr)
479 sll_allocate(mat_c(nr + 1, nr + 1), ierr)
481 mat = (0._f64, 0._f64)
483 mat_stock1 = (0._f64, 0._f64)
484 mat_a(1:nr + 1, 1:nr + 3) = d_contr(m, :, :)
485 mat_b(1:nr + 3, 1:nr + 1) = d_spl2d(m, :, :)
516 mat_stock2 = (0._f64, 0._f64)
517 mat_stock1(:, :) = mat_c(1:nr + 1, 1:nr + 1)
542 mat_stock2(i, i) = mat_stock2(i, i) - (1._f64, 0._f64)
544 mat(m, :, :) = -mat_stock2
555 sll_real64,
dimension(:, :, :),
intent(in) :: d_spl2d
556 sll_real64,
dimension(:, :, :),
intent(in) :: d_contr
557 sll_int32,
intent(in) :: num_cells_r
558 sll_int32,
intent(in) :: num_cells_theta
559 sll_real64,
dimension(:, :, :),
intent(out) :: mat
564 sll_real64,
dimension(:, :),
allocatable :: mat_stock1
565 sll_real64,
dimension(:, :),
allocatable :: mat_stock2
567 sll_real64,
dimension(:, :),
allocatable :: mat_a
568 sll_real64,
dimension(:, :),
allocatable :: mat_b
569 sll_real64,
dimension(:, :),
allocatable :: mat_c
574 ntheta = num_cells_theta
576 sll_allocate(mat_stock1(nr + 1, nr + 1), ierr)
577 sll_allocate(mat_stock2(nr + 1, nr + 1), ierr)
578 sll_allocate(mat_a(nr + 1, nr + 3), ierr)
579 sll_allocate(mat_b(nr + 3, nr + 1), ierr)
580 sll_allocate(mat_c(nr + 1, nr + 1), ierr)
585 mat_a(1:nr + 1, 1:nr + 3) = d_contr(m, :, :)
586 mat_b(1:nr + 3, 1:nr + 1) = d_spl2d(m, :, :)
618 mat_stock1(:, :) = mat_c(1:nr + 1, 1:nr + 1)
643 mat_stock2(i, i) = mat_stock2(i, i) - 1._f64
645 mat(m, :, :) = -mat_stock2
659 sll_real64,
intent(in) :: r_min
660 sll_real64,
intent(in) :: r_max
661 sll_int32,
intent(in) :: num_cells_r
662 sll_int32,
intent(in) :: num_cells_theta
663 sll_real64,
dimension(:),
intent(in) :: rho
664 sll_real64,
dimension(:, :),
intent(in) :: points
665 sll_int32,
intent(in) :: n_points
666 sll_comp64,
dimension(:, :, :),
intent(out) :: mat
667 sll_int32,
dimension(:),
allocatable :: pre_compute_n
668 sll_int32 :: size_pre_compute
669 sll_int32,
dimension(:, :),
allocatable :: pre_compute_index
670 sll_real64,
dimension(:),
allocatable :: pre_compute_coeff_spl
671 sll_real64,
dimension(:, :, :),
allocatable :: pointer_mat_contribution_circ
672 sll_comp64,
dimension(:, :, :),
allocatable :: d_spl2d
673 sll_comp64,
dimension(:, :, :),
allocatable :: d_contr
679 sll_allocate(pre_compute_n(num_cells_r + 1), ierr)
694 sll_allocate(pre_compute_index(2, size_pre_compute), ierr)
695 sll_allocate(pre_compute_coeff_spl(size_pre_compute), ierr)
707 pre_compute_coeff_spl)
711 sll_allocate(pointer_mat_contribution_circ(num_cells_theta, num_cells_r + 1, num_cells_r + 3), ierr)
718 pre_compute_coeff_spl, &
720 pointer_mat_contribution_circ)
724 sll_allocate(d_spl2d(num_cells_theta, num_cells_r + 3, num_cells_r + 1), ierr)
733 sll_allocate(d_contr(num_cells_theta, num_cells_r + 1, num_cells_r + 3), ierr)
738 pointer_mat_contribution_circ, &
794 sll_comp64,
dimension(:, :, :),
intent(inout) :: mat
795 sll_real64,
dimension(:),
intent(in) :: lambda
796 sll_int32,
intent(in) :: num_cells_r
797 sll_int32,
intent(in) :: num_cells_theta
799 sll_int32,
dimension(:),
allocatable :: ipiv
800 sll_comp64,
dimension(:),
allocatable :: work
805 sll_allocate(ipiv(num_cells_r + 1), ierr)
806 sll_allocate(work((num_cells_r + 1)**2), ierr)
807 do i = 1, num_cells_r + 1
808 do m = 1, num_cells_theta
809 mat(m, i, i) = mat(m, i, i) + lambda(i)
813 do m = 1, num_cells_theta
827 (num_cells_r + 1)**2, &
831 print *,
'#here is INFO'
841 sll_comp64,
dimension(:, :, :),
intent(in) :: mat
842 sll_real64,
dimension(:, :),
intent(inout) :: phi
843 sll_comp64,
dimension(:, :),
allocatable :: phi_comp
844 sll_comp64,
dimension(:, :),
allocatable :: phi_old
845 sll_real64,
dimension(:),
allocatable::buf_fft
846 sll_int32,
intent(in) :: num_cells_r
847 sll_int32,
intent(in) :: num_cells_theta
857 ntheta = num_cells_theta
859 sll_allocate(phi_comp(1:nr + 1, 1:ntheta), ierr)
860 sll_allocate(phi_old(1:nr + 1, 1:ntheta), ierr)
861 sll_allocate(buf_fft(1:4*ntheta + 15), ierr)
864 phi_comp = phi*(1._f64, 0._f64)
865 call zffti(ntheta, buf_fft)
867 call zfftf(ntheta, phi_comp(i, :), buf_fft)
874 result = (0._f64, 0._f64)
876 result = result + mat(m, i, j)*phi_old(j, m)
878 phi_comp(i, m) = result
884 call zfftb(ntheta, phi_comp(i, :), buf_fft)
886 phi = real(phi_comp, f64)/real(ntheta, f64)
893 sll_deallocate_array(phi_comp, ierr)
894 sll_deallocate_array(phi_old, ierr)
895 sll_deallocate_array(buf_fft, ierr)
Fortran module where set some physical and mathematical constants.
real(kind=f64), parameter, public sll_p_pi
subroutine, public sll_s_compute_qns_matrix_polar_splines(r_min, r_max, num_cells_r, num_cells_theta, rho, points, N_points, mat)
subroutine compute_d_contr(num_cells_r, num_cells_theta, pointer_mat_contribution_circ, D_contr)
subroutine precompute_double_gyroaverage_coeff_polar_splines(r_min, r_max, num_cells_r, num_cells_theta, rho, points, N_points, size_pre_compute, pre_compute_index, pre_compute_coeff_spl)
subroutine compute_d_spl2d(num_cells_r, num_cells_theta, D_spl2D)
subroutine, public sll_s_solve_qns_polar_splines(mat, phi, num_cells_r, num_cells_theta)
subroutine compute_contribution_matrix(num_cells_r, num_cells_theta, pre_compute_N, pre_compute_index, pre_compute_coeff_spl, size_pre_compute, pointer_mat_contribution_circ)
subroutine compute_double_gyroaverage_matrix_blas(D_spl2D, D_contr, num_cells_r, num_cells_theta, mat)
subroutine compute_double_gyroaverage_matrix(D_spl2D, D_contr, num_cells_r, num_cells_theta, mat)
subroutine, public sll_s_compute_qns_inverse_polar_splines(mat, lambda, num_cells_r, num_cells_theta)
subroutine compute_double_gyroaverage_matrix_blas_real(D_spl2D, D_contr, num_cells_r, num_cells_theta, mat)
subroutine pre_precompute_double_gyroaverage_coeff_polar_splines(r_min, r_max, num_cells_r, num_cells_theta, rho, points, N_points, pre_compute_N, size_pre_compute)
subroutine, public sll_s_compute_splines_coefs_matrix_per_1d(mat, dper, lper, mper, N)
subroutine, public sll_s_contribution_spl(x, val)
subroutine, public sll_s_matrix_product_compf(A, NxA, NyA, B, NxB, NyB, prod)
subroutine, public sll_s_localize_polar(x, eta_min, eta_max, ii, eta, N)
subroutine, public sll_s_splcoefper1d0old(dper, lper, mper, N)
subroutine, public sll_s_compute_splines_coefs_matrix_nat_1d(mat, dnat, lnat, N)
subroutine, public sll_s_splcoefnat1d0old(dnat, lnat, N)