diff options
Diffstat (limited to 'src/labat/spline.f')
| -rw-r--r-- | src/labat/spline.f | 34 |
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) | ||
| 2 | c spline calculates the cubic spline interpolation of the density | ||
| 3 | c together with subroutine splint. | ||
| 4 | c the main ideas are "stolen" from "numerical recipes", cambridge | ||
| 5 | c university press (1992). | ||
| 6 | c input r : position coordinate (array) | ||
| 7 | c input start : index, r(start) = starting point of the spline | ||
| 8 | c input n : index, r(n) = r_max | ||
| 9 | c input db : spin up and down density. (array) | ||
| 10 | c 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 | ||
