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
20 real(rprec),
intent(out) :: y
21 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_nr(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_nr(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) :: a, b, h
117 integer :: k, khi, klo
122 if (khi-klo <= 1)
exit
133 > stop
"spline_cubic: bad xa input! xa(i) have to be distinct!"
136 y=a*ya(klo)+b*ya(khi) +
137 > ((a**3-a)*y2a(klo)+(b**3-b)*y2a(khi))*(h**2)/6.d+0
139 end subroutine splint_nr