13 integer,
intent(in) :: n
14 integer,
intent(inout) :: iflag
15 real(rprec),
intent(in) :: x
16 real(rprec),
dimension(n),
intent(in) :: xx,yy
17 real(rprec),
intent(out) :: y
18 real(rprec),
dimension(n) :: y2, dxx
22 real(rprec) :: yp1, ypn
27 if(x < xx(1) .or. x > xx(n))
then
32 dxx(1:n-1)=xx(2:n)-xx(1:n-1)
33 if(minval(dxx(1:n-1)) <= 0.d+0)
then
40 c=((yy(3)-yy(1))/(xx(3)-xx(1))-(yy(2)-yy(1))/(xx(2)-xx(1)))
42 yp1=(yy(2)-yy(1))/(xx(2)-xx(1))-c*(xx(2)-xx(1))
44 c=((yy(n-2)-yy(n))/(xx(n-2)-xx(n))
45 > -(yy(n-1)-yy(n))/(xx(n-1)-xx(n)))
47 ypn=(yy(n-1)-yy(n))/(xx(n-1)-xx(n))-c*(xx(n-1)-xx(n))
50 call splint_int(xx,yy,y2,n,x,y)
67 integer,
intent(in) :: n
68 integer,
parameter :: nmax=500
69 real(rprec),
intent(in) :: yp1, ypn
70 real(rprec),
dimension(n),
intent(in) :: x, y
71 real(rprec),
dimension(n),
intent(out) :: y2
73 real(rprec) :: p, qn, sig, un
74 real(rprec),
dimension(n) :: u
76 if(yp1 > .99d+30)
then
81 u(1)=(3.d+0/(x(2)-x(1)))*((y(2)-y(1))/(x(2)-x(1))-yp1)
85 sig=(x(i)-x(i-1))/(x(i+1)-x(i-1))
88 u(i)=(6.d+0*((y(i+1)-y(i))/(x(i+1)-x(i))-(y(i)-y(i-1))
89 > /(x(i)-x(i-1)))/(x(i+1)-x(i-1))-sig*u(i-1))/p
91 if (ypn > .99d+30)
then
96 un=(3.d+0/(x(n)-x(n-1)))*(ypn-(y(n)-y(n-1))/(x(n)-x(n-1)))
98 y2(n)=(un-qn*u(n-1))/(qn*y2(n-1)+1.d+0)
100 y2(k)=y2(k)*y2(k+1)+u(k)
105 subroutine splint_int(xa,ya,y2a,n,x,y)
111 integer,
intent(in) :: n
112 real(rprec),
intent(in) :: x
113 real(rprec),
intent(out) :: y
114 real(rprec),
dimension(n),
intent(in) :: xa, ya, y2a
116 real(rprec) :: h, c, dx
117 integer :: k, khi, klo
118 real(rprec),
dimension(n) :: dxa,dxa3, dya, dy2a, my2a, mya
123 if (khi-klo <= 1)
exit
132 dxa(1:n-1)=xa(2:n)-xa(1:n-1)
134 dya(1:n-1)=ya(2:n)-ya(1:n-1)
135 mya(1:n-1)=ya(2:n)+ya(1:n-1)
136 dy2a(1:n-1)=y2a(2:n)-y2a(1:n-1)
137 my2a(1:n-1)=y2a(2:n)+y2a(1:n-1)
139 c = .5d+0*dot_product(dxa(1:klo-1),mya(1:klo-1))
140 > -dot_product(dxa3(1:klo-1),my2a(1:klo-1))/24.0d+0
143 > stop
"spline_cubic: bad xa input! xa(i) have to be distinct!"
145 y = ya(klo)*dx +.5d+0*dya(klo)*dx**2/h +
146 > y2a(klo)*dx**2*(2*dx-3*h)/12.d+0 +
147 > dy2a(klo)*dx**2*(dx**2-2*h**2)/(h*24.d+0)
150 end subroutine splint_int