/[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.20 by jmc, Sat Mar 2 04:35:05 2013 UTC revision 1.28 by mlosch, Mon Dec 1 12:31:36 2014 UTC
# Line 2  C $Header$ Line 2  C $Header$
2  C $Name$  C $Name$
3    
4  #include "SEAICE_OPTIONS.h"  #include "SEAICE_OPTIONS.h"
5    #ifdef ALLOW_AUTODIFF
6    # include "AUTODIFF_OPTIONS.h"
7    #endif
8    
9  C--  File seaice_jfnk.F: seaice jfnk dynamical solver S/R:  C--  File seaice_jfnk.F: seaice jfnk dynamical solver S/R:
10  C--   Contents  C--   Contents
# Line 53  C     myThid :: my Thread Id. number Line 56  C     myThid :: my Thread Id. number
56        INTEGER myIter        INTEGER myIter
57        INTEGER myThid        INTEGER myThid
58    
59  #if ( (defined SEAICE_CGRID) && \  #ifdef SEAICE_ALLOW_JFNK
       (defined SEAICE_ALLOW_JFNK) && \  
       (defined SEAICE_ALLOW_DYNAMICS) )  
60  C     !FUNCTIONS:  C     !FUNCTIONS:
61        LOGICAL  DIFFERENT_MULTIPLE        LOGICAL  DIFFERENT_MULTIPLE
62        EXTERNAL DIFFERENT_MULTIPLE        EXTERNAL DIFFERENT_MULTIPLE
# Line 75  C     FGMRES flag that indicates what fg Line 76  C     FGMRES flag that indicates what fg
76        _RL     JFNKresidual        _RL     JFNKresidual
77        _RL     JFNKresidualKm1        _RL     JFNKresidualKm1
78  C     parameters to compute convergence criterion  C     parameters to compute convergence criterion
79        _RL     phi_e, alp_e, JFNKgamma_lin        _RL     JFNKgamma_lin
80        _RL     FGMRESeps        _RL     FGMRESeps
81        _RL     JFNKtol        _RL     JFNKtol
82    C     backward differences extrapolation factors
83          _RL bdfFac, bdfAlpha
84    C
85        _RL     recip_deltaT        _RL     recip_deltaT
86        LOGICAL JFNKconverged, krylovConverged        LOGICAL JFNKconverged, krylovConverged
87        LOGICAL writeNow        LOGICAL writeNow
# Line 87  C     parameters to compute convergence Line 90  C     parameters to compute convergence
90  C     u/vIceRes :: residual of sea-ice momentum equations  C     u/vIceRes :: residual of sea-ice momentum equations
91        _RL uIceRes(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)        _RL uIceRes(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
92        _RL vIceRes(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)        _RL vIceRes(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
93    C     extra time level required for backward difference time stepping
94          _RL duIcNm1(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
95          _RL dvIcNm1(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
96  C     du/vIce   :: ice velocity increment to be added to u/vIce  C     du/vIce   :: ice velocity increment to be added to u/vIce
97        _RL duIce  (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)        _RL duIce  (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
98        _RL dvIce  (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)        _RL dvIce  (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
99  C     precomputed (= constant per Newton iteration) versions of  C     precomputed (= constant per Newton iteration) versions of
100  C     zeta, eta, and DWATN, press  C     zeta, eta, and DWATN, press
101        _RL zetaPre (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)        _RL zetaPre (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
102          _RL zetaZPre(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
103        _RL etaPre  (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)        _RL etaPre  (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
104        _RL etaZPre (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)        _RL etaZPre (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
105        _RL dwatPre (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)        _RL dwatPre (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
# Line 115  C     with iOutFgmres=1, seaice_fgmres p Line 122  C     with iOutFgmres=1, seaice_fgmres p
122       &     DIFFERENT_MULTIPLE( SEAICE_monFreq, myTime, deltaTClock ) )       &     DIFFERENT_MULTIPLE( SEAICE_monFreq, myTime, deltaTClock ) )
123       &     iOutFGMRES=1       &     iOutFGMRES=1
124    
125    C     backward difference extrapolation factors
126          bdfFac = 0. _d 0
127          IF ( SEAICEuseBDF2 ) THEN
128           IF ( myIter.EQ.nIter0 .AND. SEAICEmomStartBDF.EQ.0 ) THEN
129            bdfFac = 0. _d 0
130           ELSE
131            bdfFac = 0.5 _d 0
132           ENDIF
133          ENDIF
134          bdfAlpha = 1. _d 0 + bdfFac
135    
136        DO bj=myByLo(myThid),myByHi(myThid)        DO bj=myByLo(myThid),myByHi(myThid)
137         DO bi=myBxLo(myThid),myBxHi(myThid)         DO bi=myBxLo(myThid),myBxHi(myThid)
138          DO J=1-OLy,sNy+OLy          DO J=1-OLy,sNy+OLy
# Line 123  C     with iOutFgmres=1, seaice_fgmres p Line 141  C     with iOutFgmres=1, seaice_fgmres p
141            vIceRes(I,J,bi,bj) = 0. _d 0            vIceRes(I,J,bi,bj) = 0. _d 0
142            duIce  (I,J,bi,bj) = 0. _d 0            duIce  (I,J,bi,bj) = 0. _d 0
143            dvIce  (I,J,bi,bj) = 0. _d 0            dvIce  (I,J,bi,bj) = 0. _d 0
144             ENDDO
145            ENDDO
146    C     cycle ice velocities
147            DO J=1-OLy,sNy+OLy
148             DO I=1-OLx,sNx+OLx
149              duIcNm1(I,J,bi,bj) = uIce(I,J,bi,bj) * bdfAlpha
150         &         + ( uIce(I,J,bi,bj) - uIceNm1(I,J,bi,bj) ) * bdfFac
151              dvIcNm1(I,J,bi,bj) = vIce(I,J,bi,bj) * bdfAlpha
152         &         + ( vIce(I,J,bi,bj) - vIceNm1(I,J,bi,bj) ) * bdfFac
153            uIceNm1(I,J,bi,bj) = uIce(I,J,bi,bj)            uIceNm1(I,J,bi,bj) = uIce(I,J,bi,bj)
154            vIceNm1(I,J,bi,bj) = vIce(I,J,bi,bj)            vIceNm1(I,J,bi,bj) = vIce(I,J,bi,bj)
155           ENDDO           ENDDO
156          ENDDO          ENDDO
157    C     As long as IMEX is not properly implemented leave this commented out
158    CML        IF ( .NOT.SEAICEuseIMEX ) THEN
159  C     Compute things that do no change during the Newton iteration:  C     Compute things that do no change during the Newton iteration:
160  C     sea-surface tilt and wind stress:  C     sea-surface tilt and wind stress:
161  C     FORCEX/Y0 - mass*(u/vIceNm1)/deltaT  C     FORCEX/Y0 - mass*(1.5*u/vIceNm1+0.5*(u/vIceNm1-u/vIceNm2))/deltaT
162          DO J=1-OLy,sNy+OLy          DO J=1-OLy,sNy+OLy
163           DO I=1-OLx,sNx+OLx           DO I=1-OLx,sNx+OLx
164            FORCEX(I,J,bi,bj) = FORCEX0(I,J,bi,bj)            FORCEX(I,J,bi,bj) = FORCEX0(I,J,bi,bj)
165       &         + seaiceMassU(I,J,bi,bj)*uIceNm1(I,J,bi,bj)*recip_deltaT       &         + seaiceMassU(I,J,bi,bj)*duIcNm1(I,J,bi,bj)*recip_deltaT
166            FORCEY(I,J,bi,bj) = FORCEY0(I,J,bi,bj)            FORCEY(I,J,bi,bj) = FORCEY0(I,J,bi,bj)
167       &         + seaiceMassV(I,J,bi,bj)*vIceNm1(I,J,bi,bj)*recip_deltaT       &         + seaiceMassV(I,J,bi,bj)*dvIcNm1(I,J,bi,bj)*recip_deltaT
168           ENDDO           ENDDO
169          ENDDO          ENDDO
170    CML        ENDIF
171         ENDDO         ENDDO
172        ENDDO        ENDDO
173  C     Start nonlinear Newton iteration: outer loop iteration  C     Start nonlinear Newton iteration: outer loop iteration
# Line 158  C     constant for the preconditioner Line 188  C     constant for the preconditioner
188           DO j=1-OLy,sNy+OLy           DO j=1-OLy,sNy+OLy
189            DO i=1-OLx,sNx+OLx            DO i=1-OLx,sNx+OLx
190             zetaPre(I,J,bi,bj) =  zeta(I,J,bi,bj)             zetaPre(I,J,bi,bj) =  zeta(I,J,bi,bj)
191               zetaZPre(I,J,bi,bj)= zetaZ(I,J,bi,bj)
192              etaPre(I,J,bi,bj) =   eta(I,J,bi,bj)              etaPre(I,J,bi,bj) =   eta(I,J,bi,bj)
193             etaZPre(I,J,bi,bj) =  etaZ(I,J,bi,bj)             etaZPre(I,J,bi,bj) =  etaZ(I,J,bi,bj)
194             dwatPre(I,J,bi,bj) = DWATN(I,J,bi,bj)             dwatPre(I,J,bi,bj) = DWATN(I,J,bi,bj)
# Line 169  C     compute convergence criterion for Line 200  C     compute convergence criterion for
200         JFNKgamma_lin = JFNKgamma_lin_max         JFNKgamma_lin = JFNKgamma_lin_max
201         IF ( newtonIter.GT.1.AND.newtonIter.LE.SEAICE_JFNK_tolIter         IF ( newtonIter.GT.1.AND.newtonIter.LE.SEAICE_JFNK_tolIter
202       &      .AND.JFNKresidual.LT.JFNKres_t ) THEN       &      .AND.JFNKresidual.LT.JFNKres_t ) THEN
203  C     Eisenstat, 1996, equ.(2.6)  C     Eisenstat and Walker (1996), eq.(2.6)
204          phi_e = 1. _d 0          JFNKgamma_lin = SEAICE_JFNKphi
205          alp_e = 1. _d 0       &       *( JFNKresidual/JFNKresidualKm1 )**SEAICE_JFNKalpha
         JFNKgamma_lin = phi_e*( JFNKresidual/JFNKresidualKm1 )**alp_e  
206          JFNKgamma_lin = min(JFNKgamma_lin_max, JFNKgamma_lin)          JFNKgamma_lin = min(JFNKgamma_lin_max, JFNKgamma_lin)
207          JFNKgamma_lin = max(JFNKgamma_lin_min, JFNKgamma_lin)          JFNKgamma_lin = max(JFNKgamma_lin_min, JFNKgamma_lin)
208         ENDIF         ENDIF
# Line 215  C     Call preconditioner Line 245  C     Call preconditioner
245            IF ( SOLV_MAX_ITERS .GT. 0 )            IF ( SOLV_MAX_ITERS .GT. 0 )
246       &         CALL SEAICE_PRECONDITIONER(       &         CALL SEAICE_PRECONDITIONER(
247       U         duIce, dvIce,       U         duIce, dvIce,
248       I         zetaPre, etaPre, etaZpre, dwatPre,       I         zetaPre, etaPre, etaZpre, zetaZpre, dwatPre,
249       I         newtonIter, krylovIter, myTime, myIter, myThid )       I         newtonIter, krylovIter, myTime, myIter, myThid )
250           ELSEIF (iCode.GE.2) THEN           ELSEIF (iCode.GE.2) THEN
251  C     Compute Jacobian times vector  C     Compute Jacobian times vector
# Line 529  C     iterations, 0.25*du/vIce in the se Line 559  C     iterations, 0.25*du/vIce in the se
559  C     This is the new residual  C     This is the new residual
560        JFNKresidual = resLoc        JFNKresidual = resLoc
561    
562  #endif /* SEAICE_ALLOW_DYNAMICS and SEAICE_CGRID and SEAICE_ALLOW_JFNK */  #endif /* SEAICE_ALLOW_JFNK */
563    
564        RETURN        RETURN
565        END        END

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.28

  ViewVC Help
Powered by ViewVC 1.1.22