source: LMDZ5/trunk/libf/dyn3dmem/spline.F @ 1632

Last change on this file since 1632 was 1632, checked in by Laurent Fairhead, 12 years ago

Import initial du répertoire dyn3dmem

Attention! ceci n'est qu'une version préliminaire du code "basse mémoire":
le code contenu dans ce répertoire est basé sur la r1320 et a donc besoin
d'être mis à jour par rapport à la dynamique parallèle d'aujourd'hui.
Ce code est toutefois mis à disposition pour circonvenir à des problèmes
de mémoire que certaines configurations du modèle pourraient rencontrer.
Dans l'état, il compile et tourne sur vargas et au CCRT


Initial import of dyn3dmem

Warning! this is just a preliminary version of the memory light code:
it is based on r1320 of the code and thus needs to be updated before
it can replace the present dyn3dpar code. It is nevertheless put at your
disposal to circumvent some memory problems some LMDZ configurations may
encounter. In its present state, it will compile and run on vargas and CCRT

File size: 1.6 KB
Line 
1!
2! $Header$
3!
4      subroutine spline(x,y,n,yp1,ypn,y2)
5     
6c
7     
8c     Routine to set up the interpolating function for a cubic spline
9     
10c     interpolation (see "Numerical Recipes" for details).
11     
12c
13          implicit real (a-h,o-z)
14          implicit integer (i-n)
15     
16      parameter(nllm=4096)
17     
18      dimension x(n),y(n),y2(n),u(nllm)
19     
20c
21c       write(6,*)(x(i),i=1,n)
22c       write(6,*)(y(i),i=1,n)
23     
24      if(yp1.gt.0.99E30) then
25c the lower boundary condition is set
26       y2(1)=0.
27c either to be "natural"
28       u(1)=0.
29     
30      else
31c or else to have a specified first
32       y2(1)=-0.5
33c derivative
34       u(1)=(3./(x(2)-x(1)))*((y(2)-y(1))/(x(2)-x(1))-yp1)
35     
36      end if
37     
38      do 11 i=2,n-1
39c decomposition loop of the tridiagonal
40       sig=(x(i)-x(i-1))/(x(i+1)-x(i-1))
41c algorithm. Y2 and U are used
42       p=sig*y2(i-1)+2.
43c for temporary storage of the decompo-
44       y2(i)=(sig-1.)/p
45c sed factors
46       u(i)=(6.*((y(i+1)-y(i))/(x(i+1)-x(i))-(y(i)-y(i-1))
47     
48     . /(x(i)-x(i-1)))/(x(i+1)-x(i-1))-sig*u(i-1))/p
49     
50 11   continue
51     
52      if(ypn.gt.0.99E30) then
53c the upper boundary condition is set
54       qn=0.
55c either to be "natural"
56       un=0.
57     
58      else
59c or else to have a specified first
60       qn=0.5
61c derivative
62       un=(3./(x(n)-x(n-1)))*(ypn-(y(n)-y(n-1))/(x(n)-x(n-1)))
63     
64      end if
65     
66      y2(n)=(un-qn*u(n-1))/(qn*y2(n-1)+1.)
67     
68      do 12 k=n-1,1,-1
69c this is the backsubstitution loop of
70       y2(k)=y2(k)*y2(k+1)+u(k)
71c the tridiagonal algorithm
72 12   continue
73     
74c
75     
76      return
77     
78      end
79     
Note: See TracBrowser for help on using the repository browser.