10 integer,
intent(in) :: npts
11 integer,
intent(inout) :: iflag
12 real(rprec),
intent(in) :: x
13 real(rprec),
intent(out) :: y
14 real(rprec),
dimension(npts),
intent(in) :: xx, yy
18 real(rprec),
dimension(-1:size(xx)+2) :: a, b, c, d
19 real(rprec),
dimension(-1:size(xx)+2) :: xloc, yloc,dxloc
20 real(rprec),
dimension(-1:size(xx)+2) :: m, t, dm, p, q
21 real(rprec),
dimension(-1:size(xx)+2) :: int_f
22 integer :: i, ix, iv, ivm1
23 real(rprec) :: cl,bl,cr,br,dx
24 real(rprec),
parameter :: onethird = 1._dp/3._dp
30 > stop
'spline_akima_int: more active points
31 > requested than available'
32 if(ix /=
size(yy)) stop
'size mismatch of xx and yy!'
36 a = 0._dp ; b = 0._dp ; c = 0._dp ; d = 0._dp
37 xloc = 0._dp ; yloc = 0._dp
38 m = 0._dp ; t = 0._dp ; dm = 0._dp
42 xloc(-1)= 2*xloc(1)-xloc(3)
43 xloc( 0)= xloc(1)+xloc(2)-xloc(3)
44 xloc(iv+2)= 2*xloc(iv)-xloc(iv-2)
45 xloc(iv+1)= xloc(iv)+xloc(iv-1)-xloc(iv-2)
46 dxloc(-1:iv+1)=xloc(0:iv+2)-xloc(-1:iv+1)
49 m(-1:iv+1) = (yloc(0:iv+2)-yloc(-1:iv+1))/
53 cl = (m(2)-m(1))/(xloc(3)-xloc(1))
54 bl = m(1) - cl*(xloc(2)-xloc(1))
55 cr = (m(iv-2)-m(iv-1))/(xloc(iv)-xloc(iv-2))
56 br = m(iv-2) - cr*(xloc(iv-1)-xloc(iv-2))
57 yloc( 0)=yloc(1)+bl*(xloc( 0)-xloc(1))+
58 > cl*(xloc( 0)-xloc(1))**2
59 yloc(-1)=yloc(1)+bl*(xloc(-1)-xloc(1))+
60 > cl*(xloc(-1)-xloc(1))**2
61 yloc(iv+1)=yloc(iv)+br*(xloc(iv+1)-xloc(iv))+
62 > cl*(xloc(iv+1)-xloc(iv))**2
63 yloc(iv+2)=yloc(iv)+br*(xloc(iv+2)-xloc(iv))+
64 > cl*(xloc(iv+2)-xloc(iv))**2
66 m(-1) = (yloc(0)-yloc(-1))/(xloc(0)-xloc(-1))
67 m( 0) = (yloc(1)-yloc( 0))/(xloc(1)-xloc( 0))
68 m(iv ) = (yloc(iv+1)-yloc(iv ))/(xloc(iv+1)-xloc(iv ))
69 m(iv+1) = (yloc(iv+2)-yloc(iv+1))/(xloc(iv+2)-xloc(iv+1))
71 dm(-1:iv)= abs(m(0:iv+1)-m(-1:iv))
73 p(1:iv) = dm(1:iv)/(dm(1:iv)+dm(-1:iv-2))
76 q(1:iv) = dm(-1:iv-2)/(dm(1:iv)+dm(-1:iv-2))
78 t(1:iv) = p(1:iv)*m(0:iv-1)+q(1:iv)*m(1:iv)
79 where ( p(1:iv)+q(1:iv) < tiny(1._dp))
80 t(1:iv) = 0.5_dp*m(0:iv-1)+0.5_dp*m(1:iv)
85 c(1:iv-1) = (3*m(1:iv-1)-t(2:iv)-2*t(1:iv-1))/
87 d(1:iv-1) = (t(2:iv)+t(1:iv-1)-2*m(1:iv-1))/
91 int_f(1:iv-1) = a(1:iv-1)*dxloc(1:iv-1)+
92 > 0.5_dp*b(1:iv-1)*dxloc(1:iv-1)**2 +
93 > onethird*c(1:iv-1)*dxloc(1:iv-1)**3 +
94 > 0.25_dp*d(1:iv-1)*dxloc(1:iv-1)**4
95 if(x >= xloc(iv))
then
96 y = sum(int_f(1:iv-1))
98 if(x>xloc(iv)) iflag=-1
101 if(x <= xloc(1))
then
104 if(x<xloc(1)) iflag=-1
109 if(x >= xloc(i+1))
then
113 y=y+dx*(a(i)+dx*(.5_dp*b(i)+dx*(
114 > onethird*c(i)+.25_dp*d(i)*dx)))