summaryrefslogtreecommitdiff
path: root/src/labat/spline.f
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2011-10-08 20:30:28 +0200
committerHenrik Rydberg <rydberg@euromail.se>2011-10-08 20:30:28 +0200
commit5df79c53745fde5d6c3340a2979b1429cd5892c1 (patch)
tree1a81af141708b826e9c61e8a04019994fcca8298 /src/labat/spline.f
Initial import of htcd system 1.0
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/labat/spline.f')
-rw-r--r--src/labat/spline.f34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/labat/spline.f b/src/labat/spline.f
new file mode 100644
index 0000000..aa523be
--- /dev/null
+++ b/src/labat/spline.f
@@ -0,0 +1,34 @@
1 subroutine spline(r,start,n,db,db2)
2c spline calculates the cubic spline interpolation of the density
3c together with subroutine splint.
4c the main ideas are "stolen" from "numerical recipes", cambridge
5c university press (1992).
6c input r : position coordinate (array)
7c input start : index, r(start) = starting point of the spline
8c input n : index, r(n) = r_max
9c input db : spin up and down density. (array)
10c output db2 : second derivative of db (array)
11 implicit logical (a-z)
12 double precision r,db,db2,u,sig,p,qn,un
13 integer spin,start,n,i
14 dimension r(561),db(2,561),db2(2,561),u(561)
15 do 100 spin = 1,2
16 db2(spin,start) = 0.d0
17 u(start) = 0.d0
18 do 10 i = start+1,n-1
19 sig = (r(i)-r(i-1))/(r(i+1)-r(i-1))
20 p = sig*db2(spin,i-1)+2.d0
21 db2(spin,i) = (sig-1.d0)/p
22 u(i) = (6.d0*((db(spin,i+1)-db(spin,i))/(r(i+1)-r(i))-
23 j (db(spin,i)-db(spin,i-1))/(r(i)-r(i-1)))/
24 j (r(i+1)-r(i-1))-sig*u(i-1))/p
25 10 continue
26 qn = 0.d0
27 un = 0.d0
28 db2(spin,n) = (un-qn*u(n-1))/(qn*db2(spin,n-1)+1.d0)
29 do 20 i = n-1,start,-1
30 db2(spin,i) = db2(spin,i)*db2(spin,i+1)+u(i)
31 20 continue
32 100 continue
33 return
34 end