1 SUBROUTINE point_wise_to_power(npts, x, f, n, ac, i_full,
8 INTEGER,
INTENT(IN) :: npts, i_full, nsp_pts, n
9 REAL(rprec),
DIMENSION(npts),
INTENT(IN) :: x, f
10 REAL(rprec),
DIMENSION(0:n),
INTENT(OUT) :: ac
12 REAL,
PARAMETER :: tol_res = 0.005_dp
13 INTEGER :: i, j, k , n_count, n_int
14 CHARACTER(len=2) :: cdum
15 CHARACTER(len=15) :: form
16 REAL(rprec) :: res, ohs_sp
17 REAL(rprec),
DIMENSION(:),
ALLOCATABLE :: tc, norm, y,
19 REAL(rprec),
DIMENSION(:,:),
ALLOCATABLE :: a_inv, b_inv,
24 REAL(rprec) ,
EXTERNAL :: integral
86 ALLOCATE (y(npts), fy(npts),
87 1 y_sp(nsp_pts), fy_sp(nsp_pts), stat=i)
88 IF (i .ne. 0) stop
'Allocation error in point_wise_to_power!'
90 y(:npts) = 2*x(:npts) - 1
92 IF (i_full .eq. 1) fy(1)= fy(2)
97 ohs_sp = 2._dp/nsp_pts
98 y_sp= (/( -1 + (i -0.5_dp)*ohs_sp, i = 1,nsp_pts)/)
100 CALL spline_it(npts, y, fy, nsp_pts, y_sp, fy_sp, i_full)
105 DO WHILE(res .gt. tol_res)
107 IF(n_int < n)
DEALLOCATE (a, b, a_inv, b_inv, tleg,
109 ALLOCATE(a(0:n_int,0:n_int), b(0:n_int,0:n_int),
110 1 a_inv(0:n_int,0:n_int), b_inv(0:n_int,0:n_int),
111 2 tleg(0:n_int, nsp_pts), inorm(0:n_int,0:n_int),
112 3 norm(0:n_int), stat=i)
113 IF (i .ne. 0) stop
'Allocation error in point_wise_to_power!'
115 norm(0:n_int) = (/(2._dp/(2*i+1), i=0, n_int)/)
117 CALL build_matrices_legendre (n_int, a, b, a_inv, b_inv)
124 tleg(i,:nsp_pts) = a_inv(i,k) + y_sp(:nsp_pts)
133 inorm(i,j) = integral(nsp_pts, y_sp, tleg(j,1:nsp_pts),
136 WRITE(cdum,
'(i2)')n_int+1
138 form =
'('//trim(cdum)//
'(x,f8.3))'
145 res = abs((norm(n_int) - inorm(n_int,n_int))/(norm(n_int)))
146 n_count = n_count + 1
147 IF(n_count == n-1) stop
'Precision bad for even 2 Polynomial'
151 ALLOCATE(tc(0:n_int))
153 tc(j) = integral(nsp_pts, y_sp, fy_sp, tleg(j,1:nsp_pts))
160 CALL legendre_to_power(n_int, a_inv, b_inv, tc, ac(0))
162 DEALLOCATE(a_inv, b_inv, a, b, tc, tleg, inorm, norm, y,
165 END SUBROUTINE point_wise_to_power