20 #include "sll_memory.h" 
   21 #include "sll_working_precision.h" 
   61       sll_real64          :: eta_min(2)     
 
   62       sll_real64          :: eta_max(2)     
 
   66       sll_int32           :: interp_degree(2)  
 
   68       sll_real64, 
dimension(:, :), 
pointer    :: points
 
   69       sll_real64, 
dimension(:, :, :), 
pointer  :: deriv
 
   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_real64, 
dimension(:, :), 
pointer    :: lunat
 
   75       sll_real64, 
dimension(:), 
pointer      :: luper
 
   76       sll_real64, 
dimension(:, :, :), 
pointer  :: a_fft
 
   86       sll_real64, 
intent(in) :: eta_min(2)
 
   87       sll_real64, 
intent(in) :: eta_max(2)
 
   88       sll_int32, 
intent(in)  :: nc(2)
 
   89       sll_int32, 
intent(in)  :: n_points
 
   90       sll_int32, 
intent(in)  :: interp_degree(2)
 
   91       sll_int32, 
intent(in)  :: deriv_size
 
   96       sll_allocate(this, err)
 
   97       sll_allocate(this%deriv(deriv_size, nc(1) + 1, nc(2) + 1), err)
 
   98       sll_allocate(this%points(3, n_points), err)
 
  102       this%eta_min = eta_min
 
  103       this%eta_max = eta_max
 
  105       this%N_points = n_points
 
  106       this%interp_degree = interp_degree
 
  114       sll_real64, 
intent(in) :: eta_min(2)
 
  115       sll_real64, 
intent(in) :: eta_max(2)
 
  116       sll_int32, 
intent(in)  :: nc(2)
 
  117       sll_int32, 
intent(in)  :: n_points
 
  122       sll_allocate(this, err)
 
  123       sll_allocate(this%points(3, n_points), err)
 
  127       this%eta_min = eta_min
 
  128       this%eta_max = eta_max
 
  130       this%N_points = n_points
 
  138       sll_real64, 
intent(in) :: eta_min(2)
 
  139       sll_real64, 
intent(in) :: eta_max(2)
 
  140       sll_int32, 
intent(in)  :: nc(2)
 
  144       sll_allocate(this, err)
 
  146       this%eta_min = eta_min
 
  147       this%eta_max = eta_max
 
  154       sll_real64, 
dimension(:, :), 
intent(inout) :: f
 
  155       sll_real64, 
intent(in)                   :: rho
 
  156       sll_int32                               :: i, j, k, ii(2)
 
  157       sll_real64::fval, sum_fval, eta_star(2), eta(2), delta_eta(2), x(2)
 
  160       delta_eta(1) = (gyro%eta_max(1) - gyro%eta_min(1))/real(gyro%Nc(1), f64)
 
  161       delta_eta(2) = (gyro%eta_max(2) - gyro%eta_min(2))/real(gyro%Nc(2), f64)
 
  163       call hermite_coef_nat_per(f(1:gyro%Nc(1) + 1, 1:gyro%Nc(2)), gyro%deriv, gyro%Nc, gyro%interp_degree)
 
  166          eta(2) = gyro%eta_min(2) + real(j - 1, f64)*delta_eta(2)
 
  167          do i = 1, gyro%Nc(1) + 1
 
  168             eta(1) = gyro%eta_min(1) + real(i - 1, f64)*delta_eta(1)
 
  170             do k = 1, gyro%N_points
 
  171                x(1) = eta(1)*cos(eta(2)) + rho*gyro%points(1, k)
 
  172                x(2) = eta(1)*sin(eta(2)) + rho*gyro%points(2, k)
 
  173                call localize_polar(x, gyro%eta_min, gyro%eta_max, ii, eta_star, gyro%Nc)
 
  175                sum_fval = sum_fval + gyro%points(3, k)*fval
 
  181       f(1:gyro%Nc(1) + 1, gyro%Nc(2) + 1) = f(1:gyro%Nc(1) + 1, 1)
 
  184       f(1, 1:gyro%Nc(2) + 1) = 0._f64
 
  185       f(gyro%Nc(1) + 1, 1:gyro%Nc(2) + 1) = 0._f64
 
  191       sll_real64, 
dimension(:, :), 
intent(inout) :: f
 
  192       sll_real64, 
intent(in)::rho
 
  193       sll_int32 ::i, j, k, ii(2)
 
  194       sll_real64::fval, sum_fval, eta_star(2), eta(2), delta_eta(2), x(2)
 
  197       delta_eta(1) = (gyro%eta_max(1) - gyro%eta_min(1))/real(gyro%Nc(1), f64)
 
  198       delta_eta(2) = (gyro%eta_max(2) - gyro%eta_min(2))/real(gyro%Nc(2), f64)
 
  203          eta(2) = gyro%eta_min(2) + real(j - 1, f64)*delta_eta(2)
 
  205          do i = 1, gyro%Nc(1) + 1
 
  206             eta(1) = gyro%eta_min(1) + real(i - 1, f64)*delta_eta(1)
 
  208             do k = 1, gyro%N_points
 
  209                x(1) = eta(1)*cos(eta(2)) + rho*gyro%points(1, k)
 
  210                x(2) = eta(1)*sin(eta(2)) + rho*gyro%points(2, k)
 
  211                eta_star(1) = sqrt(x(1)**2 + x(2)**2)
 
  212                call localize_nat(ii(1), eta_star(1), gyro%eta_min(1), gyro%eta_max(1), gyro%Nc(1))
 
  213                eta_star(2) = modulo(atan2(x(2), x(1)), 2._f64*
sll_p_pi)
 
  216                call localize_per(ii(2), eta_star(2), gyro%eta_min(2), gyro%eta_max(2), gyro%Nc(2))
 
  218                sum_fval = sum_fval + gyro%points(3, k)*fval
 
  224       f(1:gyro%Nc(1) + 1, gyro%Nc(2) + 1) = f(1:gyro%Nc(1) + 1, 1)
 
  227       f(1, 1:gyro%Nc(2) + 1) = 0._f64
 
  228       f(gyro%Nc(1) + 1, 1:gyro%Nc(2) + 1) = 0._f64
 
  234       sll_real64, 
dimension(:, :), 
intent(inout) :: f
 
  235       sll_real64, 
intent(in)::rho
 
  236       sll_int32 ::i, j, k, ii(2)
 
  237       sll_real64::fval, eta_star(2), eta(2), delta_eta(2), x(2), angle
 
  238       sll_real64, 
dimension(:, :), 
allocatable::sum_fval
 
  241       sll_allocate(sum_fval(0:gyro%Nc(1), 0:gyro%Nc(2) - 1), error)
 
  244       delta_eta(1) = (gyro%eta_max(1) - gyro%eta_min(1))/real(gyro%Nc(1), f64)
 
  245       delta_eta(2) = (gyro%eta_max(2) - gyro%eta_min(2))/real(gyro%Nc(2), f64)
 
  250          eta(1) = gyro%eta_min(1) + real(i, f64)*delta_eta(1)  
 
  251          eta(2) = gyro%eta_min(2) 
 
  252          do k = 1, gyro%N_points
 
  253             x(1) = eta(1)*cos(eta(2)) + rho*gyro%points(1, k)
 
  254             x(2) = eta(1)*sin(eta(2)) + rho*gyro%points(2, k)
 
  255             eta_star(1) = sqrt(x(1)**2 + x(2)**2)
 
  256             call localize_nat(ii(1), eta_star(1), gyro%eta_min(1), gyro%eta_max(1), gyro%Nc(1))
 
  257             angle = atan2(x(2), x(1))
 
  258             do j = 0, gyro%Nc(2) - 1
 
  259                eta_star(2) = modulo(angle + real(j, f64)*delta_eta(2), 2._f64*
sll_p_pi)
 
  260                call localize_per(ii(2), eta_star(2), gyro%eta_min(2), gyro%eta_max(2), gyro%Nc(2))
 
  262                sum_fval(i, j) = sum_fval(i, j) + gyro%points(3, k)*fval
 
  267       f(1:gyro%Nc(1) + 1, 1:gyro%Nc(2)) = sum_fval(0:gyro%Nc(1), 0:gyro%Nc(2) - 1)
 
  268       f(1:gyro%Nc(1) + 1, gyro%Nc(2) + 1) = f(1:gyro%Nc(1) + 1, 1)
 
  271       f(1, 1:gyro%Nc(2) + 1) = 0._f64
 
  272       f(gyro%Nc(1) + 1, 1:gyro%Nc(2) + 1) = 0._f64
 
  274       sll_deallocate_array(sum_fval, error)
 
  280       sll_real64, 
intent(in)::rho
 
  281       sll_int32, 
dimension(:, :), 
allocatable :: buf
 
  282       sll_int32 ::i, j, k, ell_1, ell_2, ii(2), s, nb, ind(2)
 
  283       sll_real64::val(4, 0:1, 0:1), eta_star(2), eta(2), delta_eta(2), x(2)
 
  287       delta_eta(1) = (gyro%eta_max(1) - gyro%eta_min(1))/real(gyro%Nc(1), f64)
 
  288       delta_eta(2) = (gyro%eta_max(2) - gyro%eta_min(2))/real(gyro%Nc(2), f64)
 
  290       sll_allocate(buf(0:gyro%Nc(1), 0:gyro%Nc(2)), error)
 
  292       sll_allocate(gyro%pre_compute_N(gyro%Nc(1) + 1), error)
 
  298       eta(2) = gyro%eta_min(2)
 
  301       do i = 1, gyro%Nc(1) + 1
 
  302          eta(1) = gyro%eta_min(1) + real(i - 1, f64)*delta_eta(1)
 
  304          do k = 1, gyro%N_points
 
  305             x(1) = eta(1)*cos(eta(2)) + rho*gyro%points(1, k)
 
  306             x(2) = eta(1)*sin(eta(2)) + rho*gyro%points(2, k)
 
  307             call localize_polar(x, gyro%eta_min, gyro%eta_max, ii, eta_star, gyro%Nc)
 
  309                ind(2) = ii(2) + ell_2
 
  311                   ind(1) = ii(1) + ell_1
 
  312                   if (buf(ind(1), ind(2)) .ne. i) 
then 
  314                      buf(ind(1), ind(2)) = i
 
  319          gyro%pre_compute_N(i) = s
 
  323       print *, 
'#N_points pre_compute=', nb, gyro%Nc(1), nb/gyro%Nc(1)
 
  325       sll_allocate(gyro%pre_compute_index(1:2, nb), error)
 
  326       sll_allocate(gyro%pre_compute_coeff(4, nb), error)
 
  332       eta(2) = gyro%eta_min(2)
 
  333       do i = 1, gyro%Nc(1) + 1
 
  334          eta(1) = gyro%eta_min(1) + real(i - 1, f64)*delta_eta(1)
 
  335          do k = 1, gyro%N_points
 
  336             x(1) = eta(1)*cos(eta(2)) + rho*gyro%points(1, k)
 
  337             x(2) = eta(1)*sin(eta(2)) + rho*gyro%points(2, k)
 
  338             call localize_polar(x, gyro%eta_min, gyro%eta_max, ii, eta_star, gyro%Nc)
 
  343             val = val*gyro%points(3, k)
 
  345                ind(2) = ii(2) + ell_2
 
  347                   ind(1) = ii(1) + ell_1
 
  348                   j = buf(ind(1), ind(2))
 
  351                      buf(ind(1), ind(2)) = s
 
  352                      gyro%pre_compute_coeff(1:4, s) = val(1:4, ell_1, ell_2)
 
  353                      gyro%pre_compute_index(1, s) = ind(1)
 
  354                      gyro%pre_compute_index(2, s) = ind(2)
 
  356                      gyro%pre_compute_coeff(1:4, j) = gyro%pre_compute_coeff(1:4, j) + val(1:4, ell_1, ell_2)
 
  367       print *, 
'#min/max=', minval(gyro%pre_compute_coeff(1:4, :)), maxval(gyro%pre_compute_coeff(1:4, :))
 
  368       sll_deallocate_array(buf, error)
 
  399       sll_real64, 
dimension(:, :), 
intent(in) :: pre_compute_coeff
 
  400       sll_int32, 
dimension(:), 
intent(in) :: pre_compute_n
 
  401       sll_int32, 
dimension(:, :), 
intent(in) :: pre_compute_index
 
  402       sll_int32, 
intent(in) :: nb
 
  403       sll_int32, 
intent(in) :: nc(2)
 
  404       sll_int32, 
dimension(:), 
pointer :: ia
 
  405       sll_int32, 
dimension(:), 
pointer :: ja
 
  406       sll_real64, 
dimension(:), 
pointer :: a
 
  407       sll_int32, 
intent(out) :: num_rows
 
  408       sll_int32, 
intent(out) :: num_nz
 
  416       if ((
size(pre_compute_coeff, 1) < 4) .or. (
size(pre_compute_coeff, 2) < nb)) 
then 
  417          print *, 
'#bad size for pre_compute_coeff' 
  418          print *, 
'#in assemble_csr_from_pre_comput' 
  422       if (
size(pre_compute_n, 1) < nc(1) + 1) 
then 
  423          print *, 
'#bad size for pre_compute_N' 
  424          print *, 
'#in assemble_csr_from_pre_comput' 
  428       if ((
size(pre_compute_index, 1) < 2) .or. (
size(pre_compute_index, 2) < nb)) 
then 
  429          print *, 
'#bad size for pre_compute_index' 
  430          print *, 
'#in assemble_csr_from_pre_comput' 
  434       num_rows = (nc(1) + 1)*nc(2)
 
  438          num_nz = num_nz*pre_compute_n(i)
 
  441       sll_allocate(ia(num_rows + 1), ierr)
 
  442       sll_allocate(ja(num_nz), ierr)
 
  443       sll_allocate(a(num_nz), ierr)
 
  463       sll_real64, 
dimension(:, :), 
intent(inout) :: f
 
  464       sll_int32 ::i, j, k, ell, ii(2), s
 
  465       sll_real64::fval, delta_eta(2)
 
  468       delta_eta(1) = (gyro%eta_max(1) - gyro%eta_min(1))/real(gyro%Nc(1), f64)
 
  469       delta_eta(2) = (gyro%eta_max(2) - gyro%eta_min(2))/real(gyro%Nc(2), f64)
 
  475          do i = 1, gyro%Nc(1) + 1
 
  477             do k = 1, gyro%pre_compute_N(i)
 
  480                   ii(1) = gyro%pre_compute_index(1, s)
 
  481                   ii(2) = modulo(j - 1 + gyro%pre_compute_index(2, s) + gyro%Nc(2), gyro%Nc(2))
 
  482                   fval = fval + gyro%deriv(ell, ii(1) + 1, ii(2) + 1)*gyro%pre_compute_coeff(ell, s)
 
  496       f(1:gyro%Nc(1) + 1, gyro%Nc(2) + 1) = f(1:gyro%Nc(1) + 1, 1)
 
  499       f(1, 1:gyro%Nc(2) + 1) = 0._f64
 
  500       f(gyro%Nc(1) + 1, 1:gyro%Nc(2) + 1) = 0._f64
 
  506       sll_real64, 
dimension(:, :), 
intent(inout) :: f
 
  507       sll_real64, 
dimension(:, :), 
allocatable, 
target::fbords
 
  508       sll_real64, 
dimension(:, :), 
pointer::pointer_f_bords
 
  509       sll_real64, 
dimension(:), 
allocatable, 
target::buf, dnat, lnat, dper, lper, mper
 
  510       sll_real64, 
dimension(:), 
pointer::pointer_buf, pointer_dnat, pointer_lnat
 
  511       sll_real64, 
dimension(:), 
pointer::pointer_dper, pointer_lper, pointer_mper
 
  512       sll_real64, 
intent(in)::rho
 
  514       sll_real64::fval, sum_fval, eta(2), delta_eta(2), x(2), xx(2)
 
  518       delta_eta(1) = (gyro%eta_max(1) - gyro%eta_min(1))/real(gyro%Nc(1), f64)
 
  519       delta_eta(2) = (gyro%eta_max(2) - gyro%eta_min(2))/real(gyro%Nc(2), f64)
 
  521       sll_allocate(dnat(0:gyro%Nc(1) + 2), error)
 
  522       sll_allocate(lnat(0:gyro%Nc(1) + 2), error)
 
  523       sll_allocate(dper(0:gyro%Nc(2) - 1), error)
 
  524       sll_allocate(lper(0:gyro%Nc(2) - 1), error)
 
  525       sll_allocate(mper(0:gyro%Nc(2) - 1), error)
 
  527       sll_allocate(fbords(0:gyro%Nc(1) + 2, 0:gyro%Nc(2) - 1), error)
 
  528       sll_allocate(buf(0:max(gyro%Nc(1) + 2, gyro%Nc(2) - 1)), error)
 
  533       fbords(0, 0:gyro%Nc(2) - 1) = 0._f64
 
  534       fbords(1:gyro%Nc(1) + 1, 0:gyro%Nc(2) - 1) = f(1:gyro%Nc(1) + 1, 1:gyro%Nc(2))
 
  535       fbords(gyro%Nc(1) + 2, 0:gyro%Nc(2) - 1) = 0._f64
 
  537       pointer_f_bords => fbords
 
  545       call splcoefnatper2d(pointer_f_bords, pointer_buf, pointer_dnat, pointer_lnat, &
 
  546                            pointer_dper, pointer_lper, pointer_mper, gyro%Nc(1), gyro%Nc(2))
 
  549          eta(2) = gyro%eta_min(2) + real(j - 1, f64)*delta_eta(2)
 
  551          do i = 1, gyro%Nc(1) + 1
 
  552             eta(1) = gyro%eta_min(1) + real(i - 1, f64)*delta_eta(1)
 
  554             do k = 1, gyro%N_points
 
  555                x(1) = eta(1)*cos(eta(2)) + rho*gyro%points(1, k)
 
  556                x(2) = eta(1)*sin(eta(2)) + rho*gyro%points(2, k)
 
  557                xx(1) = sqrt(x(1)**2 + x(2)**2)
 
  558                xx(2) = modulo(atan2(x(2), x(1)), 2._f64*
sll_p_pi)
 
  561                call splnatper2d(pointer_f_bords, xx(1), gyro%eta_min(1), gyro%eta_max(1), &
 
  562                                 xx(2), gyro%eta_min(2), gyro%eta_max(2), fval, gyro%Nc(1), gyro%Nc(2))
 
  563                sum_fval = sum_fval + gyro%points(3, k)*fval
 
  568       f(1:gyro%Nc(1) + 1, gyro%Nc(2) + 1) = f(1:gyro%Nc(1) + 1, 1)
 
  571       f(1, 1:gyro%Nc(2) + 1) = 0._f64
 
  572       f(gyro%Nc(1) + 1, 1:gyro%Nc(2) + 1) = 0._f64
 
  574       sll_deallocate_array(dnat, error)
 
  575       sll_deallocate_array(lnat, error)
 
  576       sll_deallocate_array(dper, error)
 
  577       sll_deallocate_array(lper, error)
 
  578       sll_deallocate_array(mper, error)
 
  580       sll_deallocate_array(fbords, error)
 
  581       sll_deallocate_array(buf, error)
 
  587       sll_real64, 
dimension(:, :), 
intent(inout) :: f
 
  588       sll_real64, 
intent(in)::rho
 
  590       sll_real64::fval, eta(2), delta_eta(2), x(2), xx(2), angle
 
  591       sll_real64, 
dimension(:, :), 
allocatable::buf, sum_fval
 
  592       sll_real64, 
dimension(:), 
allocatable::buf2
 
  595       sll_allocate(buf(0:gyro%Nc(1) + 2, 0:gyro%Nc(2)), error)
 
  596       sll_allocate(buf2(0:gyro%Nc(2) - 1), error)
 
  597       sll_allocate(sum_fval(0:gyro%Nc(1), 0:gyro%Nc(2) - 1), error)
 
  598       sll_allocate(gyro%lunat(0:1, 0:gyro%Nc(1) + 2), error)
 
  599       sll_allocate(gyro%luper(0:3*gyro%Nc(2) - 1), error)
 
  601       delta_eta(1) = (gyro%eta_max(1) - gyro%eta_min(1))/real(gyro%Nc(1), f64)
 
  602       delta_eta(2) = (gyro%eta_max(2) - gyro%eta_min(2))/real(gyro%Nc(2), f64)
 
  610             buf(i + 1, j) = f(i + 1, j + 1)
 
  612          buf(gyro%Nc(1) + 2, j) = 0._f64
 
  615       do j = 0, gyro%Nc(2) - 1
 
  618       buf(0:gyro%Nc(1) + 2, gyro%Nc(2)) = buf(0:gyro%Nc(1) + 2, 0)
 
  621       do i = 0, gyro%Nc(1) + 2
 
  628          eta(1) = gyro%eta_min(1) + real(i, f64)*delta_eta(1)  
 
  629          eta(2) = gyro%eta_min(2) 
 
  630          do k = 1, gyro%N_points
 
  631             x(1) = eta(1)*cos(eta(2)) + rho*gyro%points(1, k)
 
  632             x(2) = eta(1)*sin(eta(2)) + rho*gyro%points(2, k)
 
  633             xx(1) = sqrt(x(1)**2 + x(2)**2)
 
  634             xx(2) = atan2(x(2), x(1))
 
  635             do j = 0, gyro%Nc(2) - 1
 
  636                call splnat1d(buf(:, j), xx(1), gyro%eta_min(1), gyro%eta_max(1), buf2(j), gyro%Nc(1))
 
  639             do j = 0, gyro%Nc(2) - 1
 
  640                angle = modulo(xx(2) + real(j, f64)*delta_eta(2), 2._f64*
sll_p_pi)
 
  641                call splper1d(buf2, angle, gyro%eta_min(2), gyro%eta_max(2), fval, gyro%Nc(2))
 
  642                sum_fval(i, j) = sum_fval(i, j) + gyro%points(3, k)*fval
 
  647       f(1:gyro%Nc(1) + 1, 1:gyro%Nc(2)) = sum_fval(0:gyro%Nc(1), 0:gyro%Nc(2) - 1)
 
  648       f(1:gyro%Nc(1) + 1, gyro%Nc(2) + 1) = f(1:gyro%Nc(1) + 1, 1)
 
  651       f(1, 1:gyro%Nc(2) + 1) = 0._f64
 
  652       f(gyro%Nc(1) + 1, 1:gyro%Nc(2) + 1) = 0._f64
 
  654       sll_deallocate_array(gyro%lunat, error)
 
  655       sll_deallocate_array(gyro%luper, error)
 
  656       sll_deallocate_array(buf, error)
 
  657       sll_deallocate_array(buf2, error)
 
  658       sll_deallocate_array(sum_fval, error)
 
  664       sll_real64, 
intent(in)::rho
 
  665       sll_int32, 
dimension(:, :), 
allocatable :: buf
 
  666       sll_int32 ::i, j, k, ell_1, ell_2, ii(2), s, nb, ind(2)
 
  667       sll_real64::val(-1:2, -1:2), eta_star(2), eta(2), delta_eta(2), x(2)
 
  670       delta_eta(1) = (gyro%eta_max(1) - gyro%eta_min(1))/real(gyro%Nc(1), f64)
 
  671       delta_eta(2) = (gyro%eta_max(2) - gyro%eta_min(2))/real(gyro%Nc(2), f64)
 
  673       sll_allocate(buf(0:gyro%Nc(1) + 2, 0:gyro%Nc(2) - 1), error)
 
  675       sll_allocate(gyro%pre_compute_N(gyro%Nc(1) + 1), error)
 
  677       eta(2) = gyro%eta_min(2)
 
  680       do i = 1, gyro%Nc(1) + 1
 
  681          eta(1) = gyro%eta_min(1) + real(i - 1, f64)*delta_eta(1)
 
  683          do k = 1, gyro%N_points
 
  684             x(1) = eta(1)*cos(eta(2)) + rho*gyro%points(1, k)
 
  685             x(2) = eta(1)*sin(eta(2)) + rho*gyro%points(2, k)
 
  686             call localize_polar(x, gyro%eta_min, gyro%eta_max, ii, eta_star, gyro%Nc)
 
  688                ind(2) = modulo(ii(2) + ell_2, gyro%Nc(2))
 
  690                   ind(1) = ii(1) + 1 + ell_1
 
  691                   if (buf(ind(1), ind(2)) .ne. i) 
then 
  693                      buf(ind(1), ind(2)) = i
 
  698          gyro%pre_compute_N(i) = s
 
  702       print *, 
'#N_points pre_compute=', nb, gyro%Nc(1), nb/gyro%Nc(1)
 
  704       sll_allocate(gyro%pre_compute_index(1:2, nb), error)
 
  705       sll_allocate(gyro%pre_compute_coeff_spl(nb), error)
 
  711       eta(2) = gyro%eta_min(2)
 
  712       do i = 1, gyro%Nc(1) + 1
 
  713          eta(1) = gyro%eta_min(1) + real(i - 1, f64)*delta_eta(1)
 
  714          do k = 1, gyro%N_points
 
  715             x(1) = eta(1)*cos(eta(2)) + rho*gyro%points(1, k)
 
  716             x(2) = eta(1)*sin(eta(2)) + rho*gyro%points(2, k)
 
  717             call localize_polar(x, gyro%eta_min, gyro%eta_max, ii, eta_star, gyro%Nc)
 
  721             val = val*gyro%points(3, k)
 
  724                ind(2) = modulo(ii(2) + ell_2, gyro%Nc(2))
 
  726                   ind(1) = ii(1) + 1 + ell_1
 
  727                   j = buf(ind(1), ind(2))
 
  730                      buf(ind(1), ind(2)) = s
 
  731                      gyro%pre_compute_coeff_spl(s) = val(ell_1, ell_2)
 
  732                      gyro%pre_compute_index(1, s) = ind(1)
 
  733                      gyro%pre_compute_index(2, s) = ind(2)
 
  735                      gyro%pre_compute_coeff_spl(j) = &
 
  736                         gyro%pre_compute_coeff_spl(j) + val(ell_1, ell_2)
 
  744       print *, 
'#min/max=', minval(gyro%pre_compute_coeff_spl(:)), maxval(gyro%pre_compute_coeff_spl(:))
 
  745       sll_deallocate_array(buf, error)
 
  750       sll_real64, 
dimension(:, :), 
intent(inout) :: f
 
  751       sll_real64, 
dimension(:, :), 
allocatable, 
target::fbords
 
  752       sll_real64, 
dimension(:, :), 
pointer::pointer_f_bords
 
  753       sll_real64, 
dimension(:), 
allocatable, 
target::buf, dnat, lnat, dper, lper, mper
 
  754       sll_real64, 
dimension(:), 
pointer::pointer_buf, pointer_dnat, pointer_lnat
 
  755       sll_real64, 
dimension(:), 
pointer::pointer_dper, pointer_lper, pointer_mper
 
  756       sll_real64, 
dimension(:, :), 
allocatable ::tmp_f
 
  757       sll_int32 ::i, j, k, ii(2), s
 
  758       sll_real64::fval, delta_eta(2)
 
  761       sll_allocate(dnat(0:gyro%Nc(1) + 2), error)
 
  762       sll_allocate(lnat(0:gyro%Nc(1) + 2), error)
 
  763       sll_allocate(dper(0:gyro%Nc(2) - 1), error)
 
  764       sll_allocate(lper(0:gyro%Nc(2) - 1), error)
 
  765       sll_allocate(mper(0:gyro%Nc(2) - 1), error)
 
  766       sll_allocate(fbords(0:gyro%Nc(1) + 2, 0:gyro%Nc(2) - 1), error)
 
  767       sll_allocate(buf(0:max(gyro%Nc(1) + 2, gyro%Nc(2) - 1)), error)
 
  768       sll_allocate(tmp_f(1:gyro%Nc(1) + 1, 1:gyro%Nc(2)), error)
 
  771       delta_eta(1) = (gyro%eta_max(1) - gyro%eta_min(1))/real(gyro%Nc(1), f64)
 
  772       delta_eta(2) = (gyro%eta_max(2) - gyro%eta_min(2))/real(gyro%Nc(2), f64)
 
  777       fbords(0, 0:gyro%Nc(2) - 1) = 0._f64
 
  778       fbords(1:gyro%Nc(1) + 1, 0:gyro%Nc(2) - 1) = f(1:gyro%Nc(1) + 1, 1:gyro%Nc(2))
 
  779       fbords(gyro%Nc(1) + 2, 0:gyro%Nc(2) - 1) = 0._f64
 
  781       pointer_f_bords => fbords
 
  789       call splcoefnatper2d(pointer_f_bords, pointer_buf, pointer_dnat, pointer_lnat, &
 
  790                            pointer_dper, pointer_lper, pointer_mper, gyro%Nc(1), gyro%Nc(2))
 
  794          do i = 1, gyro%Nc(1) + 1
 
  796             do k = 1, gyro%pre_compute_N(i)
 
  798                ii(1) = gyro%pre_compute_index(1, s)
 
  799                ii(2) = modulo(j - 1 + gyro%pre_compute_index(2, s), gyro%Nc(2))
 
  800                fval = fval + pointer_f_bords(ii(1), ii(2))*gyro%pre_compute_coeff_spl(s)
 
  806       f(1:gyro%Nc(1) + 1, 1:gyro%Nc(2)) = tmp_f(1:gyro%Nc(1) + 1, 1:gyro%Nc(2))
 
  807       f(1:gyro%Nc(1) + 1, gyro%Nc(2) + 1) = f(1:gyro%Nc(1) + 1, 1)
 
  810       f(1, 1:gyro%Nc(2) + 1) = 0._f64
 
  811       f(gyro%Nc(1) + 1, 1:gyro%Nc(2) + 1) = 0._f64
 
  813       sll_deallocate_array(dnat, error)
 
  814       sll_deallocate_array(lnat, error)
 
  815       sll_deallocate_array(dper, error)
 
  816       sll_deallocate_array(lper, error)
 
  817       sll_deallocate_array(mper, error)
 
  818       sll_deallocate_array(fbords, error)
 
  819       sll_deallocate_array(buf, error)
 
  820       sll_deallocate_array(tmp_f, error)
 
  826       sll_real64, 
intent(in)::rho
 
  827       sll_int32, 
dimension(:, :), 
allocatable :: buf
 
  828       sll_real64, 
dimension(:), 
allocatable::buf_fft
 
  829       sll_int32 ::i, j, k, ell_1, ell_2, ii(2), s, nb, ind(2)
 
  830       sll_real64::val(-1:2, -1:2), eta_star(2), eta(2), delta_eta(2), x(2)
 
  833       delta_eta(1) = (gyro%eta_max(1) - gyro%eta_min(1))/real(gyro%Nc(1), f64)
 
  834       delta_eta(2) = (gyro%eta_max(2) - gyro%eta_min(2))/real(gyro%Nc(2), f64)
 
  836       sll_allocate(buf(1:gyro%Nc(1) + 1, 0:gyro%Nc(1) + 2), error)
 
  838       sll_allocate(gyro%A_fft(1:gyro%Nc(1) + 1, 0:gyro%Nc(1) + 2, 0:gyro%Nc(2) - 1), error)
 
  839       sll_allocate(buf_fft(1:2*gyro%Nc(2) + 15), error)
 
  841       eta(2) = gyro%eta_min(2)
 
  844       do i = 1, gyro%Nc(1) + 1
 
  845          eta(1) = gyro%eta_min(1) + real(i - 1, f64)*delta_eta(1)
 
  847          do k = 1, gyro%N_points
 
  848             x(1) = eta(1)*cos(eta(2)) + rho*gyro%points(1, k)
 
  849             x(2) = eta(1)*sin(eta(2)) + rho*gyro%points(2, k)
 
  850             call localize_polar(x, gyro%eta_min, gyro%eta_max, ii, eta_star, gyro%Nc)
 
  852                ind(2) = modulo(ii(2) + ell_2, gyro%Nc(2))
 
  854                   ind(1) = ii(1) + 1 + ell_1
 
  855                   if (buf(i, ind(1)) .ne. 1) 
then 
  865       sll_allocate(gyro%pre_compute_index(1:2, nb), error)
 
  871       eta(2) = gyro%eta_min(2)
 
  872       do i = 1, gyro%Nc(1) + 1
 
  873          eta(1) = gyro%eta_min(1) + real(i - 1, f64)*delta_eta(1)
 
  874          do k = 1, gyro%N_points
 
  875             x(1) = eta(1)*cos(eta(2)) + rho*gyro%points(1, k)
 
  876             x(2) = eta(1)*sin(eta(2)) + rho*gyro%points(2, k)
 
  877             call localize_polar(x, gyro%eta_min, gyro%eta_max, ii, eta_star, gyro%Nc)
 
  881             val = val*gyro%points(3, k)
 
  884                ind(2) = modulo(ii(2) + ell_2, gyro%Nc(2))
 
  886                   ind(1) = ii(1) + 1 + ell_1
 
  891                      gyro%pre_compute_index(1, s) = i
 
  892                      gyro%pre_compute_index(2, s) = ind(1)
 
  893                      gyro%A_fft(i, ind(1), ind(2)) = val(ell_1, ell_2)
 
  895                      gyro%A_fft(i, ind(1), ind(2)) = &
 
  896                         gyro%A_fft(i, ind(1), ind(2)) + val(ell_1, ell_2)
 
  903       call dffti(gyro%Nc(2), buf_fft)
 
  905          call dfftf(gyro%Nc(2), gyro%A_fft(gyro%pre_compute_index(1, s), gyro%pre_compute_index(2, s), :), buf_fft)
 
  908       sll_deallocate_array(buf, error)
 
  909       sll_deallocate_array(buf_fft, error)
 
  915       sll_real64, 
dimension(:, :), 
intent(inout) :: f
 
  916       sll_real64, 
dimension(:, :), 
allocatable, 
target::fbords
 
  917       sll_real64, 
dimension(:, :), 
pointer::pointer_f_bords
 
  918       sll_real64, 
dimension(:), 
allocatable, 
target::buf, dnat, lnat, dper, lper, mper
 
  919       sll_real64, 
dimension(:), 
pointer::pointer_buf, pointer_dnat, pointer_lnat
 
  920       sll_real64, 
dimension(:), 
pointer::pointer_dper, pointer_lper, pointer_mper
 
  921       sll_real64, 
dimension(:, :), 
allocatable ::tmp_f
 
  922       sll_real64, 
dimension(:), 
allocatable::buf_fft
 
  924       sll_real64::fval, delta_eta(2)
 
  927       sll_allocate(dnat(0:gyro%Nc(1) + 2), error)
 
  928       sll_allocate(lnat(0:gyro%Nc(1) + 2), error)
 
  929       sll_allocate(dper(0:gyro%Nc(2) - 1), error)
 
  930       sll_allocate(lper(0:gyro%Nc(2) - 1), error)
 
  931       sll_allocate(mper(0:gyro%Nc(2) - 1), error)
 
  932       sll_allocate(fbords(0:gyro%Nc(1) + 2, 0:gyro%Nc(2) - 1), error)
 
  933       sll_allocate(buf(0:max(gyro%Nc(1) + 2, gyro%Nc(2) - 1)), error)
 
  934       sll_allocate(tmp_f(1:gyro%Nc(1) + 1, 0:gyro%Nc(2) - 1), error)
 
  935       sll_allocate(buf_fft(1:2*gyro%Nc(2) + 15), error)
 
  939       delta_eta(1) = (gyro%eta_max(1) - gyro%eta_min(1))/real(gyro%Nc(1), f64)
 
  940       delta_eta(2) = (gyro%eta_max(2) - gyro%eta_min(2))/real(gyro%Nc(2), f64)
 
  945       fbords(0, 0:gyro%Nc(2) - 1) = 0._f64
 
  946       fbords(1:gyro%Nc(1) + 1, 0:gyro%Nc(2) - 1) = f(1:gyro%Nc(1) + 1, 1:gyro%Nc(2))
 
  947       fbords(gyro%Nc(1) + 2, 0:gyro%Nc(2) - 1) = 0._f64
 
  949       pointer_f_bords => fbords
 
  957       call splcoefnatper2d(pointer_f_bords, pointer_buf, pointer_dnat, pointer_lnat, &
 
  958                            pointer_dper, pointer_lper, pointer_mper, gyro%Nc(1), gyro%Nc(2))
 
  960       call dffti(gyro%Nc(2), buf_fft)
 
  961       do i = 0, gyro%Nc(1) + 2
 
  962          call dfftf(gyro%Nc(2), pointer_f_bords(i, :), buf_fft)
 
  965       do j = 0, gyro%Nc(2) - 1
 
  966          do s = 1, 
size(gyro%pre_compute_index(1, :))
 
  967             tmp_f(gyro%pre_compute_index(1, s), j) = &
 
  968                tmp_f(gyro%pre_compute_index(1, s), j) + &
 
  969                gyro%A_fft(gyro%pre_compute_index(1, s), &
 
  970                           gyro%pre_compute_index(2, s), j)* &
 
  971                pointer_f_bords(gyro%pre_compute_index(2, s), j)
 
  975       do i = 1, gyro%Nc(1) + 1
 
  976          call dfftb(gyro%Nc(2), tmp_f(i, :), buf_fft)
 
  979       tmp_f = tmp_f/real(gyro%Nc(2), f64)
 
  981       f(1:gyro%Nc(1) + 1, 1:gyro%Nc(2)) = tmp_f(1:gyro%Nc(1) + 1, 0:gyro%Nc(2) - 1)
 
  982       f(1:gyro%Nc(1) + 1, gyro%Nc(2) + 1) = f(1:gyro%Nc(1) + 1, 1)
 
  985       f(1, 1:gyro%Nc(2) + 1) = 0._f64
 
  986       f(gyro%Nc(1) + 1, 1:gyro%Nc(2) + 1) = 0._f64
 
  988       sll_deallocate_array(dnat, error)
 
  989       sll_deallocate_array(lnat, error)
 
  990       sll_deallocate_array(dper, error)
 
  991       sll_deallocate_array(lper, error)
 
  992       sll_deallocate_array(mper, error)
 
  993       sll_deallocate_array(fbords, error)
 
  994       sll_deallocate_array(buf, error)
 
  995       sll_deallocate_array(buf_fft, error)
 
  996       sll_deallocate_array(tmp_f, error)
 
 1002       sll_real64, 
dimension(:, :), 
intent(inout) :: f
 
 1003       sll_real64, 
dimension(:, :), 
allocatable :: fcomp
 
 1004       sll_real64, 
dimension(:), 
allocatable :: buf, diagm1, diag, diagp1
 
 1005       sll_real64, 
intent(in)::rho
 
 1010       dr = (gyro%eta_max(1) - gyro%eta_min(1))/real(gyro%Nc(1), f64)
 
 1012       sll_allocate(buf(1:2*gyro%Nc(2) + 15), error)
 
 1013       sll_allocate(fcomp(1:gyro%Nc(1) + 1, 1:gyro%Nc(2)), error)
 
 1014       sll_allocate(diagm1(1:gyro%Nc(1) + 1), error)
 
 1015       sll_allocate(diag(1:gyro%Nc(1) + 1), error)
 
 1016       sll_allocate(diagp1(1:gyro%Nc(1) + 1), error)
 
 1018       fcomp(1:gyro%Nc(1) + 1, 1:gyro%Nc(2)) = f(1:gyro%Nc(1) + 1, 1:gyro%Nc(2))
 
 1022       call dffti(gyro%Nc(2), buf)
 
 1023       do i = 1, gyro%Nc(1) + 1
 
 1024          call dfftf(gyro%Nc(2), fcomp(i, :), buf)
 
 1026       fcomp = fcomp/real(gyro%Nc(2), f64)
 
 1029       do k = 1, gyro%Nc(2)
 
 1030          do i = 1, gyro%Nc(1)
 
 1031             diagm1(i + 1) = -(rho**2/4._f64)*(1._f64/dr**2 - 1._f64/(2._f64*dr*(gyro%eta_min(1) + &
 
 1032                                                                                 (gyro%eta_max(1) - gyro%eta_min(1))*real(i, f64) &
 
 1033                                                                                 /real(gyro%Nc(1), f64))))
 
 1034             diag(i) = 1._f64 - (rho**2/4._f64)*(-(2._f64/dr**2) - (real(floor(k/2._f64), kind=f64)/ &
 
 1035                                                                    (gyro%eta_min(1) + (gyro%eta_max(1) - gyro%eta_min(1))* &
 
 1036                                                                     real(i - 1, f64)/
real(gyro%Nc(1), f64)))**2)
 
 1037             diagp1(i) = -(rho**2/4._f64)*(1._f64/dr**2 + 1._f64/(2._f64*dr*(gyro%eta_min(1) + &
 
 1038                                                                             (gyro%eta_max(1) - gyro%eta_min(1))*real(i - 1, f64) &
 
 1039                                                                             /real(gyro%Nc(1), f64))))
 
 1042          diagp1(gyro%Nc(1) + 1) = 0._f64
 
 1044          diag(gyro%Nc(1) + 1) = 1._f64
 
 1047          diagm1(gyro%Nc(1) + 1) = 0._f64
 
 1051          call solve_tridiag(diagm1, diag, diagp1, fcomp(1:gyro%Nc(1) + 1, k), f(1:gyro%Nc(1) + 1, k), gyro%Nc(1) + 1)
 
 1055       do i = 1, gyro%Nc(1) + 1
 
 1056          call dfftb(gyro%Nc(2), f(i, 1:gyro%Nc(2)), buf)
 
 1060       f(1:gyro%Nc(1) + 1, gyro%Nc(2) + 1) = f(1:gyro%Nc(1) + 1, 1)
 
 1066       sll_real64, 
dimension(:, :), 
intent(inout) :: f
 
 1067       sll_real64, 
dimension(:, :), 
allocatable :: fcomp
 
 1068       sll_real64, 
dimension(:), 
allocatable :: buf
 
 1069       sll_real64, 
dimension(:), 
allocatable :: diagm1_left, diag_left, diagp1_left, diagm2_left, diagp2_left
 
 1070       sll_real64, 
dimension(:), 
allocatable :: diagm1_right, diag_right, diagp1_right, fbuf
 
 1071       sll_int32, 
intent(in) :: order(2)
 
 1072       sll_real64, 
intent(in)::rho
 
 1074       sll_real64::dr, a, b, c, ri, rip1, rip2, nfloat
 
 1077       if ((order(1) == 0) .and. (order(2) == 2)) 
then 
 1078          a = -(rho**2)/4._f64
 
 1081       elseif ((order(1) == 0) .and. (order(2) == 4)) 
then 
 1082          a = -(rho**2)/4._f64
 
 1083          b = 3._f64*(rho**4)/64._f64
 
 1085       elseif ((order(1) == 2) .and. (order(2) == 4)) 
then 
 1086          a = -2._f64*(rho**2)/27._f64
 
 1087          b = 5._f64*(rho**4)/1728._f64
 
 1088          c = 19._f64*(rho**2)/108._f64
 
 1090          print *, 
'#bad value of pade_order=', order
 
 1091          print *, 
'#not implemented' 
 1092          print *, 
'#in sll_s_compute_gyroaverage_pade_high_order_polar' 
 1096       dr = (gyro%eta_max(1) - gyro%eta_min(1))/real(gyro%Nc(1), f64)
 
 1098       sll_allocate(buf(1:2*gyro%Nc(2) + 15), error)
 
 1099       sll_allocate(fcomp(1:gyro%Nc(1) + 1, 1:gyro%Nc(2)), error)
 
 1100       sll_allocate(diagm2_left(1:gyro%Nc(1) + 1), error)
 
 1101       sll_allocate(diagm1_left(1:gyro%Nc(1) + 1), error)
 
 1102       sll_allocate(diag_left(1:gyro%Nc(1) + 1), error)
 
 1103       sll_allocate(diagp1_left(1:gyro%Nc(1) + 1), error)
 
 1104       sll_allocate(diagp2_left(1:gyro%Nc(1) + 1), error)
 
 1105       sll_allocate(diagm1_right(1:gyro%Nc(1) + 1), error)
 
 1106       sll_allocate(diag_right(1:gyro%Nc(1) + 1), error)
 
 1107       sll_allocate(diagp1_right(1:gyro%Nc(1) + 1), error)
 
 1108       sll_allocate(fbuf(1:gyro%Nc(1) + 1), error)
 
 1110       fcomp(1:gyro%Nc(1) + 1, 1:gyro%Nc(2)) = f(1:gyro%Nc(1) + 1, 1:gyro%Nc(2))
 
 1114       call dffti(gyro%Nc(2), buf)
 
 1115       do i = 1, gyro%Nc(1) + 1
 
 1116          call dfftf(gyro%Nc(2), fcomp(i, :), buf)
 
 1118       fcomp = fcomp/real(gyro%Nc(2), f64)
 
 1121       do k = 1, gyro%Nc(2)
 
 1122          nfloat = real(floor(k/2._f64), kind=f64)
 
 1123          do i = 1, gyro%Nc(1) - 1
 
 1124             ri = gyro%eta_min(1) + (gyro%eta_max(1) - gyro%eta_min(1))*real(i - 1, f64)/real(gyro%Nc(1), f64)
 
 1125             rip1 = gyro%eta_min(1) + (gyro%eta_max(1) - gyro%eta_min(1))*real(i, f64)/real(gyro%Nc(1), f64)
 
 1126             rip2 = gyro%eta_min(1) + (gyro%eta_max(1) - gyro%eta_min(1))*real(i + 1, f64)/real(gyro%Nc(1), f64)
 
 1130             diagm2_left(i + 2) = b/dr**4 + &
 
 1131                                  (2._f64*b/rip2)*(-1._f64/(2._f64*dr**3))
 
 1133             diagm1_left(i + 1) = -4._f64*b/dr**4 + &
 
 1134                                  (2._f64*b/rip1)*(2._f64/(2._f64*dr**3)) + &
 
 1135                                  (a - (b*(2._f64*(nfloat**2) + 1._f64)/rip1**2))*(1._f64/dr**2) + &
 
 1136                                  (a/rip1 + b*(2._f64*(nfloat**2) + 1._f64)/(rip1**3))*(-1._f64/(2._f64*dr))
 
 1138             diag_left(i) = 6._f64*b/dr**4 + &
 
 1139                            (a - (b*(2._f64*(nfloat**2) + 1._f64)/ri**2))*(-2._f64/dr**2) + &
 
 1140                            (1._f64 - a*(nfloat**2)/(rip1**2) + b*(nfloat**2)*(nfloat**2 - 4._f64)/(ri**4))
 
 1142             diagp1_left(i) = -4._f64*b/dr**4 + &
 
 1143                              (2._f64*b/ri)*(-2._f64/(2._f64*dr**3)) + &
 
 1144                              (a - (b*(2._f64*(nfloat**2) + 1._f64)/ri**2))*(1._f64/dr**2) + &
 
 1145                              (a/ri + b*(2._f64*(nfloat**2) + 1._f64)/(ri**3))*(1._f64/(2._f64*dr))
 
 1147             diagp2_left(i) = b/dr**4 + &
 
 1148                              (2._f64*b/ri)*(1._f64/(2._f64*dr**3))
 
 1152             diagm1_right(i + 1) = c*(1._f64/dr**2) + &
 
 1153                                   (c/rip1)*(-1._f64/(2._f64*dr))
 
 1155             diag_right(i) = c*(-2._f64/dr**2) + &
 
 1156                             (1._f64 - c*(nfloat**2)/(rip1**2))
 
 1158             diagp1_right(i) = c*(1._f64/dr**2) + &
 
 1159                               (c/ri)*(1._f64/(2._f64*dr))
 
 1162          diagm1_left(1) = 0._f64
 
 1163          diagm2_left(1) = 0._f64
 
 1164          diagm2_left(2) = 0._f64
 
 1165          diagp1_left(gyro%Nc(1) + 1) = 0._f64
 
 1166          diagp2_left(gyro%Nc(1) + 1) = 0._f64
 
 1167          diagp2_left(gyro%Nc(1)) = 0._f64
 
 1169          diag_left(1) = 1._f64
 
 1170          diagp1_left(1) = 0._f64
 
 1171          diagp2_left(1) = 0._f64
 
 1172          diagm1_left(2) = 0._f64
 
 1173          diag_left(2) = 1._f64
 
 1174          diagp1_left(2) = 0._f64
 
 1175          diagp2_left(2) = 0._f64
 
 1176          diagm1_left(gyro%Nc(1)) = 0._f64
 
 1177          diagm2_left(gyro%Nc(1)) = 0._f64
 
 1178          diag_left(gyro%Nc(1)) = 1._f64
 
 1179          diagp1_left(gyro%Nc(1)) = 0._f64
 
 1180          diagm1_left(gyro%Nc(1) + 1) = 0._f64
 
 1181          diagm2_left(gyro%Nc(1) + 1) = 0._f64
 
 1182          diag_left(gyro%Nc(1) + 1) = 1._f64
 
 1184          diagm1_right(1) = 0._f64
 
 1185          diagp1_right(gyro%Nc(1) + 1) = 0._f64
 
 1187          diag_right(1) = 1._f64
 
 1188          diagp1_right(1) = 0._f64
 
 1189          diagm1_right(2) = 0._f64
 
 1190          diag_right(2) = 1._f64
 
 1191          diagp1_right(2) = 0._f64
 
 1192          diagm1_right(gyro%Nc(1)) = 0._f64
 
 1193          diag_right(gyro%Nc(1)) = 1._f64
 
 1194          diagp1_right(gyro%Nc(1)) = 0._f64
 
 1195          diagm1_right(gyro%Nc(1) + 1) = 0._f64
 
 1196          diag_right(gyro%Nc(1) + 1) = 1._f64
 
 1199          fbuf(1:gyro%Nc(1) + 1) = fcomp(1:gyro%Nc(1) + 1, k)
 
 1200          do i = 2, gyro%Nc(1)
 
 1201             fcomp(i, k) = diagm1_right(i)*fbuf(i - 1) + diag_right(i)*fbuf(i) + diagp1_right(i)*fbuf(i + 1)
 
 1205 call sll_s_penta(gyro%Nc(1)+1,diagm2_left,diagm1_left,diag_left,diagp1_left,diagp2_left,fcomp(1:gyro%Nc(1)+1,k),f(1:gyro%Nc(1)+1,k))
 
 1209       do i = 1, gyro%Nc(1) + 1
 
 1210          call dfftb(gyro%Nc(2), f(i, 1:gyro%Nc(2)), buf)
 
 1214       f(1:gyro%Nc(1) + 1, gyro%Nc(2) + 1) = f(1:gyro%Nc(1) + 1, 1)
 
 1219       sll_int32, 
intent(in)::n(2), d(2)
 
 1220       sll_real64, 
dimension(N(1) + 1, N(2)), 
intent(in)::f
 
 1221       sll_real64, 
dimension(9, N(1) + 1, N(2) + 1), 
intent(out)::buf3d
 
 1222       sll_real64 ::w_left_1(-d(1)/2:(d(1) + 1)/2), w_right_1((-d(1) + 1)/2:d(1)/2 + 1)
 
 1223       sll_real64 ::w_left_2(-d(2)/2:(d(2) + 1)/2), w_right_2((-d(2) + 1)/2:d(2)/2 + 1)
 
 1225       sll_int32  ::i, j, ii, r_left(2), r_right(2), s_left(2), s_right(2), ind
 
 1228       r_right = (-d + 1)/2
 
 1233       if ((2*(d(1)/2) - d(1)) == 0) 
then 
 1234          w_right_1(r_right(1):s_right(1)) = w_left_1(r_left(1):s_left(1))
 
 1236          w_right_1(r_right(1):s_right(1)) = -w_left_1(s_left(1):r_left(1):-1)
 
 1239       if ((2*(d(2)/2) - d(2)) == 0) 
then 
 1240          w_right_2(r_right(2):s_right(2)) = w_left_2(r_left(2):s_left(2))
 
 1242          w_right_2(r_right(2):s_right(2)) = -w_left_2(s_left(2):r_left(2):-1)
 
 1250             buf3d(1, i, j) = f(i, j) 
 
 1252             do ii = r_left(1), s_left(1)
 
 1253                ind = i + ii; 
if (ind > n(1) + 1) ind = 2*(n(1) + 1) - ind; 
if (ind < 1) ind = 2 - ind
 
 1254                tmp = tmp + w_left_1(ii)*f(ind, j)
 
 1256             buf3d(2, i, j) = tmp 
 
 1258             do ii = r_right(1), s_right(1)
 
 1259                ind = i + ii; 
if (ind > n(1) + 1) ind = 2*(n(1) + 1) - ind; 
if (ind < 1) ind = 2 - ind
 
 1260                tmp = tmp + w_right_1(ii)*f(ind, j)
 
 1262             buf3d(3, i, j) = tmp 
 
 1268             do ii = r_left(2), s_left(2)
 
 1269                ind = modulo(j + ii - 1 + n(2), n(2)) + 1
 
 1270                tmp = tmp + w_left_2(ii)*f(i, ind)
 
 1272             buf3d(4, i, j) = tmp 
 
 1274             do ii = r_right(2), s_right(2)
 
 1275                ind = modulo(j + ii - 1 + n(2), n(2)) + 1
 
 1276                tmp = tmp + w_right_2(ii)*f(i, ind)
 
 1278             buf3d(5, i, j) = tmp 
 
 1285             do ii = r_left(1), s_left(1)
 
 1286                ind = i + ii; 
if (ind > n(1) + 1) ind = 2*(n(1) + 1) - ind; 
if (ind < 1) ind = 2 - ind
 
 1287                tmp = tmp + w_left_1(ii)*buf3d(4, ind, j)
 
 1289             buf3d(6, i, j) = tmp 
 
 1291             do ii = r_right(1), s_right(1)
 
 1292                ind = i + ii; 
if (ind > n(1) + 1) ind = 2*(n(1) + 1) - ind; 
if (ind < 1) ind = 2 - ind
 
 1293                tmp = tmp + w_right_1(ii)*buf3d(4, ind, j)
 
 1295             buf3d(7, i, j) = tmp 
 
 1297             do ii = r_left(1), s_left(1)
 
 1298                ind = i + ii; 
if (ind > n(1) + 1) ind = 2*(n(1) + 1) - ind; 
if (ind < 1) ind = 2 - ind
 
 1299                tmp = tmp + w_left_1(ii)*buf3d(5, ind, j)
 
 1301             buf3d(8, i, j) = tmp  
 
 1303             do ii = r_right(1), s_right(1)
 
 1304                ind = i + ii; 
if (ind > n(1) + 1) ind = 2*(n(1) + 1) - ind; 
if (ind < 1) ind = 2 - ind
 
 1305                tmp = tmp + w_right_1(ii)*buf3d(5, ind, j)
 
 1307             buf3d(9, i, j) = tmp 
 
 1311       buf3d(:, :, n(2) + 1) = buf3d(:, :, 1)
 
 1316       integer, 
intent(in)::N(2), d(2)
 
 1317       sll_real64, 
dimension(N(1) + 1, N(2)), 
intent(in)::f
 
 1318       sll_real64, 
dimension(4, N(1) + 1, N(2) + 1), 
intent(out)::buf3d
 
 1319       sll_real64, 
dimension(:), 
allocatable ::w_left_1, w_left_2
 
 1321       sll_int32::i, j, ii, r_left(2), s_left(2), ind, dd(2)
 
 1323       dd(1) = 2*((d(1) + 1)/2)
 
 1324       dd(2) = 2*((d(2) + 1)/2)
 
 1329       sll_allocate(w_left_1(-dd(1)/2:dd(1)/2), error)
 
 1330       sll_allocate(w_left_2(-dd(2)/2:dd(2)/2), error)
 
 1340             buf3d(1, i, j) = f(i, j) 
 
 1342             do ii = r_left(1), s_left(1)
 
 1343                ind = i + ii; 
if (ind > n(1) + 1) ind = 2*(n(1) + 1) - ind; 
if (ind < 1) ind = 2 - ind
 
 1344                tmp = tmp + w_left_1(ii)*f(ind, j)
 
 1346             buf3d(2, i, j) = tmp 
 
 1352             do ii = r_left(2), s_left(2)
 
 1353                ind = modulo(j + ii - 1 + n(2), n(2)) + 1
 
 1354                tmp = tmp + w_left_2(ii)*f(i, ind)
 
 1356             buf3d(3, i, j) = tmp 
 
 1363             do ii = r_left(1), s_left(1)
 
 1364                ind = i + ii; 
if (ind > n(1) + 1) ind = 2*(n(1) + 1) - ind; 
if (ind < 1) ind = 2 - ind
 
 1365                tmp = tmp + w_left_1(ii)*buf3d(3, ind, j)
 
 1367             buf3d(4, i, j) = tmp 
 
 1371       buf3d(:, :, n(2) + 1) = buf3d(:, :, 1)
 
 1373       sll_deallocate_array(w_left_1, error)
 
 1374       sll_deallocate_array(w_left_2, error)
 
 1379       sll_int32, 
intent(in)::r, s
 
 1380       sll_real64, 
dimension(r:s), 
intent(out)::w
 
 1398             tmp = tmp*real(i - j, f64)
 
 1401             tmp = tmp*real(i - j, f64)
 
 1405             tmp = tmp*real(-j, f64)
 
 1408             tmp = tmp*real(-j, f64)
 
 1411             tmp = tmp*real(-j, f64)
 
 1419             tmp = tmp*real(i - j, f64)
 
 1422             tmp = tmp*real(i - j, f64)
 
 1426             tmp = tmp*real(-j, f64)
 
 1429             tmp = tmp*real(-j, f64)
 
 1432             tmp = tmp*real(-j, f64)
 
 1454       sll_real64, 
intent(in)::x(2), eta_min(2), eta_max(2)
 
 1455       sll_int32, 
intent(out)::ii(2)
 
 1456       sll_int32, 
intent(in)::n(2)
 
 1457       sll_real64, 
intent(out)::eta(2)
 
 1459       eta(1) = sqrt(x(1)**2 + x(2)**2)
 
 1460       call localize_nat(ii(1), eta(1), eta_min(1), eta_max(1), n(1))
 
 1461       eta(2) = atan2(x(2), x(1))
 
 1462       call localize_per(ii(2), eta(2), eta_min(2), eta_max(2), n(2))
 
 1466       sll_int32, 
intent(out)::i
 
 1467       sll_real64, 
intent(inout)::x
 
 1468       sll_real64, 
intent(in)::xmin, xmax
 
 1469       sll_int32, 
intent(in)::n
 
 1470       x = (x - xmin)/(xmax - xmin)
 
 1471       x = x - real(floor(x), f64)
 
 1474       x = x - real(i, f64)
 
 1482       sll_int32, 
intent(out)::i
 
 1483       sll_real64, 
intent(inout)::x
 
 1484       sll_real64, 
intent(in)::xmin, xmax
 
 1485       sll_int32, 
intent(in)::n
 
 1486       x = (x - xmin)/(xmax - xmin)
 
 1488       if (x >= real(n, f64)) 
then 
 1491       if (x <= 0._f64) 
then 
 1495       x = x - real(i, f64)
 
 1503       sll_int32, 
intent(in)::i(2), n(2)
 
 1505       sll_real64, 
intent(in)::x(2)
 
 1506       sll_real64, 
intent(out)::fval
 
 1507       sll_real64, 
dimension(0:8, 0:N(1), 0:N(2))::f
 
 1510       sll_real64::w(2, 0:3), tmp(0:3)
 
 1511       sll_real64::g(0:3, 0:3)
 
 1518          w(s, 0) = (2._f64*x(s) + 1)*(1._f64 - x(s))*(1._f64 - x(s)); 
 
 1519          w(s, 1) = x(s)*x(s)*(3._f64 - 2._f64*x(s))
 
 1520          w(s, 2) = x(s)*(1._f64 - x(s))*(1._f64 - x(s))
 
 1521          w(s, 3) = x(s)*x(s)*(x(s) - 1._f64)
 
 1525       g(0, 0) = f(0, i(1), i(2))          
 
 1526       g(1, 0) = f(0, i1(1), i(2))         
 
 1527       g(2, 0) = f(1, i(1), i(2))          
 
 1528       g(3, 0) = f(2, i(1), i(2))          
 
 1529       g(0, 1) = f(0, i(1), i1(2))         
 
 1530       g(1, 1) = f(0, i1(1), i1(2))        
 
 1531       g(2, 1) = f(1, i(1), i1(2))         
 
 1532       g(3, 1) = f(2, i(1), i1(2))         
 
 1533       g(0, 2) = f(3, i(1), i(2))          
 
 1534       g(1, 2) = f(3, i1(1), i(2))         
 
 1535       g(2, 2) = f(5, i(1), i(2))          
 
 1536       g(3, 2) = f(6, i(1), i(2))          
 
 1537       g(0, 3) = f(4, i(1), i(2))          
 
 1538       g(1, 3) = f(4, i1(1), i(2))         
 
 1539       g(2, 3) = f(7, i(1), i(2))          
 
 1540       g(3, 3) = f(8, i(1), i(2))          
 
 1543          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)
 
 1546       fval = w(2, 0)*tmp(0) + w(2, 1)*tmp(1) + w(2, 2)*tmp(2) + w(2, 3)*tmp(3)
 
 1552       sll_int32, 
intent(in)::i(2), n(2)
 
 1554       sll_real64, 
intent(in)::x(2)
 
 1555       sll_real64, 
intent(out)::fval
 
 1556       sll_real64, 
dimension(0:3, 0:N(1), 0:N(2))::f
 
 1559       sll_real64::w(2, 0:3), tmp(0:3)
 
 1560       sll_real64::g(0:3, 0:3)
 
 1567          w(s, 0) = (2._f64*x(s) + 1)*(1._f64 - x(s))*(1._f64 - x(s)); 
 
 1568          w(s, 1) = x(s)*x(s)*(3._f64 - 2._f64*x(s))
 
 1569          w(s, 2) = x(s)*(1._f64 - x(s))*(1._f64 - x(s))
 
 1570          w(s, 3) = x(s)*x(s)*(x(s) - 1._f64)
 
 1574       g(0, 0) = f(0, i(1), i(2))          
 
 1575       g(1, 0) = f(0, i1(1), i(2))         
 
 1576       g(2, 0) = f(1, i(1), i(2))          
 
 1577       g(3, 0) = f(1, i1(1), i(2))          
 
 1578       g(0, 1) = f(0, i(1), i1(2))         
 
 1579       g(1, 1) = f(0, i1(1), i1(2))        
 
 1580       g(2, 1) = f(1, i(1), i1(2))         
 
 1581       g(3, 1) = f(1, i1(1), i1(2))         
 
 1582       g(0, 2) = f(2, i(1), i(2))          
 
 1583       g(1, 2) = f(2, i1(1), i(2))         
 
 1584       g(2, 2) = f(3, i(1), i(2))          
 
 1585       g(3, 2) = f(3, i1(1), i(2))          
 
 1586       g(0, 3) = f(2, i(1), i1(2))          
 
 1587       g(1, 3) = f(2, i1(1), i1(2))         
 
 1588       g(2, 3) = f(3, i(1), i1(2))          
 
 1589       g(3, 3) = f(3, i1(1), i1(2))          
 
 1592          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)
 
 1595       fval = w(2, 0)*tmp(0) + w(2, 1)*tmp(1) + w(2, 2)*tmp(2) + w(2, 3)*tmp(3)
 
 1600       sll_real64, 
intent(in)::x(0:1)
 
 1601       sll_real64, 
intent(out)::val(4, 0:1, 0:1)
 
 1603       sll_real64::w(0:3, 0:1)
 
 1605          w(0, s) = (2._f64*x(s) + 1)*(1._f64 - x(s))*(1._f64 - x(s)); 
 
 1606          w(1, s) = x(s)*x(s)*(3._f64 - 2._f64*x(s))
 
 1607          w(2, s) = x(s)*(1._f64 - x(s))*(1._f64 - x(s))
 
 1608          w(3, s) = x(s)*x(s)*(x(s) - 1._f64)
 
 1611       val(1, 0, 0) = w(0, 0)*w(0, 1)
 
 1612       val(2, 0, 0) = w(2, 0)*w(0, 1)
 
 1613       val(3, 0, 0) = w(0, 0)*w(2, 1)
 
 1614       val(4, 0, 0) = w(2, 0)*w(2, 1)
 
 1616       val(1, 1, 0) = w(1, 0)*w(0, 1)
 
 1617       val(2, 1, 0) = w(3, 0)*w(0, 1)
 
 1618       val(3, 1, 0) = w(1, 0)*w(2, 1)
 
 1619       val(4, 1, 0) = w(3, 0)*w(2, 1)
 
 1621       val(1, 0, 1) = w(0, 0)*w(1, 1)
 
 1622       val(2, 0, 1) = w(2, 0)*w(1, 1)
 
 1623       val(3, 0, 1) = w(0, 0)*w(3, 1)
 
 1624       val(4, 0, 1) = w(2, 0)*w(3, 1)
 
 1626       val(1, 1, 1) = w(1, 0)*w(1, 1)
 
 1627       val(2, 1, 1) = w(3, 0)*w(1, 1)
 
 1628       val(3, 1, 1) = w(1, 0)*w(3, 1)
 
 1629       val(4, 1, 1) = w(3, 0)*w(3, 1)
 
 1637       sll_real64, 
intent(in)::x(0:1)
 
 1638       sll_real64, 
intent(out)::val(-1:2, -1:2)
 
 1640       sll_real64::w(-1:2, 0:1)
 
 1642          w(-1, s) = (1._f64/6._f64)*(1._f64 - x(s))*(1._f64 - x(s))*(1._f64 - x(s)); 
 
 1643          w(0, s) = 1._f64/6._f64 + 0.5_f64*(1._f64 - x(s))*(-(1._f64 - x(s))* &
 
 1644                                                             (1._f64 - x(s)) + (1._f64 - x(s)) + 1._f64); 
 
 1645          w(1, s) = 1._f64/6._f64 + 0.5_f64*x(s)*(-x(s)*x(s) + x(s) + 1._f64); 
 
 1646          w(2, s) = (1._f64/6._f64)*x(s)*x(s)*x(s); 
 
 1649       val(-1, -1) = w(-1, 0)*w(-1, 1)
 
 1650       val(-1, 0) = w(-1, 0)*w(0, 1)
 
 1651       val(-1, 1) = w(-1, 0)*w(1, 1)
 
 1652       val(-1, 2) = w(-1, 0)*w(2, 1)
 
 1654       val(0, -1) = w(0, 0)*w(-1, 1)
 
 1655       val(0, 0) = w(0, 0)*w(0, 1)
 
 1656       val(0, 1) = w(0, 0)*w(1, 1)
 
 1657       val(0, 2) = w(0, 0)*w(2, 1)
 
 1659       val(1, -1) = w(1, 0)*w(-1, 1)
 
 1660       val(1, 0) = w(1, 0)*w(0, 1)
 
 1661       val(1, 1) = w(1, 0)*w(1, 1)
 
 1662       val(1, 2) = w(1, 0)*w(2, 1)
 
 1664       val(2, -1) = w(2, 0)*w(-1, 1)
 
 1665       val(2, 0) = w(2, 0)*w(0, 1)
 
 1666       val(2, 1) = w(2, 0)*w(1, 1)
 
 1667       val(2, 2) = w(2, 0)*w(2, 1)
 
 1672       sll_int32, 
intent(in)::n
 
 1673       sll_real64, 
dimension(0:1, 0:N + 2), 
intent(out)::lunat
 
 1676       a(0) = -3._f64; a(1) = 0._f64; a(2) = 3._f64; 
 
 1678       lunat(1, 0) = 1._f64/lunat(0, 0); 
 
 1679       lunat(0, 1) = 4._f64 - a(1)*lunat(1, 0); 
 
 1680       lunat(1, 1) = 1._f64/lunat(0, 1); 
 
 1681       lunat(0, 2) = 4._f64 - lunat(1, 1)*(1._f64 - a(2)/a(0)); 
 
 1683          lunat(1, i) = 1._f64/lunat(0, i); 
 
 1684          lunat(0, i + 1) = 4._f64 - lunat(1, i); 
 
 1686       lunat(1, n + 2) = a(0)/lunat(0, n); 
 
 1687       lunat(1, n + 1) = (a(1) - lunat(1, n + 2))/lunat(0, n + 1); 
 
 1688       lunat(0, n + 2) = a(2) - lunat(1, n + 1); 
 
 1692       sll_int32, 
intent(in)::n
 
 1693       sll_real64, 
dimension(0:1, 0:N + 2), 
intent(in)::lunat
 
 1694       sll_real64, 
dimension(0:N + 2), 
intent(inout)::p
 
 1697       a(0) = -3._f64; a(1) = 0._f64; a(2) = 3._f64; 
 
 1703       do i = 1, n + 1; p(i) = p(i) - lunat(1, i - 1)*p(i - 1);
 end do 
 1704       p(n + 2) = p(n + 2) - (lunat(1, n + 1)*p(n + 1) + lunat(1, n + 2)*p(n)); 
 
 1705       p(n + 2) = p(n + 2)/lunat(0, n + 2); 
 
 1706       do i = n + 1, 2, -1; p(i) = (p(i) - p(i + 1))/lunat(0, i);
 end do 
 1707       p(1) = (p(1) - (1._f64 - a(2)/a(0))*p(2))/lunat(0, 1); 
 
 1708       p(0) = (p(0) - a(1)*p(1) - a(2)*p(2))/lunat(0, 0); 
 
 1715       sll_int32, 
intent(in)::n
 
 1716       sll_real64, 
dimension(0:N + 2), 
intent(inout)::dnat, lnat
 
 1719       a(0) = -3._f64; a(1) = 0._f64; a(2) = 3._f64; 
 
 1721       lnat(0) = 1._f64/dnat(0); 
 
 1722       dnat(1) = 4._f64 - a(1)*lnat(0); 
 
 1723       lnat(1) = 1._f64/dnat(1); 
 
 1724       dnat(2) = 4._f64 - lnat(1)*(1._f64 - a(2)/a(0)); 
 
 1726          lnat(i) = 1._f64/dnat(i); 
 
 1727          dnat(i + 1) = 4._f64 - lnat(i); 
 
 1729       lnat(n + 2) = a(0)/dnat(n); 
 
 1730       lnat(n + 1) = (a(1) - lnat(n + 2))/dnat(n + 1); 
 
 1731       dnat(n + 2) = a(2) - lnat(n + 1); 
 
 1735       sll_int32, 
intent(in)::nx, ny
 
 1736       sll_real64, 
dimension(:, :), 
pointer::f
 
 1737       sll_real64, 
dimension(:), 
pointer::buf, dpery, lpery, mpery, dnatx, lnatx
 
 1741          do i = 0, nx + 2; buf(i) = f(i, j);
 end do 
 1743          do i = 0, nx + 2; f(i, j) = buf(i);
 end do 
 1747          do j = 0, ny - 1; buf(j) = f(i, j);
 end do 
 1749          do j = 0, ny - 1; f(i, j) = buf(j);
 end do 
 1754    subroutine splnatper2d(f, xx, xmin, xmax, yy, ymin, ymax, fval, Nx, Ny)
 
 1755       sll_int32, 
intent(in)::nx, ny
 
 1756       sll_real64, 
intent(in)::xx, xmin, xmax, yy, ymin, ymax
 
 1757       sll_real64, 
intent(out)::fval
 
 1758       sll_real64, 
dimension(:, :), 
pointer::f
 
 1760       sll_int32::ix(0:3), iy(0:3)
 
 1762       sll_real64::wx(0:3), wy(0:3), tmp(0:3)
 
 1764       x = (xx - xmin)/(xmax - xmin)
 
 1766       if (x < 0._f64) x = 0._f64; 
 
 1767       if (x >= 1.0_f64) 
then 
 1768          x = 1.0_f64 - 1.e-12_f64; 
 
 1772       x = x - real(i, f64)
 
 1774       y = (yy - ymin)/(ymax - ymin)
 
 1775       y = y - real(floor(y), f64)
 
 1778       y = y - real(j, f64)
 
 1780       wx(0) = (1.0_f64/6._f64)*(1.0_f64 - x)*(1.0_f64 - x)*(1.0_f64 - x); 
 
 1783          0.5_f64*(1.0_f64 - x)*(-(1.0_f64 - x)*(1.0_f64 - x) + (1.0_f64 - x) + 1.0_f64); 
 
 1784       wx(2) = 1.0_f64/6._f64 + 0.5_f64*x*(-x*x + x + 1.0_f64); 
 
 1785       wx(3) = (1.0_f64/6._f64)*x*x*x; 
 
 1786       wy(0) = (1.0_f64/6._f64)*(1.0_f64 - y)*(1.0_f64 - y)*(1.0_f64 - y); 
 
 1789          0.5_f64*(1.0_f64 - y)*(-(1.0_f64 - y)*(1.0_f64 - y) + (1.0_f64 - y) + 1.0_f64); 
 
 1790       wy(2) = 1.0_f64/6._f64 + 0.5_f64*y*(-y*y + y + 1.0_f64); 
 
 1791       wy(3) = (1.0_f64/6._f64)*y*y*y; 
 
 1792       iy(0) = mod(j + ny - 1, ny)
 
 1794       iy(2) = mod(j + 1, ny)
 
 1795       iy(3) = mod(j + 2, ny)
 
 1802       tmp(0) = wx(0)*f(ix(0), iy(0)) + wx(1)*f(ix(1), iy(0)) &
 
 1803                + wx(2)*f(ix(2), iy(0)) + wx(3)*f(ix(3), iy(0))
 
 1804       tmp(1) = wx(0)*f(ix(0), iy(1)) + wx(1)*f(ix(1), iy(1)) &
 
 1805                + wx(2)*f(ix(2), iy(1)) + wx(3)*f(ix(3), iy(1))
 
 1806       tmp(2) = wx(0)*f(ix(0), iy(2)) + wx(1)*f(ix(1), iy(2)) &
 
 1807                + wx(2)*f(ix(2), iy(2)) + wx(3)*f(ix(3), iy(2))
 
 1808       tmp(3) = wx(0)*f(ix(0), iy(3)) + wx(1)*f(ix(1), iy(3)) &
 
 1809                + wx(2)*f(ix(2), iy(3)) + wx(3)*f(ix(3), iy(3))
 
 1811       fval = wy(0)*tmp(0) + wy(1)*tmp(1) + wy(2)*tmp(2) + wy(3)*tmp(3)
 
 1816       sll_int32, 
intent(in)::n
 
 1817       sll_real64, 
intent(in)::xx, xmin, xmax
 
 1818       sll_real64, 
intent(out)::fval
 
 1819       sll_real64, 
dimension(0:N - 1), 
intent(inout)::f
 
 1823       x = (xx - xmin)/(xmax - xmin)
 
 1824       x = x - real(floor(x), f64)
 
 1827       x = x - real(i, f64)
 
 1828       w(0) = (1.0_f64/6._f64)*(1.0_f64 - x)*(1.0_f64 - x)*(1.0_f64 - x); 
 
 1831          0.5_f64*(1.0_f64 - x)*(-(1.0_f64 - x)*(1.0_f64 - x) + (1.0_f64 - x) + 1.0_f64); 
 
 1832       w(2) = 1.0_f64/6._f64 + 0.5_f64*x*(-x*x + x + 1.0_f64); 
 
 1833       w(3) = (1.0_f64/6._f64)*x*x*x; 
 
 1834       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))
 
 1838       sll_int32, 
intent(in)::n
 
 1839       sll_real64, 
intent(in)::xx, xmin, xmax
 
 1840       sll_real64, 
intent(out)::fval
 
 1841       sll_real64, 
dimension(0:N + 2), 
intent(inout)::f
 
 1845       x = (xx - xmin)/(xmax - xmin)
 
 1847       if (x < 0._f64) x = 0._f64; 
 
 1848       if (x > 1.0_f64) 
then 
 1849          x = 1.0_f64 - 1.e-12_f64; 
 
 1853       x = x - real(i, f64)
 
 1855       w(0) = (1.0_f64/6._f64)*(1.0_f64 - x)*(1.0_f64 - x)*(1.0_f64 - x); 
 
 1858          0.5_f64*(1.0_f64 - x)*(-(1.0_f64 - x)*(1.0_f64 - x) + (1.0_f64 - x) + 1.0_f64); 
 
 1859       w(2) = 1.0_f64/6._f64 + 0.5_f64*x*(-x*x + x + 1.0_f64); 
 
 1860       w(3) = (1.0_f64/6._f64)*x*x*x; 
 
 1861       fval = w(0)*f(i) + w(1)*f(i + 1) + w(2)*f(i + 2) + w(3)*f(i + 3)
 
 1865       sll_int32, 
intent(in)::n
 
 1866       sll_real64, 
dimension(0:N - 1), 
intent(out)::dper, lper, mper
 
 1872          lper(i) = 1.0_f64/dper(i)
 
 1873          dper(i + 1) = 4._f64 - lper(i)
 
 1874          mper(i + 1) = -mper(i)/dper(i + 1)
 
 1876       dper(n - 1) = dper(n - 1) - (lper(n - 2) + 2._f64*mper(n - 2))
 
 1878          dper(i) = 1.0_f64/dper(i)
 
 1883       sll_int32, 
intent(in)::n
 
 1884       sll_real64, 
dimension(0:3*N - 1), 
intent(out)::luper
 
 1887       luper(0 + 3*0) = 4._f64
 
 1888       luper(2 + 3*0) = 0.25_f64
 
 1890          luper(1 + 3*i) = 1.0_f64/luper(0 + 3*i)
 
 1891          luper(0 + 3*(i + 1)) = 4._f64 - luper(1 + 3*i)
 
 1892          luper(2 + 3*(i + 1)) = -luper(2 + 3*i)/luper(0 + 3*(i + 1))
 
 1894       luper(0 + 3*(n - 1)) = &
 
 1895          luper(0 + 3*(n - 1)) - (luper(1 + 3*(n - 2)) + 2._f64*luper(2 + 3*(n - 2)))
 
 1897          luper(0 + 3*i) = 1.0_f64/luper(0 + 3*i)
 
 1902       sll_int32, 
intent(in)::n
 
 1903       sll_real64, 
dimension(0:3*N - 1), 
intent(in)::luper
 
 1904       sll_real64, 
dimension(0:N - 1), 
intent(inout)::f
 
 1906       do i = 0, n - 1; f(i) = 6._f64*f(i); 
end do; 
 
 1908          f(i) = f(i) - f(i - 1)*luper(1 + 3*(i - 1))
 
 1911          f(n - 1) = f(n - 1) - luper(2 + 3*i)*f(i)
 
 1913       f(n - 1) = f(n - 1)*luper(0 + 3*(n - 1)); f(n - 2) = &
 
 1914  luper(0 + 3*(n - 2))*(f(n - 2) - (1.0_f64 - luper(2 + 3*(n - 3)))*f(n - 1))
 
 1916          f(i) = luper(0 + 3*i)*(f(i) - f(i + 1) + luper(2 + 3*(i - 1))*f(n - 1))
 
 1918       f(0) = luper(0 + 3*0)*(f(0) - f(1) - f(n - 1)); 
 
 1922       sll_int32, 
intent(in)::n
 
 1923       sll_real64, 
dimension(0:N + 2), 
intent(in)::dnat, lnat
 
 1924       sll_real64, 
dimension(0:N + 2), 
intent(inout)::p
 
 1927       a(0) = -3._f64; a(1) = 0._f64; a(2) = 3._f64; 
 
 1933       do i = 1, n + 1; p(i) = p(i) - lnat(i - 1)*p(i - 1);
 end do 
 1934       p(n + 2) = p(n + 2) - (lnat(n + 1)*p(n + 1) + lnat(n + 2)*p(n)); 
 
 1935       p(n + 2) = p(n + 2)/dnat(n + 2); 
 
 1936       do i = n + 1, 2, -1; p(i) = (p(i) - p(i + 1))/dnat(i);
 end do 
 1937       p(1) = (p(1) - (1.0_f64 - a(2)/a(0))*p(2))/dnat(1); 
 
 1938       p(0) = (p(0) - a(1)*p(1) - a(2)*p(2))/dnat(0); 
 
 1945       sll_int32, 
intent(in)::n
 
 1946       sll_real64, 
dimension(0:N - 1), 
intent(in)::dper, lper, mper
 
 1947       sll_real64, 
dimension(0:N - 1), 
intent(inout)::f
 
 1949       do i = 0, n - 1; f(i) = 6._f64*f(i); 
end do; 
 
 1951          f(i) = f(i) - f(i - 1)*lper(i - 1)
 
 1954          f(n - 1) = f(n - 1) - mper(i)*f(i)
 
 1956       f(n - 1) = f(n - 1)*dper(n - 1); f(n - 2) = dper(n - 2)*(f(n - 2) - (1.0_f64 - mper(n - 3))*f(n - 1))
 
 1958          f(i) = dper(i)*(f(i) - f(i + 1) + mper(i - 1)*f(n - 1))
 
 1960       f(0) = dper(0)*(f(0) - f(1) - f(n - 1)); 
 
 1973       sll_int32, 
intent(in) :: n
 
 1974       sll_real64, 
dimension(n), 
intent(in) :: a, b, c, v
 
 1975       sll_real64, 
dimension(n), 
intent(out) :: x
 
 1976       sll_real64, 
dimension(n) :: bp, vp
 
 1985       firstpass: 
do i = 2, n
 
 1987          bp(i) = b(i) - m*c(i - 1)
 
 1988          vp(i) = v(i) - m*vp(i - 1)
 
 1993       backsub: 
do i = n - 1, 1, -1
 
 1994          x(i) = (vp(i) - c(i)*x(i + 1))/bp(i)
 
 2037       sll_int32, 
intent(in) :: n
 
 2038       sll_real64, 
intent(inout), 
dimension(n) :: e, a, b, c, f, d
 
 2039       sll_real64, 
intent(out) :: x(n)
 
 2045          b(i) = b(i) - q*c(i - 1)
 
 2046          c(i) = c(i) - q*f(i - 1)
 
 2047          d(i) = d(i) - q*d(i - 1)
 
 2048          q = e(i + 1)/b(i - 1)
 
 2049          a(i + 1) = a(i + 1) - q*c(i - 1)
 
 2050          b(i + 1) = b(i + 1) - q*f(i - 1)
 
 2051          d(i + 1) = d(i + 1) - q*d(i - 1)
 
 2054       b(n) = b(n) - q*c(n - 1)
 
 2055       x(n) = (d(n) - q*d(n - 1))/b(n)
 
 2056       x(n - 1) = (d(n - 1) - c(n - 1)*x(n))/b(n - 1)
 
 2058          x(i) = (d(i) - f(i)*x(i + 2) - c(i)*x(i + 1))/b(i)
 
Fortran module where set some physical and mathematical constants.
 
real(kind=f64), parameter, public sll_p_pi
 
type(sll_t_plan_gyroaverage_polar) function, pointer, public sll_f_new_plan_gyroaverage_polar_splines(eta_min, eta_max, Nc, N_points)
 
subroutine splcoefnat1d0(lunat, N)
 
subroutine splcoefper1d(f, luper, N)
 
subroutine, public sll_s_compute_gyroaverage_pade_polar(gyro, f, rho)
 
subroutine, public sll_s_compute_gyroaverage_points_polar_hermite(gyro, f, rho)
 
subroutine splcoefper1d0old(dper, lper, mper, N)
 
subroutine, public sll_s_compute_gyroaverage_points_polar_spl(gyro, f, rho)
 
subroutine splcoefnat1dold(p, dnat, lnat, N)
 
subroutine localize_polar(x, eta_min, eta_max, ii, eta, N)
 
subroutine, public sll_s_pre_compute_gyroaverage_polar_spl(gyro, rho)
 
subroutine splcoefper1dold(f, dper, lper, mper, N)
 
subroutine, public sll_s_pre_compute_gyroaverage_polar_spl_fft(gyro, rho)
 
subroutine compute_w_hermite(w, r, s)
 
subroutine solve_tridiag(a, b, c, v, x, n)
 
subroutine, public sll_s_compute_gyroaverage_points_polar_hermite_c1(gyro, f, rho)
 
subroutine, public sll_s_compute_gyroaverage_pre_compute_polar_spl(gyro, f)
 
subroutine localize_nat(i, x, xmin, xmax, N)
 
subroutine splper1d(f, xx, xmin, xmax, fval, N)
 
type(sll_t_plan_gyroaverage_polar) function, pointer, public sll_f_new_plan_gyroaverage_polar_pade(eta_min, eta_max, Nc)
 
subroutine, public sll_s_compute_gyroaverage_pade_high_order_polar(gyro, f, rho, order)
 
subroutine splcoefnat1d(p, lunat, N)
 
subroutine splcoefnat1d0old(dnat, lnat, N)
 
subroutine interpolate_hermite(f, i, x, fval, N)
 
subroutine splcoefnatper2d(f, buf, dnatx, lnatx, dpery, lpery, mpery, Nx, Ny)
 
type(sll_t_plan_gyroaverage_polar) function, pointer, public sll_f_new_plan_gyroaverage_polar_hermite(eta_min, eta_max, Nc, N_points, interp_degree, deriv_size)
 
subroutine hermite_coef_nat_per(f, buf3d, N, d)
 
subroutine hermite_c1_coef_nat_per(f, buf3d, N, d)
 
subroutine, public sll_s_compute_gyroaverage_points_polar_with_invar_spl(gyro, f, rho)
 
subroutine assemble_csr_from_pre_compute(pre_compute_coeff, pre_compute_N, pre_compute_index, nb, Nc, ia, ja, a, num_rows, num_nz)
 
subroutine, public sll_s_compute_gyroaverage_pre_compute_polar_hermite_c1(gyro, f)
 
subroutine, public sll_s_pre_compute_gyroaverage_polar_hermite_c1(gyro, rho)
 
subroutine, public sll_s_compute_gyroaverage_points_polar_with_invar_hermite_c1(gyro, f, rho)
 
subroutine contribution_hermite_c1(x, val)
 
subroutine splcoefper1d0(luper, N)
 
subroutine, public sll_s_compute_gyroaverage_pre_compute_polar_spl_fft(gyro, f)
 
subroutine interpolate_hermite_c1(f, i, x, fval, N)
 
subroutine splnat1d(f, xx, xmin, xmax, fval, N)
 
subroutine contribution_spl(x, val)
 
subroutine localize_per(i, x, xmin, xmax, N)
 
subroutine, public sll_s_penta(n, e, a, b, c, f, d, x)
 
subroutine splnatper2d(f, xx, xmin, xmax, yy, ymin, ymax, fval, Nx, Ny)
 
subroutine, public sll_s_compute_shape_circle(points, N_points)