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 |
73 |
_RL JFNKresidual |
_RL JFNKresidual |
74 |
_RL JFNKresidualKm1 |
_RL JFNKresidualKm1 |
75 |
C parameters to compute convergence criterion |
C parameters to compute convergence criterion |
76 |
_RL phi_e, alp_e, JFNKgamma_lin |
_RL JFNKgamma_lin |
77 |
_RL FGMRESeps |
_RL FGMRESeps |
78 |
_RL JFNKtol |
_RL JFNKtol |
79 |
C |
C backward differences extrapolation factors |
80 |
|
_RL bdfFac, bdfAlpha |
81 |
|
C |
82 |
_RL recip_deltaT |
_RL recip_deltaT |
83 |
LOGICAL JFNKconverged, krylovConverged |
LOGICAL JFNKconverged, krylovConverged |
84 |
LOGICAL writeNow |
LOGICAL writeNow |
85 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
86 |
C |
|
87 |
C u/vIceRes :: residual of sea-ice momentum equations |
C u/vIceRes :: residual of sea-ice momentum equations |
88 |
_RL uIceRes(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
_RL uIceRes(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
89 |
_RL vIceRes(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
_RL vIceRes(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
90 |
C vector version of the residuals |
C extra time level required for backward difference time stepping |
91 |
_RL resTmp (nVec,1,nSx,nSy) |
_RL duIcNm1(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
92 |
|
_RL dvIcNm1(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
93 |
C du/vIce :: ice velocity increment to be added to u/vIce |
C du/vIce :: ice velocity increment to be added to u/vIce |
94 |
_RL duIce (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
_RL duIce (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
95 |
_RL dvIce (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
_RL dvIce (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
96 |
C precomputed (= constant per Newton iteration) versions of |
C precomputed (= constant per Newton iteration) versions of |
97 |
C zeta, eta, and DWATN, press |
C zeta, eta, and DWATN, press |
98 |
_RL zetaPre (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
_RL zetaPre (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
99 |
_RL etaPre (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
_RL etaPre (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
118 |
& DIFFERENT_MULTIPLE( SEAICE_monFreq, myTime, deltaTClock ) ) |
& DIFFERENT_MULTIPLE( SEAICE_monFreq, myTime, deltaTClock ) ) |
119 |
& iOutFGMRES=1 |
& iOutFGMRES=1 |
120 |
|
|
121 |
C |
C backward difference extrapolation factors |
122 |
|
bdfFac = 0. _d 0 |
123 |
|
IF ( SEAICEuseBDF2 ) THEN |
124 |
|
IF ( myIter.EQ.nIter0 .AND. SEAICEmomStartBDF.EQ.0 ) THEN |
125 |
|
bdfFac = 0. _d 0 |
126 |
|
ELSE |
127 |
|
bdfFac = 0.5 _d 0 |
128 |
|
ENDIF |
129 |
|
ENDIF |
130 |
|
bdfAlpha = 1. _d 0 + bdfFac |
131 |
|
|
132 |
DO bj=myByLo(myThid),myByHi(myThid) |
DO bj=myByLo(myThid),myByHi(myThid) |
133 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
DO bi=myBxLo(myThid),myBxHi(myThid) |
134 |
DO J=1-Oly,sNy+Oly |
DO J=1-OLy,sNy+OLy |
135 |
DO I=1-Olx,sNx+Olx |
DO I=1-OLx,sNx+OLx |
136 |
uIceRes(I,J,bi,bj) = 0. _d 0 |
uIceRes(I,J,bi,bj) = 0. _d 0 |
137 |
vIceRes(I,J,bi,bj) = 0. _d 0 |
vIceRes(I,J,bi,bj) = 0. _d 0 |
138 |
duIce (I,J,bi,bj) = 0. _d 0 |
duIce (I,J,bi,bj) = 0. _d 0 |
139 |
dvIce (I,J,bi,bj) = 0. _d 0 |
dvIce (I,J,bi,bj) = 0. _d 0 |
140 |
|
ENDDO |
141 |
|
ENDDO |
142 |
|
C cycle ice velocities |
143 |
|
DO J=1-OLy,sNy+OLy |
144 |
|
DO I=1-OLx,sNx+OLx |
145 |
|
duIcNm1(I,J,bi,bj) = uIce(I,J,bi,bj) * bdfAlpha |
146 |
|
& + ( uIce(I,J,bi,bj) - uIceNm1(I,J,bi,bj) ) * bdfFac |
147 |
|
dvIcNm1(I,J,bi,bj) = vIce(I,J,bi,bj) * bdfAlpha |
148 |
|
& + ( vIce(I,J,bi,bj) - vIceNm1(I,J,bi,bj) ) * bdfFac |
149 |
uIceNm1(I,J,bi,bj) = uIce(I,J,bi,bj) |
uIceNm1(I,J,bi,bj) = uIce(I,J,bi,bj) |
150 |
vIceNm1(I,J,bi,bj) = vIce(I,J,bi,bj) |
vIceNm1(I,J,bi,bj) = vIce(I,J,bi,bj) |
151 |
ENDDO |
ENDDO |
152 |
ENDDO |
ENDDO |
153 |
|
C As long as IMEX is not properly implemented leave this commented out |
154 |
|
CML IF ( .NOT.SEAICEuseIMEX ) THEN |
155 |
C Compute things that do no change during the Newton iteration: |
C Compute things that do no change during the Newton iteration: |
156 |
C sea-surface tilt and wind stress: |
C sea-surface tilt and wind stress: |
157 |
C FORCEX/Y0 - mass*(u/vIceNm1)/deltaT |
C FORCEX/Y0 - mass*(1.5*u/vIceNm1+0.5*(u/vIceNm1-u/vIceNm2))/deltaT |
158 |
DO J=1-Oly,sNy+Oly |
DO J=1-OLy,sNy+OLy |
159 |
DO I=1-Olx,sNx+Olx |
DO I=1-OLx,sNx+OLx |
160 |
FORCEX(I,J,bi,bj) = FORCEX0(I,J,bi,bj) |
FORCEX(I,J,bi,bj) = FORCEX0(I,J,bi,bj) |
161 |
& + seaiceMassU(I,J,bi,bj)*uIceNm1(I,J,bi,bj)*recip_deltaT |
& + seaiceMassU(I,J,bi,bj)*duIcNm1(I,J,bi,bj)*recip_deltaT |
162 |
FORCEY(I,J,bi,bj) = FORCEY0(I,J,bi,bj) |
FORCEY(I,J,bi,bj) = FORCEY0(I,J,bi,bj) |
163 |
& + seaiceMassV(I,J,bi,bj)*vIceNm1(I,J,bi,bj)*recip_deltaT |
& + seaiceMassV(I,J,bi,bj)*dvIcNm1(I,J,bi,bj)*recip_deltaT |
164 |
ENDDO |
ENDDO |
165 |
ENDDO |
ENDDO |
166 |
|
CML ENDIF |
167 |
ENDDO |
ENDDO |
168 |
ENDDO |
ENDDO |
169 |
C Start nonlinear Newton iteration: outer loop iteration |
C Start nonlinear Newton iteration: outer loop iteration |
172 |
newtonIter = newtonIter + 1 |
newtonIter = newtonIter + 1 |
173 |
C Compute initial residual F(u), (includes computation of global |
C Compute initial residual F(u), (includes computation of global |
174 |
C variables DWATN, zeta, and eta) |
C variables DWATN, zeta, and eta) |
175 |
IF ( newtonIter .EQ. 1 ) CALL SEAICE_JFNK_UPDATE( |
IF ( newtonIter .EQ. 1 ) CALL SEAICE_JFNK_UPDATE( |
176 |
I duIce, dvIce, |
I duIce, dvIce, |
177 |
U uIce, vIce, JFNKresidual, |
U uIce, vIce, JFNKresidual, |
178 |
O uIceRes, vIceRes, |
O uIceRes, vIceRes, |
179 |
I newtonIter, myTime, myIter, myThid ) |
I newtonIter, myTime, myIter, myThid ) |
181 |
C constant for the preconditioner |
C constant for the preconditioner |
182 |
DO bj=myByLo(myThid),myByHi(myThid) |
DO bj=myByLo(myThid),myByHi(myThid) |
183 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
DO bi=myBxLo(myThid),myBxHi(myThid) |
184 |
DO j=1-Oly,sNy+Oly |
DO j=1-OLy,sNy+OLy |
185 |
DO i=1-Olx,sNx+Olx |
DO i=1-OLx,sNx+OLx |
186 |
zetaPre(I,J,bi,bj) = zeta(I,J,bi,bj) |
zetaPre(I,J,bi,bj) = zeta(I,J,bi,bj) |
187 |
etaPre(I,J,bi,bj) = eta(I,J,bi,bj) |
etaPre(I,J,bi,bj) = eta(I,J,bi,bj) |
188 |
etaZPre(I,J,bi,bj) = etaZ(I,J,bi,bj) |
etaZPre(I,J,bi,bj) = etaZ(I,J,bi,bj) |
193 |
ENDDO |
ENDDO |
194 |
C compute convergence criterion for linear preconditioned FGMRES |
C compute convergence criterion for linear preconditioned FGMRES |
195 |
JFNKgamma_lin = JFNKgamma_lin_max |
JFNKgamma_lin = JFNKgamma_lin_max |
196 |
IF ( newtonIter.GT.1.AND.newtonIter.LE.100 |
IF ( newtonIter.GT.1.AND.newtonIter.LE.SEAICE_JFNK_tolIter |
197 |
& .AND.JFNKresidual.LT.JFNKres_t ) THEN |
& .AND.JFNKresidual.LT.JFNKres_t ) THEN |
198 |
C Eisenstat, 1996, equ.(2.6) |
C Eisenstat and Walker (1996), eq.(2.6) |
199 |
phi_e = 1. _d 0 |
JFNKgamma_lin = SEAICE_JFNKphi |
200 |
alp_e = 1. _d 0 |
& *( JFNKresidual/JFNKresidualKm1 )**SEAICE_JFNKalpha |
|
JFNKgamma_lin = phi_e*( JFNKresidual/JFNKresidualKm1 )**alp_e |
|
201 |
JFNKgamma_lin = min(JFNKgamma_lin_max, JFNKgamma_lin) |
JFNKgamma_lin = min(JFNKgamma_lin_max, JFNKgamma_lin) |
202 |
JFNKgamma_lin = max(JFNKgamma_lin_min, JFNKgamma_lin) |
JFNKgamma_lin = max(JFNKgamma_lin_min, JFNKgamma_lin) |
203 |
ENDIF |
ENDIF |
204 |
C save the residual for the next iteration |
C save the residual for the next iteration |
205 |
JFNKresidualKm1 = JFNKresidual |
JFNKresidualKm1 = JFNKresidual |
206 |
C |
|
207 |
C The Krylov iteration using FGMRES, the preconditioner is LSOR |
C The Krylov iteration using FGMRES, the preconditioner is LSOR |
208 |
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 |
209 |
C down. |
C down. |
211 |
C in that routine |
C in that routine |
212 |
krylovIter = 0 |
krylovIter = 0 |
213 |
iCode = 0 |
iCode = 0 |
214 |
C |
|
215 |
JFNKconverged = JFNKresidual.LT.JFNKtol |
JFNKconverged = JFNKresidual.LT.JFNKtol |
216 |
C |
|
217 |
C do Krylov loop only if convergence is not reached |
C do Krylov loop only if convergence is not reached |
218 |
C |
|
219 |
IF ( .NOT.JFNKconverged ) THEN |
IF ( .NOT.JFNKconverged ) THEN |
220 |
C |
|
221 |
C start Krylov iteration (FGMRES) |
C start Krylov iteration (FGMRES) |
222 |
C |
|
223 |
krylovConverged = .FALSE. |
krylovConverged = .FALSE. |
224 |
FGMRESeps = JFNKgamma_lin * JFNKresidual |
FGMRESeps = JFNKgamma_lin * JFNKresidual |
225 |
DO WHILE ( .NOT.krylovConverged ) |
DO WHILE ( .NOT.krylovConverged ) |
226 |
C solution vector sol = du/vIce |
C solution vector sol = du/vIce |
227 |
C residual vector (rhs) Fu = u/vIceRes |
C residual vector (rhs) Fu = u/vIceRes |
228 |
C output work vectors wk1, -> input work vector wk2 |
C output work vectors wk1, -> input work vector wk2 |
229 |
C |
|
230 |
CALL SEAICE_FGMRES_DRIVER( |
CALL SEAICE_FGMRES_DRIVER( |
231 |
I uIceRes, vIceRes, |
I uIceRes, vIceRes, |
232 |
U duIce, dvIce, iCode, |
U duIce, dvIce, iCode, |
233 |
I FGMRESeps, iOutFGMRES, |
I FGMRESeps, iOutFGMRES, |
234 |
I newtonIter, krylovIter, myTime, myIter, myThid ) |
I newtonIter, krylovIter, myTime, myIter, myThid ) |
236 |
C or product of matrix (Jacobian) times vector. For iCode = 0, terminate |
C or product of matrix (Jacobian) times vector. For iCode = 0, terminate |
237 |
C iteration |
C iteration |
238 |
IF (iCode.EQ.1) THEN |
IF (iCode.EQ.1) THEN |
239 |
C Call preconditioner |
C Call preconditioner |
240 |
IF ( SOLV_MAX_ITERS .GT. 0 ) |
IF ( SOLV_MAX_ITERS .GT. 0 ) |
241 |
& CALL SEAICE_PRECONDITIONER( |
& CALL SEAICE_PRECONDITIONER( |
242 |
U duIce, dvIce, |
U duIce, dvIce, |
243 |
I zetaPre, etaPre, etaZpre, dwatPre, |
I zetaPre, etaPre, etaZpre, dwatPre, |
244 |
I newtonIter, krylovIter, myTime, myIter, myThid ) |
I newtonIter, krylovIter, myTime, myIter, myThid ) |
245 |
ELSEIF (iCode.GE.2) THEN |
ELSEIF (iCode.GE.2) THEN |
246 |
C Compute Jacobian times vector |
C Compute Jacobian times vector |
247 |
CALL SEAICE_JACVEC( |
CALL SEAICE_JACVEC( |
248 |
I uIce, vIce, uIceRes, vIceRes, |
I uIce, vIce, uIceRes, vIceRes, |
249 |
U duIce, dvIce, |
U duIce, dvIce, |
250 |
I newtonIter, krylovIter, myTime, myIter, myThid ) |
I newtonIter, krylovIter, myTime, myIter, myThid ) |
251 |
ENDIF |
ENDIF |
252 |
krylovConverged = iCode.EQ.0 |
krylovConverged = iCode.EQ.0 |
256 |
C some output diagnostics |
C some output diagnostics |
257 |
IF ( debugLevel.GE.debLevA ) THEN |
IF ( debugLevel.GE.debLevA ) THEN |
258 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
259 |
totalNewtonItersLoc = |
totalNewtonItersLoc = |
260 |
& SEAICEnewtonIterMax*(myIter-nIter0)+newtonIter |
& SEAICEnewtonIterMax*(myIter-nIter0)+newtonIter |
261 |
WRITE(msgBuf,'(2A,2(1XI6),2E12.5)') |
WRITE(msgBuf,'(2A,2(1XI6),2E12.5)') |
262 |
& ' S/R SEAICE_JFNK: Newton iterate / total, ', |
& ' S/R SEAICE_JFNK: Newton iterate / total, ', |
263 |
& 'JFNKgamma_lin, initial norm = ', |
& 'JFNKgamma_lin, initial norm = ', |
264 |
& newtonIter, totalNewtonItersLoc, |
& newtonIter, totalNewtonItersLoc, |
266 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
267 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
268 |
WRITE(msgBuf,'(3(A,I6))') |
WRITE(msgBuf,'(3(A,I6))') |
269 |
& ' S/R SEAICE_JFNK: Newton iterate / total = ',newtonIter, |
& ' S/R SEAICE_JFNK: Newton iterate / total = ',newtonIter, |
270 |
& ' / ', totalNewtonItersLoc, |
& ' / ', totalNewtonItersLoc, |
271 |
& ', Nb. of FGMRES iterations = ', krylovIter |
& ', Nb. of FGMRES iterations = ', krylovIter |
272 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
276 |
IF ( krylovIter.EQ.SEAICEkrylovIterMax ) THEN |
IF ( krylovIter.EQ.SEAICEkrylovIterMax ) THEN |
277 |
krylovFails = krylovFails + 1 |
krylovFails = krylovFails + 1 |
278 |
ENDIF |
ENDIF |
279 |
C Set the stopping criterion for the Newton iteration |
C Set the stopping criterion for the Newton iteration and the |
280 |
IF ( newtonIter .EQ. 1 ) JFNKtol=JFNKgamma_nonlin*JFNKresidual |
C criterion for the transition from accurate to approximate FGMRES |
281 |
|
IF ( newtonIter .EQ. 1 ) THEN |
282 |
|
JFNKtol=JFNKgamma_nonlin*JFNKresidual |
283 |
|
IF ( JFNKres_tFac .NE. UNSET_RL ) |
284 |
|
& JFNKres_t = JFNKresidual * JFNKres_tFac |
285 |
|
ENDIF |
286 |
C Update linear solution vector and return to Newton iteration |
C Update linear solution vector and return to Newton iteration |
287 |
C Do a linesearch if necessary, and compute a new residual. |
C Do a linesearch if necessary, and compute a new residual. |
288 |
C Note that it should be possible to do the following operations |
C Note that it should be possible to do the following operations |
289 |
C at the beginning of the Newton iteration, thereby saving us from |
C at the beginning of the Newton iteration, thereby saving us from |
290 |
C the extra call of seaice_jfnk_update, but unfortunately that |
C the extra call of seaice_jfnk_update, but unfortunately that |
291 |
C changes the results, so we leave the stuff here for now. |
C changes the results, so we leave the stuff here for now. |
292 |
CALL SEAICE_JFNK_UPDATE( |
CALL SEAICE_JFNK_UPDATE( |
293 |
I duIce, dvIce, |
I duIce, dvIce, |
294 |
U uIce, vIce, JFNKresidual, |
U uIce, vIce, JFNKresidual, |
295 |
O uIceRes, vIceRes, |
O uIceRes, vIceRes, |
296 |
I newtonIter, myTime, myIter, myThid ) |
I newtonIter, myTime, myIter, myThid ) |
297 |
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 |
298 |
DO bj=myByLo(myThid),myByHi(myThid) |
DO bj=myByLo(myThid),myByHi(myThid) |
299 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
DO bi=myBxLo(myThid),myBxHi(myThid) |
300 |
DO J=1-Oly,sNy+Oly |
DO J=1-OLy,sNy+OLy |
301 |
DO I=1-Olx,sNx+Olx |
DO I=1-OLx,sNx+OLx |
302 |
duIce(I,J,bi,bj)= 0. _d 0 |
duIce(I,J,bi,bj)= 0. _d 0 |
303 |
dvIce(I,J,bi,bj)= 0. _d 0 |
dvIce(I,J,bi,bj)= 0. _d 0 |
304 |
ENDDO |
ENDDO |
308 |
ENDIF |
ENDIF |
309 |
C end of Newton iterate |
C end of Newton iterate |
310 |
ENDDO |
ENDDO |
311 |
C |
|
312 |
C-- Output diagnostics |
C-- Output diagnostics |
313 |
C |
|
314 |
IF ( SEAICE_monFreq .GT. 0. _d 0 ) THEN |
IF ( SEAICE_monFreq .GT. 0. _d 0 ) THEN |
315 |
C Count iterations |
C Count iterations |
316 |
totalJFNKtimeSteps = totalJFNKtimeSteps + 1 |
totalJFNKtimeSteps = totalJFNKtimeSteps + 1 |
319 |
C Record failure |
C Record failure |
320 |
totalKrylovFails = totalKrylovFails + krylovFails |
totalKrylovFails = totalKrylovFails + krylovFails |
321 |
IF ( newtonIter .EQ. SEAICEnewtonIterMax ) THEN |
IF ( newtonIter .EQ. SEAICEnewtonIterMax ) THEN |
322 |
totalNewtonFails = totalNewtonFails + 1 |
totalNewtonFails = totalNewtonFails + 1 |
323 |
ENDIF |
ENDIF |
324 |
ENDIF |
ENDIF |
325 |
C Decide whether it is time to dump and reset the counter |
C Decide whether it is time to dump and reset the counter |
326 |
writeNow = DIFFERENT_MULTIPLE(SEAICE_monFreq, |
writeNow = DIFFERENT_MULTIPLE(SEAICE_monFreq, |
327 |
& myTime+deltaTClock, deltaTClock) |
& myTime+deltaTClock, deltaTClock) |
328 |
#ifdef ALLOW_CAL |
#ifdef ALLOW_CAL |
329 |
IF ( useCAL ) THEN |
IF ( useCAL ) THEN |
330 |
CALL CAL_TIME2DUMP( |
CALL CAL_TIME2DUMP( |
331 |
I zeroRL, SEAICE_monFreq, deltaTClock, |
I zeroRL, SEAICE_monFreq, deltaTClock, |
332 |
U writeNow, |
U writeNow, |
333 |
I myTime+deltaTclock, myIter+1, myThid ) |
I myTime+deltaTclock, myIter+1, myThid ) |
335 |
#endif |
#endif |
336 |
IF ( writeNow ) THEN |
IF ( writeNow ) THEN |
337 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
338 |
WRITE(msgBuf,'(A)') |
WRITE(msgBuf,'(A)') |
339 |
&' // =======================================================' |
&' // =======================================================' |
340 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
341 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
342 |
WRITE(msgBuf,'(A)') ' // Begin JFNK statistics' |
WRITE(msgBuf,'(A)') ' // Begin JFNK statistics' |
343 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
344 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
345 |
WRITE(msgBuf,'(A)') |
WRITE(msgBuf,'(A)') |
346 |
&' // =======================================================' |
&' // =======================================================' |
347 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
348 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
349 |
WRITE(msgBuf,'(A,I10)') |
WRITE(msgBuf,'(A,I10)') |
350 |
& ' %JFNK_MON: time step = ', myIter+1 |
& ' %JFNK_MON: time step = ', myIter+1 |
351 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
352 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
353 |
WRITE(msgBuf,'(A,I10)') |
WRITE(msgBuf,'(A,I10)') |
354 |
& ' %JFNK_MON: Nb. of time steps = ', totalJFNKtimeSteps |
& ' %JFNK_MON: Nb. of time steps = ', totalJFNKtimeSteps |
355 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
356 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
357 |
WRITE(msgBuf,'(A,I10)') |
WRITE(msgBuf,'(A,I10)') |
358 |
& ' %JFNK_MON: Nb. of Newton steps = ', totalNewtonIters |
& ' %JFNK_MON: Nb. of Newton steps = ', totalNewtonIters |
359 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
360 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
361 |
WRITE(msgBuf,'(A,I10)') |
WRITE(msgBuf,'(A,I10)') |
362 |
& ' %JFNK_MON: Nb. of Krylov steps = ', totalKrylovIters |
& ' %JFNK_MON: Nb. of Krylov steps = ', totalKrylovIters |
363 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
364 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
365 |
WRITE(msgBuf,'(A,I10)') |
WRITE(msgBuf,'(A,I10)') |
366 |
& ' %JFNK_MON: Nb. of Newton failures = ', totalNewtonFails |
& ' %JFNK_MON: Nb. of Newton failures = ', totalNewtonFails |
367 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
368 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
369 |
WRITE(msgBuf,'(A,I10)') |
WRITE(msgBuf,'(A,I10)') |
370 |
& ' %JFNK_MON: Nb. of Krylov failures = ', totalKrylovFails |
& ' %JFNK_MON: Nb. of Krylov failures = ', totalKrylovFails |
371 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
372 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
373 |
WRITE(msgBuf,'(A)') |
WRITE(msgBuf,'(A)') |
374 |
&' // =======================================================' |
&' // =======================================================' |
375 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
376 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
377 |
WRITE(msgBuf,'(A)') ' // End JFNK statistics' |
WRITE(msgBuf,'(A)') ' // End JFNK statistics' |
378 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
379 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
380 |
WRITE(msgBuf,'(A)') |
WRITE(msgBuf,'(A)') |
381 |
&' // =======================================================' |
&' // =======================================================' |
382 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
383 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
394 |
IF ( debugLevel.GE.debLevA ) THEN |
IF ( debugLevel.GE.debLevA ) THEN |
395 |
IF ( newtonIter .EQ. SEAICEnewtonIterMax ) THEN |
IF ( newtonIter .EQ. SEAICEnewtonIterMax ) THEN |
396 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
397 |
WRITE(msgBuf,'(A,I10)') |
WRITE(msgBuf,'(A,I10)') |
398 |
& ' S/R SEAICE_JFNK: JFNK did not converge in timestep ', |
& ' S/R SEAICE_JFNK: JFNK did not converge in timestep ', |
399 |
& myIter+1 |
& myIter+1 |
400 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
403 |
ENDIF |
ENDIF |
404 |
IF ( krylovFails .GT. 0 ) THEN |
IF ( krylovFails .GT. 0 ) THEN |
405 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
406 |
WRITE(msgBuf,'(A,I4,A,I10)') |
WRITE(msgBuf,'(A,I4,A,I10)') |
407 |
& ' S/R SEAICE_JFNK: FGMRES did not converge ', |
& ' S/R SEAICE_JFNK: FGMRES did not converge ', |
408 |
& krylovFails, ' times in timestep ', myIter+1 |
& krylovFails, ' times in timestep ', myIter+1 |
409 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
411 |
_END_MASTER( myThid ) |
_END_MASTER( myThid ) |
412 |
ENDIF |
ENDIF |
413 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
414 |
WRITE(msgBuf,'(A,I6,A,I10)') |
WRITE(msgBuf,'(A,I6,A,I10)') |
415 |
& ' S/R SEAICE_JFNK: Total number FGMRES iterations = ', |
& ' S/R SEAICE_JFNK: Total number FGMRES iterations = ', |
416 |
& totalKrylovItersLoc, ' in timestep ', myIter+1 |
& totalKrylovItersLoc, ' in timestep ', myIter+1 |
417 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
427 |
C !ROUTINE: SEAICE_JFNK_UPDATE |
C !ROUTINE: SEAICE_JFNK_UPDATE |
428 |
C !INTERFACE: |
C !INTERFACE: |
429 |
|
|
430 |
SUBROUTINE SEAICE_JFNK_UPDATE( |
SUBROUTINE SEAICE_JFNK_UPDATE( |
431 |
I duIce, dvIce, |
I duIce, dvIce, |
432 |
U uIce, vIce, JFNKresidual, |
U uIce, vIce, JFNKresidual, |
433 |
O uIceRes, vIceRes, |
O uIceRes, vIceRes, |
434 |
I newtonIter, myTime, myIter, myThid ) |
I newtonIter, myTime, myIter, myThid ) |
487 |
_RL resLoc, facLS |
_RL resLoc, facLS |
488 |
LOGICAL doLineSearch |
LOGICAL doLineSearch |
489 |
C nVec :: size of the input vector(s) |
C nVec :: size of the input vector(s) |
490 |
C vector version of the residuals |
C resTmp :: vector version of the residuals |
491 |
INTEGER nVec |
INTEGER nVec |
492 |
PARAMETER ( nVec = 2*sNx*sNy ) |
PARAMETER ( nVec = 2*sNx*sNy ) |
493 |
_RL resTmp (nVec,1,nSx,nSy) |
_RL resTmp (nVec,1,nSx,nSy) |
494 |
C |
|
495 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
496 |
CEOP |
CEOP |
497 |
|
|
501 |
facLS = 1. _d 0 |
facLS = 1. _d 0 |
502 |
doLineSearch = .TRUE. |
doLineSearch = .TRUE. |
503 |
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 |
|
504 |
C Create update |
C Create update |
505 |
DO bj=myByLo(myThid),myByHi(myThid) |
DO bj=myByLo(myThid),myByHi(myThid) |
506 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
DO bi=myBxLo(myThid),myBxHi(myThid) |
507 |
DO J=1-Oly,sNy+Oly |
DO J=1-OLy,sNy+OLy |
508 |
DO I=1-Olx,sNx+Olx |
DO I=1-OLx,sNx+OLx |
509 |
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) |
510 |
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) |
511 |
ENDDO |
ENDDO |
514 |
ENDDO |
ENDDO |
515 |
C Compute current residual F(u), (includes re-computation of global |
C Compute current residual F(u), (includes re-computation of global |
516 |
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) |
517 |
CALL SEAICE_CALC_RESIDUAL( |
CALL SEAICE_CALC_RESIDUAL( |
518 |
I uIce, vIce, |
I uIce, vIce, |
519 |
O uIceRes, vIceRes, |
O uIceRes, vIceRes, |
520 |
I newtonIter, 0, myTime, myIter, myThid ) |
I newtonIter, 0, myTime, myIter, myThid ) |
521 |
C Important: Compute the norm of the residual using the same scalar |
C Important: Compute the norm of the residual using the same scalar |
522 |
C product that SEAICE_FGMRES does |
C product that SEAICE_FGMRES does |
523 |
CALL SEAICE_MAP2VEC(nVec,uIceRes,vIceRes,resTmp,.TRUE.,myThid) |
CALL SEAICE_MAP2VEC(nVec,uIceRes,vIceRes,resTmp,.TRUE.,myThid) |
524 |
CALL SEAICE_SCALPROD(nVec,1,1,1,resTmp,resTmp,resLoc,myThid) |
CALL SEAICE_SCALPROD(nVec,1,1,1,resTmp,resTmp,resLoc,myThid) |
525 |
resLoc = SQRT(resLoc) |
resLoc = SQRT(resLoc) |
526 |
|
C Determine, if we need more iterations |
527 |
|
doLineSearch = resLoc .GE. JFNKresidual |
528 |
|
C Limit the maximum number of iterations arbitrarily to four |
529 |
|
doLineSearch = doLineSearch .AND. l .LT. 4 |
530 |
|
C For the first iteration du/vIce = 0 and there will be no |
531 |
|
C improvement of the residual possible, so we do only the first |
532 |
|
C iteration |
533 |
|
IF ( newtonIter .EQ. 1 ) doLineSearch = .FALSE. |
534 |
|
C Only start a linesearch after some Newton iterations |
535 |
|
IF ( newtonIter .LE. SEAICE_JFNK_lsIter ) doLineSearch = .FALSE. |
536 |
|
C Increment counter |
537 |
|
l = l + 1 |
538 |
C some output diagnostics |
C some output diagnostics |
539 |
IF ( debugLevel.GE.debLevA .AND. doLineSearch ) THEN |
IF ( debugLevel.GE.debLevA .AND. doLineSearch ) THEN |
540 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
541 |
WRITE(msgBuf,'(2A,2(1XI6),3E12.5)') |
WRITE(msgBuf,'(2A,2(1XI6),3E12.5)') |
542 |
& ' S/R SEAICE_JFNK_UPDATE: Newton iter, LSiter, ', |
& ' S/R SEAICE_JFNK_UPDATE: Newton iter, LSiter, ', |
543 |
& 'facLS, JFNKresidual, resLoc = ', |
& 'facLS, JFNKresidual, resLoc = ', |
544 |
& newtonIter, l, facLS, JFNKresidual, resLoc |
& newtonIter, l, facLS, JFNKresidual, resLoc |
554 |
C This is the new residual |
C This is the new residual |
555 |
JFNKresidual = resLoc |
JFNKresidual = resLoc |
556 |
|
|
557 |
#endif /* SEAICE_ALLOW_DYNAMICS and SEAICE_CGRID and SEAICE_ALLOW_JFNK */ |
#endif /* SEAICE_ALLOW_JFNK */ |
558 |
|
|
559 |
RETURN |
RETURN |
560 |
END |
END |