2 ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 SUBROUTINE KppDecomp( JVS
, IER
)
4 ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 ! Sparse LU factorization
6 ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 USE KPP_ROOT_Parameters
9 USE KPP_ROOT_JacobianSP
12 KPP_REAL
:: JVS(KPP_LU_NONZERO
), W(KPP_NVAR
), a
13 INTEGER :: k
, kk
, j
, jj
15 a
= 0. ! mz_rs_20050606
18 ! mz_rs_20050606: don't check if real value == 0
19 ! IF ( JVS( LU_DIAG(k) ) .EQ. 0. ) THEN
20 IF ( ABS(JVS(LU_DIAG(k
))) < TINY(a
) ) THEN
24 DO kk
= LU_CROW(k
), LU_CROW(k
+1)-1
25 W( LU_ICOL(kk
) ) = JVS(kk
)
27 DO kk
= LU_CROW(k
), LU_DIAG(k
)-1
29 a
= -W(j
) / JVS( LU_DIAG(j
) )
31 DO jj
= LU_DIAG(j
)+1, LU_CROW(j
+1)-1
32 W( LU_ICOL(jj
) ) = W( LU_ICOL(jj
) ) + a
*JVS(jj
)
35 DO kk
= LU_CROW(k
), LU_CROW(k
+1)-1
36 JVS(kk
) = W( LU_ICOL(kk
) )
40 END SUBROUTINE KppDecomp
43 ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
44 SUBROUTINE KppDecompCmplx( JVS
, IER
)
45 ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
46 ! Sparse LU factorization, complex
47 ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49 USE KPP_ROOT_Parameters
50 USE KPP_ROOT_JacobianSP
53 DOUBLE COMPLEX :: JVS(KPP_LU_NONZERO
), W(KPP_NVAR
), a
54 INTEGER :: k
, kk
, j
, jj
58 IF ( JVS( LU_DIAG(k
) ) .EQ
. 0. ) THEN
62 DO kk
= LU_CROW(k
), LU_CROW(k
+1)-1
63 W( LU_ICOL(kk
) ) = JVS(kk
)
65 DO kk
= LU_CROW(k
), LU_DIAG(k
)-1
67 a
= -W(j
) / JVS( LU_DIAG(j
) )
69 DO jj
= LU_DIAG(j
)+1, LU_CROW(j
+1)-1
70 W( LU_ICOL(jj
) ) = W( LU_ICOL(jj
) ) + a
*JVS(jj
)
73 DO kk
= LU_CROW(k
), LU_CROW(k
+1)-1
74 JVS(kk
) = W( LU_ICOL(kk
) )
78 END SUBROUTINE KppDecompCmplx
80 ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
81 SUBROUTINE KppSolveIndirect( JVS
, X
)
82 ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
83 ! Sparse solve subroutine using indirect addressing
84 ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
86 USE KPP_ROOT_Parameters
87 USE KPP_ROOT_JacobianSP
90 KPP_REAL
JVS(KPP_LU_NONZERO
), X(KPP_NVAR
), sum
93 DO j
= LU_CROW(i
), LU_DIAG(i
)-1
94 X(i
) = X(i
) - JVS(j
)*X(LU_ICOL(j
));
100 DO j
= LU_DIAG(i
)+1, LU_CROW(i
+1)-1
101 sum
= sum
- JVS(j
)*X(LU_ICOL(j
));
103 X(i
) = sum
/JVS(LU_DIAG(i
));
106 END SUBROUTINE KppSolveIndirect
108 ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
109 SUBROUTINE KppSolveCmplx( JVS
, X
)
110 ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
111 ! Complex sparse solve subroutine using indirect addressing
112 ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
114 USE KPP_ROOT_Parameters
115 USE KPP_ROOT_JacobianSP
118 DOUBLE COMPLEX JVS(KPP_LU_NONZERO
), X(KPP_NVAR
), sum
121 DO j
= LU_CROW(i
), LU_DIAG(i
)-1
122 X(i
) = X(i
) - JVS(j
)*X(LU_ICOL(j
));
128 DO j
= LU_DIAG(i
)+1, LU_CROW(i
+1)-1
129 sum
= sum
- JVS(j
)*X(LU_ICOL(j
));
131 X(i
) = sum
/JVS(LU_DIAG(i
));
134 END SUBROUTINE KppSolveCmplx