34 integer(kind=kint ),
intent(inout):: iter, error
35 real (kind=
kreal),
intent(inout):: resid, tset, tsol, tcomm
37 integer(kind=kint ) :: n, np, ndof, nndof
38 integer(kind=kint ) :: my_rank
39 integer(kind=kint ) :: iterlog, timelog
40 real(kind=
kreal),
pointer :: b(:), x(:)
42 real(kind=
kreal),
dimension(:,:),
allocatable :: ww
44 integer(kind=kint ) :: maxit, nrest
46 real (kind=
kreal) :: tol
48 real (kind=
kreal),
dimension(:),
allocatable :: ss
49 real (kind=
kreal),
dimension(:,:),
allocatable :: h
51 integer(kind=kint ) :: cs, sn
53 real (kind=
kreal) zero, one
54 parameter( zero = 0.0d+0, one = 1.0d+0 )
56 integer(kind=kint ) :: nrk,i,k,kk,jj,info,ik
57 integer(kind=kint ) :: irow
58 real (kind=
kreal) :: s_time,e_time,s1_time,e1_time
59 real (kind=
kreal) :: ldh,ldw,bnrm2,dnrm2,rnorm
60 real (kind=
kreal) :: commtime,comptime, coef,val,vcs,vsn,dtemp,aa,bb,r0,scale,rr
61 integer(kind=kint ) :: estcond
62 real (kind=
kreal) :: t_max,t_min,t_avg,t_sd
64 integer(kind=kint),
parameter :: r = 1
65 integer(kind=kint),
parameter :: zp = r + 1
66 integer(kind=kint),
parameter :: zq = r + 2
67 integer(kind=kint),
parameter :: s = r + 3
68 integer(kind=kint),
parameter :: w = s + 1
69 integer(kind=kint),
parameter :: y = w
70 integer(kind=kint),
parameter :: av = y + 1
71 integer(kind=kint),
parameter :: v = av + 1
81 my_rank = hecmesh%my_rank
92 if (nrest >= ndof*np-1) nrest = ndof*np-2
98 allocate (ww(ndof*np,nrk))
133 if (bnrm2.eq.0.d0)
then
141 if (timelog.eq.2)
then
143 t_max, t_min, t_avg, t_sd)
144 if (hecmesh%my_rank.eq.0)
then
145 write(*,*)
'Time solver setup'
146 write(*,*)
' Max :',t_max
147 write(*,*)
' Min :',t_min
148 write(*,*)
' Avg :',t_avg
149 write(*,*)
' Std Dev :',t_sd
153 tset = e_time - s_time
173 if (dnrm2 == 0.d0)
exit
178 ww(ik,v)= ww(ik,r) * coef
204 call hecmw_matvec(hecmesh, hecmat, ww(:,zq), ww(:,w), tcomm)
218 ww(ik,w)= ww(ik,w) - val * ww(ik,v+k-1)
224 if (val == 0.d0)
exit
229 ww(ik,v+i+1-1)= ww(ik,w) * coef
244 dtemp = vcs*h(k ,i) + vsn*h(k+1,i)
245 h(k+1,i)= vcs*h(k+1,i) - vsn*h(k ,i)
254 if (dabs(aa).gt.dabs(bb)) r0= aa
255 scale= dabs(aa) + dabs(bb)
257 if (scale.ne.0.d0)
then
258 rr= scale * dsqrt((aa/scale)**2+(bb/scale)**2)
259 rr= dsign(1.d0,r0)*rr
272 dtemp = vcs*h(i ,i) + vsn*h(i+1,i)
273 h(i+1,i)= vcs*h(i+1,i) - vsn*h(i ,i)
276 dtemp = vcs*ww(i ,s) + vsn*ww(i+1,s)
277 ww(i+1,s)= vcs*ww(i+1,s) - vsn*ww(i ,s)
280 resid = dabs( ww(i+1,s))/dsqrt(bnrm2)
282 if (my_rank.eq.0 .and. iterlog.eq.1) &
283 &
write (*,
'(2i8, 1pe16.6)') iter,i+1, resid
285 if (estcond /= 0 .and. hecmesh%my_rank == 0)
then
289 if ( resid.le.tol )
then
295 ww(irow,y)= ss(irow) / h(irow,irow)
298 do jj= irow, kk+1, -1
299 ss(kk)= ss(kk) - h(kk,jj)*ww(jj,y)
301 ww(kk,y)= ss(kk) / h(kk,kk)
312 ww(kk,av)= ww(kk,av) + ww(jj,y)*ww(kk,v+jj-1)
319 x(kk)= x(kk) + ww(kk,zq)
325 if ( iter.gt.maxit )
then
343 ww(irow,y)= ss(irow) / h(irow,irow)
346 do jj= irow, kk+1, -1
347 ss(kk)= ss(kk) - h(kk,jj)*ww(jj,y)
349 ww(kk,y)= ss(kk) / h(kk,kk)
360 ww(kk,av)= ww(kk,av) + ww(jj,y)*ww(kk,v+jj-1)
367 x(kk)= x(kk) + ww(kk,zq)
376 ww(i+1,s)= dsqrt(dnrm2/bnrm2)
379 if ( resid.le.tol )
exit outer
380 if ( iter .gt.maxit )
then
399 ww(irow,y)= ss(irow) / h(irow,irow)
402 do jj= irow, kk+1, -1
403 ss(kk)= ss(kk) - h(kk,jj)*ww(jj,y)
405 ww(kk,y)= ss(kk) / h(kk,kk)
416 ww(kk,av)= ww(kk ,av) + ww(jj,y)*ww(kk ,v+jj-1)
423 x(kk)= x(kk) + ww(kk,zq)
429 if (estcond /= 0 .and. hecmesh%my_rank == 0)
then
437 tcomm = tcomm + e_time - s_time
439 deallocate (h, ww, ss)
443 if (timelog.eq.2)
then
445 t_max, t_min, t_avg, t_sd)
446 if (hecmesh%my_rank.eq.0)
then
447 write(*,*)
'Time solver iterations'
448 write(*,*)
' Max :',t_max
449 write(*,*)
' Min :',t_min
450 write(*,*)
' Avg :',t_avg
451 write(*,*)
' Std Dev :',t_sd
455 tsol = e1_time - s1_time