This commit is contained in:
@@ -17,6 +17,7 @@ program test_linear_solver_cg
|
||||
call check_bicgstab_ilu0_solve()
|
||||
call check_gmres_solve()
|
||||
call check_dense_pivot_solve()
|
||||
call check_iterative_failure_status()
|
||||
call check_invalid_configuration()
|
||||
|
||||
contains
|
||||
@@ -325,6 +326,62 @@ contains
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(8618)
|
||||
end subroutine check_dense_pivot_solve
|
||||
|
||||
subroutine check_iterative_failure_status()
|
||||
call check_failed_dispatch(LSOLVER_BICGSTAB, 8701)
|
||||
call check_failed_dispatch(LSOLVER_GMRES, 8751)
|
||||
call check_failed_dispatch(LSOLVER_CG, 8801)
|
||||
end subroutine check_iterative_failure_status
|
||||
|
||||
subroutine check_failed_dispatch(method_in, code_base)
|
||||
integer, intent(in) :: method_in
|
||||
integer, intent(in) :: code_base
|
||||
type(csr_matrix) :: a
|
||||
integer :: ierr
|
||||
integer :: iter
|
||||
integer :: method
|
||||
integer :: preconditioner
|
||||
integer :: status_code
|
||||
integer :: matrix_class
|
||||
real(rk) :: b(3)
|
||||
real(rk) :: x(3)
|
||||
real(rk) :: res_norm
|
||||
real(rk) :: initial_resid
|
||||
real(rk) :: final_resid
|
||||
real(rk) :: relative_resid
|
||||
|
||||
call linear_solver_configure(method_in, LPRECOND_JACOBI, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(code_base)
|
||||
call make_nonsymmetric(a, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(code_base + 1)
|
||||
|
||||
b = (/ 6.0_rk, 9.0_rk, 6.0_rk /)
|
||||
x = ZERO
|
||||
call linear_solver_solve(a, b, x, 1, 1.0e-30_rk, iter, res_norm, ierr)
|
||||
if (ierr .eq. FEM_SUCCESS) call fail(code_base + 2)
|
||||
call linear_solver_get_stats(method, preconditioner, iter, res_norm, &
|
||||
status_code, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(code_base + 3)
|
||||
if (method .ne. method_in) call fail(code_base + 4)
|
||||
if (preconditioner .ne. LPRECOND_JACOBI) call fail(code_base + 5)
|
||||
if (status_code .ne. LS_STATUS_FAILED) call fail(code_base + 6)
|
||||
if (iter .ne. 1) call fail(code_base + 7)
|
||||
if (res_norm .le. ZERO) call fail(code_base + 8)
|
||||
call linear_solver_get_diagnostics(matrix_class, initial_resid, &
|
||||
final_resid, relative_resid, &
|
||||
status_code, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(code_base + 9)
|
||||
if (status_code .ne. LS_STATUS_FAILED) call fail(code_base + 10)
|
||||
if (matrix_class .ne. CSR_CLASS_GENERAL) call fail(code_base + 11)
|
||||
if (initial_resid .le. ONE) call fail(code_base + 12)
|
||||
if (final_resid .le. ZERO) call fail(code_base + 13)
|
||||
if (relative_resid .le. ZERO) call fail(code_base + 14)
|
||||
|
||||
call csr_free(a, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(code_base + 15)
|
||||
call linear_solver_configure(LSOLVER_CG, LPRECOND_JACOBI, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(code_base + 16)
|
||||
end subroutine check_failed_dispatch
|
||||
|
||||
subroutine check_invalid_configuration()
|
||||
integer :: ierr
|
||||
integer :: method
|
||||
|
||||
Reference in New Issue
Block a user