172 use,
intrinsic :: iso_fortran_env
207 real(real64) :: x_limit(2)
208 type(c_ptr) :: spl, acc
209 real(real64),
public :: x_threshold
252 type(c_ptr),
intent(inout) :: spl, acc
257 use,
intrinsic :: iso_fortran_env
259 integer,
intent(in) :: nrc
260 real(real64),
intent(in) :: x
261 real(real64),
intent(in) :: y
262 type(c_ptr),
intent(inout) :: spl
263 type(c_ptr),
intent(inout) :: acc
268 use,
intrinsic :: iso_fortran_env
270 real(real64),
intent(in) :: x
271 type(c_ptr),
intent(in) :: spl
272 type(c_ptr),
intent(in) :: acc
277 use,
intrinsic :: iso_fortran_env
279 integer,
intent(in) :: nn
280 real(real64),
intent(inout) :: xf
281 type(c_ptr),
intent(in) :: spl
282 type(c_ptr),
intent(in) :: acc
287 use,
intrinsic :: iso_fortran_env
289 integer,
intent(in) :: nn
290 complex(real64),
intent(inout) :: xf
291 type(c_ptr),
intent(in) :: spl
292 type(c_ptr),
intent(in) :: acc
297 use,
intrinsic :: iso_fortran_env
299 real(real64),
intent(in) :: x
300 type(c_ptr),
intent(in) :: spl
301 type(c_ptr),
intent(in) :: acc
306 use,
intrinsic :: iso_fortran_env
308 real(real64),
intent(in) :: x
309 type(c_ptr),
intent(in) :: spl
310 type(c_ptr),
intent(in) :: acc
313 integer pure function oct_spline_npoints(spl, acc)
316 type(c_ptr),
intent(in) :: spl
317 type(c_ptr),
intent(in) :: acc
322 use,
intrinsic :: iso_fortran_env
324 type(c_ptr),
intent(in) :: spl
325 real(real64),
intent(out) :: x
330 use,
intrinsic :: iso_fortran_env
332 type(c_ptr),
intent(in) :: spl
333 real(real64),
intent(out) :: y
336 real(real64)
pure function oct_spline_eval_integ(spl, a, b, acc)
338 use,
intrinsic :: iso_fortran_env
340 type(c_ptr),
intent(in) :: spl
341 real(real64),
intent(in) :: a
342 real(real64),
intent(in) :: b
343 type(c_ptr),
intent(in) :: acc
346 real(real64)
pure function oct_spline_eval_integ_full(spl, acc)
348 use,
intrinsic :: iso_fortran_env
350 type(c_ptr),
intent(in) :: spl
351 type(c_ptr),
intent(in) :: acc
355 real(real64),
parameter :: tol_x = 1e-14_real64
369 spl%x_limit(1) = -1_real64
370 spl%x_limit(2) = -2_real64
372 spl%x_threshold = m_zero
379 type(
spline_t),
intent(out) :: spl(:)
395 type(
spline_t),
intent(out) :: spl(:, :)
401 do i = 1,
size(spl, 1)
402 do j = 1,
size(spl, 2)
413 type(
spline_t),
intent(inout) :: spl
417 if (c_associated(spl%spl) .and. c_associated(spl%acc))
then
428 type(
spline_t),
intent(inout) :: spl(:)
444 type(
spline_t),
intent(inout) :: spl(:, :)
450 do i = 1,
size(spl, 1)
451 do j = 1,
size(spl, 2)
462 integer,
intent(in) :: nrc
463 real(real64),
intent(in) :: rofi(:)
464 real(real64),
intent(in) :: ffit(:)
465 type(
spline_t),
intent(inout) :: spl
466 real(real64),
optional,
intent(in) :: threshold
472 spl%x_limit(1) = rofi(1)
473 spl%x_limit(2) = rofi(nrc)
476 if (
present(threshold))
then
477 if (threshold > m_zero)
then
480 spl%x_threshold = spl%x_limit(2)
483 spl%x_threshold = m_zero
491 real(real64),
intent(in) :: x
500 integer,
intent(in) :: nn
501 real(real64),
intent(inout) :: xf(:)
512 integer,
intent(in) :: nn
513 complex(real64),
intent(inout) :: xf(:)
522 real(real64),
intent(in) :: a
523 type(
spline_t),
intent(inout) :: spl
524 real(real64),
intent(in) :: threshold
526 integer :: npoints, i
527 real(real64),
allocatable :: x(:), y(:)
534 safe_allocate(x(1:npoints))
535 safe_allocate(y(1:npoints))
544 call spline_fit(npoints, x, y, spl, threshold)
568 real(real64),
intent(in) :: a
569 real(real64),
intent(in) :: b
577 type(
spline_t),
intent(inout) :: splw
578 real(real64),
intent(in) :: threshold
579 real(real64),
optional,
intent(in) :: gmax
582 real(real64) :: g, dg
584 integer :: npoints, i, j
585 real(real64),
allocatable :: x(:), y(:), y2(:), xw(:), yw(:)
592 safe_allocate( x(1:npoints))
593 safe_allocate( y(1:npoints))
594 safe_allocate(y2(1:npoints))
600 if (c_associated(splw%spl))
then
602 safe_allocate(xw(1:np))
603 safe_allocate(yw(1:np))
610 safe_allocate(xw(1:np))
611 safe_allocate(yw(1:np))
621 y2(j) = m_four*m_pi*y(j)*x(j)**2
631 y2(j) = (m_four*m_pi/xw(i))*y(j)*x(j)*
sin(xw(i)*x(j))
644 safe_deallocate_a(y2)
645 safe_deallocate_a(xw)
646 safe_deallocate_a(yw)
655 type(
spline_t),
intent(inout) :: splw
656 integer,
intent(in) :: l
657 real(real64),
optional,
intent(in) :: threshold
658 real(real64),
optional,
intent(in) :: gmax
663 integer :: npoints, i, j
664 real(real64),
allocatable :: x(:), y(:), y2(:), xw(:), yw(:)
671 safe_allocate( x(1:npoints))
672 safe_allocate( y(1:npoints))
673 safe_allocate(y2(1:npoints))
679 if (c_associated(splw%spl))
then
681 safe_allocate(xw(1:np))
682 safe_allocate(yw(1:np))
687 assert(
present(gmax))
690 safe_allocate(xw(1:np))
691 safe_allocate(yw(1:np))
701 y2(j) = y(j) * x(j)**2 * loct_sph_bessel(l, x(j)*xw(i))
715 safe_deallocate_a(y2)
716 safe_deallocate_a(xw)
717 safe_deallocate_a(yw)
725 type(
spline_t),
intent(inout) :: spl
726 real(real64),
intent(in) :: cutoff
727 real(real64),
intent(in) :: beta
728 real(real64),
optional,
intent(in) :: threshold
730 integer :: npoints, i
731 real(real64),
allocatable :: x(:), y(:)
732 real(real64) :: exp_arg
739 safe_allocate(x(1:npoints))
740 safe_allocate(y(1:npoints))
746 do i = npoints, 1, -1
747 if (x(i)<cutoff)
then
751 exp_arg = -beta*(x(i)/cutoff - m_one)**2
753 if (exp_arg > m_min_exp_arg)
then
754 y(i) = y(i) *
exp(exp_arg)
759 call spline_fit(npoints, x, y, spl, threshold)
774 type(
spline_t),
intent(inout) :: spla
776 real(real64),
optional,
intent(in) :: threshold
778 integer :: npoints, i, new_npoints
779 real(real64),
allocatable :: x(:), y(:)
787 safe_allocate(x(1:npoints))
788 safe_allocate(y(1:npoints))
794 assert(splb%x_limit(2) >= splb%x_limit(1))
799 do i = npoints, 1, -1
800 if (x(i) > splb%x_limit(2)-
tol_x) cycle
803 new_npoints = new_npoints + 1
806 call spline_fit(new_npoints, x, y, spla, threshold)
818 type(
spline_t),
intent(inout) :: spl
819 real(real64),
intent(in) :: threshold
821 integer :: npoints, i
822 real(real64),
allocatable :: x(:), y(:)
829 safe_allocate(x(1:npoints))
830 safe_allocate(y(1:npoints))
837 do i = npoints, 1, -1
838 y(i) = max(y(i),m_zero)
841 call spline_fit(npoints, x, y, spl, threshold)
852 type(
spline_t),
intent(inout) :: spla
854 real(real64),
intent(in) :: threshold
856 integer :: npoints, i
857 real(real64),
allocatable :: x(:), y(:)
863 if(npoints <= 0)
then
868 safe_allocate(x(1:npoints))
869 safe_allocate(y(1:npoints))
875 assert(splb%x_limit(2) >= splb%x_limit(1))
878 do i = npoints, 1, -1
879 if (x(i) > splb%x_limit(2) -
tol_x)
then
887 call spline_fit(npoints, x, y, spla, threshold)
899 type(
spline_t),
intent(inout) :: dspl
900 real(real64),
intent(in) :: threshold
902 integer :: npoints, i
903 real(real64),
allocatable :: x(:), y(:)
908 if (.not. c_associated(dspl%spl))
then
911 safe_allocate(x(1:npoints))
912 safe_allocate(y(1:npoints))
917 safe_allocate(x(1:npoints))
918 safe_allocate(y(1:npoints))
924 call spline_fit(npoints, x, y, dspl, threshold)
937 type(
spline_t),
intent(inout) :: dspl
938 real(real64),
intent(in) :: threshold
939 real(real64),
optional,
intent(in) :: grid(:)
941 integer :: npoints, i
942 real(real64),
allocatable :: x(:), y(:)
947 if (.not. c_associated(dspl%spl))
then
950 safe_allocate(x(1:npoints))
951 safe_allocate(y(1:npoints))
952 if (
present(grid))
then
960 safe_allocate(x(1:npoints))
961 safe_allocate(y(1:npoints))
967 call spline_fit(npoints, x, y, dspl, threshold)
979 integer,
intent(in) :: iunit
982 real(real64),
allocatable :: x(:), y(:)
988 safe_allocate(x(1:np))
989 safe_allocate(y(1:np))
994 write(iunit,
'(2es18.8E3)') x(i), y(i)
1007 type(
spline_t),
intent(in) :: spl(:)
1008 integer,
intent(in) :: iunit
1010 character(len=4) :: fm
1011 integer :: np, i, n, j
1012 real(real64),
allocatable :: x(:)
1013 real(real64) :: x_limit
1023 write(fm,
'(i4)') n + 1
1026 x_limit = spl(1)%x_limit(2)
1027 safe_allocate(x(1:np))
1034 x_limit = min(x_limit, spl(i)%x_limit(2))
1038 if (x(i) > x_limit -
tol_x) cycle
1039 write(iunit,
'('//trim(fm)//
'es18.8E3)') x(i), (
spline_eval(spl(j), x(i)), j = 1,
size(spl))
1042 safe_deallocate_a(x)
1052 integer,
intent(in) :: iunit
1054 character(len=4) :: fm
1055 integer :: np, i, n1, n2, j, k
1056 real(real64),
allocatable :: x(:)
1057 real(real64) :: x_limit
1063 if (n1 * n2 <= 0)
then
1068 write(fm,
'(i4)') n1*n2 + 1
1072 safe_allocate(x(1:np))
1075 x_limit = spl(1,1)%x_limit(2)
1081 x_limit = min(x_limit, spl(i,j)%x_limit(2))
1086 if (x(i) > x_limit -
tol_x) cycle
1087 write(iunit,
'('//trim(fm)//
'es18.8E3)') x(i), &
1088 ((
spline_eval(spl(j, k), x(i)), j = 1, n1), k = 1, n2)
1091 safe_deallocate_a(x)
1102 real(real64),
intent(in) :: threshold
1105 real(real64),
parameter :: dx = 0.01_real64
1108 assert(spl%x_limit(2) >= spl%x_limit(1))
1110 call profiling_in(
'SPLINE_CUTOFF_RADIUS')
1112 jj =
floor(spl%x_limit(2)/dx) + 1
1115 do while(dx*(jj-1) > spl%x_limit(2) - m_half * dx)
1124 call profiling_out(
'SPLINE_CUTOFF_RADIUS')
1133 range = this%x_limit(1)
1142 range = this%x_limit(2)
1149 real(real64),
allocatable,
intent(inout) :: x_shifted(:)
1151 real(real64),
allocatable :: x(:)
1152 integer :: npoints, i
1159 safe_allocate(x(1:npoints))
1160 safe_allocate(x_shifted(1:npoints))
1162 do i = 1, npoints -1
1163 x_shifted(i) = m_half*(x(i) + x(i+1))
1165 x_shifted(npoints) = x(npoints)
1166 safe_deallocate_a(x)
Both the filling of the function, and the retrieval of the values may be done using single- or double...
Some operations may be done for one spline-function, or for an array of them.
The integral may be done with or without integration limits, but we want the interface to be common.
double exp(double __x) __attribute__((__nothrow__
double sin(double __x) __attribute__((__nothrow__
double sqrt(double __x) __attribute__((__nothrow__
double floor(double __x) __attribute__((__nothrow__
subroutine, public spline_der(spl, dspl, threshold)
subroutine spline_end_0(spl)
subroutine, public spline_force_pos(spl, threshold)
real(real64) pure function spline_integral_limits(spl, a, b)
subroutine, public spline_fit(nrc, rofi, ffit, spl, threshold)
real(real64) function, public spline_x_threshold(spl, threshold)
Determines the largest value of x for which the spline values are above the threshold.
subroutine, public spline_3dft(spl, splw, threshold, gmax)
subroutine, public spline_der2(spl, dspl, threshold, grid)
Returns a spline that contains the second derivative of the original spline.
subroutine spline_end_2(spl)
real(real64), parameter tol_x
Tolerance for checking if x is inside or outside the limits of the splines.
subroutine, public spline_besselft(spl, splw, l, threshold, gmax)
real(real64) pure function, public spline_range_min(this)
subroutine spline_end_1(spl)
subroutine spline_print_1(spl, iunit)
Print debug information for a 1D array of splines.
real(real64) function spline_integral_full(spl)
real(real64) function, public spline_eval(spl, x)
subroutine spline_init_0(spl)
subroutine spline_print_0(spl, iunit)
subroutine spline_print_2(spl, iunit)
Print debug information for a 2D array of splines.
subroutine spline_eval8_array(spl, nn, xf)
subroutine spline_init_1(spl)
subroutine, public spline_cut(spl, cutoff, beta, threshold)
subroutine, public spline_div(spla, splb, threshold)
Returns the values of spla divided by the values of splb.
real(real64) pure function, public spline_range_max(this)
subroutine, public spline_times(a, spl, threshold)
subroutine spline_init_2(spl)
subroutine, public spline_mult(spla, splb, threshold)
subroutine spline_evalz_array(spl, nn, xf)
subroutine, public spline_generate_shifted_grid(this, x_shifted)
the basic spline datatype