20 #include "sll_memory.h"
21 #include "sll_working_precision.h"
64 sll_real64 :: eta_min(2)
65 sll_real64 :: eta_max(2)
69 sll_real64,
dimension(:, :),
pointer :: points
70 sll_int32,
dimension(:, :),
pointer :: pre_compute_n
71 sll_real64,
dimension(:, :, :),
pointer :: pre_compute_coeff
72 sll_int32,
dimension(:, :, :),
pointer :: pre_compute_index
73 sll_real64,
dimension(:, :),
pointer :: pre_compute_coeff_spl
74 sll_int32 :: size_pre_compute
76 sll_real64,
dimension(:, :, :),
pointer :: mat_gyro
77 sll_real64,
dimension(:, :, :),
pointer :: mat_double_gyro
78 sll_real64,
dimension(:, :, :, :),
pointer :: mat_gyro_circ
79 sll_real64,
dimension(:, :, :, :),
pointer :: mat_double_gyro_circ
81 sll_comp64,
dimension(:, :, :),
pointer :: mat_qn_inverse
83 sll_real64,
dimension(:),
allocatable :: lambda
84 sll_real64,
dimension(:),
allocatable :: t_i
87 sll_real64,
dimension(:),
pointer :: mu_points_for_phi
88 sll_real64,
dimension(:),
pointer :: mu_weights_for_phi
89 sll_int32 :: n_mu_for_phi
97 sll_real64,
intent(in) :: eta_min(2)
98 sll_real64,
intent(in) :: eta_max(2)
99 sll_int32,
intent(in) :: nc(2)
100 sll_int32,
intent(in) :: n_points
101 sll_real64,
dimension(:),
intent(in) :: lambda
102 sll_real64,
dimension(:),
intent(in) :: t_i
107 sll_allocate(this%points(3, n_points), err)
108 sll_allocate(this%lambda(1:nc(1) + 1), err)
109 sll_allocate(this%T_i(1:nc(1) + 1), err)
113 this%eta_min = eta_min
114 this%eta_max = eta_max
116 this%N_points = n_points
124 sll_int32,
intent(in)::n
125 sll_real64,
dimension(0:N + 2, 1:N + 1),
intent(inout) :: mat
126 sll_real64,
dimension(0:N + 2),
intent(in)::dnat, lnat
127 sll_real64,
dimension(:, :),
allocatable :: matb
128 sll_int32 :: err, i, j
132 sll_allocate(matb(0:n + 2, 0:n + 2), err)
142 matb(i, j) = matb(i, j) - lnat(i - 1)*matb(i - 1, j)
147 matb(n + 2, j) = (matb(n + 2, j) - lnat(n + 1)*matb(n + 1, j) - lnat(n + 2)*matb(n, j))/dnat(n + 2)
152 matb(i, j) = (matb(i, j) - matb(i + 1, j))/dnat(i)
157 matb(1, j) = (matb(1, j) - 2._f64*matb(2, j))/dnat(1)
161 matb(0, j) = (matb(0, j) - 3._f64*matb(2, j))/dnat(0)
164 mat(0:n + 2, 1:n + 1) = matb(0:n + 2, 1:n + 1)
169 sll_int32,
intent(in)::n
170 sll_real64,
dimension(0:N - 1, 0:N - 1),
intent(inout) :: mat
171 sll_real64,
dimension(0:N + 2),
intent(in)::dper, lper, mper
182 mat(i, j) = mat(i, j) - lper(i - 1)*mat(i - 1, j)
188 mat(n - 1, j) = mat(n - 1, j) - mper(i)*mat(i, j)
193 mat(n - 1, j) = mat(n - 1, j)*dper(n - 1)
197 mat(n - 2, j) = dper(n - 2)*(mat(n - 2, j) - (1._f64 - mper(n - 3))*mat(n - 1, j))
202 mat(i, j) = dper(i)*(mat(i, j) - mat(i + 1, j) + mper(i - 1)*mat(n - 1, j))
207 mat(0, j) = dper(0)*(mat(0, j) - mat(1, j) - mat(n - 1, j))
213 sll_int32,
intent(in)::nxa, nya, nxb, nyb
214 sll_real64,
dimension(0:NxA - 1, 0:NyA - 1),
intent(in)::a
215 sll_real64,
dimension(0:NxB - 1, 0:NyB - 1),
intent(in)::b
216 sll_real64,
dimension(0:NxA*NxB - 1, 0:NyA*NyB - 1),
intent(inout) :: kronecker
217 sll_int32 :: ia, ib, ja, jb
223 kronecker(ib + nxb*ia, jb + nyb*ja) = a(ia, ja)*b(ib, jb)
232 sll_int32,
intent(in)::nxa, nya, nxb, nyb
233 sll_real64,
dimension(0:NxA - 1, 0:NyA - 1),
intent(in)::a
234 sll_real64,
dimension(0:NxB - 1, 0:NyB - 1),
intent(in)::b
235 sll_real64,
dimension(0:NxA - 1, 0:NyB - 1),
intent(inout) :: prod
240 print *,
'#incompatible sizes in matrix_product'
247 result = result + a(i, k)*b(k, j)
257 sll_int32,
intent(in)::nxa, nya, nxb, nyb
258 sll_comp64,
dimension(:, :),
intent(in)::a
259 sll_comp64,
dimension(:, :),
intent(in)::b
260 sll_comp64,
dimension(:, :),
intent(inout) :: prod
265 print *,
'#incompatible sizes in matrix_product'
270 result = (0.0_f64, 0.0_f64)
272 result = result + a(i, k)*b(k, j)
282 sll_int32,
intent(in)::nxa, nya, nxb, nyb
283 sll_comp64,
dimension(0:NxA - 1, 0:NyA - 1),
intent(in)::a
284 sll_comp64,
dimension(0:NxB - 1, 0:NyB - 1),
intent(in)::b
285 sll_comp64,
dimension(0:NxA - 1, 0:NyB - 1),
intent(inout) :: prod
290 print *,
'#incompatible sizes in matrix_product'
295 result = (0._f64, 0.0_f64)
297 result = result + a(i, k)*b(k, j)
307 sll_int32,
intent(in)::ntheta, nxa, nya, nxb, nyb
308 sll_real64,
dimension(0:Ntheta - 1, 0:NxA - 1, 0:NyA - 1),
intent(in)::a
309 sll_real64,
dimension(0:Ntheta - 1, 0:NxB - 1, 0:NyB - 1),
intent(in)::b
310 sll_real64,
dimension(0:Ntheta - 1, 0:NxA - 1, 0:NyB - 1),
intent(inout) :: prod
311 sll_real64,
dimension(:, :),
allocatable :: mat_stock, mat_stock_sum
312 sll_int32 :: i, j, error
315 sll_allocate(mat_stock(0:nxa - 1, 0:nyb - 1), error)
316 sll_allocate(mat_stock_sum(0:nxa - 1, 0:nyb - 1), error)
319 print *,
'#incompatible sizes in matrix_product_circ'
323 mat_stock_sum = 0._f64
325 call matrix_product(a(modulo(i + j, ntheta), :, :), nxa, nya, b(j, :, :), nxb, nyb, mat_stock)
326 mat_stock_sum = mat_stock_sum + mat_stock
328 prod(i, :, :) = mat_stock_sum
337 sll_real64,
dimension(1:N_rho),
intent(in) :: rho
338 sll_int32,
dimension(:, :),
allocatable :: buf
339 sll_int32 ::i, j, k, p, ell_1, ell_2, ii(2), s, nb, ind(2)
340 sll_real64::val(-1:2, -1:2), eta_star(2), eta(2), delta_eta(2), x(2)
341 sll_int32 ::error, max_nb
343 delta_eta(1) = (quasineutral%eta_max(1) - quasineutral%eta_min(1))/real(quasineutral%Nc(1), f64)
344 delta_eta(2) = (quasineutral%eta_max(2) - quasineutral%eta_min(2))/real(quasineutral%Nc(2), f64)
346 sll_allocate(buf(0:quasineutral%Nc(1) + 2, 0:quasineutral%Nc(2) - 1), error)
347 sll_allocate(quasineutral%pre_compute_N(1:n_rho, quasineutral%Nc(1) + 1), error)
349 eta(2) = quasineutral%eta_min(2)
357 do i = 1, quasineutral%Nc(1) + 1
358 eta(1) = quasineutral%eta_min(1) + real(i - 1, f64)*delta_eta(1)
360 do k = 1, quasineutral%N_points
361 x(1) = eta(1)*cos(eta(2)) + rho(p)*quasineutral%points(1, k)
362 x(2) = eta(1)*sin(eta(2)) + rho(p)*quasineutral%points(2, k)
363 call sll_s_localize_polar(x, quasineutral%eta_min, quasineutral%eta_max, ii, eta_star, quasineutral%Nc)
365 ind(2) = modulo(ii(2) + ell_2, quasineutral%Nc(2))
367 ind(1) = ii(1) + 1 + ell_1
368 if (buf(ind(1), ind(2)) .ne. i)
then
370 buf(ind(1), ind(2)) = i
375 quasineutral%pre_compute_N(p, i) = s
378 max_nb = max(max_nb, nb)
380 quasineutral%size_pre_compute = max_nb
385 sll_allocate(quasineutral%pre_compute_index(1:n_rho, 1:2, 1:max_nb), error)
386 sll_allocate(quasineutral%pre_compute_coeff_spl(1:n_rho, 1:max_nb), error)
394 eta(2) = quasineutral%eta_min(2)
395 do i = 1, quasineutral%Nc(1) + 1
396 eta(1) = quasineutral%eta_min(1) + real(i - 1, f64)*delta_eta(1)
397 do k = 1, quasineutral%N_points
398 x(1) = eta(1)*cos(eta(2)) + rho(p)*quasineutral%points(1, k)
399 x(2) = eta(1)*sin(eta(2)) + rho(p)*quasineutral%points(2, k)
400 call sll_s_localize_polar(x, quasineutral%eta_min, quasineutral%eta_max, ii, eta_star, quasineutral%Nc)
404 val = val*quasineutral%points(3, k)
407 ind(2) = modulo(ii(2) + ell_2, quasineutral%Nc(2))
409 ind(1) = ii(1) + 1 + ell_1
410 j = buf(ind(1), ind(2))
413 buf(ind(1), ind(2)) = s
414 quasineutral%pre_compute_coeff_spl(p, s) = val(ell_1, ell_2)
415 quasineutral%pre_compute_index(p, 1, s) = ind(1)
416 quasineutral%pre_compute_index(p, 2, s) = ind(2)
418 quasineutral%pre_compute_coeff_spl(p, j) = quasineutral%pre_compute_coeff_spl(p, j) + val(ell_1, ell_2)
430 sll_deallocate_array(buf, error)
436 sll_int32,
intent(in) :: n_mu
437 sll_real64,
dimension(1:N_mu),
intent(in) :: mu_points
438 sll_real64,
dimension(1:N_mu),
intent(in) :: mu_weights
439 sll_comp64,
dimension(:, :),
allocatable :: mat_stock1, mat_stock2
440 sll_real64,
dimension(:),
allocatable,
target::dnat, lnat, dper, lper, mper
441 sll_real64,
dimension(:),
pointer::pointer_dnat, pointer_lnat
442 sll_real64,
dimension(:),
pointer::pointer_dper, pointer_lper, pointer_mper
443 sll_real64,
dimension(:, :),
allocatable,
target::mat_nat, mat_per
444 sll_real64,
dimension(:, :),
pointer::pointer_mat_nat, pointer_mat_per
445 sll_real64,
dimension(:, :, :),
allocatable,
target::mat_spl2d_circ
446 sll_real64,
dimension(:, :, :),
pointer::pointer_mat_spl2d_circ
447 sll_real64,
dimension(:, :, :, :),
allocatable,
target::mat_contribution_circ
448 sll_real64,
dimension(:, :, :, :),
pointer::pointer_mat_contribution_circ
449 sll_comp64,
dimension(:, :, :),
allocatable::d_spl2d
450 sll_comp64,
dimension(:, :, :, :),
allocatable::d_contr
451 sll_int32,
dimension(:),
allocatable :: ipiv
452 sll_comp64,
dimension(:),
allocatable :: work
454 sll_comp64 :: exp_comp
456 sll_int32 :: nr, ntheta
458 sll_int32 :: i, j, k, m, p, s
462 nr = quasineutral%Nc(1)
463 ntheta = quasineutral%Nc(2)
466 sll_allocate(mat_stock1(0:nr, 0:nr), error)
467 sll_allocate(mat_stock2(0:nr, 0:nr), error)
468 sll_allocate(quasineutral%mat_qn_inverse(0:ntheta - 1, 0:nr, 0:nr), error)
469 sll_allocate(dnat(0:nr + 2), error)
470 sll_allocate(lnat(0:nr + 2), error)
471 sll_allocate(dper(0:ntheta - 1), error)
472 sll_allocate(lper(0:ntheta - 1), error)
473 sll_allocate(mper(0:ntheta - 1), error)
474 sll_allocate(mat_nat(0:nr + 2, 0:nr), error)
475 sll_allocate(mat_per(0:ntheta - 1, 0:ntheta - 1), error)
476 sll_allocate(mat_spl2d_circ(0:ntheta - 1, 0:nr + 2, 0:nr), error)
477 sll_allocate(d_spl2d(0:ntheta - 1, 0:nr + 2, 0:nr), error)
478 sll_allocate(mat_contribution_circ(0:n_mu, 0:ntheta - 1, 0:nr, 0:nr + 2), error)
479 sll_allocate(d_contr(0:n_mu, 0:ntheta - 1, 0:nr, 0:nr + 2), error)
480 sll_allocate(ipiv(nr + 1), error)
481 sll_allocate(work((nr + 1)**2), error)
483 sll_allocate(quasineutral%mat_double_gyro_circ(1:n_mu, 0:ntheta - 1, 0:nr, 0:nr), error)
484 sll_allocate(quasineutral%mat_gyro_circ(1:n_mu, 0:ntheta - 1, 0:nr, 0:nr), error)
496 pointer_mat_nat => mat_nat
497 pointer_mat_per => mat_per
498 pointer_mat_spl2d_circ => mat_spl2d_circ
499 pointer_mat_contribution_circ => mat_contribution_circ
505 pointer_mat_spl2d_circ(j, :, :) = pointer_mat_per(0, j)*pointer_mat_nat
509 pointer_mat_contribution_circ = 0._f64
513 do k = 1, quasineutral%pre_compute_N(p, i)
515 ii(1) = quasineutral%pre_compute_index(p, 1, s)
516 ii(2) = modulo(quasineutral%pre_compute_index(p, 2, s), ntheta)
517 pointer_mat_contribution_circ(p,ii(2),i-1,ii(1))=pointer_mat_contribution_circ(p,ii(2),i-1,ii(1))+quasineutral%pre_compute_coeff_spl(p,s)
523 d_spl2d = (0.0_f64, 0.0_f64)
524 d_contr = (0.0_f64, 0.0_f64)
527 mode = real(-2._f64*
sll_p_pi*real(j, f64)*real(m, f64)/real(ntheta, f64), f64)
528 exp_comp = cmplx(cos(mode), sin(mode), kind=f64)
529 d_spl2d(m, :, :) = d_spl2d(m, :, :) + pointer_mat_spl2d_circ(j, :, :)*exp_comp
531 d_contr(p, m, :, :) = d_contr(p, m, :, :) + pointer_mat_contribution_circ(p, j, :, :)*exp_comp
537 quasineutral%mat_qn_inverse = (0._f64, 0._f64)
540 mat_stock1 = (0._f64, 0._f64)
541 mat_stock2 = (0._f64, 0._f64)
542 call matrix_product_comp(d_contr(p, m, :, :), nr + 1, nr + 3, d_spl2d(m, :, :), nr + 3, nr + 1, mat_stock1)
543 call matrix_product_comp(mat_stock1(:, :), nr + 1, nr + 1, mat_stock1(:, :), nr + 1, nr + 1, mat_stock2)
548 mat_stock2(i, i) = mat_stock2(i, i) - quasineutral%lambda(i + 1)*(1._f64, 0._f64)
551 quasineutral%mat_qn_inverse(m, i, :) = &
552 quasineutral%mat_qn_inverse(m, i, :) &
553 - mu_weights(p)*mat_stock2(i, :)* &
554 cmplx(exp(-mu_points(p)/quasineutral%T_i(i + 1)), 0._f64, f64)
560 call zgetrf(nr + 1, nr + 1, quasineutral%mat_qn_inverse(m, :, :), nr + 1, ipiv, info)
561 call zgetri(nr + 1, quasineutral%mat_qn_inverse(m, :, :), nr + 1, ipiv, work, (nr + 1)**2, info)
565 sll_deallocate_array(mat_stock1, error)
566 sll_deallocate_array(mat_stock2, error)
567 sll_deallocate_array(dnat, error)
568 sll_deallocate_array(lnat, error)
569 sll_deallocate_array(dper, error)
570 sll_deallocate_array(lper, error)
571 sll_deallocate_array(mper, error)
572 sll_deallocate_array(mat_nat, error)
573 sll_deallocate_array(mat_per, error)
574 sll_deallocate_array(mat_spl2d_circ, error)
575 sll_deallocate_array(d_spl2d, error)
576 sll_deallocate_array(mat_contribution_circ, error)
577 sll_deallocate_array(d_contr, error)
578 sll_deallocate_array(ipiv, error)
579 sll_deallocate_array(work, error)
585 sll_real64,
dimension(1:quasineutral%Nc(1) + 1, 1:quasineutral%Nc(2)),
intent(inout) :: phi
586 sll_comp64,
dimension(:, :),
allocatable :: phi_comp, phi_old
587 sll_real64,
dimension(:),
allocatable::buf_fft
590 sll_int32 :: nr, ntheta
595 nr = quasineutral%Nc(1)
596 ntheta = quasineutral%Nc(2)
599 sll_allocate(phi_comp(1:nr + 1, 1:ntheta), error)
600 sll_allocate(phi_old(1:nr + 1, 1:ntheta), error)
601 sll_clear_allocate(buf_fft(1:4*ntheta + 15), error)
604 phi_comp = phi*(1._f64, 0._f64)
605 call zffti(ntheta, buf_fft)
609 call zfftf(ntheta, phi_comp(i, :), buf_fft)
617 result = (0._f64, 0.0_f64)
619 result = result + quasineutral%mat_qn_inverse(m - 1, i - 1, j - 1)*phi_old(j, m)
621 phi_comp(i, m) = result
627 call zfftb(ntheta, phi_comp(i, :), buf_fft)
630 phi = real(phi_comp, f64)/real(ntheta, f64)
639 sll_deallocate_array(phi_comp, error)
640 sll_deallocate_array(phi_old, error)
641 sll_deallocate_array(buf_fft, error)
645 subroutine sll_s_qn_2d_polar_test_solve(Nc, eta_min, eta_max, mu_points, mu_weights, N_mu, mode, lambda, T_i, phi_init, phi_qn)
646 sll_int32,
intent(in) :: nc(2)
647 sll_real64,
intent(in) :: eta_min(2)
648 sll_real64,
intent(in) :: eta_max(2)
649 sll_int32,
intent(in) :: n_mu
650 sll_int32,
intent(in) :: mode(2)
651 sll_real64,
dimension(1:N_mu),
intent(in) :: mu_points
652 sll_real64,
dimension(1:N_mu),
intent(in) :: mu_weights
653 sll_real64,
dimension(1:Nc(1) + 1, 1:Nc(2) + 1),
intent(in) :: phi_init
654 sll_real64,
dimension(1:Nc(1) + 1, 1:Nc(2) + 1),
intent(in) :: phi_qn
655 sll_real64,
dimension(1:Nc(1) + 1),
intent(in) :: lambda, t_i
656 sll_int32 :: n_min(2), n_max(2)
657 sll_real64,
dimension(:),
allocatable :: gamma0
659 sll_real64 :: eps, rho2d(2), mu2dmax(2), error(3)
660 sll_int32 :: i, ierr, p
662 sll_allocate(gamma0(1:nc(1) + 1), ierr)
668 mu2dmax(1) = maxval(mu_points)
669 mu2dmax(2) = maxval(mu_points)
677 rho2d(1) = sqrt(2._f64*mu_points(p))
678 rho2d(2) = sqrt(2._f64*mu_points(p))
681 gamma0(i) = gamma0(i) + mu_weights(p)*exp(-mu_points(p)/t_i(i))*(lambda(i) - tmp1**2)
685 gamma0(i) = 1._f64/gamma0(i)
690 print *,
'#N_min(1:2) / N_max(1:2) = ', n_min,
' / ', n_max
692 print *,
'#error subdomain=', error
694 print *,
'#error whole domain=', error
719 sll_int32,
intent(in) :: nc(2)
720 sll_real64,
intent(in) :: eta_min(2)
721 sll_real64,
intent(in) :: eta_max(2)
722 sll_int32,
intent(in) :: n_mu
723 sll_int32,
intent(in) :: mode(2)
724 sll_real64,
dimension(1:N_mu),
intent(in) :: mu_points
725 sll_real64,
dimension(1:N_mu),
intent(in) :: mu_weights
728 sll_real64 :: rho2d(2)
733 rho2d(1) = sqrt(2._f64*mu_points(p))
734 rho2d(2) = sqrt(2._f64*mu_points(p))
737 gamma0 = gamma0 + mu_weights(p)*(1._f64 - tmp1**2)
758 sll_comp64,
dimension(:, :, :),
allocatable :: dm
759 sll_comp64,
dimension(:, :),
allocatable :: sol_comp
760 sll_comp64,
dimension(:, :),
allocatable :: sol_old
761 sll_real64,
dimension(:),
allocatable :: buf_fft
763 sll_comp64 :: exp_comp, result
764 sll_int32,
dimension(:),
allocatable :: ipiv
765 sll_comp64,
dimension(:),
allocatable :: work
767 sll_real64,
dimension(0:Ntheta - 1, 0:Nr, 0:Nr),
intent(in) :: mat_circ
768 sll_real64,
dimension(1:Nr + 1, 1:Ntheta),
intent(inout) ::
sol
771 sll_allocate(dm(0:ntheta - 1, 0:nr, 0:nr), error)
772 sll_allocate(sol_comp(1:nr + 1, 1:ntheta), error)
773 sll_allocate(sol_old(1:nr + 1, 1:ntheta), error)
774 sll_allocate(buf_fft(1:4*ntheta + 15), error)
775 sll_allocate(ipiv(nr + 1), error)
776 sll_allocate(work((nr + 1)**2), error)
778 sol_comp =
sol*(1._f64, 0._f64)
781 call zffti(ntheta, buf_fft)
785 call zfftf(ntheta, sol_comp(i, :), buf_fft)
790 dm = (0._f64, 0.0_f64)
793 mode = real(-2._f64*
sll_p_pi*real(j, f64)*real(m, f64)/real(ntheta, f64), f64)
794 exp_comp = cmplx(cos(mode), sin(mode), kind=f64)
795 dm(m, :, :) = dm(m, :, :) + mat_circ(j, :, :)*exp_comp
798 call zgetrf(nr + 1, nr + 1, dm(m, :, :), nr + 1, ipiv, info)
799 call zgetri(nr + 1, dm(m, :, :), nr + 1, ipiv, work, (nr + 1)**2, info)
807 result = (0._f64, 0.0_f64)
809 result = result + dm(m - 1, i - 1, j - 1)*sol_old(j, m)
811 sol_comp(i, m) = result
817 call zfftb(ntheta, sol_comp(i, :), buf_fft)
821 sol = real(sol_comp/cmplx(ntheta, 0._f64, f64), f64)
829 sll_int32,
intent(in) :: nr, ntheta
830 sll_real64,
dimension(0:Ntheta - 1, 0:Nr, 0:Nr),
intent(in) :: mat
831 sll_real64,
dimension(:, :, :),
allocatable :: inv, test_id
832 sll_real64,
dimension(:, :),
allocatable :: phi
833 sll_int32 :: i, j, m, error
835 sll_allocate(inv(0:ntheta - 1, 0:nr, 0:nr), error)
836 sll_allocate(test_id(0:ntheta - 1, 0:nr, 0:nr), error)
837 sll_allocate(phi(1:nr + 1, 1:ntheta), error)
847 inv(modulo(ntheta - j, ntheta), i, m - 1) = phi(i + 1, j + 1)
855 test_id(0, i, i) = test_id(0, i, i) - 1._f64
858 print *,
"Inversion error = ", maxval(test_id)
865 sll_int32,
intent(in)::n(2), d(2)
866 sll_real64,
dimension(N(1) + 1, N(2)),
intent(in)::f
867 sll_real64,
dimension(9, N(1) + 1, N(2) + 1),
intent(out)::buf3d
868 sll_real64 ::w_left_1(-d(1)/2:(d(1) + 1)/2), w_right_1((-d(1) + 1)/2:d(1)/2 + 1)
869 sll_real64 ::w_left_2(-d(2)/2:(d(2) + 1)/2), w_right_2((-d(2) + 1)/2:d(2)/2 + 1)
871 sll_int32 ::i, j, ii, r_left(2), r_right(2), s_left(2), s_right(2), ind
879 if ((2*(d(1)/2) - d(1)) == 0)
then
880 w_right_1(r_right(1):s_right(1)) = w_left_1(r_left(1):s_left(1))
882 w_right_1(r_right(1):s_right(1)) = -w_left_1(s_left(1):r_left(1):-1)
885 if ((2*(d(2)/2) - d(2)) == 0)
then
886 w_right_2(r_right(2):s_right(2)) = w_left_2(r_left(2):s_left(2))
888 w_right_2(r_right(2):s_right(2)) = -w_left_2(s_left(2):r_left(2):-1)
896 buf3d(1, i, j) = f(i, j)
898 do ii = r_left(1), s_left(1)
899 ind = i + ii;
if (ind > n(1) + 1) ind = 2*(n(1) + 1) - ind;
if (ind < 1) ind = 2 - ind
900 tmp = tmp + w_left_1(ii)*f(ind, j)
904 do ii = r_right(1), s_right(1)
905 ind = i + ii;
if (ind > n(1) + 1) ind = 2*(n(1) + 1) - ind;
if (ind < 1) ind = 2 - ind
906 tmp = tmp + w_right_1(ii)*f(ind, j)
914 do ii = r_left(2), s_left(2)
915 ind = modulo(j + ii - 1 + n(2), n(2)) + 1
916 tmp = tmp + w_left_2(ii)*f(i, ind)
920 do ii = r_right(2), s_right(2)
921 ind = modulo(j + ii - 1 + n(2), n(2)) + 1
922 tmp = tmp + w_right_2(ii)*f(i, ind)
931 do ii = r_left(1), s_left(1)
932 ind = i + ii;
if (ind > n(1) + 1) ind = 2*(n(1) + 1) - ind;
if (ind < 1) ind = 2 - ind
933 tmp = tmp + w_left_1(ii)*buf3d(4, ind, j)
937 do ii = r_right(1), s_right(1)
938 ind = i + ii;
if (ind > n(1) + 1) ind = 2*(n(1) + 1) - ind;
if (ind < 1) ind = 2 - ind
939 tmp = tmp + w_right_1(ii)*buf3d(4, ind, j)
943 do ii = r_left(1), s_left(1)
944 ind = i + ii;
if (ind > n(1) + 1) ind = 2*(n(1) + 1) - ind;
if (ind < 1) ind = 2 - ind
945 tmp = tmp + w_left_1(ii)*buf3d(5, ind, j)
949 do ii = r_right(1), s_right(1)
950 ind = i + ii;
if (ind > n(1) + 1) ind = 2*(n(1) + 1) - ind;
if (ind < 1) ind = 2 - ind
951 tmp = tmp + w_right_1(ii)*buf3d(5, ind, j)
957 buf3d(:, :, n(2) + 1) = buf3d(:, :, 1)
962 integer,
intent(in)::N(2), d(2)
963 sll_real64,
dimension(N(1) + 1, N(2)),
intent(in)::f
964 sll_real64,
dimension(4, N(1) + 1, N(2) + 1),
intent(out)::buf3d
965 sll_real64,
dimension(:),
allocatable ::w_left_1, w_left_2
967 sll_int32::i, j, ii, r_left(2), s_left(2), ind, dd(2)
969 dd(1) = 2*((d(1) + 1)/2)
970 dd(2) = 2*((d(2) + 1)/2)
975 sll_allocate(w_left_1(-dd(1)/2:dd(1)/2), error)
976 sll_allocate(w_left_2(-dd(2)/2:dd(2)/2), error)
986 buf3d(1, i, j) = f(i, j)
988 do ii = r_left(1), s_left(1)
989 ind = i + ii;
if (ind > n(1) + 1) ind = 2*(n(1) + 1) - ind;
if (ind < 1) ind = 2 - ind
990 tmp = tmp + w_left_1(ii)*f(ind, j)
998 do ii = r_left(2), s_left(2)
999 ind = modulo(j + ii - 1 + n(2), n(2)) + 1
1000 tmp = tmp + w_left_2(ii)*f(i, ind)
1002 buf3d(3, i, j) = tmp
1009 do ii = r_left(1), s_left(1)
1010 ind = i + ii;
if (ind > n(1) + 1) ind = 2*(n(1) + 1) - ind;
if (ind < 1) ind = 2 - ind
1011 tmp = tmp + w_left_1(ii)*buf3d(3, ind, j)
1013 buf3d(4, i, j) = tmp
1017 buf3d(:, :, n(2) + 1) = buf3d(:, :, 1)
1019 sll_deallocate_array(w_left_1, error)
1020 sll_deallocate_array(w_left_2, error)
1025 sll_int32,
intent(in)::r, s
1026 sll_real64,
dimension(r:s),
intent(out)::w
1044 tmp = tmp*real(i - j, f64)
1047 tmp = tmp*real(i - j, f64)
1051 tmp = tmp*real(-j, f64)
1054 tmp = tmp*real(-j, f64)
1057 tmp = tmp*real(-j, f64)
1065 tmp = tmp*real(i - j, f64)
1068 tmp = tmp*real(i - j, f64)
1072 tmp = tmp*real(-j, f64)
1075 tmp = tmp*real(-j, f64)
1078 tmp = tmp*real(-j, f64)
1100 sll_real64,
intent(in)::x(2), eta_min(2), eta_max(2)
1101 sll_int32,
intent(out)::ii(2)
1102 sll_int32,
intent(in)::n(2)
1103 sll_real64,
intent(out)::eta(2)
1105 eta(1) = sqrt(x(1)**2 + x(2)**2)
1106 call localize_nat(ii(1), eta(1), eta_min(1), eta_max(1), n(1))
1107 eta(2) = atan2(x(2), x(1))
1108 call localize_per(ii(2), eta(2), eta_min(2), eta_max(2), n(2))
1112 sll_int32,
intent(out)::i
1113 sll_real64,
intent(inout)::x
1114 sll_real64,
intent(in)::xmin, xmax
1115 sll_int32,
intent(in)::n
1116 x = (x - xmin)/(xmax - xmin)
1117 x = x - real(floor(x), f64)
1120 x = x - real(i, f64)
1128 sll_int32,
intent(out)::i
1129 sll_real64,
intent(inout)::x
1130 sll_real64,
intent(in)::xmin, xmax
1131 sll_int32,
intent(in)::n
1132 x = (x - xmin)/(xmax - xmin)
1134 if (x >= real(n, f64))
then
1137 if (x <= 0._f64)
then
1141 x = x - real(i, f64)
1149 sll_int32,
intent(in)::i(2), n(2)
1151 sll_real64,
intent(in)::x(2)
1152 sll_real64,
intent(out)::fval
1153 sll_real64,
dimension(0:8, 0:N(1), 0:N(2))::f
1156 sll_real64::w(2, 0:3), tmp(0:3)
1157 sll_real64::g(0:3, 0:3)
1164 w(s, 0) = (2._f64*x(s) + 1)*(1._f64 - x(s))*(1._f64 - x(s));
1165 w(s, 1) = x(s)*x(s)*(3._f64 - 2._f64*x(s))
1166 w(s, 2) = x(s)*(1._f64 - x(s))*(1._f64 - x(s))
1167 w(s, 3) = x(s)*x(s)*(x(s) - 1._f64)
1171 g(0, 0) = f(0, i(1), i(2))
1172 g(1, 0) = f(0, i1(1), i(2))
1173 g(2, 0) = f(1, i(1), i(2))
1174 g(3, 0) = f(2, i(1), i(2))
1175 g(0, 1) = f(0, i(1), i1(2))
1176 g(1, 1) = f(0, i1(1), i1(2))
1177 g(2, 1) = f(1, i(1), i1(2))
1178 g(3, 1) = f(2, i(1), i1(2))
1179 g(0, 2) = f(3, i(1), i(2))
1180 g(1, 2) = f(3, i1(1), i(2))
1181 g(2, 2) = f(5, i(1), i(2))
1182 g(3, 2) = f(6, i(1), i(2))
1183 g(0, 3) = f(4, i(1), i(2))
1184 g(1, 3) = f(4, i1(1), i(2))
1185 g(2, 3) = f(7, i(1), i(2))
1186 g(3, 3) = f(8, i(1), i(2))
1189 tmp(s) = w(1, 0)*g(0, s) + w(1, 1)*g(1, s) + w(1, 2)*g(2, s) + w(1, 3)*g(3, s)
1192 fval = w(2, 0)*tmp(0) + w(2, 1)*tmp(1) + w(2, 2)*tmp(2) + w(2, 3)*tmp(3)
1198 sll_int32,
intent(in)::i(2), n(2)
1200 sll_real64,
intent(in)::x(2)
1201 sll_real64,
intent(out)::fval
1202 sll_real64,
dimension(0:3, 0:N(1), 0:N(2))::f
1205 sll_real64::w(2, 0:3), tmp(0:3)
1206 sll_real64::g(0:3, 0:3)
1213 w(s, 0) = (2._f64*x(s) + 1)*(1._f64 - x(s))*(1._f64 - x(s));
1214 w(s, 1) = x(s)*x(s)*(3._f64 - 2._f64*x(s))
1215 w(s, 2) = x(s)*(1._f64 - x(s))*(1._f64 - x(s))
1216 w(s, 3) = x(s)*x(s)*(x(s) - 1._f64)
1220 g(0, 0) = f(0, i(1), i(2))
1221 g(1, 0) = f(0, i1(1), i(2))
1222 g(2, 0) = f(1, i(1), i(2))
1223 g(3, 0) = f(1, i1(1), i(2))
1224 g(0, 1) = f(0, i(1), i1(2))
1225 g(1, 1) = f(0, i1(1), i1(2))
1226 g(2, 1) = f(1, i(1), i1(2))
1227 g(3, 1) = f(1, i1(1), i1(2))
1228 g(0, 2) = f(2, i(1), i(2))
1229 g(1, 2) = f(2, i1(1), i(2))
1230 g(2, 2) = f(3, i(1), i(2))
1231 g(3, 2) = f(3, i1(1), i(2))
1232 g(0, 3) = f(2, i(1), i1(2))
1233 g(1, 3) = f(2, i1(1), i1(2))
1234 g(2, 3) = f(3, i(1), i1(2))
1235 g(3, 3) = f(3, i1(1), i1(2))
1238 tmp(s) = w(1, 0)*g(0, s) + w(1, 1)*g(1, s) + w(1, 2)*g(2, s) + w(1, 3)*g(3, s)
1241 fval = w(2, 0)*tmp(0) + w(2, 1)*tmp(1) + w(2, 2)*tmp(2) + w(2, 3)*tmp(3)
1246 sll_real64,
intent(in)::x(0:1)
1247 sll_real64,
intent(out)::val(4, 0:1, 0:1)
1249 sll_real64::w(0:3, 0:1)
1251 w(0, s) = (2._f64*x(s) + 1)*(1._f64 - x(s))*(1._f64 - x(s));
1252 w(1, s) = x(s)*x(s)*(3._f64 - 2._f64*x(s))
1253 w(2, s) = x(s)*(1._f64 - x(s))*(1._f64 - x(s))
1254 w(3, s) = x(s)*x(s)*(x(s) - 1._f64)
1257 val(1, 0, 0) = w(0, 0)*w(0, 1)
1258 val(2, 0, 0) = w(2, 0)*w(0, 1)
1259 val(3, 0, 0) = w(0, 0)*w(2, 1)
1260 val(4, 0, 0) = w(2, 0)*w(2, 1)
1262 val(1, 1, 0) = w(1, 0)*w(0, 1)
1263 val(2, 1, 0) = w(3, 0)*w(0, 1)
1264 val(3, 1, 0) = w(1, 0)*w(2, 1)
1265 val(4, 1, 0) = w(3, 0)*w(2, 1)
1267 val(1, 0, 1) = w(0, 0)*w(1, 1)
1268 val(2, 0, 1) = w(2, 0)*w(1, 1)
1269 val(3, 0, 1) = w(0, 0)*w(3, 1)
1270 val(4, 0, 1) = w(2, 0)*w(3, 1)
1272 val(1, 1, 1) = w(1, 0)*w(1, 1)
1273 val(2, 1, 1) = w(3, 0)*w(1, 1)
1274 val(3, 1, 1) = w(1, 0)*w(3, 1)
1275 val(4, 1, 1) = w(3, 0)*w(3, 1)
1283 sll_real64,
intent(in)::x(0:1)
1284 sll_real64,
intent(out)::val(-1:2, -1:2)
1286 sll_real64::w(-1:2, 0:1)
1288 w(-1, s) = (1._f64/6._f64)*(1._f64 - x(s))*(1._f64 - x(s))*(1._f64 - x(s));
1289 w(0, s) = 1._f64/6._f64 + 0.5_f64*(1._f64 - x(s))*(-(1._f64 - x(s))* &
1290 (1._f64 - x(s)) + (1._f64 - x(s)) + 1._f64);
1291 w(1, s) = 1._f64/6._f64 + 0.5_f64*x(s)*(-x(s)*x(s) + x(s) + 1._f64);
1292 w(2, s) = (1._f64/6._f64)*x(s)*x(s)*x(s);
1295 val(-1, -1) = w(-1, 0)*w(-1, 1)
1296 val(-1, 0) = w(-1, 0)*w(0, 1)
1297 val(-1, 1) = w(-1, 0)*w(1, 1)
1298 val(-1, 2) = w(-1, 0)*w(2, 1)
1300 val(0, -1) = w(0, 0)*w(-1, 1)
1301 val(0, 0) = w(0, 0)*w(0, 1)
1302 val(0, 1) = w(0, 0)*w(1, 1)
1303 val(0, 2) = w(0, 0)*w(2, 1)
1305 val(1, -1) = w(1, 0)*w(-1, 1)
1306 val(1, 0) = w(1, 0)*w(0, 1)
1307 val(1, 1) = w(1, 0)*w(1, 1)
1308 val(1, 2) = w(1, 0)*w(2, 1)
1310 val(2, -1) = w(2, 0)*w(-1, 1)
1311 val(2, 0) = w(2, 0)*w(0, 1)
1312 val(2, 1) = w(2, 0)*w(1, 1)
1313 val(2, 2) = w(2, 0)*w(2, 1)
1318 sll_int32,
intent(in)::n
1319 sll_real64,
dimension(0:1, 0:N + 2),
intent(out)::lunat
1322 a(0) = -3._f64; a(1) = 0._f64; a(2) = 3._f64;
1324 lunat(1, 0) = 1._f64/lunat(0, 0);
1325 lunat(0, 1) = 4._f64 - a(1)*lunat(1, 0);
1326 lunat(1, 1) = 1._f64/lunat(0, 1);
1327 lunat(0, 2) = 4._f64 - lunat(1, 1)*(1._f64 - a(2)/a(0));
1329 lunat(1, i) = 1._f64/lunat(0, i);
1330 lunat(0, i + 1) = 4._f64 - lunat(1, i);
1332 lunat(1, n + 2) = a(0)/lunat(0, n);
1333 lunat(1, n + 1) = (a(1) - lunat(1, n + 2))/lunat(0, n + 1);
1334 lunat(0, n + 2) = a(2) - lunat(1, n + 1);
1338 sll_int32,
intent(in)::n
1339 sll_real64,
dimension(0:1, 0:N + 2),
intent(in)::lunat
1340 sll_real64,
dimension(0:N + 2),
intent(inout)::p
1343 a(0) = -3._f64; a(1) = 0._f64; a(2) = 3._f64;
1349 do i = 1, n + 1; p(i) = p(i) - lunat(1, i - 1)*p(i - 1);
end do
1350 p(n + 2) = p(n + 2) - (lunat(1, n + 1)*p(n + 1) + lunat(1, n + 2)*p(n));
1351 p(n + 2) = p(n + 2)/lunat(0, n + 2);
1352 do i = n + 1, 2, -1; p(i) = (p(i) - p(i + 1))/lunat(0, i);
end do
1353 p(1) = (p(1) - (1._f64 - a(2)/a(0))*p(2))/lunat(0, 1);
1354 p(0) = (p(0) - a(1)*p(1) - a(2)*p(2))/lunat(0, 0);
1361 sll_int32,
intent(in)::n
1362 sll_real64,
dimension(0:N + 2),
intent(inout)::dnat, lnat
1365 a(0) = -3._f64; a(1) = 0._f64; a(2) = 3._f64;
1367 lnat(0) = 1._f64/dnat(0);
1368 dnat(1) = 4._f64 - a(1)*lnat(0);
1369 lnat(1) = 1._f64/dnat(1);
1370 dnat(2) = 4._f64 - lnat(1)*(1._f64 - a(2)/a(0));
1372 lnat(i) = 1._f64/dnat(i);
1373 dnat(i + 1) = 4._f64 - lnat(i);
1375 lnat(n + 2) = a(0)/dnat(n);
1376 lnat(n + 1) = (a(1) - lnat(n + 2))/dnat(n + 1);
1377 dnat(n + 2) = a(2) - lnat(n + 1);
1381 sll_int32,
intent(in)::nx, ny
1382 sll_real64,
dimension(:, :),
pointer::f
1383 sll_real64,
dimension(:),
pointer::buf, dpery, lpery, mpery, dnatx, lnatx
1387 do i = 0, nx + 2; buf(i) = f(i, j);
end do
1389 do i = 0, nx + 2; f(i, j) = buf(i);
end do
1393 do j = 0, ny - 1; buf(j) = f(i, j);
end do
1395 do j = 0, ny - 1; f(i, j) = buf(j);
end do
1400 subroutine splnatper2d(f, xx, xmin, xmax, yy, ymin, ymax, fval, Nx, Ny)
1401 sll_int32,
intent(in)::nx, ny
1402 sll_real64,
intent(in)::xx, xmin, xmax, yy, ymin, ymax
1403 sll_real64,
intent(out)::fval
1404 sll_real64,
dimension(:, :),
pointer::f
1406 sll_int32::ix(0:3), iy(0:3)
1408 sll_real64::wx(0:3), wy(0:3), tmp(0:3)
1410 x = (xx - xmin)/(xmax - xmin)
1412 if (x < 0._f64) x = 0._f64;
1413 if (x >= 1._f64) x = 1._f64 - 1.e-12_f64;
1416 x = x - real(i, f64)
1418 y = (yy - ymin)/(ymax - ymin)
1419 y = y - real(floor(y), f64)
1422 y = y - real(j, f64)
1424 wx(0) = (1._f64/6._f64)*(1._f64 - x)*(1._f64 - x)*(1._f64 - x);
1425 wx(1) = 1._f64/6._f64 + 0.5_f64*(1._f64 - x)*(-(1._f64 - x)* &
1426 (1._f64 - x) + (1._f64 - x) + 1._f64);
1427 wx(2) = 1._f64/6._f64 + 0.5_f64*x*(-x*x + x + 1._f64);
1428 wx(3) = (1._f64/6._f64)*x*x*x;
1429 wy(0) = (1._f64/6._f64)*(1._f64 - y)*(1._f64 - y)*(1._f64 - y);
1430 wy(1) = 1._f64/6._f64 + 0.5_f64*(1._f64 - y)*(-(1._f64 - y)* &
1431 (1._f64 - y) + (1._f64 - y) + 1._f64);
1432 wy(2) = 1._f64/6._f64 + 0.5_f64*y*(-y*y + y + 1._f64);
1433 wy(3) = (1._f64/6._f64)*y*y*y;
1434 iy(0) = mod(j + ny - 1, ny)
1436 iy(2) = mod(j + 1, ny)
1437 iy(3) = mod(j + 2, ny)
1444 tmp(0) = wx(0)*f(ix(0), iy(0)) + wx(1)*f(ix(1), iy(0)) &
1445 + wx(2)*f(ix(2), iy(0)) + wx(3)*f(ix(3), iy(0))
1446 tmp(1) = wx(0)*f(ix(0), iy(1)) + wx(1)*f(ix(1), iy(1)) &
1447 + wx(2)*f(ix(2), iy(1)) + wx(3)*f(ix(3), iy(1))
1448 tmp(2) = wx(0)*f(ix(0), iy(2)) + wx(1)*f(ix(1), iy(2)) &
1449 + wx(2)*f(ix(2), iy(2)) + wx(3)*f(ix(3), iy(2))
1450 tmp(3) = wx(0)*f(ix(0), iy(3)) + wx(1)*f(ix(1), iy(3)) &
1451 + wx(2)*f(ix(2), iy(3)) + wx(3)*f(ix(3), iy(3))
1453 fval = wy(0)*tmp(0) + wy(1)*tmp(1) + wy(2)*tmp(2) + wy(3)*tmp(3)
1458 sll_int32,
intent(in)::n
1459 sll_real64,
intent(in)::xx, xmin, xmax
1460 sll_real64,
intent(out)::fval
1461 sll_real64,
dimension(0:N - 1),
intent(inout)::f
1465 x = (xx - xmin)/(xmax - xmin)
1466 x = x - real(floor(x), f64)
1469 x = x - real(i, f64)
1470 w(0) = (1._f64/6._f64)*(1._f64 - x)*(1._f64 - x)*(1._f64 - x);
1471 w(1) = 1._f64/6._f64 + 0.5_f64*(1._f64 - x)*(-(1._f64 - x)* &
1472 (1._f64 - x) + (1._f64 - x) + 1._f64);
1473 w(2) = 1._f64/6._f64 + 0.5_f64*x*(-x*x + x + 1._f64);
1474 w(3) = (1._f64/6._f64)*x*x*x;
1475 fval = w(0)*f(mod(i + n - 1, n)) + w(1)*f(i) + w(2)*f(mod(i + 1, n)) + w(3)*f(mod(i + 2, n))
1479 sll_int32,
intent(in)::n
1480 sll_real64,
intent(in)::xx, xmin, xmax
1481 sll_real64,
intent(out)::fval
1482 sll_real64,
dimension(0:N + 2),
intent(inout)::f
1486 x = (xx - xmin)/(xmax - xmin)
1488 if (x < 0._f64) x = 0._f64;
1489 if (x > 1._f64) x = 1._f64 - 1.e-12_f64;
1492 x = x - real(i, f64)
1494 w(0) = (1._f64/6._f64)*(1._f64 - x)*(1._f64 - x)*(1._f64 - x);
1495 w(1) = 1._f64/6._f64 + 0.5_f64*(1._f64 - x)*(-(1._f64 - x)* &
1496 (1._f64 - x) + (1._f64 - x) + 1._f64);
1497 w(2) = 1._f64/6._f64 + 0.5_f64*x*(-x*x + x + 1._f64);
1498 w(3) = (1._f64/6._f64)*x*x*x;
1499 fval = w(0)*f(i) + w(1)*f(i + 1) + w(2)*f(i + 2) + w(3)*f(i + 3)
1503 sll_int32,
intent(in)::n
1504 sll_real64,
dimension(0:N - 1),
intent(out)::dper, lper, mper
1510 lper(i) = 1._f64/dper(i)
1511 dper(i + 1) = 4._f64 - lper(i)
1512 mper(i + 1) = -mper(i)/dper(i + 1)
1514 dper(n - 1) = dper(n - 1) - (lper(n - 2) + 2._f64*mper(n - 2))
1516 dper(i) = 1._f64/dper(i)
1521 sll_int32,
intent(in)::n
1522 sll_real64,
dimension(0:3*N - 1),
intent(out)::luper
1525 luper(0 + 3*0) = 4._f64
1526 luper(2 + 3*0) = 0.25_f64
1528 luper(1 + 3*i) = 1._f64/luper(0 + 3*i)
1529 luper(0 + 3*(i + 1)) = 4._f64 - luper(1 + 3*i)
1530 luper(2 + 3*(i + 1)) = -luper(2 + 3*i)/luper(0 + 3*(i + 1))
1532 luper(0 + 3*(n - 1)) = luper(0 + 3*(n - 1)) - (luper(1 + 3*(n - 2)) + 2._f64*luper(2 + 3*(n - 2)))
1534 luper(0 + 3*i) = 1._f64/luper(0 + 3*i)
1539 sll_int32,
intent(in)::n
1540 sll_real64,
dimension(0:3*N - 1),
intent(in)::luper
1541 sll_real64,
dimension(0:N - 1),
intent(inout)::f
1543 do i = 0, n - 1; f(i) = 6._f64*f(i);
end do;
1545 f(i) = f(i) - f(i - 1)*luper(1 + 3*(i - 1))
1548 f(n - 1) = f(n - 1) - luper(2 + 3*i)*f(i)
1550 f(n - 1) = f(n - 1)*luper(0 + 3*(n - 1)); f(n - 2) = luper(0 + 3*(n - 2))*(f(n - 2) - (1._f64 - luper(2 + 3*(n - 3)))*f(n - 1))
1552 f(i) = luper(0 + 3*i)*(f(i) - f(i + 1) + luper(2 + 3*(i - 1))*f(n - 1))
1554 f(0) = luper(0 + 3*0)*(f(0) - f(1) - f(n - 1));
1558 sll_int32,
intent(in)::n
1559 sll_real64,
dimension(0:N + 2),
intent(in)::dnat, lnat
1560 sll_real64,
dimension(0:N + 2),
intent(inout)::p
1563 a(0) = -3._f64; a(1) = 0._f64; a(2) = 3._f64;
1569 do i = 1, n + 1; p(i) = p(i) - lnat(i - 1)*p(i - 1);
end do
1570 p(n + 2) = p(n + 2) - (lnat(n + 1)*p(n + 1) + lnat(n + 2)*p(n));
1571 p(n + 2) = p(n + 2)/dnat(n + 2);
1572 do i = n + 1, 2, -1; p(i) = (p(i) - p(i + 1))/dnat(i);
end do
1573 p(1) = (p(1) - (1._f64 - a(2)/a(0))*p(2))/dnat(1);
1574 p(0) = (p(0) - a(1)*p(1) - a(2)*p(2))/dnat(0);
1581 sll_int32,
intent(in)::n
1582 sll_real64,
dimension(0:N - 1),
intent(in)::dper, lper, mper
1583 sll_real64,
dimension(0:N - 1),
intent(inout)::f
1585 do i = 0, n - 1; f(i) = 6._f64*f(i);
end do;
1587 f(i) = f(i) - f(i - 1)*lper(i - 1)
1590 f(n - 1) = f(n - 1) - mper(i)*f(i)
1592 f(n - 1) = f(n - 1)*dper(n - 1); f(n - 2) = dper(n - 2)*(f(n - 2) - (1._f64 - mper(n - 3))*f(n - 1))
1594 f(i) = dper(i)*(f(i) - f(i + 1) + mper(i - 1)*f(n - 1))
1596 f(0) = dper(0)*(f(0) - f(1) - f(n - 1));
1609 sll_int32,
intent(in) :: n
1610 sll_real64,
dimension(n),
intent(in) :: a, b, c, v
1611 sll_real64,
dimension(n),
intent(out) :: x
1612 sll_real64,
dimension(n) :: bp, vp
1621 firstpass:
do i = 2, n
1623 bp(i) = b(i) - m*c(i - 1)
1624 vp(i) = v(i) - m*vp(i - 1)
1629 backsub:
do i = n - 1, 1, -1
1630 x(i) = (vp(i) - c(i)*x(i + 1))/bp(i)
1637 sll_int32,
intent(out)::n_min, n_max
1638 sll_int32,
intent(in)::n
1639 sll_real64,
intent(in)::rho(2), eta_min, eta_max
1640 sll_real64::delta_eta
1642 delta_eta = (eta_max - eta_min)/real(n, f64)
1643 n_rho = floor(max(rho(1), rho(2))/delta_eta) + 1
1645 n_max = n + 1 - n_rho
1646 if ((n_min > n + 1) .or. (n_max < 1) .or. (n_min > n_max))
then
1647 print *,
'#Warning: rho is too big'
1648 print *,
'#Bad computation of N_min and N_max'
1655 sll_real64,
dimension(:, :),
intent(in)::f, f_init
1656 sll_int32,
intent(in)::n_min(2), n_max(2)
1657 sll_real64,
intent(in)::eps
1658 sll_real64,
intent(out)::bounds(2)
1662 bounds(1) = 1.e10_f64
1663 bounds(2) = -bounds(1)
1664 do j = n_min(2), n_max(2) + 1
1665 do i = n_min(1), n_max(1) + 1
1666 if (abs(f_init(i, j)) > eps)
then
1667 tmp = f(i, j)/f_init(i, j)
1668 if (tmp > bounds(2)) bounds(2) = tmp;
1669 if (tmp < bounds(1)) bounds(1) = tmp;
1676 sll_real64,
dimension(:, :),
intent(in)::f, f_init
1677 sll_int32,
intent(in)::n_min(2), n_max(2)
1678 sll_real64,
intent(in)::j_factor
1679 sll_real64,
intent(out)::err(3)
1681 sll_real64::tmp, delta
1685 do j = n_min(2), n_max(2) + 1
1686 do i = n_min(1), n_max(1) + 1
1687 tmp = f(i, j) - j_factor*f_init(i, j)
1688 err(1) = err(1) + abs(tmp)
1689 err(2) = err(2) + abs(tmp)**2
1690 err(3) = max(err(3), abs(tmp))
1693 delta = 1._f64/(real((n_max(2) - n_min(2)), f64)*real((n_max(1) - n_min(1)), f64))
1694 err(1) = err(1)*delta
1695 err(2) = sqrt(err(2)*delta)
1700 sll_real64,
dimension(:, :),
intent(in)::f, f_init
1701 sll_int32,
intent(in)::n_min(2), n_max(2)
1702 sll_real64,
dimension(:),
intent(in) :: j_factor
1703 sll_real64,
intent(out)::err(3)
1705 sll_real64::tmp, delta
1709 do j = n_min(2), n_max(2) + 1
1710 do i = n_min(1), n_max(1) + 1
1711 tmp = f(i, j) - j_factor(i)*f_init(i, j)
1712 err(1) = err(1) + abs(tmp)
1713 err(2) = err(2) + abs(tmp)**2
1714 err(3) = max(err(3), abs(tmp))
1717 delta = 1._f64/(real((n_max(2) - n_min(2)), f64)*real((n_max(1) - n_min(1)), f64))
1718 err(1) = err(1)*delta
1719 err(2) = sqrt(err(2)*delta)
1724 sll_real64,
intent(in)::rho(2), eta_min(2), eta_max(2)
1725 sll_int32,
intent(in)::mode(2)
1726 sll_real64,
intent(out)::val
1731 if (abs(rho(1) - rho(2)) > 1.e-12)
then
1732 print *,
'#for the moment rho(1)=rho(2) is needed'
1735 call sll_s_zero_bessel_dir_dir(mode, eta_min(1), eta_max(1), tmp)
1742 sll_real64,
intent(in)::eta_min(2), eta_max(2)
1743 sll_int32,
intent(in)::mode(2)
1744 sll_real64,
intent(out)::val
1752 call sll_s_zero_bessel_dir_dir(mode, eta_min(1), eta_max(1), tmp)
1755 if (abs(tmp - 3.9651944700162098_f64) > 1.e-12)
then
1756 print *,
'#error : gamma0 not computed for this mode : ', mode
1759 if (abs(eta_max(1) - 18._f64) > 1.e-12)
then
1760 print *,
'#error : gamma0 not computed for this eta_max : ', eta_max(1)
1763 val = 0.95319247622058476357_f64
1779 mu_quadr_for_phi_case, &
1782 mu_points_user_defined, &
1783 mu_weights_user_defined, &
1787 character(len=256),
intent(in) :: mu_quadr_for_phi_case
1788 sll_int32,
intent(in) :: n_mu_for_phi
1789 sll_real64,
intent(in) :: mu_max_for_phi
1790 sll_real64,
dimension(:),
intent(in),
optional :: mu_points_user_defined
1791 sll_real64,
dimension(:),
intent(in),
optional :: mu_weights_user_defined
1792 sll_int32,
intent(in) :: n_mu_user_defined
1794 sll_int32 :: ierr, i
1796 if (mu_quadr_for_phi_case ==
"SLL_USER_DEFINED")
then
1797 quasineutral%N_mu_for_phi = n_mu_user_defined
1798 sll_allocate(quasineutral%mu_points_for_phi(1:n_mu_user_defined), ierr)
1799 sll_allocate(quasineutral%mu_weights_for_phi(1:n_mu_user_defined), ierr)
1800 if (.not. ((
present(mu_points_user_defined)) &
1801 .and. (
present(mu_weights_user_defined))))
then
1802 print *,
'#provide mu_points_user_defined, mu_weights_user_defined'
1803 print *,
'#in sll_s_mu_quadr_for_phi_init'
1817 select case (mu_quadr_for_phi_case)
1818 case (
"SLL_USER_DEFINED")
1819 if (
size(mu_points_user_defined) /= n_mu_user_defined)
then
1820 print *,
'#incompatible sizes for mu_points_user_defined :',
size(mu_points_user_defined)
1821 print *,
'#and N_mu_user_defined :', n_mu_user_defined
1822 print *,
'#in sll_s_mu_quadr_for_phi_init'
1824 elseif (
size(mu_weights_user_defined) /= n_mu_user_defined)
then
1825 print *,
'#incompatible sizes for mu_weights_user_defined :',
size(mu_weights_user_defined)
1826 print *,
'#and N_mu_user_defined :', n_mu_user_defined
1827 print *,
'#in sll_s_mu_quadr_for_phi_init'
1830 quasineutral%mu_points_for_phi(1:n_mu_user_defined) = mu_points_user_defined
1831 quasineutral%mu_weights_for_phi(1:n_mu_user_defined) = mu_weights_user_defined
1833 case (
"SLL_LIN_LEE")
1834 quasineutral%N_mu_for_phi = n_mu_for_phi
1835 sll_allocate(quasineutral%mu_points_for_phi(1:n_mu_for_phi), ierr)
1836 sll_allocate(quasineutral%mu_weights_for_phi(1:n_mu_for_phi), ierr)
1837 select case (n_mu_for_phi)
1839 quasineutral%mu_points_for_phi(1) = 1._f64
1840 quasineutral%mu_weights_for_phi(1) = 1._f64
1842 quasineutral%mu_points_for_phi(1) = 0.4167845_f64
1843 quasineutral%mu_points_for_phi(2) = 2.495154605_f64
1844 quasineutral%mu_weights_for_phi(1) = 0.7194_f64
1845 quasineutral%mu_weights_for_phi(2) = 0.2806_f64
1847 quasineutral%mu_points_for_phi(1) = 0.148131245_f64
1848 quasineutral%mu_points_for_phi(2) = 1._f64
1849 quasineutral%mu_points_for_phi(3) = 3.15959522_f64
1850 quasineutral%mu_weights_for_phi(1) = 0.3583_f64
1851 quasineutral%mu_weights_for_phi(2) = 0.5004_f64
1852 quasineutral%mu_weights_for_phi(3) = 0.1413_f64
1854 print *,
'# bad N_mu_user_defined in SLL_LIN_LEE (must be 1, 2 or 3) : ', n_mu_for_phi
1855 print *,
'#in sll_s_mu_quadr_for_phi_init'
1858 case (
"SLL_RECTANGLES")
1859 quasineutral%N_mu_for_phi = n_mu_for_phi
1860 sll_allocate(quasineutral%mu_points_for_phi(1:n_mu_for_phi), ierr)
1861 sll_allocate(quasineutral%mu_weights_for_phi(1:n_mu_for_phi), ierr)
1862 do i = 1, n_mu_for_phi
1863 quasineutral%mu_points_for_phi(i) = mu_max_for_phi*real(i - 1, f64)/real(n_mu_for_phi, f64)
1864 quasineutral%mu_weights_for_phi(i) = mu_max_for_phi/real(n_mu_for_phi, f64)
1866 case (
"SLL_SIMPSON")
1867 quasineutral%N_mu_for_phi = n_mu_for_phi
1868 sll_allocate(quasineutral%mu_points_for_phi(1:n_mu_for_phi), ierr)
1869 sll_allocate(quasineutral%mu_weights_for_phi(1:n_mu_for_phi), ierr)
1870 do i = 1, n_mu_for_phi
1871 quasineutral%mu_points_for_phi(i) = mu_max_for_phi*real(i - 1, f64)/real(n_mu_for_phi - 1, f64)
1873 h = mu_max_for_phi/(3._f64*real(n_mu_for_phi, f64))
1874 quasineutral%mu_weights_for_phi(1) = h
1875 do i = 1, (n_mu_for_phi - 1)/2 - 1
1876 quasineutral%mu_weights_for_phi(2*i) = 4._f64*h
1877 quasineutral%mu_weights_for_phi(2*i + 1) = 2._f64*h
1879 quasineutral%mu_weights_for_phi(n_mu_for_phi - 1) = 4._f64*h
1880 quasineutral%mu_weights_for_phi(n_mu_for_phi) = h
1882 print *,
'#mu_quadr_for_phi_case not defined'
1883 print *,
'#in sll_s_mu_quadr_for_phi_init'
Write file for gnuplot to display 2d field.
Fortran module where set some physical and mathematical constants.
real(kind=f64), parameter, public sll_p_pi
subroutine, public sll_s_fft_exec_r2c_1d(plan, array_in, array_out)
Compute fast Fourier transform in real to complex mode.
subroutine, public sll_s_fft_free(plan)
Delete a plan.
subroutine, public sll_s_fft_init_r2c_1d(plan, nx, array_in, array_out, normalized, aligned, optimization)
Create new 1d real to complex plan for forward FFT.
subroutine, public sll_s_fft_exec_c2r_1d(plan, array_in, array_out)
Compute fast Fourier transform in complex to real mode.
subroutine, public sll_s_fft_init_c2r_1d(plan, nx, array_in, array_out, normalized, aligned, optimization)
Create new 1d complex to real plan for backward FFT.
Implements the functions to write data file plotable by GNUplot.
subroutine, public sll_s_compute_shape_circle(points, N_points)
subroutine, public sll_s_zero_bessel_dir_dir(mode, eta_min, eta_max, val)
subroutine matrix_product_circ(A, NxA, NyA, B, NxB, NyB, prod, Ntheta)
subroutine solve_tridiag(a, b, c, v, x, n)
subroutine splnat1d(f, xx, xmin, xmax, fval, N)
subroutine, public sll_s_precompute_inverse_qn_matrix_polar_splines(quasineutral, mu_points, mu_weights, N_mu)
subroutine compute_error_1d(f, f_init, J_factor, err, N_min, N_max)
subroutine splcoefnat1dold(p, dnat, lnat, N)
subroutine compute_w_hermite(w, r, s)
subroutine, public sll_s_compute_splines_coefs_matrix_per_1d(mat, dper, lper, mper, N)
subroutine, public sll_s_contribution_spl(x, val)
subroutine kronecker_product(A, NxA, NyA, B, NxB, NyB, kronecker)
subroutine splnatper2d(f, xx, xmin, xmax, yy, ymin, ymax, fval, Nx, Ny)
subroutine splcoefper1d(f, luper, N)
subroutine interpolate_hermite(f, i, x, fval, N)
subroutine splcoefnat1d(p, lunat, N)
subroutine, public sll_s_mu_quadr_for_phi_init(quasineutral, mu_quadr_for_phi_case, N_mu_for_phi, mu_max_for_phi, mu_points_user_defined, mu_weights_user_defined, N_mu_user_defined)
subroutine splper1d(f, xx, xmin, xmax, fval, N)
subroutine matrix_product_comp(A, NxA, NyA, B, NxB, NyB, prod)
subroutine solution_polar_circle(rho, mode, eta_min, eta_max, val)
subroutine, public sll_s_matrix_product_compf(A, NxA, NyA, B, NxB, NyB, prod)
subroutine interpolate_hermite_c1(f, i, x, fval, N)
subroutine, public sll_s_localize_polar(x, eta_min, eta_max, ii, eta, N)
subroutine splcoefnat1d0(lunat, N)
subroutine contribution_hermite_c1(x, val)
subroutine matrix_product(A, NxA, NyA, B, NxB, NyB, prod)
subroutine solve_circulant_system(Ntheta, Nr, mat_circ, sol)
subroutine, public sll_s_compute_gamma0(mode, eta_min, eta_max, val)
subroutine hermite_coef_nat_per(f, buf3d, N, d)
subroutine, public sll_s_qn_2d_polar_init(this, eta_min, eta_max, Nc, N_points, lambda, T_i)
subroutine, public sll_s_precompute_gyroaverage_index(quasineutral, rho, N_rho)
subroutine, public sll_s_compute_error(f, f_init, J_factor, err, N_min, N_max)
subroutine, public sll_s_qn_2d_polar_solve(quasineutral, phi)
subroutine, public sll_s_splcoefper1d0old(dper, lper, mper, N)
subroutine compute_n_bounds_polar_circle(N_min, N_max, N, rho, eta_min, eta_max)
subroutine localize_per(i, x, xmin, xmax, N)
subroutine localize_nat(i, x, xmin, xmax, N)
subroutine, public sll_s_compute_splines_coefs_matrix_nat_1d(mat, dnat, lnat, N)
subroutine, public sll_s_qn_2d_polar_test_solve(Nc, eta_min, eta_max, mu_points, mu_weights, N_mu, mode, lambda, T_i, phi_init, phi_qn)
subroutine compute_factor_bounds(f, f_init, eps, bounds, N_min, N_max)
subroutine, public sll_s_splcoefnat1d0old(dnat, lnat, N)
subroutine hermite_c1_coef_nat_per(f, buf3d, N, d)
subroutine splcoefper1d0(luper, N)
subroutine test_solve_circulant_system(mat, Nr, Ntheta)
subroutine splcoefnatper2d(f, buf, dnatx, lnatx, dpery, lpery, mpery, Nx, Ny)
real(kind=f64) function, public sll_f_compute_gamma0_quadrature(Nc, eta_min, eta_max, mu_points, mu_weights, N_mu, mode)
subroutine splcoefper1dold(f, dper, lper, mper, N)
subroutine sol(vkgs, vkgd, vkgi, vfg, kld, vu, neq, mp, ifac, isol, nsym, energ, ier, nsky)
Type for FFT plan in SeLaLib.