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) )
78 d(ke) = ( iv(ke) - ld(ke) * d(ke-1) ) / ( md(ke) - ld(ke) * c(ke-1) )
83 ov(k) = d(k) - c(k) * ov(k+1)
87 end subroutine matrix_solver_tridiagonal_1d
91 subroutine matrix_solver_tridiagonal_3d( &
103 integer,
intent(in) :: KA, KS, KE
104 integer,
intent(in) :: IA, IS, IE
105 integer,
intent(in) :: JA, JS, JE
106 real(RP),
intent(in) :: ud(KA,IA,JA)
107 real(RP),
intent(in) :: md(KA,IA,JA)
108 real(RP),
intent(in) :: ld(KA,IA,JA)
109 real(RP),
intent(in) :: iv(KA,IA,JA)
110 real(RP),
intent(out) :: ov(KA,IA,JA)
112 logical,
intent(in),
optional :: mask(IA,JA)
117 if (
present(mask) )
then
123 if ( mask(i,j) )
then
124 call matrix_solver_tridiagonal_1d( ka, ks, ke, &
125 ud(:,i,j), md(:,i,j), ld(:,i,j), &
137 call matrix_solver_tridiagonal_1d( ka, ks, ke, &
138 ud(:,i,j), md(:,i,j), ld(:,i,j), &
146 end subroutine matrix_solver_tridiagonal_3d