21 public :: hecmwst_saamg_coarse
28 type hecmwst_saamg_coarse
29 integer(kind=kint) :: n = 0
30 logical :: symmetric = .true.
31 real(kind=
kreal),
allocatable :: ldl(:,:)
32 integer(kind=kint),
allocatable :: ipiv(:)
33 integer(kind=kint) :: n_neg = 0
34 end type hecmwst_saamg_coarse
43 type(hecmwst_saamg_bcsr),
intent(in) :: ac
44 logical,
intent(in) :: symmetric
45 type(hecmwst_saamg_coarse),
intent(out) :: cs
46 real(kind=
kreal),
allocatable :: work(:)
47 real(kind=
kreal) :: wq(1)
48 integer(kind=kint) :: n, lwork, info, astat
49 #ifdef HECMW_WITH_LAPACK
50 external :: dsytrf, dgetrf
54 cs%n = n; cs%symmetric = symmetric
55 allocate(cs%ldl(n,n), cs%ipiv(n), stat=astat)
60 call dsytrf(
'L', n, cs%ldl, n, cs%ipiv, wq, -1, info); lwork = max(int(wq(1)), 1)
62 call dsytrf(
'L', n, cs%ldl, n, cs%ipiv, work, lwork, info)
65 write(*,
'(a,i0)')
'hecmw_saamg_coarse_setup: dsytrf info=', info
68 cs%n_neg = ldlt_n_negative(cs)
70 call dgetrf(n, n, cs%ldl, n, cs%ipiv, info)
72 write(*,
'(a,i0)')
'hecmw_saamg_coarse_setup: dgetrf info=', info
86 function ldlt_n_negative(cs)
result(nneg)
87 type(hecmwst_saamg_coarse),
intent(in) :: cs
88 integer(kind=kint) :: nneg, k
89 real(kind=
kreal) :: a, b, c, det, tr
93 if (cs%ipiv(k) > 0)
then
94 if (cs%ldl(k,k) < 0.0d0) nneg = nneg + 1
97 a = cs%ldl(k,k); b = cs%ldl(k+1,k); c = cs%ldl(k+1,k+1)
98 det = a*c - b*b; tr = a + c
101 else if (tr < 0.0d0)
then
107 end function ldlt_n_negative
112 type(hecmwst_saamg_coarse),
intent(in) :: cs
113 real(kind=
kreal),
intent(in) :: b(:)
114 real(kind=
kreal),
intent(out) :: x(:)
115 integer(kind=kint) :: info
116 #ifdef HECMW_WITH_LAPACK
117 external :: dsytrs, dgetrs
118 x(1:cs%n) = b(1:cs%n)
119 if (cs%symmetric)
then
120 call dsytrs(
'L', cs%n, 1, cs%ldl, cs%n, cs%ipiv, x, cs%n, info)
122 call dgetrs(
'N', cs%n, 1, cs%ldl, cs%n, cs%ipiv, x, cs%n, info)
125 write(*,
'(a,i0)')
'hecmw_saamg_coarse_solve: trs info=', info
129 x(1:cs%n) = b(1:cs%n)
136 type(hecmwst_saamg_coarse),
intent(inout) :: cs
137 if (
allocated(cs%ldl))
deallocate(cs%ldl)
138 if (
allocated(cs%ipiv))
deallocate(cs%ipiv)
Smoothed Aggregation AMG preconditioner : coarsest-level solver.
subroutine, public hecmw_saamg_coarse_solve(cs, b, x)
Solve Ac x = b using the stored LDL^T factors.
subroutine, public hecmw_saamg_coarse_setup(Ac, symmetric, cs)
Densify Ac and factor it: symmetric -> LDL^T (dsytrf), else -> LU (dgetrf, for a non-symmetric coarse...
subroutine, public hecmw_saamg_coarse_free(cs)
Smoothed Aggregation AMG preconditioner : lightweight comm table.
subroutine, public hecmw_saamg_check_alloc(ier, what)
Report a failed allocation (stat /= 0) with a clear message and a collective abort,...
subroutine, public hecmw_saamg_abort(msg)
Fatal-error termination with a clear message. Under MPI this is a COLLECTIVE abort (hecmw_abort -> MP...
subroutine, public hecmw_saamg_require_lapack(site)
Abort with a uniform message when a LAPACK-only code path is reached in a build without LAPACK....
Smoothed Aggregation AMG preconditioner : internal block-CSR matrix.
subroutine, public hecmw_saamg_to_dense_blk(A, dense)
Densify from the block-CSR storage.
Smoothed Aggregation AMG preconditioner : kind parameters.
integer(kind=4), parameter kreal