2 #include "sll_working_precision.h"
3 #include "sll_memory.h"
4 #include "sll_assert.h"
16 sll_comp64,
allocatable :: f1d(:)
17 sll_comp64,
allocatable :: f1(:)
18 sll_comp64,
allocatable :: f2(:)
19 sll_comp64,
allocatable :: fcmplx(:, :)
20 sll_int32,
allocatable :: i(:)
21 sll_int32,
allocatable :: j(:)
22 sll_real64,
allocatable :: x(:)
23 sll_real64,
allocatable :: y(:)
24 sll_real64 :: epsnufft = 1.0d-9
27 sll_real64 :: eta1_min, eta1_max
28 sll_real64 :: eta2_min, eta2_max
38 nc_eta1, eta1_min, eta1_max, &
39 nc_eta2, eta2_min, eta2_max)
42 sll_int32,
intent(in) :: nc_eta1
43 sll_int32,
intent(in) :: nc_eta2
44 sll_real64,
intent(in) :: eta1_min
45 sll_real64,
intent(in) :: eta1_max
46 sll_real64,
intent(in) :: eta2_min
47 sll_real64,
intent(in) :: eta2_max
50 self%nc_eta1 = nc_eta1
51 self%nc_eta2 = nc_eta2
53 self%eta1_min = eta1_min
54 self%eta2_min = eta2_min
55 self%eta1_max = eta1_max
56 self%eta2_max = eta2_max
58 sll_allocate(self%x(1:nc_eta1*nc_eta2), err)
59 sll_allocate(self%y(1:nc_eta1*nc_eta2), err)
60 sll_allocate(self%i(1:nc_eta1*nc_eta2), err)
61 sll_allocate(self%j(1:nc_eta1*nc_eta2), err)
62 sll_allocate(self%fcmplx(1:nc_eta1, 1:nc_eta2), err)
63 sll_allocate(self%f1(1:nc_eta1), err)
64 sll_allocate(self%f2(1:nc_eta2), err)
65 sll_allocate(self%f1d(1:nc_eta1*nc_eta2), err)
85 DEALLOCATE (self%fcmplx)
96 sll_real64,
intent(in) :: f_in(:, :)
98 sll_int32 :: i, j, m, n1, n2, p
103 self%fcmplx = cmplx(f_in(1:n1, 1:n2), 0., f64)
105 self%fcmplx = self%fcmplx/cmplx(n1*n2, 0., f64)
109 self%f2 = self%fcmplx(i, :)
110 self%fcmplx(i, :) = self%f2([[(p, p=m + 1, n2)], [(p, p=1, m)]])
114 self%f1 = self%fcmplx(:, j)
115 self%fcmplx(:, j) = self%f1([[(p, p=m + 1, n1)], [(p, p=1, m)]])
125 sll_real64,
intent(in) :: x
126 sll_real64,
intent(in) :: y
129 sll_real64 :: xij, yij
131 xij = (x - self%eta1_min)/(self%eta1_max - self%eta1_min)
132 yij = (y - self%eta2_min)/(self%eta2_max - self%eta2_min)
134 if (0.0_f64 < xij .and. xij < 1.0_f64 .and. &
135 0.0_f64 < yij .and. yij < 1.0_f64)
then
142 call nufft2d2f90(1, &
153 f_out = real(self%f1d(1))
168 sll_real64,
intent(in) :: f_in(:, :)
169 sll_real64,
intent(in) :: x(:, :)
170 sll_real64,
intent(in) :: y(:, :)
171 sll_real64,
intent(out) :: f_out(:, :)
185 sll_real64,
intent(inout) :: f(:, :)
186 sll_real64,
intent(in) :: x(:, :)
187 sll_real64,
intent(in) :: y(:, :)
188 sll_int32 :: i, j, k, error
189 sll_int32 :: n1, n2, p
190 sll_real64 :: xij, yij
200 xij = (x(i, j) - self%eta1_min)/(self%eta1_max - self%eta1_min)
201 yij = (y(i, j) - self%eta2_min)/(self%eta2_max - self%eta2_min)
202 if (0.0_f64 < xij .and. xij < 1.0_f64 .and. &
203 0.0_f64 < yij .and. yij < 1.0_f64)
then
215 call nufft2d2f90(p, &
227 f(self%i(k), self%j(k)) = real(self%f1d(k))
238 sll_real64,
intent(in) :: x(:, :)
239 sll_real64,
intent(in) :: y(:, :)
240 sll_real64,
intent(out) :: f(:, :)
248 sll_assert(
size(f, 1) == n1 .and.
size(f, 2) == n2)
249 sll_assert(
size(x, 1) == n1 .and.
size(x, 2) == n2)
250 sll_assert(
size(y, 1) == n1 .and.
size(y, 2) == n2)
254 self%x((j - 1)*n1 + i) = (-self%eta1_min + x(i, j))*2.0*
sll_p_pi/(self%eta1_max - self%eta1_min)
255 self%y((j - 1)*n1 + i) = (-self%eta2_min + y(i, j))*2.0*
sll_p_pi/(self%eta2_max - self%eta2_min)
259 call nufft2d2f90(n1*n2, &
271 f(i, j) = real(self%f1d((j - 1)*n1 + i))
Fortran module where set some physical and mathematical constants.
real(kind=f64), parameter, public sll_p_pi
subroutine, public sll_s_fft_init_c2c_2d(plan, nx, ny, array_in, array_out, direction, normalized, aligned, optimization)
Create new 2d complex to complex plan.
subroutine, public sll_s_fft_exec_c2c_2d(plan, array_in, array_out)
Compute fast Fourier transform in complex to complex mode.
integer, parameter, public sll_p_fft_forward
Flag to specify forward FFT (negative sign) [value -1].
subroutine sll_s_nufft_2d_compute_fft(self, f_in)
Compute the fft and prepare data for nufft call.
subroutine sll_s_nufft_2d_interpolate_array_values(self, f_in, x, y, f_out)
Compute the fft and interpolate array values.
subroutine sll_s_nufft_2d_interpolate_array_values_axi(self, f, x, y)
Compute the fft and interpolate array values when x and y could be outside the domaine....
subroutine sll_s_nufft_2d_free(self)
Delete the nufft object.
real(kind=f64) function sll_f_nufft_2d_interpolate_value_from_fft(self, x, y)
Interpolate single value when the fft is already compute.
subroutine sll_s_nufft_2d_init(self, nc_eta1, eta1_min, eta1_max, nc_eta2, eta2_min, eta2_max)
Allocate and initialize data and prepare the fft plan.
subroutine sll_s_nufft_2d_interpolate_array_from_fft(self, x, y, f)
Compute the fft and interpolate array values when x and y are surely inside the domain....
Nufft object for 2d interpolation. It contains fft plan and 1d array to pass data to nufft2d subrouti...
Type for FFT plan in SeLaLib.