OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
spline.f
Go to the documentation of this file.
1  subroutine spline(s,x,y,n,in,t,il,iu,vl,vu,e,u)
2 c x,y array of ind. & depen. var.,s the argument to be interpolated
3 c t the interpolated value,n the dimension of (x,y)
4 c in=1 determines spline func,in=2 interpolates spline fnc
5 c il,iu=1 parabolic runout conditions at lower & upper bound.
6 c il,iu=2 1st derivative (vl,vu) at lower or upper bound resp.
7 c il,iu=3 2nd derivative (vl,vu) at lower or upper bound resp.
8  implicit real*8 (a-h,o-z)
9  dimension x(*), y(*), e(*),u(*)
10  go to (10,40),in
11  10 continue
12  n1=n-1
13  b1=x(2)-x(1)
14  c1=(y(2)-y(1))/b1
15  go to (12,14,16),il
16  12 e(1)=1.0
17  u(1)=0.0
18  go to 18
19  14 e(1)=-.5
20  u(1)=(c1-vl)/2/b1
21  go to 18
22  16 e(1)=0
23  u(1)=vl/12
24  18 continue
25  do 20 j=2,n1
26  b2=x(j+1)-x(j)
27  c2=(y(j+1)-y(j))/b2
28  b=x(j+1)-x(j-1)
29  d=(c2-c1)/b
30  c=b1/b
31  b1=b2
32  c1=c2
33  p=c*e(j-1)+2.0
34  e(j)=(c-1.0)/p
35  20 u(j)=(d-c*u(j-1))/p
36  go to (22,24,26),iu
37  22 continue
38  e(n)=u(n1)/(1.0-e(n1))
39  go to 28
40  24 c2=vu-(y(n)-y(n1))/(x(n)-x(n1))
41  e(n)=(c2/(x(n)-x(n1))-u(n1))/(2.0d0+e(n1))
42  go to 28
43  26 e(n)=vu/12.0
44  28 continue
45  do 30 kk=1,n1
46  k=n-kk
47  e(k)=e(k)*e(k+1)+u(k)
48 c to obtain the derivatives at the knots remove c from the
49 c following comments cards.then the array u will contain
50 c the derivatives of the spline function at the knots
51  b2=x(k+1)-x(k)
52  u(k)=(y(k+1)-y(k))/b2-b2*(e(k)*2+e(k+1))
53  30 continue
54  b2=x(n)-x(n1)
55  u(n)=(e(n1)+2.0d0*e(n))*b2+(y(n)-y(n1))/b2
56  40 if (x(1).gt.x(n)) go to 50
57  idir=0
58  mlb=0
59  mub=n
60  go to 60
61  50 idir=1
62  mlb=n
63  mub=0
64  60 if (s.ge.x(mub+idir)) go to 100
65  if (s.le.x(mlb+1-idir)) go to 110
66  ml=mlb
67  mu=mub
68  go to 80
69  70 if (iabs(mu-ml).le.1) go to 120
70  80 mav=(ml+mu)/2
71  if (s.lt.x(mav)) go to 90
72  ml=mav
73  go to 70
74  90 mu=mav
75  go to 70
76  100 mu=mub+2*idir
77  go to 130
78  110 mu=mlb+2*(1-idir)
79  go to 130
80  120 mu=mu+idir
81 130 continue
82  t=(e(mu-1)*((x(mu)-s)**3)+e(mu)*((s-x(mu-1))**3)+
83  1 (y(mu-1)-e(mu-1)*((x(mu)-x(mu-1))**2))*(x(mu)-s)+
84  2 (y(mu)-e(mu)*((x(mu)-x(mu-1))**2))*(s-x(mu-1)))/
85  3 (x(mu)-x(mu-1))
86  return
87  end
88 c***********************************************************************
subroutine spline(s, x, y, n, in, t, il, iu, vl, vu, e, u)
Definition: phs.f:1348