@@ -20,14 +20,14 @@ contains
20
20
${t}$, intent(in) :: b(:), tol
21
21
${t}$, intent(inout) :: x(:)
22
22
integer, intent(in) :: maxiter
23
- type(cg_workspace_ ${s}$), intent(inout) :: workspace
23
+ type(solver_workspace_ ${s}$), intent(inout) :: workspace
24
24
!-------------------------
25
25
integer :: iter
26
26
${t}$ :: rtr, rtrold, alpha, beta, norm0_sq
27
27
!-------------------------
28
- associate( p => workspace%p , &
29
- r => workspace%r , &
30
- Ap => workspace%Ap )
28
+ associate( p => workspace%tmp(:,1) , &
29
+ r => workspace%tmp(:,2) , &
30
+ Ap => workspace%tmp(:,3) )
31
31
x = zero_${s}$
32
32
rtr = A%inner_product(r, r)
33
33
norm0_sq = A%inner_product(b, b)
@@ -60,10 +60,10 @@ contains
60
60
${t}$, intent(in) :: b(:), tol
61
61
${t}$, intent(inout) :: x(:)
62
62
integer, intent(in), optional :: maxiter
63
- type(cg_workspace_ ${s}$), optional, intent(inout), target :: workspace
63
+ type(solver_workspace_ ${s}$), optional, intent(inout), target :: workspace
64
64
!-------------------------
65
65
type(linop_${s}$) :: op
66
- type(cg_workspace_ ${s}$), pointer :: workspace_
66
+ type(solver_workspace_ ${s}$), pointer :: workspace_
67
67
integer :: n, maxiter_
68
68
!-------------------------
69
69
n = size(b)
@@ -75,10 +75,7 @@ contains
75
75
if(present(workspace)) then
76
76
workspace_ => workspace
77
77
else
78
- allocate( workspace_%r(n), &
79
- workspace_%p(n), &
80
- workspace_%Ap(n))
81
-
78
+ allocate( workspace_%tmp(n,3) )
82
79
end if
83
80
call solve_cg_generic(op,b,x,tol,maxiter_,workspace_)
84
81
contains
0 commit comments