36 SUBROUTINE spline_d(x, y, yd, n, yp1, ypn, y2, y2d)
40 INTEGER,
INTENT(IN) :: n
41 REAL,
INTENT(IN) :: x(n)
42 REAL,
INTENT(IN) :: y(n)
43 REAL,
INTENT(IN) :: yd(n)
44 REAL,
INTENT(IN) :: yp1
45 REAL,
INTENT(IN) :: ypn
46 REAL,
INTENT(OUT) :: y2(n)
47 REAL,
INTENT(OUT) :: y2d(n)
50 INTEGER,
PARAMETER :: nmax=1000
52 REAL :: p, qn,
sig, un, u(nmax)
53 REAL :: pd, und, ud(nmax)
55 IF (yp1 .GT. 0.99e30)
THEN 64 ud(1) = 3.0*(yd(2)-yd(1))/(x(2)-x(1))**2
65 u(1) = 3.0/(x(2)-x(1))*((y(2)-y(1))/(x(2)-x(1))-yp1)
68 IF ((x(i+1) - x(i) .EQ. 0.0 .OR. x(i) - x(i-1) .EQ. 0.0) .OR. x(i+1)&
69 & - x(i-1) .EQ. 0.0)
THEN 72 sig = (x(i)-x(i-1))/(x(i+1)-x(i-1))
75 y2d(i) = -((
sig-1.0)*pd/p**2)
77 ud(i) = ((6.0*((yd(i+1)-yd(i))/(x(i+1)-x(i))-(yd(i)-yd(i-1))/(x(i)&
78 & -x(i-1)))/(x(i+1)-x(i-1))-
sig*ud(i-1))*p-(6.0*((y(i+1)-y(i))/(x(&
79 & i+1)-x(i))-(y(i)-y(i-1))/(x(i)-x(i-1)))/(x(i+1)-x(i-1))-
sig*u(i-&
81 u(i) = (6.0*((y(i+1)-y(i))/(x(i+1)-x(i))-(y(i)-y(i-1))/(x(i)-x(i-1&
82 & )))/(x(i+1)-x(i-1))-
sig*u(i-1))/p
85 IF (ypn .GT. 0.99e30)
THEN 91 und = -(3.0*(yd(n)-yd(n-1))/(x(n)-x(n-1))**2)
92 un = 3.0/(x(n)-x(n-1))*(ypn-(y(n)-y(n-1))/(x(n)-x(n-1)))
94 y2d(n) = ((und-qn*ud(n-1))*(qn*y2(n-1)+1.0)-(un-qn*u(n-1))*qn*y2d(n-1)&
95 & )/(qn*y2(n-1)+1.0)**2
96 y2(n) = (un-qn*u(n-1))/(qn*y2(n-1)+1.0)
98 y2d(k) = y2d(k)*y2(k+1) + y2(k)*y2d(k+1) + ud(k)
99 y2(k) = y2(k)*y2(k+1) + u(k)
102 100
WRITE(*, *)
'i x', i, x(i+1), x(i), x(i-1)
103 WRITE(*, *)
'error in spline-interpolation' 106 END SUBROUTINE spline_d
128 SUBROUTINE splint_integral_d(xa, ya, yad, y2a, y2ad, n, xlo, xhi, &
129 & integral, integrald)
134 INTEGER,
INTENT(IN) :: n
135 REAL,
INTENT(IN) :: xa(n)
136 REAL,
INTENT(IN) :: ya(n)
137 REAL,
INTENT(IN) :: yad(n)
138 REAL,
INTENT(IN) :: y2a(n)
139 REAL,
INTENT(IN) :: y2ad(n)
140 REAL,
INTENT(IN) :: xlo
141 REAL,
INTENT(IN) :: xhi
142 REAL,
INTENT(OUT) :: integral
143 REAL,
INTENT(OUT) :: integrald
146 INTEGER :: k, khi_l, klo_l, khi_h, klo_h
147 REAL :: xl, xh, h, int, x0, x1, y0, y1, y20, y21
148 REAL :: intd, y0d, y1d, y20d, y21d
153 1
IF (khi_l - klo_l .GT. 1)
THEN 155 IF (xa(k) .GT. xlo)
THEN 164 2
IF (khi_h - klo_h .GT. 1)
THEN 166 IF (xa(k) .GT. xhi)
THEN 178 3
IF (khi_h .GT. khi_l)
THEN 180 ELSE IF (khi_h .EQ. khi_l)
THEN 183 WRITE(*, *)
'error in spline-integration' 186 h = xa(khi_l) - xa(klo_l)
187 IF (h .EQ. 0.0) pause
'bad xa input in splint' 208 intd = -((xl*((x1-.5*xl)*y0d+(0.5*xl-x0)*y1d)-(x1-xl)**4*y20d/24.+(0.5&
209 & *xl*xl-x1*xl)*h**2*y20d/6.+(xl-x0)**4*y21d/24.-(0.5*xl*xl-x0*xl)*h**&
211 int = -(1.0/h*(xl*((x1-.5*xl)*y0+(0.5*xl-x0)*y1)-y20/24.*(x1-xl)**4+&
212 & y20/6.*(0.5*xl*xl-x1*xl)*h*h+y21/24.*(xl-x0)**4-y21/6.*(0.5*xl*xl-x0&
214 intd = intd + (xh*((x1-.5*xh)*y0d+(0.5*xh-x0)*y1d)-(x1-xh)**4*y20d/24.&
215 & +(0.5*xh*xh-x1*xh)*h**2*y20d/6.+(xh-x0)**4*y21d/24.-(0.5*xh*xh-x0*xh&
217 int = int + 1.0/h*(xh*((x1-.5*xh)*y0+(0.5*xh-x0)*y1)-y20/24.*(x1-xh)**&
218 & 4+y20/6.*(0.5*xh*xh-x1*xh)*h*h+y21/24.*(xh-x0)**4-y21/6.*(0.5*xh*xh-&
220 integrald = integrald + intd
221 integral = integral + int
226 IF (khi_h .NE. khi_l - 1)
GOTO 3
227 END SUBROUTINE splint_integral_d
double sig
correlated to variance of initial distribution