*=*=*=*= sys3v.html =*=*=*=*
SUBROUTINE sys3v

SUBROUTINE sys3v


      SUBROUTINE sys3v(KDLON,n,a,b,d,e,y)
      IMPLICIT NONE
c.......................................................................
c
c  inversion d'un systeme lineaire tridiagonal
c
c  |  b1  d1               |   | y1 |   | e1 |
c  |  a2  b2  d2           |   | y2 |   | e2 |
c  |      a3  b3  d3       | * | y3 | = | e3 |
c  |             ....      |   |    |   |    |
c  |              an  bn   |   | yn |   | en |
c
c  in :   * KDLON        --> dimension de vectorisation
c         * n            --> dimension du systeme
c         * a,b,d,e      --> voir dessin
c
c  out :  * y            --> voir dessin
c
c.......................................................................
c  include des dimensions locales
c
#include "dimensions.h"
#include "dimphys.h"
#include "dimradmars.h"
c.......................................................................
c  declaration des arguments
c
      INTEGER KDLON,n
      REAL a(NDLO2,n),b(NDLO2,n),d(NDLO2,n),e(NDLO2,n),y(NDLO2,n)
c.......................................................................
c  declaration des variables locales
c
      INTEGER iv,i
      REAL as(NDLON,4*nlayermx),ds(NDLON,4*nlayermx)
     &    ,x(NDLON,4*nlayermx)
c.......................................................................
c
c.......................................................................
                                                   do 99999 iv=1,KDLON
      as(iv,n)=a(iv,n)/b(iv,n)
      ds(iv,n)=e(iv,n)/b(iv,n)
99999                                              continue
      do 10001 i=n-1,1,-1
                                                   do 99998 iv=1,KDLON
      x(iv,i)=1.E+0/(b(iv,i)-d(iv,i)*as(iv,i+1))
      as(iv,i)=a(iv,i)*x(iv,i)
      ds(iv,i)=(e(iv,i)-d(iv,i)*ds(iv,i+1))*x(iv,i)
99998                                              continue
10001 continue
                                                   do 99997 iv=1,KDLON
      y(iv,1)=ds(iv,1)
99997                                              continue
      do 10002 i=2,n
                                                   do 99996 iv=1,KDLON
      y(iv,i)=ds(iv,i)-as(iv,i)*y(iv,i-1)
99996                                              continue
10002 continue
c.......................................................................
c
c.......................................................................
      RETURN
      END