Skip to content

Commit

Permalink
Merge pull request #1596 from ExtremeFLOW/fix/proper_usage_of_intent_…
Browse files Browse the repository at this point in the history
…in_krylov_solvers

Fix proper usage of intent in Krylov solvers
  • Loading branch information
njansson authored Nov 11, 2024
2 parents a1b8f3c + bd9e275 commit b9d3c5b
Show file tree
Hide file tree
Showing 19 changed files with 230 additions and 230 deletions.
4 changes: 2 additions & 2 deletions src/bc/bc.f90
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ end subroutine bc_list_add
!! @param t Current time.
!! @param tstep Current time-step.
subroutine bc_list_apply_scalar(bclst, x, n, t, tstep)
type(bc_list_t), intent(inout) :: bclst
type(bc_list_t), intent(in) :: bclst
integer, intent(in) :: n
real(kind=rp), intent(inout), dimension(n) :: x
real(kind=rp), intent(in), optional :: t
Expand Down Expand Up @@ -584,7 +584,7 @@ end subroutine bc_list_apply_scalar
!! @param t Current time.
!! @param tstep Current time-step.
subroutine bc_list_apply_vector(bclst, x, y, z, n, t, tstep)
type(bc_list_t), intent(inout) :: bclst
type(bc_list_t), intent(in) :: bclst
integer, intent(in) :: n
real(kind=rp), intent(inout), dimension(n) :: x
real(kind=rp), intent(inout), dimension(n) :: y
Expand Down
26 changes: 13 additions & 13 deletions src/krylov/bcknd/cpu/bicgstab.f90
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ module bicgstab
!> Constructor.
subroutine bicgstab_init(this, n, max_iter, M, rel_tol, abs_tol, monitor)
class(bicgstab_t), intent(inout) :: this
class(pc_t), optional, intent(inout), target :: M
class(pc_t), optional, intent(in), target :: M
integer, intent(in) :: n
integer, intent(in) :: max_iter
real(kind=rp), optional, intent(inout) :: rel_tol
real(kind=rp), optional, intent(inout) :: abs_tol
real(kind=rp), optional, intent(in) :: rel_tol
real(kind=rp), optional, intent(in) :: abs_tol
logical, optional, intent(in) :: monitor


Expand Down Expand Up @@ -154,12 +154,12 @@ end subroutine bicgstab_free
!> Bi-Conjugate Gradient Stabilized method solve
function bicgstab_solve(this, Ax, x, f, n, coef, blst, gs_h, niter) result(ksp_results)
class(bicgstab_t), intent(inout) :: this
class(ax_t), intent(inout) :: Ax
class(ax_t), intent(in) :: Ax
type(field_t), intent(inout) :: x
integer, intent(in) :: n
real(kind=rp), dimension(n), intent(inout) :: f
real(kind=rp), dimension(n), intent(in) :: f
type(coef_t), intent(inout) :: coef
type(bc_list_t), intent(inout) :: blst
type(bc_list_t), intent(in) :: blst
type(gs_t), intent(inout) :: gs_h
type(ksp_monitor_t) :: ksp_results
integer, optional, intent(in) :: niter
Expand Down Expand Up @@ -250,18 +250,18 @@ end function bicgstab_solve
function bicgstab_solve_coupled(this, Ax, x, y, z, fx, fy, fz, &
n, coef, blstx, blsty, blstz, gs_h, niter) result(ksp_results)
class(bicgstab_t), intent(inout) :: this
class(ax_t), intent(inout) :: Ax
class(ax_t), intent(in) :: Ax
type(field_t), intent(inout) :: x
type(field_t), intent(inout) :: y
type(field_t), intent(inout) :: z
integer, intent(in) :: n
real(kind=rp), dimension(n), intent(inout) :: fx
real(kind=rp), dimension(n), intent(inout) :: fy
real(kind=rp), dimension(n), intent(inout) :: fz
real(kind=rp), dimension(n), intent(in) :: fx
real(kind=rp), dimension(n), intent(in) :: fy
real(kind=rp), dimension(n), intent(in) :: fz
type(coef_t), intent(inout) :: coef
type(bc_list_t), intent(inout) :: blstx
type(bc_list_t), intent(inout) :: blsty
type(bc_list_t), intent(inout) :: blstz
type(bc_list_t), intent(in) :: blstx
type(bc_list_t), intent(in) :: blsty
type(bc_list_t), intent(in) :: blstz
type(gs_t), intent(inout) :: gs_h
type(ksp_monitor_t), dimension(3) :: ksp_results
integer, optional, intent(in) :: niter
Expand Down
28 changes: 14 additions & 14 deletions src/krylov/bcknd/cpu/cacg.f90
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ module cacg
!> Initialise a s-step CA PCG solver
subroutine cacg_init(this, n, max_iter, M, s, rel_tol, abs_tol, monitor)
class(cacg_t), intent(inout) :: this
class(pc_t), optional, intent(inout), target :: M
class(pc_t), optional, intent(in), target :: M
integer, intent(in) :: n
integer, intent(in) :: max_iter
real(kind=rp), optional, intent(inout) :: rel_tol
real(kind=rp), optional, intent(inout) :: abs_tol
real(kind=rp), optional, intent(in) :: rel_tol
real(kind=rp), optional, intent(in) :: abs_tol
logical, optional, intent(in) :: monitor
integer, optional, intent(inout) :: s
integer, optional, intent(in) :: s
call this%free()

if (present(s)) then
Expand Down Expand Up @@ -137,12 +137,12 @@ end subroutine cacg_free
!> S-step CA PCG solve
function cacg_solve(this, Ax, x, f, n, coef, blst, gs_h, niter) result(ksp_results)
class(cacg_t), intent(inout) :: this
class(ax_t), intent(inout) :: Ax
class(ax_t), intent(in) :: Ax
type(field_t), intent(inout) :: x
integer, intent(in) :: n
real(kind=rp), dimension(n), intent(inout) :: f
real(kind=rp), dimension(n), intent(in) :: f
type(coef_t), intent(inout) :: coef
type(bc_list_t), intent(inout) :: blst
type(bc_list_t), intent(in) :: blst
type(gs_t), intent(inout) :: gs_h
type(ksp_monitor_t) :: ksp_results
integer, optional, intent(in) :: niter
Expand Down Expand Up @@ -352,18 +352,18 @@ end subroutine construct_basis_matrix
function cacg_solve_coupled(this, Ax, x, y, z, fx, fy, fz, &
n, coef, blstx, blsty, blstz, gs_h, niter) result(ksp_results)
class(cacg_t), intent(inout) :: this
class(ax_t), intent(inout) :: Ax
class(ax_t), intent(in) :: Ax
type(field_t), intent(inout) :: x
type(field_t), intent(inout) :: y
type(field_t), intent(inout) :: z
integer, intent(in) :: n
real(kind=rp), dimension(n), intent(inout) :: fx
real(kind=rp), dimension(n), intent(inout) :: fy
real(kind=rp), dimension(n), intent(inout) :: fz
real(kind=rp), dimension(n), intent(in) :: fx
real(kind=rp), dimension(n), intent(in) :: fy
real(kind=rp), dimension(n), intent(in) :: fz
type(coef_t), intent(inout) :: coef
type(bc_list_t), intent(inout) :: blstx
type(bc_list_t), intent(inout) :: blsty
type(bc_list_t), intent(inout) :: blstz
type(bc_list_t), intent(in) :: blstx
type(bc_list_t), intent(in) :: blsty
type(bc_list_t), intent(in) :: blstz
type(gs_t), intent(inout) :: gs_h
type(ksp_monitor_t), dimension(3) :: ksp_results
integer, optional, intent(in) :: niter
Expand Down
26 changes: 13 additions & 13 deletions src/krylov/bcknd/cpu/cg.f90
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ module cg
subroutine cg_init(this, n, max_iter, M, rel_tol, abs_tol, monitor)
class(cg_t), intent(inout), target :: this
integer, intent(in) :: max_iter
class(pc_t), optional, intent(inout), target :: M
class(pc_t), optional, intent(in), target :: M
integer, intent(in) :: n
real(kind=rp), optional, intent(inout) :: rel_tol
real(kind=rp), optional, intent(inout) :: abs_tol
real(kind=rp), optional, intent(in) :: rel_tol
real(kind=rp), optional, intent(in) :: abs_tol
logical, optional, intent(in) :: monitor

call this%free()
Expand Down Expand Up @@ -137,12 +137,12 @@ end subroutine cg_free
!> Standard PCG solve
function cg_solve(this, Ax, x, f, n, coef, blst, gs_h, niter) result(ksp_results)
class(cg_t), intent(inout) :: this
class(ax_t), intent(inout) :: Ax
class(ax_t), intent(in) :: Ax
type(field_t), intent(inout) :: x
integer, intent(in) :: n
real(kind=rp), dimension(n), intent(inout) :: f
real(kind=rp), dimension(n), intent(in) :: f
type(coef_t), intent(inout) :: coef
type(bc_list_t), intent(inout) :: blst
type(bc_list_t), intent(in) :: blst
type(gs_t), intent(inout) :: gs_h
type(ksp_monitor_t) :: ksp_results
integer, optional, intent(in) :: niter
Expand Down Expand Up @@ -258,18 +258,18 @@ end subroutine second_cg_part
function cg_solve_coupled(this, Ax, x, y, z, fx, fy, fz, &
n, coef, blstx, blsty, blstz, gs_h, niter) result(ksp_results)
class(cg_t), intent(inout) :: this
class(ax_t), intent(inout) :: Ax
class(ax_t), intent(in) :: Ax
type(field_t), intent(inout) :: x
type(field_t), intent(inout) :: y
type(field_t), intent(inout) :: z
integer, intent(in) :: n
real(kind=rp), dimension(n), intent(inout) :: fx
real(kind=rp), dimension(n), intent(inout) :: fy
real(kind=rp), dimension(n), intent(inout) :: fz
real(kind=rp), dimension(n), intent(in) :: fx
real(kind=rp), dimension(n), intent(in) :: fy
real(kind=rp), dimension(n), intent(in) :: fz
type(coef_t), intent(inout) :: coef
type(bc_list_t), intent(inout) :: blstx
type(bc_list_t), intent(inout) :: blsty
type(bc_list_t), intent(inout) :: blstz
type(bc_list_t), intent(in) :: blstx
type(bc_list_t), intent(in) :: blsty
type(bc_list_t), intent(in) :: blstz
type(gs_t), intent(inout) :: gs_h
type(ksp_monitor_t), dimension(3) :: ksp_results
integer, optional, intent(in) :: niter
Expand Down
26 changes: 13 additions & 13 deletions src/krylov/bcknd/cpu/cg_coupled.f90
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ module cg_cpld
subroutine cg_cpld_init(this, n, max_iter, M, rel_tol, abs_tol, monitor)
class(cg_cpld_t), intent(inout) :: this
integer, intent(in) :: max_iter
class(pc_t), optional, intent(inout), target :: M
class(pc_t), optional, intent(in), target :: M
integer, intent(in) :: n
real(kind=rp), optional, intent(inout) :: rel_tol
real(kind=rp), optional, intent(inout) :: abs_tol
real(kind=rp), optional, intent(in) :: rel_tol
real(kind=rp), optional, intent(in) :: abs_tol
logical, optional, intent(in) :: monitor

call this%free()
Expand Down Expand Up @@ -184,12 +184,12 @@ end subroutine cg_cpld_free
function cg_cpld_nop(this, Ax, x, f, n, coef, blst, gs_h, niter) &
result(ksp_results)
class(cg_cpld_t), intent(inout) :: this
class(ax_t), intent(inout) :: Ax
class(ax_t), intent(in) :: Ax
type(field_t), intent(inout) :: x
integer, intent(in) :: n
real(kind=rp), dimension(n), intent(inout) :: f
real(kind=rp), dimension(n), intent(in) :: f
type(coef_t), intent(inout) :: coef
type(bc_list_t), intent(inout) :: blst
type(bc_list_t), intent(in) :: blst
type(gs_t), intent(inout) :: gs_h
type(ksp_monitor_t) :: ksp_results
integer, optional, intent(in) :: niter
Expand All @@ -205,18 +205,18 @@ end function cg_cpld_nop
function cg_cpld_solve(this, Ax, x, y, z, fx, fy, fz, &
n, coef, blstx, blsty, blstz, gs_h, niter) result(ksp_results)
class(cg_cpld_t), intent(inout) :: this
class(ax_t), intent(inout) :: Ax
class(ax_t), intent(in) :: Ax
type(field_t), intent(inout) :: x
type(field_t), intent(inout) :: y
type(field_t), intent(inout) :: z
integer, intent(in) :: n
real(kind=rp), dimension(n), intent(inout) :: fx
real(kind=rp), dimension(n), intent(inout) :: fy
real(kind=rp), dimension(n), intent(inout) :: fz
real(kind=rp), dimension(n), intent(in) :: fx
real(kind=rp), dimension(n), intent(in) :: fy
real(kind=rp), dimension(n), intent(in) :: fz
type(coef_t), intent(inout) :: coef
type(bc_list_t), intent(inout) :: blstx
type(bc_list_t), intent(inout) :: blsty
type(bc_list_t), intent(inout) :: blstz
type(bc_list_t), intent(in) :: blstx
type(bc_list_t), intent(in) :: blsty
type(bc_list_t), intent(in) :: blstz
type(gs_t), intent(inout) :: gs_h
type(ksp_monitor_t), dimension(3) :: ksp_results
integer, optional, intent(in) :: niter
Expand Down
30 changes: 15 additions & 15 deletions src/krylov/bcknd/cpu/cheby.f90
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ module cheby
subroutine cheby_init(this, n, max_iter, M, rel_tol, abs_tol, monitor)
class(cheby_t), intent(inout), target :: this
integer, intent(in) :: max_iter
class(pc_t), optional, intent(inout), target :: M
class(pc_t), optional, intent(in), target :: M
integer, intent(in) :: n
real(kind=rp), optional, intent(inout) :: rel_tol
real(kind=rp), optional, intent(inout) :: abs_tol
real(kind=rp), optional, intent(in) :: rel_tol
real(kind=rp), optional, intent(in) :: abs_tol
logical, optional, intent(in) :: monitor

call this%free()
Expand Down Expand Up @@ -113,11 +113,11 @@ end subroutine cheby_free

subroutine cheby_power(this, Ax, x, n, coef, blst, gs_h)
class(cheby_t), intent(inout) :: this
class(ax_t), intent(inout) :: Ax
class(ax_t), intent(in) :: Ax
type(field_t), intent(inout) :: x
integer, intent(in) :: n
type(coef_t), intent(inout) :: coef
type(bc_list_t), intent(inout) :: blst
type(bc_list_t), intent(in) :: blst
type(gs_t), intent(inout) :: gs_h
real(kind=rp) :: lam, b, a, rn
real(kind=rp) :: boost = 1.2_rp
Expand Down Expand Up @@ -165,12 +165,12 @@ end subroutine cheby_power
function cheby_solve(this, Ax, x, f, n, coef, blst, gs_h, niter) &
result(ksp_results)
class(cheby_t), intent(inout) :: this
class(ax_t), intent(inout) :: Ax
class(ax_t), intent(in) :: Ax
type(field_t), intent(inout) :: x
integer, intent(in) :: n
real(kind=rp), dimension(n), intent(inout) :: f
real(kind=rp), dimension(n), intent(in) :: f
type(coef_t), intent(inout) :: coef
type(bc_list_t), intent(inout) :: blst
type(bc_list_t), intent(in) :: blst
type(gs_t), intent(inout) :: gs_h
type(ksp_monitor_t) :: ksp_results
integer, optional, intent(in) :: niter
Expand Down Expand Up @@ -247,18 +247,18 @@ end function cheby_solve
function cheby_solve_coupled(this, Ax, x, y, z, fx, fy, fz, &
n, coef, blstx, blsty, blstz, gs_h, niter) result(ksp_results)
class(cheby_t), intent(inout) :: this
class(ax_t), intent(inout) :: Ax
class(ax_t), intent(in) :: Ax
type(field_t), intent(inout) :: x
type(field_t), intent(inout) :: y
type(field_t), intent(inout) :: z
integer, intent(in) :: n
real(kind=rp), dimension(n), intent(inout) :: fx
real(kind=rp), dimension(n), intent(inout) :: fy
real(kind=rp), dimension(n), intent(inout) :: fz
real(kind=rp), dimension(n), intent(in) :: fx
real(kind=rp), dimension(n), intent(in) :: fy
real(kind=rp), dimension(n), intent(in) :: fz
type(coef_t), intent(inout) :: coef
type(bc_list_t), intent(inout) :: blstx
type(bc_list_t), intent(inout) :: blsty
type(bc_list_t), intent(inout) :: blstz
type(bc_list_t), intent(in) :: blstx
type(bc_list_t), intent(in) :: blsty
type(bc_list_t), intent(in) :: blstz
type(gs_t), intent(inout) :: gs_h
type(ksp_monitor_t), dimension(3) :: ksp_results
integer, optional, intent(in) :: niter
Expand Down
28 changes: 14 additions & 14 deletions src/krylov/bcknd/cpu/gmres.f90
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ subroutine gmres_init(this, n, max_iter, M, lgmres, &
class(gmres_t), intent(inout) :: this
integer, intent(in) :: n
integer, intent(in) :: max_iter
class(pc_t), optional, intent(inout), target :: M
integer, optional, intent(inout) :: lgmres
real(kind=rp), optional, intent(inout) :: rel_tol
real(kind=rp), optional, intent(inout) :: abs_tol
class(pc_t), optional, intent(in), target :: M
integer, optional, intent(in) :: lgmres
real(kind=rp), optional, intent(in) :: rel_tol
real(kind=rp), optional, intent(in) :: abs_tol
logical, optional, intent(in) :: monitor

if (present(lgmres)) then
Expand Down Expand Up @@ -170,12 +170,12 @@ end subroutine gmres_free
function gmres_solve(this, Ax, x, f, n, coef, blst, gs_h, niter) &
result(ksp_results)
class(gmres_t), intent(inout) :: this
class(ax_t), intent(inout) :: Ax
class(ax_t), intent(in) :: Ax
type(field_t), intent(inout) :: x
integer, intent(in) :: n
real(kind=rp), dimension(n), intent(inout) :: f
real(kind=rp), dimension(n), intent(in) :: f
type(coef_t), intent(inout) :: coef
type(bc_list_t), intent(inout) :: blst
type(bc_list_t), intent(in) :: blst
type(gs_t), intent(inout) :: gs_h
type(ksp_monitor_t) :: ksp_results
integer, optional, intent(in) :: niter
Expand Down Expand Up @@ -371,18 +371,18 @@ end function gmres_solve
function gmres_solve_coupled(this, Ax, x, y, z, fx, fy, fz, &
n, coef, blstx, blsty, blstz, gs_h, niter) result(ksp_results)
class(gmres_t), intent(inout) :: this
class(ax_t), intent(inout) :: Ax
class(ax_t), intent(in) :: Ax
type(field_t), intent(inout) :: x
type(field_t), intent(inout) :: y
type(field_t), intent(inout) :: z
integer, intent(in) :: n
real(kind=rp), dimension(n), intent(inout) :: fx
real(kind=rp), dimension(n), intent(inout) :: fy
real(kind=rp), dimension(n), intent(inout) :: fz
real(kind=rp), dimension(n), intent(in) :: fx
real(kind=rp), dimension(n), intent(in) :: fy
real(kind=rp), dimension(n), intent(in) :: fz
type(coef_t), intent(inout) :: coef
type(bc_list_t), intent(inout) :: blstx
type(bc_list_t), intent(inout) :: blsty
type(bc_list_t), intent(inout) :: blstz
type(bc_list_t), intent(in) :: blstx
type(bc_list_t), intent(in) :: blsty
type(bc_list_t), intent(in) :: blstz
type(gs_t), intent(inout) :: gs_h
type(ksp_monitor_t), dimension(3) :: ksp_results
integer, optional, intent(in) :: niter
Expand Down
Loading

0 comments on commit b9d3c5b

Please sign in to comment.