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 integer(kind=kint),
dimension(:),
allocatable :: idxbfgs
43 real(kind=
kreal),
dimension(:) ,
allocatable :: vecr,workpc,tmpvecbfgs,rho,alpha
44 real(kind=
kreal),
dimension(:,:),
allocatable :: u,c,uin,cin,sbfgs,ybfgs
46 integer(kind=kint ) :: maxit, nrest,nbfgs
48 real (kind=
kreal) :: tol
50 real (kind=
kreal) zero, one
51 parameter( zero = 0.0d+0, one = 1.0d+0 )
53 integer(kind=kint ) :: nrk,i,k,kk,jj,info,ik,iorth,idx,tmpidx,ibfgs
54 integer(kind=kint ) :: irow
55 real (kind=
kreal) :: s_time,e_time,s1_time,e1_time
56 real (kind=
kreal) :: ldh,ldw,bnrm2,dnrm2,rnorm
57 real (kind=
kreal) :: commtime,comptime, coef,coef2,val,vcs,vsn,dtemp,aa,bb,r0,scale,rr
58 integer(kind=kint ) :: estcond
59 real (kind=
kreal) :: t_max,t_min,t_avg,t_sd
70 my_rank = hecmesh%my_rank
84 allocate (vecr(ndof*np))
85 allocate (workpc(ndof*np))
86 allocate (u(ndof*np,nrest))
87 allocate (c(ndof*np,nrest))
88 allocate (uin(ndof*np,nrest))
89 allocate (cin(ndof*np,nrest))
92 allocate (tmpvecbfgs(ndof*np))
93 allocate (sbfgs(ndof*np,nbfgs))
94 allocate (ybfgs(ndof*np,nbfgs))
95 allocate (idxbfgs(nbfgs))
97 allocate (alpha(nbfgs))
120 if (bnrm2.eq.0.d0)
then
128 if (timelog.eq.2)
then
130 t_max, t_min, t_avg, t_sd)
131 if (hecmesh%my_rank.eq.0)
then
132 write(*,*)
'Time solver setup'
133 write(*,*)
' Max :',t_max
134 write(*,*)
' Min :',t_min
135 write(*,*)
' Avg :',t_avg
136 write(*,*)
' Std Dev :',t_sd
140 tset = e_time - s_time
160 tmpvecbfgs(kk)= vecr(kk)
165 rho(k) = 1.0d0 / coef
167 alpha(k) = rho(k)*coef2
169 tmpvecbfgs(kk)= tmpvecbfgs(kk) - alpha(k)*ybfgs(kk,idx)
176 coef2 = rho(k) * coef
178 uin(kk,1)= uin(kk,1) + (alpha(k)-coef2)*sbfgs(kk,idx)
183 call hecmw_matvec(hecmesh, hecmat, uin(:,1), cin(:,1), tcomm)
190 cin(kk,iorth+1)= cin(kk,iorth) - coef * c(kk,iorth)
191 uin(kk,iorth+1)= uin(kk,iorth) - coef * u(kk,iorth)
195 coef = 1.0d0 / dsqrt(coef)
197 c(kk,i)= coef * cin(kk,i)
198 u(kk,i)= coef * uin(kk,i)
203 x(kk)= x(kk) + coef*u(kk,i)
204 vecr(kk)= vecr(kk) - coef*c(kk,i)
209 if (ibfgs == nbfgs+1)
then
212 idxbfgs(kk) = idxbfgs(kk+1)
214 idxbfgs(nbfgs) = tmpidx
218 ybfgs(kk,idxbfgs(ibfgs))= coef*c(kk,i)
219 sbfgs(kk,idxbfgs(ibfgs))= coef*u(kk,i)
225 resid= dsqrt(dnrm2/bnrm2)
228 if (my_rank.eq.0.and.iterlog.eq.1)
write (*,
'(i7, 1pe16.6)') iter, resid
231 if ( resid.le.tol )
exit outer
232 if ( iter.gt.maxit )
then
249 tcomm = tcomm + e_time - s_time
261 if (timelog.eq.2)
then
263 t_max, t_min, t_avg, t_sd)
264 if (hecmesh%my_rank.eq.0)
then
265 write(*,*)
'Time solver iterations'
266 write(*,*)
' Max :',t_max
267 write(*,*)
' Min :',t_min
268 write(*,*)
' Avg :',t_avg
269 write(*,*)
' Std Dev :',t_sd
273 tsol = e1_time - s1_time