/[MITgcm]/MITgcm/pkg/seaice/seaice_jfnk.F
ViewVC logotype

Diff of /MITgcm/pkg/seaice/seaice_jfnk.F

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

revision 1.18 by mlosch, Fri Feb 15 15:19:17 2013 UTC revision 1.21 by mlosch, Thu Apr 4 07:02:51 2013 UTC
# Line 53  C     myThid :: my Thread Id. number Line 53  C     myThid :: my Thread Id. number
53        INTEGER myIter        INTEGER myIter
54        INTEGER myThid        INTEGER myThid
55    
56  #if ( (defined SEAICE_CGRID) && \  #ifdef SEAICE_ALLOW_JFNK
       (defined SEAICE_ALLOW_JFNK) && \  
       (defined SEAICE_ALLOW_DYNAMICS) )  
57  C     !FUNCTIONS:  C     !FUNCTIONS:
58        LOGICAL  DIFFERENT_MULTIPLE        LOGICAL  DIFFERENT_MULTIPLE
59        EXTERNAL DIFFERENT_MULTIPLE        EXTERNAL DIFFERENT_MULTIPLE
# Line 78  C     parameters to compute convergence Line 76  C     parameters to compute convergence
76        _RL     phi_e, alp_e, JFNKgamma_lin        _RL     phi_e, alp_e, JFNKgamma_lin
77        _RL     FGMRESeps        _RL     FGMRESeps
78        _RL     JFNKtol        _RL     JFNKtol
79  C      
80        _RL     recip_deltaT        _RL     recip_deltaT
81        LOGICAL JFNKconverged, krylovConverged        LOGICAL JFNKconverged, krylovConverged
82        LOGICAL writeNow        LOGICAL writeNow
83        CHARACTER*(MAX_LEN_MBUF) msgBuf        CHARACTER*(MAX_LEN_MBUF) msgBuf
84  C  
85  C     u/vIceRes :: residual of sea-ice momentum equations  C     u/vIceRes :: residual of sea-ice momentum equations
86        _RL uIceRes(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)        _RL uIceRes(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
87        _RL vIceRes(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)        _RL vIceRes(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
 C     vector version of the residuals  
       _RL resTmp (nVec,1,nSx,nSy)  
88  C     du/vIce   :: ice velocity increment to be added to u/vIce  C     du/vIce   :: ice velocity increment to be added to u/vIce
89        _RL duIce  (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)        _RL duIce  (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
90        _RL dvIce  (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)        _RL dvIce  (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
91  C     precomputed (= constant per Newton iteration) versions of  C     precomputed (= constant per Newton iteration) versions of
92  C     zeta, eta, and DWATN, press  C     zeta, eta, and DWATN, press
93        _RL zetaPre (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)        _RL zetaPre (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
94        _RL etaPre  (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)        _RL etaPre  (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
# Line 117  C     with iOutFgmres=1, seaice_fgmres p Line 113  C     with iOutFgmres=1, seaice_fgmres p
113       &     DIFFERENT_MULTIPLE( SEAICE_monFreq, myTime, deltaTClock ) )       &     DIFFERENT_MULTIPLE( SEAICE_monFreq, myTime, deltaTClock ) )
114       &     iOutFGMRES=1       &     iOutFGMRES=1
115    
 C      
116        DO bj=myByLo(myThid),myByHi(myThid)        DO bj=myByLo(myThid),myByHi(myThid)
117         DO bi=myBxLo(myThid),myBxHi(myThid)         DO bi=myBxLo(myThid),myBxHi(myThid)
118          DO J=1-Oly,sNy+Oly          DO J=1-OLy,sNy+OLy
119           DO I=1-Olx,sNx+Olx           DO I=1-OLx,sNx+OLx
120            uIceRes(I,J,bi,bj) = 0. _d 0            uIceRes(I,J,bi,bj) = 0. _d 0
121            vIceRes(I,J,bi,bj) = 0. _d 0            vIceRes(I,J,bi,bj) = 0. _d 0
122            duIce  (I,J,bi,bj) = 0. _d 0            duIce  (I,J,bi,bj) = 0. _d 0
# Line 131  C Line 126  C
126           ENDDO           ENDDO
127          ENDDO          ENDDO
128  C     Compute things that do no change during the Newton iteration:  C     Compute things that do no change during the Newton iteration:
129  C     sea-surface tilt and wind stress:  C     sea-surface tilt and wind stress:
130  C     FORCEX/Y0 - mass*(u/vIceNm1)/deltaT  C     FORCEX/Y0 - mass*(u/vIceNm1)/deltaT
131          DO J=1-Oly,sNy+Oly          DO J=1-OLy,sNy+OLy
132           DO I=1-Olx,sNx+Olx           DO I=1-OLx,sNx+OLx
133            FORCEX(I,J,bi,bj) = FORCEX0(I,J,bi,bj)            FORCEX(I,J,bi,bj) = FORCEX0(I,J,bi,bj)
134       &         + seaiceMassU(I,J,bi,bj)*uIceNm1(I,J,bi,bj)*recip_deltaT           &         + seaiceMassU(I,J,bi,bj)*uIceNm1(I,J,bi,bj)*recip_deltaT
135            FORCEY(I,J,bi,bj) = FORCEY0(I,J,bi,bj)            FORCEY(I,J,bi,bj) = FORCEY0(I,J,bi,bj)
136       &         + seaiceMassV(I,J,bi,bj)*vIceNm1(I,J,bi,bj)*recip_deltaT           &         + seaiceMassV(I,J,bi,bj)*vIceNm1(I,J,bi,bj)*recip_deltaT
137           ENDDO           ENDDO
138          ENDDO          ENDDO
139         ENDDO         ENDDO
# Line 149  C     Start nonlinear Newton iteration: Line 144  C     Start nonlinear Newton iteration:
144         newtonIter = newtonIter + 1         newtonIter = newtonIter + 1
145  C     Compute initial residual F(u), (includes computation of global  C     Compute initial residual F(u), (includes computation of global
146  C     variables DWATN, zeta, and eta)  C     variables DWATN, zeta, and eta)
147         IF ( newtonIter .EQ. 1 ) CALL SEAICE_JFNK_UPDATE(         IF ( newtonIter .EQ. 1 ) CALL SEAICE_JFNK_UPDATE(
148       I      duIce, dvIce,       I      duIce, dvIce,
149       U      uIce, vIce, JFNKresidual,       U      uIce, vIce, JFNKresidual,
150       O      uIceRes, vIceRes,       O      uIceRes, vIceRes,
151       I      newtonIter, myTime, myIter, myThid )       I      newtonIter, myTime, myIter, myThid )
# Line 158  C     local copies of precomputed coeffi Line 153  C     local copies of precomputed coeffi
153  C     constant for the preconditioner  C     constant for the preconditioner
154         DO bj=myByLo(myThid),myByHi(myThid)         DO bj=myByLo(myThid),myByHi(myThid)
155          DO bi=myBxLo(myThid),myBxHi(myThid)          DO bi=myBxLo(myThid),myBxHi(myThid)
156           DO j=1-Oly,sNy+Oly           DO j=1-OLy,sNy+OLy
157            DO i=1-Olx,sNx+Olx            DO i=1-OLx,sNx+OLx
158             zetaPre(I,J,bi,bj) =  zeta(I,J,bi,bj)             zetaPre(I,J,bi,bj) =  zeta(I,J,bi,bj)
159              etaPre(I,J,bi,bj) =   eta(I,J,bi,bj)              etaPre(I,J,bi,bj) =   eta(I,J,bi,bj)
160             etaZPre(I,J,bi,bj) =  etaZ(I,J,bi,bj)             etaZPre(I,J,bi,bj) =  etaZ(I,J,bi,bj)
# Line 172  C     compute convergence criterion for Line 167  C     compute convergence criterion for
167         JFNKgamma_lin = JFNKgamma_lin_max         JFNKgamma_lin = JFNKgamma_lin_max
168         IF ( newtonIter.GT.1.AND.newtonIter.LE.SEAICE_JFNK_tolIter         IF ( newtonIter.GT.1.AND.newtonIter.LE.SEAICE_JFNK_tolIter
169       &      .AND.JFNKresidual.LT.JFNKres_t ) THEN       &      .AND.JFNKresidual.LT.JFNKres_t ) THEN
170  C     Eisenstat, 1996, equ.(2.6)        C     Eisenstat, 1996, equ.(2.6)
171          phi_e = 1. _d 0          phi_e = 1. _d 0
172          alp_e = 1. _d 0          alp_e = 1. _d 0
173          JFNKgamma_lin = phi_e*( JFNKresidual/JFNKresidualKm1 )**alp_e          JFNKgamma_lin = phi_e*( JFNKresidual/JFNKresidualKm1 )**alp_e
# Line 181  C     Eisenstat, 1996, equ.(2.6) Line 176  C     Eisenstat, 1996, equ.(2.6)
176         ENDIF         ENDIF
177  C     save the residual for the next iteration  C     save the residual for the next iteration
178         JFNKresidualKm1 = JFNKresidual         JFNKresidualKm1 = JFNKresidual
179  C  
180  C     The Krylov iteration using FGMRES, the preconditioner is LSOR  C     The Krylov iteration using FGMRES, the preconditioner is LSOR
181  C     for now. The code is adapted from SEAICE_LSR, but heavily stripped  C     for now. The code is adapted from SEAICE_LSR, but heavily stripped
182  C     down.  C     down.
# Line 189  C     krylovIter is mapped into "its" in Line 184  C     krylovIter is mapped into "its" in
184  C     in that routine  C     in that routine
185         krylovIter    = 0         krylovIter    = 0
186         iCode         = 0         iCode         = 0
187  C  
188         JFNKconverged = JFNKresidual.LT.JFNKtol         JFNKconverged = JFNKresidual.LT.JFNKtol
189  C  
190  C     do Krylov loop only if convergence is not reached  C     do Krylov loop only if convergence is not reached
191  C  
192         IF ( .NOT.JFNKconverged ) THEN         IF ( .NOT.JFNKconverged ) THEN
193  C  
194  C     start Krylov iteration (FGMRES)  C     start Krylov iteration (FGMRES)
195  C  
196          krylovConverged = .FALSE.          krylovConverged = .FALSE.
197          FGMRESeps = JFNKgamma_lin * JFNKresidual          FGMRESeps = JFNKgamma_lin * JFNKresidual
198          DO WHILE ( .NOT.krylovConverged )          DO WHILE ( .NOT.krylovConverged )
199  C     solution vector sol = du/vIce  C     solution vector sol = du/vIce
200  C     residual vector (rhs) Fu = u/vIceRes  C     residual vector (rhs) Fu = u/vIceRes
201  C     output work vectors wk1, -> input work vector wk2  C     output work vectors wk1, -> input work vector wk2
202  C      
203           CALL SEAICE_FGMRES_DRIVER(           CALL SEAICE_FGMRES_DRIVER(
204       I        uIceRes, vIceRes,       I        uIceRes, vIceRes,
205       U        duIce, dvIce, iCode,       U        duIce, dvIce, iCode,
206       I        FGMRESeps, iOutFGMRES,       I        FGMRESeps, iOutFGMRES,
207       I        newtonIter, krylovIter, myTime, myIter, myThid )       I        newtonIter, krylovIter, myTime, myIter, myThid )
# Line 214  C     FGMRES returns iCode either asking Line 209  C     FGMRES returns iCode either asking
209  C     or product of matrix (Jacobian) times vector. For iCode = 0, terminate  C     or product of matrix (Jacobian) times vector. For iCode = 0, terminate
210  C     iteration  C     iteration
211           IF (iCode.EQ.1) THEN           IF (iCode.EQ.1) THEN
212  C     Call preconditioner  C     Call preconditioner
213            IF ( SOLV_MAX_ITERS .GT. 0 )            IF ( SOLV_MAX_ITERS .GT. 0 )
214       &         CALL SEAICE_PRECONDITIONER(       &         CALL SEAICE_PRECONDITIONER(
215       U         duIce, dvIce,       U         duIce, dvIce,
216       I         zetaPre, etaPre, etaZpre, dwatPre,       I         zetaPre, etaPre, etaZpre, dwatPre,
217       I         newtonIter, krylovIter, myTime, myIter, myThid )       I         newtonIter, krylovIter, myTime, myIter, myThid )
218           ELSEIF (iCode.GE.2) THEN           ELSEIF (iCode.GE.2) THEN
219  C     Compute Jacobian times vector  C     Compute Jacobian times vector
220            CALL SEAICE_JACVEC(            CALL SEAICE_JACVEC(
221       I         uIce, vIce, uIceRes, vIceRes,       I         uIce, vIce, uIceRes, vIceRes,
222       U         duIce, dvIce,         U         duIce, dvIce,
223       I         newtonIter, krylovIter, myTime, myIter, myThid )       I         newtonIter, krylovIter, myTime, myIter, myThid )
224           ENDIF           ENDIF
225           krylovConverged = iCode.EQ.0           krylovConverged = iCode.EQ.0
# Line 234  C     End of Krylov iterate Line 229  C     End of Krylov iterate
229  C     some output diagnostics  C     some output diagnostics
230          IF ( debugLevel.GE.debLevA ) THEN          IF ( debugLevel.GE.debLevA ) THEN
231           _BEGIN_MASTER( myThid )           _BEGIN_MASTER( myThid )
232           totalNewtonItersLoc =           totalNewtonItersLoc =
233       &        SEAICEnewtonIterMax*(myIter-nIter0)+newtonIter       &        SEAICEnewtonIterMax*(myIter-nIter0)+newtonIter
234           WRITE(msgBuf,'(2A,2(1XI6),2E12.5)')           WRITE(msgBuf,'(2A,2(1XI6),2E12.5)')
235       &        ' S/R SEAICE_JFNK: Newton iterate / total, ',       &        ' S/R SEAICE_JFNK: Newton iterate / total, ',
236       &        'JFNKgamma_lin, initial norm = ',       &        'JFNKgamma_lin, initial norm = ',
237       &        newtonIter, totalNewtonItersLoc,       &        newtonIter, totalNewtonItersLoc,
# Line 244  C     some output diagnostics Line 239  C     some output diagnostics
239           CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,           CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
240       &        SQUEEZE_RIGHT, myThid )       &        SQUEEZE_RIGHT, myThid )
241           WRITE(msgBuf,'(3(A,I6))')           WRITE(msgBuf,'(3(A,I6))')
242       &        ' S/R SEAICE_JFNK: Newton iterate / total = ',newtonIter,       &        ' S/R SEAICE_JFNK: Newton iterate / total = ',newtonIter,
243       &        ' / ', totalNewtonItersLoc,       &        ' / ', totalNewtonItersLoc,
244       &        ', Nb. of FGMRES iterations = ', krylovIter       &        ', Nb. of FGMRES iterations = ', krylovIter
245           CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,           CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
# Line 267  C     Note that it should be possible to Line 262  C     Note that it should be possible to
262  C     at the beginning of the Newton iteration, thereby saving us from  C     at the beginning of the Newton iteration, thereby saving us from
263  C     the extra call of seaice_jfnk_update, but unfortunately that  C     the extra call of seaice_jfnk_update, but unfortunately that
264  C     changes the results, so we leave the stuff here for now.  C     changes the results, so we leave the stuff here for now.
265          CALL SEAICE_JFNK_UPDATE(          CALL SEAICE_JFNK_UPDATE(
266       I       duIce, dvIce,       I       duIce, dvIce,
267       U       uIce, vIce, JFNKresidual,       U       uIce, vIce, JFNKresidual,
268       O       uIceRes, vIceRes,       O       uIceRes, vIceRes,
269       I       newtonIter, myTime, myIter, myThid )       I       newtonIter, myTime, myIter, myThid )
270  C     reset du/vIce here instead of setting sol = 0 in seaice_fgmres_driver  C     reset du/vIce here instead of setting sol = 0 in seaice_fgmres_driver
271          DO bj=myByLo(myThid),myByHi(myThid)          DO bj=myByLo(myThid),myByHi(myThid)
272           DO bi=myBxLo(myThid),myBxHi(myThid)           DO bi=myBxLo(myThid),myBxHi(myThid)
273            DO J=1-Oly,sNy+Oly            DO J=1-OLy,sNy+OLy
274             DO I=1-Olx,sNx+Olx             DO I=1-OLx,sNx+OLx
275              duIce(I,J,bi,bj)= 0. _d 0              duIce(I,J,bi,bj)= 0. _d 0
276              dvIce(I,J,bi,bj)= 0. _d 0              dvIce(I,J,bi,bj)= 0. _d 0
277             ENDDO             ENDDO
# Line 286  C     reset du/vIce here instead of sett Line 281  C     reset du/vIce here instead of sett
281         ENDIF         ENDIF
282  C     end of Newton iterate  C     end of Newton iterate
283        ENDDO        ENDDO
284  C  
285  C--   Output diagnostics  C--   Output diagnostics
286  C  
287        IF ( SEAICE_monFreq .GT. 0. _d 0 ) THEN        IF ( SEAICE_monFreq .GT. 0. _d 0 ) THEN
288  C     Count iterations  C     Count iterations
289         totalJFNKtimeSteps = totalJFNKtimeSteps + 1         totalJFNKtimeSteps = totalJFNKtimeSteps + 1
# Line 297  C     Count iterations Line 292  C     Count iterations
292  C     Record failure  C     Record failure
293         totalKrylovFails   = totalKrylovFails + krylovFails         totalKrylovFails   = totalKrylovFails + krylovFails
294         IF ( newtonIter .EQ. SEAICEnewtonIterMax ) THEN         IF ( newtonIter .EQ. SEAICEnewtonIterMax ) THEN
295          totalNewtonFails = totalNewtonFails + 1          totalNewtonFails = totalNewtonFails + 1
296         ENDIF         ENDIF
297        ENDIF        ENDIF
298  C     Decide whether it is time to dump and reset the counter  C     Decide whether it is time to dump and reset the counter
299        writeNow = DIFFERENT_MULTIPLE(SEAICE_monFreq,        writeNow = DIFFERENT_MULTIPLE(SEAICE_monFreq,
300       &     myTime+deltaTClock, deltaTClock)       &     myTime+deltaTClock, deltaTClock)
301  #ifdef ALLOW_CAL  #ifdef ALLOW_CAL
302        IF ( useCAL ) THEN        IF ( useCAL ) THEN
303         CALL CAL_TIME2DUMP(         CALL CAL_TIME2DUMP(
304       I      zeroRL, SEAICE_monFreq,  deltaTClock,       I      zeroRL, SEAICE_monFreq,  deltaTClock,
305       U      writeNow,       U      writeNow,
306       I      myTime+deltaTclock, myIter+1, myThid )       I      myTime+deltaTclock, myIter+1, myThid )
# Line 313  C     Decide whether it is time to dump Line 308  C     Decide whether it is time to dump
308  #endif  #endif
309        IF ( writeNow ) THEN        IF ( writeNow ) THEN
310         _BEGIN_MASTER( myThid )         _BEGIN_MASTER( myThid )
311         WRITE(msgBuf,'(A)')         WRITE(msgBuf,'(A)')
312       &' // ======================================================='       &' // ======================================================='
313         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
314       &      SQUEEZE_RIGHT, myThid )       &      SQUEEZE_RIGHT, myThid )
315         WRITE(msgBuf,'(A)') ' // Begin JFNK statistics'         WRITE(msgBuf,'(A)') ' // Begin JFNK statistics'
316         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
317       &      SQUEEZE_RIGHT, myThid )       &      SQUEEZE_RIGHT, myThid )
318         WRITE(msgBuf,'(A)')         WRITE(msgBuf,'(A)')
319       &' // ======================================================='       &' // ======================================================='
320         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
321       &      SQUEEZE_RIGHT, myThid )       &      SQUEEZE_RIGHT, myThid )
322         WRITE(msgBuf,'(A,I10)')         WRITE(msgBuf,'(A,I10)')
323       &      ' %JFNK_MON: time step              = ', myIter+1       &      ' %JFNK_MON: time step              = ', myIter+1
324         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
325       &      SQUEEZE_RIGHT, myThid )       &      SQUEEZE_RIGHT, myThid )
326         WRITE(msgBuf,'(A,I10)')         WRITE(msgBuf,'(A,I10)')
327       &      ' %JFNK_MON: Nb. of time steps      = ', totalJFNKtimeSteps       &      ' %JFNK_MON: Nb. of time steps      = ', totalJFNKtimeSteps
328         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
329       &      SQUEEZE_RIGHT, myThid )       &      SQUEEZE_RIGHT, myThid )
330         WRITE(msgBuf,'(A,I10)')         WRITE(msgBuf,'(A,I10)')
331       &      ' %JFNK_MON: Nb. of Newton steps    = ', totalNewtonIters       &      ' %JFNK_MON: Nb. of Newton steps    = ', totalNewtonIters
332         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
333       &      SQUEEZE_RIGHT, myThid )       &      SQUEEZE_RIGHT, myThid )
334         WRITE(msgBuf,'(A,I10)')         WRITE(msgBuf,'(A,I10)')
335       &      ' %JFNK_MON: Nb. of Krylov steps    = ', totalKrylovIters       &      ' %JFNK_MON: Nb. of Krylov steps    = ', totalKrylovIters
336         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
337       &      SQUEEZE_RIGHT, myThid )       &      SQUEEZE_RIGHT, myThid )
338         WRITE(msgBuf,'(A,I10)')         WRITE(msgBuf,'(A,I10)')
339       &      ' %JFNK_MON: Nb. of Newton failures = ', totalNewtonFails       &      ' %JFNK_MON: Nb. of Newton failures = ', totalNewtonFails
340         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
341       &      SQUEEZE_RIGHT, myThid )       &      SQUEEZE_RIGHT, myThid )
342         WRITE(msgBuf,'(A,I10)')         WRITE(msgBuf,'(A,I10)')
343       &      ' %JFNK_MON: Nb. of Krylov failures = ', totalKrylovFails       &      ' %JFNK_MON: Nb. of Krylov failures = ', totalKrylovFails
344         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
345       &      SQUEEZE_RIGHT, myThid )       &      SQUEEZE_RIGHT, myThid )
346         WRITE(msgBuf,'(A)')         WRITE(msgBuf,'(A)')
347       &' // ======================================================='       &' // ======================================================='
348         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
349       &      SQUEEZE_RIGHT, myThid )       &      SQUEEZE_RIGHT, myThid )
350         WRITE(msgBuf,'(A)') ' // End JFNK statistics'         WRITE(msgBuf,'(A)') ' // End JFNK statistics'
351         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
352       &      SQUEEZE_RIGHT, myThid )       &      SQUEEZE_RIGHT, myThid )
353         WRITE(msgBuf,'(A)')         WRITE(msgBuf,'(A)')
354       &' // ======================================================='       &' // ======================================================='
355         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
356       &      SQUEEZE_RIGHT, myThid )       &      SQUEEZE_RIGHT, myThid )
# Line 372  C     Print more debugging information Line 367  C     Print more debugging information
367        IF ( debugLevel.GE.debLevA ) THEN        IF ( debugLevel.GE.debLevA ) THEN
368         IF ( newtonIter .EQ. SEAICEnewtonIterMax ) THEN         IF ( newtonIter .EQ. SEAICEnewtonIterMax ) THEN
369          _BEGIN_MASTER( myThid )          _BEGIN_MASTER( myThid )
370          WRITE(msgBuf,'(A,I10)')          WRITE(msgBuf,'(A,I10)')
371       &       ' S/R SEAICE_JFNK: JFNK did not converge in timestep ',       &       ' S/R SEAICE_JFNK: JFNK did not converge in timestep ',
372       &       myIter+1       &       myIter+1
373          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
# Line 381  C     Print more debugging information Line 376  C     Print more debugging information
376         ENDIF         ENDIF
377         IF ( krylovFails .GT. 0 ) THEN         IF ( krylovFails .GT. 0 ) THEN
378          _BEGIN_MASTER( myThid )          _BEGIN_MASTER( myThid )
379          WRITE(msgBuf,'(A,I4,A,I10)')          WRITE(msgBuf,'(A,I4,A,I10)')
380       &       ' S/R SEAICE_JFNK: FGMRES did not converge ',       &       ' S/R SEAICE_JFNK: FGMRES did not converge ',
381       &       krylovFails, ' times in timestep ', myIter+1       &       krylovFails, ' times in timestep ', myIter+1
382          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
# Line 389  C     Print more debugging information Line 384  C     Print more debugging information
384          _END_MASTER( myThid )          _END_MASTER( myThid )
385         ENDIF         ENDIF
386         _BEGIN_MASTER( myThid )         _BEGIN_MASTER( myThid )
387         WRITE(msgBuf,'(A,I6,A,I10)')         WRITE(msgBuf,'(A,I6,A,I10)')
388       &      ' S/R SEAICE_JFNK: Total number FGMRES iterations = ',       &      ' S/R SEAICE_JFNK: Total number FGMRES iterations = ',
389       &      totalKrylovItersLoc, ' in timestep ', myIter+1       &      totalKrylovItersLoc, ' in timestep ', myIter+1
390         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
# Line 405  CBOP Line 400  CBOP
400  C     !ROUTINE: SEAICE_JFNK_UPDATE  C     !ROUTINE: SEAICE_JFNK_UPDATE
401  C     !INTERFACE:  C     !INTERFACE:
402    
403        SUBROUTINE SEAICE_JFNK_UPDATE(        SUBROUTINE SEAICE_JFNK_UPDATE(
404       I     duIce, dvIce,       I     duIce, dvIce,
405       U     uIce, vIce, JFNKresidual,       U     uIce, vIce, JFNKresidual,
406       O     uIceRes, vIceRes,       O     uIceRes, vIceRes,
407       I     newtonIter, myTime, myIter, myThid )       I     newtonIter, myTime, myIter, myThid )
# Line 465  C     i,j,bi,bj :: loop indices Line 460  C     i,j,bi,bj :: loop indices
460        _RL     resLoc, facLS        _RL     resLoc, facLS
461        LOGICAL doLineSearch        LOGICAL doLineSearch
462  C     nVec    :: size of the input vector(s)  C     nVec    :: size of the input vector(s)
463  C     vector version of the residuals  C     resTmp  :: vector version of the residuals
464        INTEGER nVec        INTEGER nVec
465        PARAMETER ( nVec  = 2*sNx*sNy )        PARAMETER ( nVec  = 2*sNx*sNy )
466        _RL resTmp (nVec,1,nSx,nSy)        _RL resTmp (nVec,1,nSx,nSy)
467  C  
468        CHARACTER*(MAX_LEN_MBUF) msgBuf        CHARACTER*(MAX_LEN_MBUF) msgBuf
469  CEOP  CEOP
470    
# Line 479  C     Initialise some local variables Line 474  C     Initialise some local variables
474        facLS = 1. _d 0        facLS = 1. _d 0
475        doLineSearch = .TRUE.        doLineSearch = .TRUE.
476        DO WHILE ( doLineSearch )        DO WHILE ( doLineSearch )
 C     Determine, if we need more iterations  
        doLineSearch = resLoc .GE. JFNKresidual  
 C     Limit the maximum number of iterations arbitrarily to four  
        doLineSearch = doLineSearch .AND. l .LE. 4  
 C     For the first iteration du/vIce = 0 and there will be no  
 C     improvement of the residual possible, so we do only the first  
 C     iteration  
        IF ( newtonIter .EQ. 1 ) doLineSearch = .FALSE.  
 C     Only start a linesearch after some Newton iterations  
        IF ( newtonIter .LE. SEAICE_JFNK_lsIter ) doLineSearch = .FALSE.  
 C     Increment counter  
        l = l + 1  
477  C     Create update  C     Create update
478         DO bj=myByLo(myThid),myByHi(myThid)         DO bj=myByLo(myThid),myByHi(myThid)
479          DO bi=myBxLo(myThid),myBxHi(myThid)          DO bi=myBxLo(myThid),myBxHi(myThid)
480           DO J=1-Oly,sNy+Oly           DO J=1-OLy,sNy+OLy
481            DO I=1-Olx,sNx+Olx            DO I=1-OLx,sNx+OLx
482             uIce(I,J,bi,bj) = uIce(I,J,bi,bj)+facLS*duIce(I,J,bi,bj)             uIce(I,J,bi,bj) = uIce(I,J,bi,bj)+facLS*duIce(I,J,bi,bj)
483             vIce(I,J,bi,bj) = vIce(I,J,bi,bj)+facLS*dvIce(I,J,bi,bj)             vIce(I,J,bi,bj) = vIce(I,J,bi,bj)+facLS*dvIce(I,J,bi,bj)
484            ENDDO            ENDDO
# Line 504  C     Create update Line 487  C     Create update
487         ENDDO         ENDDO
488  C     Compute current residual F(u), (includes re-computation of global  C     Compute current residual F(u), (includes re-computation of global
489  C     variables DWATN, zeta, and eta, i.e. they are different after this)  C     variables DWATN, zeta, and eta, i.e. they are different after this)
490         CALL SEAICE_CALC_RESIDUAL(         CALL SEAICE_CALC_RESIDUAL(
491       I      uIce, vIce,       I      uIce, vIce,
492       O      uIceRes, vIceRes,       O      uIceRes, vIceRes,
493       I      newtonIter, 0, myTime, myIter, myThid )       I      newtonIter, 0, myTime, myIter, myThid )
494  C     Important: Compute the norm of the residual using the same scalar  C     Important: Compute the norm of the residual using the same scalar
495  C     product that SEAICE_FGMRES does  C     product that SEAICE_FGMRES does
496         CALL SEAICE_MAP2VEC(nVec,uIceRes,vIceRes,resTmp,.TRUE.,myThid)         CALL SEAICE_MAP2VEC(nVec,uIceRes,vIceRes,resTmp,.TRUE.,myThid)
497         CALL SEAICE_SCALPROD(nVec,1,1,1,resTmp,resTmp,resLoc,myThid)         CALL SEAICE_SCALPROD(nVec,1,1,1,resTmp,resTmp,resLoc,myThid)
498         resLoc = SQRT(resLoc)         resLoc = SQRT(resLoc)
499    C     Determine, if we need more iterations
500           doLineSearch = resLoc .GE. JFNKresidual
501    C     Limit the maximum number of iterations arbitrarily to four
502           doLineSearch = doLineSearch .AND. l .LT. 4
503    C     For the first iteration du/vIce = 0 and there will be no
504    C     improvement of the residual possible, so we do only the first
505    C     iteration
506           IF ( newtonIter .EQ. 1 ) doLineSearch = .FALSE.
507    C     Only start a linesearch after some Newton iterations
508           IF ( newtonIter .LE. SEAICE_JFNK_lsIter ) doLineSearch = .FALSE.
509    C     Increment counter
510           l = l + 1
511  C     some output diagnostics  C     some output diagnostics
512         IF ( debugLevel.GE.debLevA .AND. doLineSearch ) THEN         IF ( debugLevel.GE.debLevA .AND. doLineSearch ) THEN
513          _BEGIN_MASTER( myThid )          _BEGIN_MASTER( myThid )
514          WRITE(msgBuf,'(2A,2(1XI6),3E12.5)')          WRITE(msgBuf,'(2A,2(1XI6),3E12.5)')
515       &       ' S/R SEAICE_JFNK_UPDATE: Newton iter, LSiter, ',       &       ' S/R SEAICE_JFNK_UPDATE: Newton iter, LSiter, ',
516       &       'facLS, JFNKresidual, resLoc = ',       &       'facLS, JFNKresidual, resLoc = ',
517       &        newtonIter, l, facLS, JFNKresidual, resLoc       &        newtonIter, l, facLS, JFNKresidual, resLoc
# Line 532  C     iterations, 0.25*du/vIce in the se Line 527  C     iterations, 0.25*du/vIce in the se
527  C     This is the new residual  C     This is the new residual
528        JFNKresidual = resLoc        JFNKresidual = resLoc
529    
530  #endif /* SEAICE_ALLOW_DYNAMICS and SEAICE_CGRID and SEAICE_ALLOW_JFNK */  #endif /* SEAICE_ALLOW_JFNK */
531    
532        RETURN        RETURN
533        END        END

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.21

  ViewVC Help
Powered by ViewVC 1.1.22