23 #include "sll_errors.h"
24 #include "sll_memory.h"
25 #include "sll_working_precision.h"
49 sll_int32 :: num_cells
52 sll_real64 :: delta_eta
54 sll_real64,
dimension(:),
pointer :: d_dx
55 sll_real64,
dimension(:),
pointer :: kx
59 sll_comp64,
dimension(:),
pointer :: fk
81 sll_int32,
intent(in) :: num_cells
82 sll_real64,
intent(in) :: eta_min
83 sll_real64,
intent(in) :: eta_max
87 sll_allocate(adv, error)
89 call adv%init(num_cells, eta_min, eta_max)
96 sll_int32,
intent(in) :: num_cells
97 sll_real64,
intent(in) :: eta_min
98 sll_real64,
intent(in) :: eta_max
101 sll_int32 :: i, error
103 adv%eta_min = eta_min
104 adv%eta_max = eta_max
105 adv%num_cells = num_cells
107 sll_clear_allocate(adv%d_dx(1:num_cells), error)
108 sll_allocate(adv%fk(1:num_cells/2 + 1), error)
109 adv%fk(1:num_cells/2 + 1) = cmplx(0.0, 0.0, kind=f64)
115 sll_clear_allocate(adv%kx(1:num_cells/2 + 1), error)
117 kx0 = 2._f64*
sll_p_pi/(eta_max - eta_min)
120 do i = 2, num_cells/2 + 1
121 adv%kx(i) = real(i - 1, f64)*kx0
129 sll_real64,
dimension(:),
intent(in) :: a
130 sll_real64,
intent(in) :: dt
131 sll_real64,
dimension(:),
intent(in) :: input
132 sll_real64,
dimension(:),
intent(out) :: output
134 character(len=*),
parameter :: this_sub_name =
'advect_1d'
135 sll_int32 :: num_cells
137 num_cells = adv%num_cells
141 sll_error(this_sub_name,
"Not implemented.")
148 sll_real64,
intent(in) :: a
149 sll_real64,
intent(in) :: dt
150 sll_real64,
dimension(:),
intent(in) :: input
151 sll_real64,
dimension(:),
intent(out) :: output
153 sll_int32 :: i, num_cells
155 num_cells = adv%num_cells
157 adv%d_dx = input(1:num_cells)
161 do i = 2, num_cells/2 + 1
162 adv%fk(i) = adv%fk(i)*cmplx(cos(adv%kx(i)*a*dt), &
163 -sin(adv%kx(i)*a*dt), kind=f64)
168 output(1:num_cells) = adv%d_dx/real(num_cells, f64)
170 output(num_cells + 1) = output(1)
Abstract class for advection.
type(sll_t_advector_1d_spectral) function, pointer, public sll_f_new_advector_1d_spectral(num_cells, eta_min, eta_max)
subroutine advect_1d(adv, a, dt, input, output)
subroutine advector_1d_spectral_init(adv, num_cells, eta_min, eta_max)
subroutine advect_1d_constant(adv, a, dt, input, output)
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.
Type for FFT plan in SeLaLib.