38 integer(int64) :: npoints, nq, nw, nr, dim
39 integer(int64),
allocatable :: lcell(:, :, :), lnext(:)
40 real(real64),
allocatable :: rsq(:), a(:, :)
41 real(real64) :: xmin, ymin, dx, dy, rmax, xyzmin(3), xyzdel(3)
43 real(real64),
allocatable :: x(:), y(:), z(:)
48 integer(int64) :: kind
49 type(qshepr_t) :: re, im
61 real(real64) function qs2val(px, py, n, x, y, f, nr, lcell, lnext, xmin, &
62 ymin, dx, dy, rmax, rsq, a)
63 use,
intrinsic :: iso_fortran_env
72 integer(int64) :: lcell(nr, nr)
73 integer(int64) :: lnext(n)
79 real(real64) :: rsq(n)
80 real(real64) :: a(5, n)
83 subroutine qs2grd(px, py, n, x, y, f, nr, lcell, lnext, xmin, &
84 ymin, dx, dy, rmax, rsq, a, q, qx, qy, ier)
85 use,
intrinsic :: iso_fortran_env
94 integer(int64) :: lcell(nr, nr)
95 integer(int64) :: lnext(n)
101 real(real64) :: rsq(n)
102 real(real64) :: a(5, n)
106 integer(int64) :: ier
109 real(real64) function qs3val(px, py, pz, n, x, y, z, f, nr, lcell, lnext, xyzmin, &
110 xyzdel, rmax, rsq, a)
111 use,
intrinsic :: iso_fortran_env
122 integer(int64) :: lcell(nr, nr, nr)
123 integer(int64) :: lnext(n)
124 real(real64) :: xyzmin(3)
125 real(real64) :: xyzdel(3)
127 real(real64) :: rsq(n)
128 real(real64) :: a(9, n)
131 subroutine qs3grd(px, py, pz, n, x, y, z, f, nr, lcell, lnext, xyzmin, &
132 xyzdel, rmax, rsq, a, q, qx, qy, qz, ier)
133 use,
intrinsic :: iso_fortran_env
144 integer(int64) :: lcell(nr, nr, nr)
145 integer(int64) :: lnext(n)
146 real(real64) :: xyzmin(3)
147 real(real64) :: xyzdel(3)
149 real(real64) :: rsq(n)
150 real(real64) :: a(9, n)
155 integer(int64) :: ier
162 subroutine dqshep_init(interp, npoints, f, x, y, z)
163 type(
qshep_t),
intent(out) :: interp
164 integer(int64),
intent(in) :: npoints
165 real(real64),
intent(in) :: f(:)
166 real(real64) :: x(:), y(:)
167 real(real64),
optional :: z(:)
172 call qshepr_init(interp%re, npoints, f, x, y, z = z)
179 subroutine zqshep_init(interp, npoints, f, x, y, z)
180 type(
qshep_t),
intent(out) :: interp
181 integer(int64),
intent(in) :: npoints
182 complex(real64),
intent(in) :: f(:)
183 real(real64) :: x(:), y(:)
184 real(real64),
optional :: z(:)
189 call qshepr_init(interp%re, npoints, real(f), x, y, z = z)
190 call qshepr_init(interp%im, npoints, aimag(f), x, y, z = z)
197 subroutine qshepr_init(interp, npoints, f, x, y, z)
198 type(
qshepr_t),
intent(out) :: interp
199 integer(int64),
intent(in) :: npoints
200 real(real64),
intent(in) :: f(:)
201 real(real64),
target :: x(:), y(:)
202 real(real64),
target,
optional :: z(:)
204 integer(int64) :: ier
208 interp%npoints = npoints
216 select case (interp%dim)
220 interp%nr = nint(
sqrt(interp%npoints/3.0_8))
221 safe_allocate(interp%lcell(1:interp%nr, 1:interp%nr, 1))
222 safe_allocate(interp%a(1:5, 1:npoints))
226 interp%nr = nint((interp%npoints/3.0_8)**(1.0_8/3.0_8))
227 safe_allocate(interp%lcell(1:interp%nr, 1:interp%nr, 1:interp%nr))
228 safe_allocate(interp%a(1:9, 1:interp%npoints))
231 safe_allocate(interp%lnext(1:npoints))
232 safe_allocate(interp%rsq(1:npoints))
234 select case (interp%dim)
236 call qshep2(npoints, x, y, f, interp%nq, interp%nw, interp%nr, interp%lcell(:, :, 1), &
237 interp%lnext, interp%xmin, interp%ymin, interp%dx, interp%dy, &
238 interp%rmax, interp%rsq, interp%a, ier)
239 safe_allocate(interp%x(1:npoints))
240 safe_allocate(interp%y(1:npoints))
241 interp%x(1:npoints) = x(1:npoints)
242 interp%y(1:npoints) = y(1:npoints)
244 call qshep3(npoints, x, y, z, f, interp%nq, interp%nw, interp%nr, interp%lcell, &
245 interp%lnext, interp%xyzmin, interp%xyzdel, interp%rmax, interp%rsq, &
247 safe_allocate(interp%x(1:npoints))
248 safe_allocate(interp%y(1:npoints))
249 safe_allocate(interp%z(1:npoints))
250 interp%x(1:npoints) = x(1:npoints)
251 interp%y(1:npoints) = y(1:npoints)
252 interp%z(1:npoints) = z(1:npoints)
260 real(real64) function qshep_interpolater(interp, f, p, gf) result(v)
261 type(
qshepr_t),
intent(in) :: interp
262 real(real64),
intent(in) :: f(:)
263 real(real64),
intent(in) :: p(:)
264 real(real64),
optional,
intent(inout) :: gf(:)
266 integer(int64) :: ier
270 select case (interp%dim)
272 if (
present(gf))
then
273 call qs2grd( p(1), p(2), interp%npoints, interp%x, interp%y, &
274 f, interp%nr, interp%lcell(:, :, 1), interp%lnext, interp%xmin, &
275 interp%ymin, interp%dx, interp%dy, interp%rmax, interp%rsq, interp%a, &
276 v, gf(1), gf(2), ier)
278 v =
qs2val( p(1), p(2), interp%npoints, interp%x, interp%y, &
279 f, interp%nr, interp%lcell(:, :, 1), interp%lnext, interp%xmin, &
280 interp%ymin, interp%dx, interp%dy, interp%rmax, interp%rsq, interp%a)
283 if (
present(gf))
then
284 call qs3grd( p(1), p(2), p(3), interp%npoints, interp%x, interp%y, interp%z, &
285 f, interp%nr, interp%lcell, interp%lnext, interp%xyzmin, &
286 interp%xyzdel, interp%rmax, interp%rsq, interp%a , &
287 v, gf(1), gf(2), gf(3), ier)
289 v =
qs3val(p(1), p(2), p(3), interp%npoints, interp%x, interp%y, interp%z, &
290 f, interp%nr, interp%lcell, interp%lnext, interp%xyzmin, &
291 interp%xyzdel, interp%rmax, interp%rsq, interp%a)
300 real(real64) function dqshep_interpolate(interp, f, p, gf) result(v)
301 type(
qshep_t),
intent(in) :: interp
302 real(real64),
intent(in) :: f(:)
303 real(real64),
intent(in) :: p(:)
304 real(real64),
optional,
intent(inout) :: gf(:)
316 type(
qshep_t),
intent(in) :: interp
317 complex(real64),
intent(in) :: f(:)
318 real(real64),
intent(in) :: p(:)
319 complex(real64),
optional,
intent(inout) :: gf(:)
322 real(real64),
allocatable :: rgf(:), igf(:)
326 if (
present(gf))
then
327 safe_allocate(rgf(1:
size(gf)))
328 safe_allocate(igf(1:
size(gf)))
332 gf(i) = cmplx( rgf(i), igf(i), 8)
334 safe_deallocate_a(rgf)
335 safe_deallocate_a(igf)
347 type(
qshep_t),
intent(inout) :: interp
352 if (interp%kind == 1)
call qshepr_end(interp%im)
360 type(
qshepr_t),
intent(inout) :: interp
364 safe_deallocate_a(interp%lcell)
365 safe_deallocate_a(interp%lnext)
366 safe_deallocate_a(interp%rsq)
367 safe_deallocate_a(interp%a)
368 safe_deallocate_a(interp%x)
369 safe_deallocate_a(interp%y)
370 safe_deallocate_a(interp%z)
double sqrt(double __x) __attribute__((__nothrow__
subroutine dqshep_init(interp, npoints, f, x, y, z)
complex(real64) function zqshep_interpolate(interp, f, p, gf)
subroutine zqshep_init(interp, npoints, f, x, y, z)
subroutine qshepr_init(interp, npoints, f, x, y, z)
subroutine, public qshep_end(interp)
real(real64) function dqshep_interpolate(interp, f, p, gf)
real(real64) function qshep_interpolater(interp, f, p, gf)
subroutine qshepr_end(interp)