/[MITgcm]/MITgcm_contrib/torge/itd/code/seaice_fgmres.F
ViewVC logotype

Diff of /MITgcm_contrib/torge/itd/code/seaice_fgmres.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1 by torge, Wed Oct 24 21:48:53 2012 UTC revision 1.2 by torge, Fri Nov 2 16:52:08 2012 UTC
# Line 15  C     !ROUTINE: SEAICE_FGMRES_DRIVER Line 15  C     !ROUTINE: SEAICE_FGMRES_DRIVER
15  C     !INTERFACE:  C     !INTERFACE:
16    
17        SUBROUTINE SEAICE_FGMRES_DRIVER(        SUBROUTINE SEAICE_FGMRES_DRIVER(
18       I     uIceRes, vIceRes,       I     uIceRes, vIceRes,
19       U     duIce, dvIce,       U     duIce, dvIce,
20       U     iCode,       U     iCode,
21       I     FGMRESeps,         I     FGMRESeps,
22       I     newtonIter, krylovIter, myTime, myIter, myThid )       I     newtonIter, krylovIter, myTime, myIter, myThid )
23    
24  C     !DESCRIPTION: \bv  C     !DESCRIPTION: \bv
# Line 102  C     not sure if this works properly Line 102  C     not sure if this works properly
102        _BEGIN_MASTER ( myThid )        _BEGIN_MASTER ( myThid )
103        IF ( iCode .EQ. 0 ) THEN        IF ( iCode .EQ. 0 ) THEN
104  C     first guess is zero because it is a correction  C     first guess is zero because it is a correction
105  C     wk2 needs to reset for iCode = 0, because it contains  C     wk2 needs to be reset for iCode = 0, because it may contain
106  C     remains of the previous Krylov iteration  C     remains of the previous Krylov iteration
107         DO k=1,n         DO k=1,n
108          sol(k) = 0. _d 0          sol(k) = 0. _d 0
# Line 110  C     remains of the previous Krylov ite Line 110  C     remains of the previous Krylov ite
110         ENDDO         ENDDO
111        ELSEIF ( iCode .EQ. 3 ) THEN        ELSEIF ( iCode .EQ. 3 ) THEN
112         CALL SEAICE_MAP2VEC(n,uIceRes,vIceRes,rhs,.TRUE.,myThid)         CALL SEAICE_MAP2VEC(n,uIceRes,vIceRes,rhs,.TRUE.,myThid)
113  C     change sign because we are solving J*u = -F  C     change sign of rhs because we are solving J*u = -F
114    C     wk2 needs to be initialised for iCode = 3, because it may contain
115    C     garbage
116         DO k=1,n         DO k=1,n
117          rhs(k) = -rhs(k)          rhs(k) = -rhs(k)
118            wk2(k) = 0. _d 0
119         ENDDO         ENDDO
120        ELSE        ELSE
121  C     map preconditioner results or Jacobian times vector,  C     map preconditioner results or Jacobian times vector,
122  C     stored in du/vIce to wk2  C     stored in du/vIce to wk2
123         CALL SEAICE_MAP2VEC(n,duIce,dvIce,wk2,.TRUE.,myThid)         CALL SEAICE_MAP2VEC(n,duIce,dvIce,wk2,.TRUE.,myThid)
124        ENDIF        ENDIF
125  C      C
126        CALL SEAICE_FGMRES (n,im,rhs,sol,ifgmres,vv,w,wk1,wk2,        CALL SEAICE_FGMRES (n,im,rhs,sol,ifgmres,vv,w,wk1,wk2,
127       &     FGMRESeps,SEAICEkrylovIterMax,       &     FGMRESeps,SEAICEkrylovIterMax,
128       &     iout,icode,krylovIter,myThid)       &     iout,icode,krylovIter,myThid)
129  C      C
130        IF ( iCode .EQ. 0 ) THEN        IF ( iCode .EQ. 0 ) THEN
131  C     map sol(ution) vector to du/vIce  C     map sol(ution) vector to du/vIce
132         CALL SEAICE_MAP2VEC(n,duIce,dvIce,sol,.FALSE.,myThid)         CALL SEAICE_MAP2VEC(n,duIce,dvIce,sol,.FALSE.,myThid)
# Line 133  C     solution (wk1=rhs) or a Jacobian t Line 136  C     solution (wk1=rhs) or a Jacobian t
136         CALL SEAICE_MAP2VEC(n,duIce,dvIce,wk1,.FALSE.,myThid)         CALL SEAICE_MAP2VEC(n,duIce,dvIce,wk1,.FALSE.,myThid)
137        ENDIF        ENDIF
138        _END_MASTER ( myThid )        _END_MASTER ( myThid )
139            
140  C     Fill overlaps in updated fields  C     Fill overlaps in updated fields
141        CALL EXCH_UV_XY_RL( duIce, dvIce,.TRUE.,myThid)        CALL EXCH_UV_XY_RL( duIce, dvIce,.TRUE.,myThid)
142    
# Line 146  C     !ROUTINE: SEAICE_MAP2VEC Line 149  C     !ROUTINE: SEAICE_MAP2VEC
149  C     !INTERFACE:  C     !INTERFACE:
150    
151        SUBROUTINE SEAICE_MAP2VEC(        SUBROUTINE SEAICE_MAP2VEC(
152       I     n,       I     n,
153       O     xfld2d, yfld2d,       O     xfld2d, yfld2d,
154       U     vector,       U     vector,
155       I     map2vec, myThid )       I     map2vec, myThid )
156    
157  C     !DESCRIPTION: \bv  C     !DESCRIPTION: \bv
# Line 177  C     === local variables === Line 180  C     === local variables ===
180        INTEGER I, J, bi, bj        INTEGER I, J, bi, bj
181        INTEGER ii, jj, ib, jb, m        INTEGER ii, jj, ib, jb, m
182  CEOP  CEOP
183          
184        m = n/2        m = n/2
185        IF ( map2vec ) THEN        IF ( map2vec ) THEN
186         DO bj=myByLo(myThid),myByHi(myThid)         DO bj=myByLo(myThid),myByHi(myThid)
# Line 193  CEOP Line 196  CEOP
196            ENDDO            ENDDO
197           ENDDO           ENDDO
198          ENDDO          ENDDO
199         ENDDO               ENDDO
200        ELSE        ELSE
201         DO bj=myByLo(myThid),myByHi(myThid)         DO bj=myByLo(myThid),myByHi(myThid)
202          jb = nSx*sNy*sNx*(bj-1)          jb = nSx*sNy*sNx*(bj-1)
# Line 208  CEOP Line 211  CEOP
211            ENDDO            ENDDO
212           ENDDO           ENDDO
213          ENDDO          ENDDO
214         ENDDO               ENDDO
215        ENDIF        ENDIF
216    
217        RETURN        RETURN
# Line 219  CBOP Line 222  CBOP
222  C     !ROUTINE: SEAICE_FGMRES  C     !ROUTINE: SEAICE_FGMRES
223  C     !INTERFACE:  C     !INTERFACE:
224    
225        SUBROUTINE SEAICE_FGMRES (n,im,rhs,sol,i,vv,w,wk1, wk2,        SUBROUTINE SEAICE_FGMRES (n,im,rhs,sol,i,vv,w,wk1, wk2,
226       &     eps,maxits,iout,icode,its,myThid)       &     eps,maxits,iout,icode,its,myThid)
227    
228  C-----------------------------------------------------------------------  C-----------------------------------------------------------------------
229  C mlosch Oct 2012: modified the routine further to be compliant with  C mlosch Oct 2012: modified the routine further to be compliant with
# Line 229  C f90 -> F Line 232  C f90 -> F
232  C !-comment -> C-comment  C !-comment -> C-comment
233  C double precision -> _RL  C double precision -> _RL
234  C implicit none  C implicit none
235  C  C
236  C jfl Dec 1st 2006. We modified the routine so that it is double precison.  C jfl Dec 1st 2006. We modified the routine so that it is double precison.
237  C Here are the modifications:  C Here are the modifications:
238  C 1) implicit real (a-h,o-z) becomes implicit real*8 (a-h,o-z)  C 1) implicit real (a-h,o-z) becomes implicit real*8 (a-h,o-z)
239  C 2) real bocomes real*8  C 2) real bocomes real*8
240  C 3) subroutine scopy.f has been changed for dcopy.f  C 3) subroutine scopy.f has been changed for dcopy.f
241  C 4) subroutine saxpy.f has been changed for daxpy.f  C 4) subroutine saxpy.f has been changed for daxpy.f
242  C 5) function sdot.f has been changed for ddot.f  C 5) function sdot.f has been changed for ddot.f
243  C 6) 1e-08 becomes 1d-08  C 6) 1e-08 becomes 1d-08
244  C  C
245  C Be careful with the dcopy, daxpy and ddot code...there is a slight  C Be careful with the dcopy, daxpy and ddot code...there is a slight
246  C difference with the single precision versions (scopy, saxpy and sdot).  C difference with the single precision versions (scopy, saxpy and sdot).
247  C In the single precision versions, the array are declared sightly differently.  C In the single precision versions, the array are declared sightly differently.
248  C It is written for single precision:  C It is written for single precision:
# Line 254  CML   implicit double precision (a-h,o-z Line 257  CML   implicit double precision (a-h,o-z
257        _RL rhs(*), sol(*), vv(n,im+1), w(n,im)        _RL rhs(*), sol(*), vv(n,im+1), w(n,im)
258        _RL wk1(n), wk2(n), eps        _RL wk1(n), wk2(n), eps
259  C-----------------------------------------------------------------------  C-----------------------------------------------------------------------
260  C flexible GMRES routine. This is a version of GMRES which allows a  C flexible GMRES routine. This is a version of GMRES which allows a
261  C a variable preconditioner. Implemented with a reverse communication  C a variable preconditioner. Implemented with a reverse communication
262  C protocole for flexibility -  C protocole for flexibility -
263  C DISTRIBUTED VERSION (USES DISTDOT FOR DDOT)  C DISTRIBUTED VERSION (USES DISTDOT FOR DDOT)
264  C explicit (exact) residual norms for restarts    C explicit (exact) residual norms for restarts
265  C written by Y. Saad, modified by A. Malevsky, version February 1, 1995  C written by Y. Saad, modified by A. Malevsky, version February 1, 1995
266  C-----------------------------------------------------------------------  C-----------------------------------------------------------------------
267  C This Is A Reverse Communication Implementation.  C This Is A Reverse Communication Implementation.
268  C-------------------------------------------------  C-------------------------------------------------
269  C USAGE: (see also comments for icode below). FGMRES  C USAGE: (see also comments for icode below). FGMRES
270  C should be put in a loop and the loop should be active for as  C should be put in a loop and the loop should be active for as
271  C long as icode is not equal to 0. On return fgmres will  C long as icode is not equal to 0. On return fgmres will
272  C    1) either be requesting the new preconditioned vector applied  C    1) either be requesting the new preconditioned vector applied
273  C       to wk1 in case icode.eq.1 (result should be put in wk2)  C       to wk1 in case icode.eq.1 (result should be put in wk2)
274  C    2) or be requesting the product of A applied to the vector wk1  C    2) or be requesting the product of A applied to the vector wk1
275  C       in case icode.eq.2 (result should be put in wk2)  C       in case icode.eq.2 (result should be put in wk2)
276  C    3) or be terminated in case icode .eq. 0.  C    3) or be terminated in case icode .eq. 0.
277  C on entry always set icode = 0. So icode should be set back to zero  C on entry always set icode = 0. So icode should be set back to zero
278  C upon convergence.  C upon convergence.
279  C-----------------------------------------------------------------------  C-----------------------------------------------------------------------
280  C Here is a typical way of running fgmres:  C Here is a typical way of running fgmres:
281  C  C
282  C      icode = 0  C      icode = 0
283  C 1    continue  C 1    continue
# Line 284  C      if (icode .eq. 1) then Line 287  C      if (icode .eq. 1) then
287  C         call  precon(n, wk1, wk2)    <--- user variable preconditioning  C         call  precon(n, wk1, wk2)    <--- user variable preconditioning
288  C         goto 1  C         goto 1
289  C      else if (icode .ge. 2) then  C      else if (icode .ge. 2) then
290  C         call  matvec (n,wk1, wk2)    <--- user matrix vector product.  C         call  matvec (n,wk1, wk2)    <--- user matrix vector product.
291  C         goto 1  C         goto 1
292  C      else  C      else
293  C         ----- done ----  C         ----- done ----
294  C         .........  C         .........
295  C-----------------------------------------------------------------------  C-----------------------------------------------------------------------
296  C list of parameters  C list of parameters
297  C-------------------  C-------------------
298  C  C
299  C n     == integer. the dimension of the problem  C n     == integer. the dimension of the problem
300  C im    == size of Krylov subspace:  should not exceed 50 in this  C im    == size of Krylov subspace:  should not exceed 50 in this
# Line 299  C          version (can be reset in code Line 302  C          version (can be reset in code
302  C rhs   == vector of length n containing the right hand side  C rhs   == vector of length n containing the right hand side
303  C sol   == initial guess on input, approximate solution on output  C sol   == initial guess on input, approximate solution on output
304  C vv    == work space of size n x (im+1)  C vv    == work space of size n x (im+1)
305  C w     == work space of length n x im  C w     == work space of length n x im
306  C wk1,  C wk1,
307  C wk2,  == two work vectors of length n each used for the reverse  C wk2,  == two work vectors of length n each used for the reverse
308  C          communication protocole. When on return (icode .ne. 1)  C          communication protocole. When on return (icode .ne. 1)
309  C          the user should call fgmres again with wk2 = precon * wk1  C          the user should call fgmres again with wk2 = precon * wk1
310  C          and icode untouched. When icode.eq.1 then it means that  C          and icode untouched. When icode.eq.1 then it means that
311  C          convergence has taken place.  C          convergence has taken place.
312  C            C
313  C eps   == tolerance for stopping criterion. process is stopped  C eps   == tolerance for stopping criterion. process is stopped
314  C          as soon as ( ||.|| is the euclidean norm):  C          as soon as ( ||.|| is the euclidean norm):
315  C          || current residual||/||initial residual|| <= eps  C          || current residual||/||initial residual|| <= eps
# Line 315  C maxits== maximum number of iterations Line 318  C maxits== maximum number of iterations
318  C  C
319  C iout  == output unit number number for printing intermediate results  C iout  == output unit number number for printing intermediate results
320  C          if (iout .le. 0) no statistics are printed.  C          if (iout .le. 0) no statistics are printed.
321  C  C
322  C icode = integer. indicator for the reverse communication protocole.  C icode = integer. indicator for the reverse communication protocole.
323  C         ON ENTRY : icode should be set to icode = 0.  C         ON ENTRY : icode should be set to icode = 0.
324  C         ON RETURN:  C         ON RETURN:
325  C       * icode .eq. 1 value means that fgmres has not finished  C       * icode .eq. 1 value means that fgmres has not finished
326  C         and that it is requesting a preconditioned vector before  C         and that it is requesting a preconditioned vector before
327  C         continuing. The user must compute M**(-1) wk1, where M is  C         continuing. The user must compute M**(-1) wk1, where M is
328  C         the preconditioing  matrix (may vary at each call) and wk1 is  C         the preconditioing  matrix (may vary at each call) and wk1 is
329  C         the vector as provided by fgmres upun return, and put the  C         the vector as provided by fgmres upun return, and put the
330  C         result in wk2. Then fgmres must be called again without  C         result in wk2. Then fgmres must be called again without
331  C         changing any other argument.  C         changing any other argument.
332  C       * icode .eq. 2 value means that fgmres has not finished  C       * icode .eq. 2 value means that fgmres has not finished
333  C         and that it is requesting a matrix vector product before  C         and that it is requesting a matrix vector product before
334  C         continuing. The user must compute  A * wk1, where A is the  C         continuing. The user must compute  A * wk1, where A is the
335  C         coefficient  matrix and wk1 is the vector provided by  C         coefficient  matrix and wk1 is the vector provided by
336  C         upon return. The result of the operation is to be put in  C         upon return. The result of the operation is to be put in
337  C         the vector wk2. Then fgmres must be called again without  C         the vector wk2. Then fgmres must be called again without
338  C         changing any other argument.  C         changing any other argument.
339  C       * icode .eq. 0 means that fgmres has finished and sol contains  C       * icode .eq. 0 means that fgmres has finished and sol contains
340  C         the approximate solution.  C         the approximate solution.
341  C         comment: typically fgmres must be implemented in a loop  C         comment: typically fgmres must be implemented in a loop
342  C         with fgmres being called as long icode is returned with  C         with fgmres being called as long icode is returned with
343  C         a value .ne. 0.  C         a value .ne. 0.
344  C-----------------------------------------------------------------------  C-----------------------------------------------------------------------
345  C     local variables -- !jfl modif  C     local variables -- !jfl modif
346        integer imax        integer imax
347        parameter ( imax = 50 )        parameter ( imax = 50 )
348        _RL hh(4*imax+1,4*imax),c(4*imax),s(4*imax)        _RL hh(4*imax+1,4*imax),c(4*imax),s(4*imax)
349        _RL rs(4*imax+1),t,ro        _RL rs(4*imax+1),t,ro
# Line 353  C--------------------------------------- Line 356  C---------------------------------------
356  CEOP  CEOP
357        save        save
358        data epsmac/1.d-16/        data epsmac/1.d-16/
359  C      C
360  C     computed goto  C     computed goto
361  C      C
362        if ( im .gt. imax ) stop 'size of krylov space > 50'        if ( im .gt. imax ) stop 'size of krylov space > 50'
363        goto (100,200,300,11) icode +1        goto (100,200,300,11) icode +1
364   100  continue   100  continue
# Line 370  CML      call dcopy (n, sol, 1, wk1, 1) Line 373  CML      call dcopy (n, sol, 1, wk1, 1)
373         wk1(k)=sol(k)         wk1(k)=sol(k)
374        enddo        enddo
375        icode = 3        icode = 3
376        return        RETURN
377   11   continue   11   continue
378        do j=1,n        do j=1,n
379           vv(j,1) = rhs(j) - wk2(j)           vv(j,1) = rhs(j) - wk2(j)
380        enddo        enddo
381  CML 20   ro = ddot(n, vv, 1, vv,1) !jfl modification  CML 20   ro = ddot(n, vv, 1, vv,1) !jfl modification
382   20   call scalprod(n, vv, vv, ro, myThid)   20   call scalprod(n, vv, vv, ro, myThid)
383        ro = sqrt(ro)        ro = sqrt(ro)
384        if (ro .eq. 0.0d0) goto 999        if (ro .eq. 0.0d0) goto 999
385        t = 1.0d0/ ro        t = 1.0d0/ ro
386        do j=1, n        do j=1, n
387           vv(j,1) = vv(j,1)*t           vv(j,1) = vv(j,1)*t
388        enddo        enddo
389        if (its .eq. 0) eps1=eps        if (its .eq. 0) eps1=eps
390        if (its .eq. 0) r0 = ro        if (its .eq. 0) r0 = ro
391        if (iout .gt. 0) write(*, 199) its, ro!&        if (iout .gt. 0) write(*, 199) its, ro!&
392  C           print *,'chau',its, ro !write(iout, 199) its, ro  C           print *,'chau',its, ro !write(iout, 199) its, ro
393  C      C
394  C     initialize 1-st term  of rhs of hessenberg system..  C     initialize 1-st term  of rhs of hessenberg system..
395  C      C
396        rs(1) = ro        rs(1) = ro
397        i = 0        i = 0
398   4    i=i+1   4    i=i+1
399        its = its + 1        its = its + 1
400        i1 = i + 1        i1 = i + 1
401        do k=1, n        do k=1, n
402           wk1(k) = vv(k,i)           wk1(k) = vv(k,i)
403        enddo        enddo
404  C      C
405  C     return  C     return
406  C      C
407        icode = 1        icode = 1
408    
409        return        RETURN
410   200  continue   200  continue
411        do k=1, n        do k=1, n
412           w(k,i) = wk2(k)           w(k,i) = wk2(k)
413        enddo        enddo
414  C      C
415  C     call matvec operation  C     call matvec operation
416  C      C
417        icode = 2        icode = 2
418  CML      call dcopy(n, wk2, 1, wk1, 1) !jfl modification  CML      call dcopy(n, wk2, 1, wk1, 1) !jfl modification
419        do k=1,n        do k=1,n
# Line 418  CML      call dcopy(n, wk2, 1, wk1, 1) ! Line 421  CML      call dcopy(n, wk2, 1, wk1, 1) !
421        enddo        enddo
422  C  C
423  C     return  C     return
424  C      C
425        return        RETURN
426   300  continue   300  continue
427  C      C
428  C     first call to ope corresponds to intialization goto back to 11.  C     first call to ope corresponds to intialization goto back to 11.
429  C      C
430  C      if (icode .eq. 3) goto 11  C      if (icode .eq. 3) goto 11
431  CML      call  dcopy (n, wk2, 1, vv(1,i1), 1) !jfl modification  CML      call  dcopy (n, wk2, 1, vv(1,i1), 1) !jfl modification
432        do k=1,n        do k=1,n
433         vv(k,i1)=wk2(k)         vv(k,i1)=wk2(k)
434        enddo        enddo
435  C      C
436  C     modified gram - schmidt...  C     modified gram - schmidt...
437  C      C
438        do j=1, i        do j=1, i
439  CML         t = ddot(n, vv(1,j), 1, vv(1,i1), 1) !jfl modification  CML         t = ddot(n, vv(1,j), 1, vv(1,i1), 1) !jfl modification
440           call scalprod(n, vv(1,j), vv(1,i1), t, myThid)           call scalprod(n, vv(1,j), vv(1,i1), t, myThid)
# Line 453  CML      t = sqrt(ddot(n, vv(1,i1), 1, v Line 456  CML      t = sqrt(ddot(n, vv(1,i1), 1, v
456        do k=1,n        do k=1,n
457           vv(k,i1) = vv(k,i1)*t           vv(k,i1) = vv(k,i1)*t
458        enddo        enddo
459  C      C
460  C     done with modified gram schimd and arnoldi step.  C     done with modified gram schimd and arnoldi step.
461  C     now  update factorization of hh  C     now  update factorization of hh
462  C      C
463   58   if (i .eq. 1) goto 121   58   if (i .eq. 1) goto 121
464  C      C
465  C     perfrom previous transformations  on i-th column of h  C     perfrom previous transformations  on i-th column of h
466  C      C
467        do k=2,i        do k=2,i
468           k1 = k-1           k1 = k-1
469           t = hh(k1,i)           t = hh(k1,i)
# Line 474  C-----------#determine next plane rotati Line 477  C-----------#determine next plane rotati
477        s(i) = hh(i1,i)/gam        s(i) = hh(i1,i)/gam
478        rs(i1) = -s(i)*rs(i)        rs(i1) = -s(i)*rs(i)
479        rs(i) =  c(i)*rs(i)        rs(i) =  c(i)*rs(i)
480  C      C
481  C     determine res. norm. and test for convergence-  C     determine res. norm. and test for convergence-
482  C      C
483        hh(i,i) = c(i)*hh(i,i) + s(i)*hh(i1,i)        hh(i,i) = c(i)*hh(i,i) + s(i)*hh(i1,i)
484        ro = abs(rs(i1))        ro = abs(rs(i1))
485        if (iout .gt. 0) write(*, 199) its, ro        if (iout .gt. 0) write(*, 199) its, ro
486        if (i .lt. im .and. (ro .gt. eps1))  goto 4        if (i .lt. im .and. (ro .gt. eps1))  goto 4
487  C      C
488  C     now compute solution. first solve upper triangular system.  C     now compute solution. first solve upper triangular system.
489  C      C
490        rs(i) = rs(i)/hh(i,i)        rs(i) = rs(i)/hh(i,i)
491        do ii=2,i        do ii=2,i
492           k=i-ii+1           k=i-ii+1
# Line 494  C Line 497  C
497           enddo           enddo
498           rs(k) = t/hh(k,k)           rs(k) = t/hh(k,k)
499        enddo        enddo
500  C      C
501  C     done with back substitution..  C     done with back substitution..
502  C     now form linear combination to get solution  C     now form linear combination to get solution
503  C      C
504        do j=1, i        do j=1, i
505         t = rs(j)         t = rs(j)
506  C         call daxpy(n, t, w(1,j), 1, sol,1) !jfl modification  C         call daxpy(n, t, w(1,j), 1, sol,1) !jfl modification
# Line 505  C         call daxpy(n, t, w(1,j), 1, so Line 508  C         call daxpy(n, t, w(1,j), 1, so
508          sol(k) = sol(k) + t*w(k,j)          sol(k) = sol(k) + t*w(k,j)
509         enddo         enddo
510        enddo        enddo
511  C      C
512  C     test for return  C     test for return
513  C      C
514        print *, 'ml-fgmres: its, maxits: ', its, maxits, ro, '<', eps1        print *, 'ml-fgmres: its, maxits: ', its, maxits, ro, '<', eps1
515        if (ro .le. eps1 .or. its .ge. maxits) goto 999        if (ro .le. eps1 .or. its .ge. maxits) goto 999
516  C      C
517  C     else compute residual vector and continue..  C     else compute residual vector and continue..
518  C      C
519  C       goto 10  C       goto 10
520    
521        do j=1,i        do j=1,i
# Line 528  CML        call daxpy (n, t, vv(1,j), 1, Line 531  CML        call daxpy (n, t, vv(1,j), 1,
531           vv(k,1) = vv(k,1) + t*vv(k,j)           vv(k,1) = vv(k,1) + t*vv(k,j)
532          enddo          enddo
533        enddo        enddo
534  C      C
535  C     restart outer loop.  C     restart outer loop.
536  C      C
537        goto 20        goto 20
538   999  icode = 0   999  icode = 0
539    
540   199  format('   -- fgmres its =', i4, ' res. norm =', d26.16)   199  format('   -- fgmres its =', i4, ' res. norm =', d26.16)
541  C      C
542        return        RETURN
543  C-----end-of-fgmres-----------------------------------------------------  C-----end-of-fgmres-----------------------------------------------------
544  C-----------------------------------------------------------------------  C-----------------------------------------------------------------------
545        end        END
546    
547  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
548  CBOP  CBOP
# Line 548  C     !INTERFACE: Line 551  C     !INTERFACE:
551    
552        subroutine scalprod(n,dx,dy,t,myThid)        subroutine scalprod(n,dx,dy,t,myThid)
553    
 C  
554  C     forms the dot product of two vectors.  C     forms the dot product of two vectors.
555  C     uses unrolled loops for increments equal to one.  C     uses unrolled loops for increments equal to one.
556  C     jack dongarra, linpack, 3/11/78.  C     jack dongarra, linpack, 3/11/78.
557  C     ML: code stolen from BLAS and adapted for parallel applications  C     ML: code stolen from BLAS and adapted for parallel applications
558  C  
559        implicit none        implicit none
560  #include "SIZE.h"  #include "SIZE.h"
561  #include "EEPARAMS.h"  #include "EEPARAMS.h"
562  #include "EESUPPORT.h"  #include "EESUPPORT.h"
563        integer myThid        integer n
564        _RL dx(n),dy(n)        _RL dx(n),dy(n)
       real*8 dtemp  
565        real*8 t        real*8 t
566        integer i,m,mp1,n        integer myThid
567    
568          real*8 dtemp
569          integer i,m,mp1
570  #ifdef ALLOW_USE_MPI  #ifdef ALLOW_USE_MPI
571        INTEGER mpiRC        INTEGER mpiRC
572  #endif   /* ALLOW_USE_MPI */  #endif   /* ALLOW_USE_MPI */
# Line 578  C Line 582  C
582        if( n .lt. 5 ) go to 60        if( n .lt. 5 ) go to 60
583     40 mp1 = m + 1     40 mp1 = m + 1
584        do i = mp1,n,5        do i = mp1,n,5
585         dtemp = dtemp + dx(i)*dy(i) + dx(i + 1)*dy(i + 1) +         dtemp = dtemp + dx(i)*dy(i) + dx(i + 1)*dy(i + 1) +
586       &      dx(i + 2)*dy(i + 2) + dx(i + 3)*dy(i + 3) +       &      dx(i + 2)*dy(i + 2) + dx(i + 3)*dy(i + 3) +
587       &      dx(i + 4)*dy(i + 4)       &      dx(i + 4)*dy(i + 4)
588        enddo        enddo
589     60 continue     60 continue
# Line 592  C     sum over all processors Line 596  C     sum over all processors
596        ENDIF        ENDIF
597  #endif /* ALLOW_USE_MPI */  #endif /* ALLOW_USE_MPI */
598        t = dtemp        t = dtemp
599          
600  CML      return  CML      return
601  CML      end  CML      end
602  CML  CML
603  CML      subroutine daxpy(n,da,dx,incx,dy,incy)  CML      subroutine daxpy(n,da,dx,incx,dy,incy)
604  CMLC                                                                                                                                                  CMLC
605  CMLC     constant times a vector plus a vector.                  CMLC     constant times a vector plus a vector.
606  CMLC     uses unrolled loops for increments equal to one.        CMLC     uses unrolled loops for increments equal to one.
607  CMLC     jack dongarra, linpack, 3/11/78.                        CMLC     jack dongarra, linpack, 3/11/78.
608  CMLC                                                            CMLC
609  CML      _RL dx(n),dy(n),da  CML      _RL dx(n),dy(n),da
610  CML      integer i,incx,incy,ix,iy,m,mp1,n  CML      integer i,incx,incy,ix,iy,m,mp1,n
611  CMLC                                                            CMLC
612  CML      if(n.le.0)return  CML      if(n.le.0)return
613  CML      if (da .eq. 0.0d0) return  CML      if (da .eq. 0.0d0) return
614  CML      if(incx.eq.1.and.incy.eq.1)go to 20  CML      if(incx.eq.1.and.incy.eq.1)go to 20
615  CMLC                                                            CMLC
616  CMLC        code for unequal increments or equal increments      CMLC        code for unequal increments or equal increments
617  CMLC          not equal to 1                                    CMLC          not equal to 1
618  CMLC                                                            CMLC
619  CML      ix = 1  CML      ix = 1
620  CML      iy = 1  CML      iy = 1
621  CML      if(incx.lt.0)ix = (-n+1)*incx + 1  CML      if(incx.lt.0)ix = (-n+1)*incx + 1
# Line 622  CML        ix = ix + incx Line 626  CML        ix = ix + incx
626  CML        iy = iy + incy  CML        iy = iy + incy
627  CML   10 continue  CML   10 continue
628  CML      return  CML      return
629  CMLC                                                            CMLC
630  CMLC        code for both increments equal to 1                  CMLC        code for both increments equal to 1
631  CMLC                                                            CMLC
632  CMLC                                                            CMLC
633  CMLC        clean-up loop                                        CMLC        clean-up loop
634  CMLC                                                            CMLC
635  CML   20 m = mod(n,4)  CML   20 m = mod(n,4)
636  CML      if( m .eq. 0 ) go to 40  CML      if( m .eq. 0 ) go to 40
637  CML      do 30 i = 1,m  CML      do 30 i = 1,m
# Line 645  CML      return Line 649  CML      return
649  CML      end  CML      end
650  CML  CML
651  CML      subroutine  dcopy(n,dx,incx,dy,incy)  CML      subroutine  dcopy(n,dx,incx,dy,incy)
652  CMLC                                                            CMLC
653  CMLC     copies a vector, x, to a vector, y.                    CMLC     copies a vector, x, to a vector, y.
654  CMLC     uses unrolled loops for increments equal to one.        CMLC     uses unrolled loops for increments equal to one.
655  CMLC     jack dongarra, linpack, 3/11/78.                        CMLC     jack dongarra, linpack, 3/11/78.
656  CMLC                                                            CMLC
657  CML      _RL dx(n),dy(n)  CML      _RL dx(n),dy(n)
658  CML      integer i,incx,incy,ix,iy,m,mp1,n  CML      integer i,incx,incy,ix,iy,m,mp1,n
659  CMLC                                                            CMLC
660  CML      if(n.le.0)return  CML      if(n.le.0)return
661  CML      if(incx.eq.1.and.incy.eq.1)go to 20  CML      if(incx.eq.1.and.incy.eq.1)go to 20
662  CMLC                                                            CMLC
663  CMLC        code for unequal increments or equal increments      CMLC        code for unequal increments or equal increments
664  CMLC          not equal to 1                                    CMLC          not equal to 1
665  CMLC                                                            CMLC
666  CML      ix = 1  CML      ix = 1
667  CML      iy = 1  CML      iy = 1
668  CML      if(incx.lt.0)ix = (-n+1)*incx + 1  CML      if(incx.lt.0)ix = (-n+1)*incx + 1
# Line 669  CML        ix = ix + incx Line 673  CML        ix = ix + incx
673  CML        iy = iy + incy  CML        iy = iy + incy
674  CML   10 continue  CML   10 continue
675  CML      return  CML      return
676  CMLC                                                            CMLC
677  CMLC        code for both increments equal to 1                  CMLC        code for both increments equal to 1
678  CMLC                                                            CMLC
679  CMLC                                                            CMLC
680  CMLC        clean-up loop                                        CMLC        clean-up loop
681  CMLC                                                            CMLC
682  CML   20 m = mod(n,7)  CML   20 m = mod(n,7)
683  CML      if( m .eq. 0 ) go to 40  CML      if( m .eq. 0 ) go to 40
684  CML      do 30 i = 1,m  CML      do 30 i = 1,m

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.22