26 public :: matrix_solver_tridiagonal
28 interface matrix_solver_tridiagonal
29 module procedure matrix_solver_tridiagonal_1d
30 module procedure matrix_solver_tridiagonal_3d
31 end interface matrix_solver_tridiagonal
50 subroutine matrix_solver_tridiagonal_1d( &
56 integer,
intent(in) :: ka, ks, ke
58 real(RP),
intent(in) :: ud(ka)
59 real(RP),
intent(in) :: md(ka)
60 real(RP),
intent(in) :: ld(ka)
61 real(RP),
intent(in) :: iv(ka)
63 real(RP),
intent(out) :: ov(ka)
72 c(ks) = ud(ks) / md(ks)
73 d(ks) = iv(ks) / md(ks)
75 c(k) = ud(k) / ( md(k) - ld(k) * c(k-1) )
76 d(k) = ( iv(k) - ld(k) * d(k-1) ) / ( md(k) - ld(k) * c(k-1) )
82 ov(k) = d(k) - c(k) * ov(k+1)
86 end subroutine matrix_solver_tridiagonal_1d
90 subroutine matrix_solver_tridiagonal_3d( &
101 integer,
intent(in) :: ka
102 integer,
intent(in) :: ia, is, ie
103 integer,
intent(in) :: ja, js, je
104 real(RP),
intent(in) :: ud(ka,ia,ja)
105 real(RP),
intent(in) :: md(ka,ia,ja)
106 real(RP),
intent(in) :: ld(ka,ia,ja)
107 real(RP),
intent(in) :: iv(ka,ia,ja)
108 real(RP),
intent(out) :: ov(ka,ia,ja)
110 real(RP) :: c(ka,ia,ja)
111 real(RP) :: d(ka,ia,ja)
119 c(1,i,j) = ud(1,i,j) / md(1,i,j)
120 d(1,i,j) = iv(1,i,j) / md(1,i,j)
130 c(k,i,j) = ud(k,i,j) &
131 / ( md(k,i,j) - ld(k,i,j) * c(k-1,i,j) )
132 d(k,i,j) = ( iv(k,i,j) - ld(k,i,j) * d(k-1,i,j) ) &
133 / ( md(k,i,j) - ld(k,i,j) * c(k-1,i,j) )
141 ov(ka,i,j) = d(ka,i,j)
148 ov(k,i,j) = d(k,i,j) - c(k,i,j) * ov(k+1,i,j)
154 end subroutine matrix_solver_tridiagonal_3d