27 use,
intrinsic :: iso_fortran_env
61 real(real64),
allocatable :: dop(:, :, :)
62 complex(real64),
allocatable :: zop(:, :, :)
63 logical :: in_device_memory = .false.
64 type(accel_mem_t) :: op_buffer
68 real(real64),
allocatable,
public :: qq(:)
69 real(real64),
public :: singularity =
m_zero
70 real(real64),
public :: mu =
m_zero
71 real(real64),
public :: alpha =
m_zero
72 real(real64),
public :: beta =
m_zero
78 real(real64),
parameter :: TOL_VANISHING_Q = 1e-6_real64
84 class(fourier_space_op_t),
intent(inout) :: this
85 class(space_t),
intent(in) :: space
86 real(real64),
intent(in) :: qq(:)
87 type(xc_cam_t),
intent(in) :: cam
88 real(real64),
optional,
intent(in) :: singularity
90 real(real64),
parameter :: vanishing_q = 1.0e-5_real64
94 safe_allocate(this%qq(1:space%dim))
96 this%qq(1:space%periodic_dim) = qq(1:space%periodic_dim)
97 this%qq(space%periodic_dim+1:space%dim) = vanishing_q
100 this%alpha = cam%alpha
112 type(cube_t),
target,
intent(in) :: cube
113 type(cube_function_t),
intent(inout) :: cf
114 logical,
optional,
intent(in) :: force_alloc
116 integer :: n1, n2, n3
117 logical :: is_allocated
121 assert(.not.
associated(cf%fs))
122 assert(
allocated(cube%fft))
126 cf%batch_capacity = cube%batch_capacity
128 n1 = max(1, cube%fs_n(1))
129 n2 = max(1, cube%fs_n(2))
130 n3 = max(1, cube%fs_n(3))
132 is_allocated = .false.
134 select case (cube%fft%library)
136 if (.not. cf%forced_alloc)
then
137 is_allocated = .
true.
138 if (any(cube%fs_n(1:3) == 0))
then
139 cf%fs => cube%fft%fs_data(1:1,1:1,1:1,1:cf%batch_capacity)
141 cf%fs => cube%fft%fs_data(1:n3,1:n1,1:n2,1:cf%batch_capacity)
144 is_allocated = .
true.
145 safe_allocate(cf%fs(1:n3, 1:n1, 1:n2, 1:cf%batch_capacity))
148 if (cf%in_device_memory)
then
149 is_allocated = .
true.
151 int(cf%batch_capacity, int64) * product(int(cube%fs_n(1:3), int64)))
155 if (.not. cf%forced_alloc)
then
157 cf%fs => cube%fft%fs_data(1:cube%fs_n(1), 1:cube%fs_n(2), 1:cube%fs_n(3), 1:cf%batch_capacity)
161 if (.not. is_allocated)
then
162 safe_allocate(cf%fs(1:cube%fs_n(1), 1:cube%fs_n(2), 1:cube%fs_n(3), 1:cf%batch_capacity))
172 type(
cube_t),
intent(in) :: cube
175 logical :: deallocated
179 assert(
allocated(cube%fft))
181 deallocated = .false.
183 select case (cube%fft%library)
185 if (.not. cf%forced_alloc)
then
190 if (cf%in_device_memory)
then
195 if (.not. cf%forced_alloc)
then
201 if (.not. deallocated)
then
202 assert(
associated(cf%fs))
203 safe_deallocate_p(cf%fs)
216 if (this%in_device_memory)
then
218 this%in_device_memory = .false.
220 safe_deallocate_a(this%dop)
221 safe_deallocate_a(this%zop)
222 safe_deallocate_a(this%qq)
229#include "fourier_space_inc.F90"
232#include "complex.F90"
233#include "fourier_space_inc.F90"
subroutine, public accel_free_buffer(this, async)
integer, parameter, public accel_mem_read_write
Fast Fourier Transform module. This module provides a single interface that works with different FFT ...
integer, parameter, public fftlib_accel
integer, parameter, public fftlib_pfft
integer, parameter, public fftlib_fftw
subroutine, public zfourier_space_op_apply(this, cube, cf)
Applies a multiplication factor to the Fourier space grid. This is a local function.
subroutine, public zfourier_space_op_init(this, cube, op, in_device, op_move)
The operator can be provided either through op (which is copied) or through op_move (an allocatable t...
subroutine, public dfourier_space_op_apply(this, cube, cf)
Applies a multiplication factor to the Fourier space grid. This is a local function.
subroutine, public fourier_space_op_end(this)
subroutine, public zcube_function_fs2rs(cube, cf)
subroutine fourier_space_op_t_init(this, space, qq, cam, singularity)
Initialise a Fourier space Op instance.
subroutine, public dcube_function_fs2rs(cube, cf)
subroutine, public cube_function_free_fs(cube, cf)
Deallocates the Fourier space grid.
subroutine, public dfourier_space_op_init(this, cube, op, in_device, op_move)
The operator can be provided either through op (which is copied) or through op_move (an allocatable t...
subroutine, public zcube_function_rs2fs(cube, cf)
The following routines convert the function between real space and Fourier space Note that the dimens...
subroutine, public cube_function_alloc_fs(cube, cf, force_alloc)
Allocates locally the Fourier space grid, if PFFT library is not used. Otherwise, it assigns the PFFT...
subroutine, public dcube_function_rs2fs(cube, cf)
The following routines convert the function between real space and Fourier space Note that the dimens...
real(real64), parameter, public m_zero
This module is intended to contain "only mathematical" functions and procedures.
The low level module to work with the PFFT library. http:
type(type_t), parameter, public type_cmplx