-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtridiag_solver.F90
52 lines (40 loc) · 1.64 KB
/
tridiag_solver.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
subroutine clm_tridia (n, a, b, c, r, u )
!=========================================================================
!
! CLMCLMCLMCLMCLMCLMCLMCLMCL A community developed and sponsored, freely
! L M available land surface process model.
! M --COMMON LAND MODEL-- C
! C L CLM WEB INFO: http://clm.gsfc.nasa.gov
! LMCLMCLMCLMCLMCLMCLMCLMCLM CLM ListServ/Mailing List:
!
!=========================================================================
! DESCRIPTION:
!
! REVISION HISTORY:
! 15 September 1999: Yongjiu Dai; Initial code
! 15 December 1999: Paul Houser and Jon Radakovich; F90 Revision
! 15 January 2002: Ian Baker revision to work in SiB
!=========================================================================
! $Id: tridiag_solver.F90,v 1.1 2005/04/06 22:24:04 chorak Exp $
!=========================================================================
use kinds
implicit none
!=== Arguments ===========================================================
integer , intent(in) :: n
real(kind=dbl_kind), intent(in) :: a(1:n),b(1:n),c(1:n),r(1:n)
real(kind=dbl_kind), intent(out) :: u(1:n)
!=== Local Variables =====================================================
integer j
real(kind=dbl_kind) gam(1:n),bet
!=== End Variable List ===================================================
bet = b(1)
u(1) = r(1) / bet
do j = 2, n
gam(j) = c(j-1) / bet
bet = b(j) - a(j) * gam(j)
u(j) = (r(j) - a(j)*u(j-1)) / bet
enddo
do j = n-1, 1, -1
u(j) = u(j) - gam(j+1) * u(j+1)
enddo
end subroutine clm_tridia