diff --git a/src/krylov/krylov_fctry.f90 b/src/krylov/krylov_fctry.f90 index c3e5260f4a6..bef7092baaa 100644 --- a/src/krylov/krylov_fctry.f90 +++ b/src/krylov/krylov_fctry.f90 @@ -163,329 +163,63 @@ module subroutine krylov_solver_factory(object, n, type_name, & ! issues with compilers, when it was not there. However, at some point we ! should check if we can get away with just having one obj%init statement. ! Same applies to the code in the "destroy" routine below. - if (present(abstol) .and. present(M) .and. present(monitor)) then - select type (obj => object) - type is (cg_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor) - type is (sx_cg_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor) - type is (cg_cpld_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor) - type is (cg_device_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor) - type is (pipecg_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor) - type is (sx_pipecg_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor) - type is (pipecg_device_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor) - type is (fusedcg_device_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor) - type is (fusedcg_cpld_device_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor) - type is (cacg_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor) - type is (gmres_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor) - type is (sx_gmres_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor) - type is (gmres_device_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor) - type is (bicgstab_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor) - type is (cheby_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor) - type is (cheby_device_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor) - end select - else if (present(abstol) .and. present(M)) then - select type (obj => object) - type is (cg_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol) - type is (sx_cg_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol) - type is (cg_cpld_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol) - type is (cg_device_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol) - type is (pipecg_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol) - type is (sx_pipecg_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol) - type is (pipecg_device_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol) - type is (fusedcg_device_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol) - type is (fusedcg_cpld_device_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol) - type is (cacg_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol) - type is (gmres_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol) - type is (sx_gmres_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol) - type is (gmres_device_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol) - type is (bicgstab_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol) - type is (cheby_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol) - type is (cheby_device_t) - call obj%init(n, max_iter, M = M, abs_tol = abstol) - end select - else if (present(monitor) .and. present(M)) then - select type (obj => object) - type is (cg_t) - call obj%init(n, max_iter, M = M, monitor = monitor) - type is (sx_cg_t) - call obj%init(n, max_iter, M = M, monitor = monitor) - type is (cg_cpld_t) - call obj%init(n, max_iter, M = M, monitor = monitor) - type is (cg_device_t) - call obj%init(n, max_iter, M = M, monitor = monitor) - type is (pipecg_t) - call obj%init(n, max_iter, M = M, monitor = monitor) - type is (sx_pipecg_t) - call obj%init(n, max_iter, M = M, monitor = monitor) - type is (pipecg_device_t) - call obj%init(n, max_iter, M = M, monitor = monitor) - type is (fusedcg_device_t) - call obj%init(n, max_iter, M = M, monitor = monitor) - type is (fusedcg_cpld_device_t) - call obj%init(n, max_iter, M = M, monitor = monitor) - type is (cacg_t) - call obj%init(n, max_iter, M = M, monitor = monitor) - type is (gmres_t) - call obj%init(n, max_iter, M = M, monitor = monitor) - type is (sx_gmres_t) - call obj%init(n, max_iter, M = M, monitor = monitor) - type is (gmres_device_t) - call obj%init(n, max_iter, M = M, monitor = monitor) - type is (bicgstab_t) - call obj%init(n, max_iter, M = M, monitor = monitor) - type is (cheby_t) - call obj%init(n, max_iter, M = M, monitor = monitor) - type is (cheby_device_t) - call obj%init(n, max_iter, M = M, monitor = monitor) - end select - else if (present(abstol) .and. present(monitor)) then - select type (obj => object) - type is (cg_t) - call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol) - type is (sx_cg_t) - call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol) - type is (cg_cpld_t) - call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol) - type is (cg_device_t) - call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol) - type is (pipecg_t) - call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol) - type is (sx_pipecg_t) - call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol) - type is (pipecg_device_t) - call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol) - type is (fusedcg_device_t) - call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol) - type is (fusedcg_cpld_device_t) - call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol) - type is (cacg_t) - call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol) - type is (gmres_t) - call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol) - type is (sx_gmres_t) - call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol) - type is (gmres_device_t) - call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol) - type is (bicgstab_t) - call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol) - type is (cheby_t) - call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol) - type is (cheby_device_t) - call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol) - end select - else if (present(abstol)) then - select type (obj => object) - type is (cg_t) - call obj%init(n, max_iter, abs_tol = abstol) - type is (sx_cg_t) - call obj%init(n, max_iter, abs_tol = abstol) - type is (cg_cpld_t) - call obj%init(n, max_iter, abs_tol = abstol) - type is (cg_device_t) - call obj%init(n, max_iter, abs_tol = abstol) - type is (pipecg_t) - call obj%init(n, max_iter, abs_tol = abstol) - type is (sx_pipecg_t) - call obj%init(n, max_iter, abs_tol = abstol) - type is (pipecg_device_t) - call obj%init(n, max_iter, abs_tol = abstol) - type is (fusedcg_device_t) - call obj%init(n, max_iter, abs_tol = abstol) - type is (fusedcg_cpld_device_t) - call obj%init(n, max_iter, abs_tol = abstol) - type is (cacg_t) - call obj%init(n, max_iter, abs_tol = abstol) - type is (gmres_t) - call obj%init(n, max_iter, abs_tol = abstol) - type is (sx_gmres_t) - call obj%init(n, max_iter, abs_tol = abstol) - type is (gmres_device_t) - call obj%init(n, max_iter, abs_tol = abstol) - type is (bicgstab_t) - call obj%init(n, max_iter, abs_tol = abstol) - type is (cheby_t) - call obj%init(n, max_iter, abs_tol = abstol) - type is (cheby_device_t) - call obj%init(n, max_iter, abs_tol = abstol) - end select - else if (present(monitor)) then - select type (obj => object) - type is (cg_t) - call obj%init(n, max_iter, monitor = monitor) - type is (sx_cg_t) - call obj%init(n, max_iter, monitor = monitor) - type is (cg_cpld_t) - call obj%init(n, max_iter, monitor = monitor) - type is (cg_device_t) - call obj%init(n, max_iter, monitor = monitor) - type is (pipecg_t) - call obj%init(n, max_iter, monitor = monitor) - type is (sx_pipecg_t) - call obj%init(n, max_iter, monitor = monitor) - type is (pipecg_device_t) - call obj%init(n, max_iter, monitor = monitor) - type is (fusedcg_device_t) - call obj%init(n, max_iter, monitor = monitor) - type is (fusedcg_cpld_device_t) - call obj%init(n, max_iter, monitor = monitor) - type is (cacg_t) - call obj%init(n, max_iter, monitor = monitor) - type is (gmres_t) - call obj%init(n, max_iter, monitor = monitor) - type is (sx_gmres_t) - call obj%init(n, max_iter, monitor = monitor) - type is (gmres_device_t) - call obj%init(n, max_iter, monitor = monitor) - type is (bicgstab_t) - call obj%init(n, max_iter, monitor = monitor) - type is (cheby_t) - call obj%init(n, max_iter, monitor = monitor) - type is (cheby_device_t) - call obj%init(n, max_iter, monitor = monitor) - end select - else if (present(M)) then - select type (obj => object) - type is (cg_t) - call obj%init(n, max_iter, M = M) - type is (sx_cg_t) - call obj%init(n, max_iter, M = M) - type is (cg_cpld_t) - call obj%init(n, max_iter, M = M) - type is (cg_device_t) - call obj%init(n, max_iter, M = M) - type is (pipecg_t) - call obj%init(n, max_iter, M = M) - type is (sx_pipecg_t) - call obj%init(n, max_iter, M = M) - type is (pipecg_device_t) - call obj%init(n, max_iter, M = M) - type is (fusedcg_device_t) - call obj%init(n, max_iter, M = M) - type is (fusedcg_cpld_device_t) - call obj%init(n, max_iter, M = M) - type is (cacg_t) - call obj%init(n, max_iter, M = M) - type is (gmres_t) - call obj%init(n, max_iter, M = M) - type is (sx_gmres_t) - call obj%init(n, max_iter, M = M) - type is (gmres_device_t) - call obj%init(n, max_iter, M = M) - type is (bicgstab_t) - call obj%init(n, max_iter, M = M) - type is (cheby_t) - call obj%init(n, max_iter, M = M) - type is (cheby_device_t) - call obj%init(n, max_iter, M = M) - end select - else - select type (obj => object) - type is (cg_t) - call obj%init(n, max_iter) - type is (sx_cg_t) - call obj%init(n, max_iter) - type is (cg_cpld_t) - call obj%init(n, max_iter) - type is (cg_device_t) - call obj%init(n, max_iter) - type is (pipecg_t) - call obj%init(n, max_iter) - type is (sx_pipecg_t) - call obj%init(n, max_iter) - type is (pipecg_device_t) - call obj%init(n, max_iter) - type is (fusedcg_device_t) - call obj%init(n, max_iter) - type is (fusedcg_cpld_device_t) - call obj%init(n, max_iter) - type is (cacg_t) - call obj%init(n, max_iter) - type is (gmres_t) - call obj%init(n, max_iter) - type is (sx_gmres_t) - call obj%init(n, max_iter) - type is (gmres_device_t) - call obj%init(n, max_iter) - type is (bicgstab_t) - call obj%init(n, max_iter) - type is (cheby_t) - call obj%init(n, max_iter) - type is (cheby_device_t) - call obj%init(n, max_iter) - end select - end if + select type (obj => object) + type is (cg_t) + call obj%init(n, max_iter, M = M, abs_tol = abstol,& + monitor = monitor) + type is (sx_cg_t) + call obj%init(n, max_iter, M = M, abs_tol = abstol,& + monitor = monitor) + type is (cg_cpld_t) + call obj%init(n, max_iter, M = M, abs_tol = abstol,& + monitor = monitor) + type is (cg_device_t) + call obj%init(n, max_iter, M = M, abs_tol = abstol,& + monitor = monitor) + type is (pipecg_t) + call obj%init(n, max_iter, M = M, abs_tol = abstol,& + monitor = monitor) + type is (sx_pipecg_t) + call obj%init(n, max_iter, M = M, abs_tol = abstol,& + monitor = monitor) + type is (pipecg_device_t) + call obj%init(n, max_iter, M = M, abs_tol = abstol,& + monitor = monitor) + type is (fusedcg_device_t) + call obj%init(n, max_iter, M = M, abs_tol = abstol,& + monitor = monitor) + type is (fusedcg_cpld_device_t) + call obj%init(n, max_iter, M = M, abs_tol = abstol,& + monitor = monitor) + type is (cacg_t) + call obj%init(n, max_iter, M = M, abs_tol = abstol,& + monitor = monitor) + type is (gmres_t) + call obj%init(n, max_iter, M = M, abs_tol = abstol,& + monitor = monitor) + type is (sx_gmres_t) + call obj%init(n, max_iter, M = M, abs_tol = abstol,& + monitor = monitor) + type is (gmres_device_t) + call obj%init(n, max_iter, M = M, abs_tol = abstol,& + monitor = monitor) + type is (bicgstab_t) + call obj%init(n, max_iter, M = M, abs_tol = abstol,& + monitor = monitor) + type is (cheby_t) + call obj%init(n, max_iter, M = M, abs_tol = abstol,& + monitor = monitor) + type is (cheby_device_t) + call obj%init(n, max_iter, M = M, abs_tol = abstol,& + monitor = monitor) + end select end subroutine krylov_solver_factory !> Destroy an iterative Krylov type_name module subroutine krylov_solver_destroy(object) class(ksp_t), allocatable, intent(inout) :: object - - if (allocated(object)) then - select type (obj => object) - type is (cg_t) - call obj%free() - type is (sx_cg_t) - call obj%free() - type is (cg_cpld_t) - call obj%free() - type is (cg_device_t) - call obj%free() - type is (pipecg_t) - call obj%free() - type is (sx_pipecg_t) - call obj%free() - type is (pipecg_device_t) - call obj%free() - type is (fusedcg_device_t) - call obj%free() - type is (fusedcg_cpld_device_t) - call obj%free() - type is (cacg_t) - call obj%free() - type is (gmres_t) - call obj%free() - type is (sx_gmres_t) - call obj%free() - type is (gmres_device_t) - call obj%free() - type is (bicgstab_t) - call obj%free() - type is (cheby_t) - call obj%free() - end select - end if - + call object%free() end subroutine krylov_solver_destroy end submodule krylov_fctry