78 |
_RL phi_e, alp_e, JFNKgamma_lin |
_RL phi_e, alp_e, JFNKgamma_lin |
79 |
_RL FGMRESeps |
_RL FGMRESeps |
80 |
_RL JFNKtol |
_RL JFNKtol |
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) |
|
C vector version of the residuals |
|
|
_RL resTmp (nVec,1,nSx,nSy) |
|
90 |
C du/vIce :: ice velocity increment to be added to u/vIce |
C du/vIce :: ice velocity increment to be added to u/vIce |
91 |
_RL duIce (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
_RL duIce (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
92 |
_RL dvIce (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
_RL dvIce (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
93 |
C precomputed (= constant per Newton iteration) versions of |
C precomputed (= constant per Newton iteration) versions of |
94 |
C zeta, eta, and DWATN, press |
C zeta, eta, and DWATN, press |
95 |
_RL zetaPre (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
_RL zetaPre (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
96 |
_RL etaPre (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
_RL etaPre (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
115 |
& DIFFERENT_MULTIPLE( SEAICE_monFreq, myTime, deltaTClock ) ) |
& DIFFERENT_MULTIPLE( SEAICE_monFreq, myTime, deltaTClock ) ) |
116 |
& iOutFGMRES=1 |
& iOutFGMRES=1 |
117 |
|
|
|
C |
|
118 |
DO bj=myByLo(myThid),myByHi(myThid) |
DO bj=myByLo(myThid),myByHi(myThid) |
119 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
DO bi=myBxLo(myThid),myBxHi(myThid) |
120 |
DO J=1-Oly,sNy+Oly |
DO J=1-OLy,sNy+OLy |
121 |
DO I=1-Olx,sNx+Olx |
DO I=1-OLx,sNx+OLx |
122 |
uIceRes(I,J,bi,bj) = 0. _d 0 |
uIceRes(I,J,bi,bj) = 0. _d 0 |
123 |
vIceRes(I,J,bi,bj) = 0. _d 0 |
vIceRes(I,J,bi,bj) = 0. _d 0 |
124 |
duIce (I,J,bi,bj) = 0. _d 0 |
duIce (I,J,bi,bj) = 0. _d 0 |
128 |
ENDDO |
ENDDO |
129 |
ENDDO |
ENDDO |
130 |
C Compute things that do no change during the Newton iteration: |
C Compute things that do no change during the Newton iteration: |
131 |
C sea-surface tilt and wind stress: |
C sea-surface tilt and wind stress: |
132 |
C FORCEX/Y0 - mass*(u/vIceNm1)/deltaT |
C FORCEX/Y0 - mass*(u/vIceNm1)/deltaT |
133 |
DO J=1-Oly,sNy+Oly |
DO J=1-OLy,sNy+OLy |
134 |
DO I=1-Olx,sNx+Olx |
DO I=1-OLx,sNx+OLx |
135 |
FORCEX(I,J,bi,bj) = FORCEX0(I,J,bi,bj) |
FORCEX(I,J,bi,bj) = FORCEX0(I,J,bi,bj) |
136 |
& + seaiceMassU(I,J,bi,bj)*uIceNm1(I,J,bi,bj)*recip_deltaT |
& + seaiceMassU(I,J,bi,bj)*uIceNm1(I,J,bi,bj)*recip_deltaT |
137 |
FORCEY(I,J,bi,bj) = FORCEY0(I,J,bi,bj) |
FORCEY(I,J,bi,bj) = FORCEY0(I,J,bi,bj) |
138 |
& + seaiceMassV(I,J,bi,bj)*vIceNm1(I,J,bi,bj)*recip_deltaT |
& + seaiceMassV(I,J,bi,bj)*vIceNm1(I,J,bi,bj)*recip_deltaT |
139 |
ENDDO |
ENDDO |
140 |
ENDDO |
ENDDO |
141 |
ENDDO |
ENDDO |
146 |
newtonIter = newtonIter + 1 |
newtonIter = newtonIter + 1 |
147 |
C Compute initial residual F(u), (includes computation of global |
C Compute initial residual F(u), (includes computation of global |
148 |
C variables DWATN, zeta, and eta) |
C variables DWATN, zeta, and eta) |
149 |
IF ( newtonIter .EQ. 1 ) CALL SEAICE_JFNK_UPDATE( |
IF ( newtonIter .EQ. 1 ) CALL SEAICE_JFNK_UPDATE( |
150 |
I duIce, dvIce, |
I duIce, dvIce, |
151 |
U uIce, vIce, JFNKresidual, |
U uIce, vIce, JFNKresidual, |
152 |
O uIceRes, vIceRes, |
O uIceRes, vIceRes, |
153 |
I newtonIter, myTime, myIter, myThid ) |
I newtonIter, myTime, myIter, myThid ) |
155 |
C constant for the preconditioner |
C constant for the preconditioner |
156 |
DO bj=myByLo(myThid),myByHi(myThid) |
DO bj=myByLo(myThid),myByHi(myThid) |
157 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
DO bi=myBxLo(myThid),myBxHi(myThid) |
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 |
zetaPre(I,J,bi,bj) = zeta(I,J,bi,bj) |
zetaPre(I,J,bi,bj) = zeta(I,J,bi,bj) |
161 |
etaPre(I,J,bi,bj) = eta(I,J,bi,bj) |
etaPre(I,J,bi,bj) = eta(I,J,bi,bj) |
162 |
etaZPre(I,J,bi,bj) = etaZ(I,J,bi,bj) |
etaZPre(I,J,bi,bj) = etaZ(I,J,bi,bj) |
169 |
JFNKgamma_lin = JFNKgamma_lin_max |
JFNKgamma_lin = JFNKgamma_lin_max |
170 |
IF ( newtonIter.GT.1.AND.newtonIter.LE.SEAICE_JFNK_tolIter |
IF ( newtonIter.GT.1.AND.newtonIter.LE.SEAICE_JFNK_tolIter |
171 |
& .AND.JFNKresidual.LT.JFNKres_t ) THEN |
& .AND.JFNKresidual.LT.JFNKres_t ) THEN |
172 |
C Eisenstat, 1996, equ.(2.6) |
C Eisenstat, 1996, equ.(2.6) |
173 |
phi_e = 1. _d 0 |
phi_e = 1. _d 0 |
174 |
alp_e = 1. _d 0 |
alp_e = 1. _d 0 |
175 |
JFNKgamma_lin = phi_e*( JFNKresidual/JFNKresidualKm1 )**alp_e |
JFNKgamma_lin = phi_e*( JFNKresidual/JFNKresidualKm1 )**alp_e |
178 |
ENDIF |
ENDIF |
179 |
C save the residual for the next iteration |
C save the residual for the next iteration |
180 |
JFNKresidualKm1 = JFNKresidual |
JFNKresidualKm1 = JFNKresidual |
181 |
C |
|
182 |
C The Krylov iteration using FGMRES, the preconditioner is LSOR |
C The Krylov iteration using FGMRES, the preconditioner is LSOR |
183 |
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 |
184 |
C down. |
C down. |
186 |
C in that routine |
C in that routine |
187 |
krylovIter = 0 |
krylovIter = 0 |
188 |
iCode = 0 |
iCode = 0 |
189 |
C |
|
190 |
JFNKconverged = JFNKresidual.LT.JFNKtol |
JFNKconverged = JFNKresidual.LT.JFNKtol |
191 |
C |
|
192 |
C do Krylov loop only if convergence is not reached |
C do Krylov loop only if convergence is not reached |
193 |
C |
|
194 |
IF ( .NOT.JFNKconverged ) THEN |
IF ( .NOT.JFNKconverged ) THEN |
195 |
C |
|
196 |
C start Krylov iteration (FGMRES) |
C start Krylov iteration (FGMRES) |
197 |
C |
|
198 |
krylovConverged = .FALSE. |
krylovConverged = .FALSE. |
199 |
FGMRESeps = JFNKgamma_lin * JFNKresidual |
FGMRESeps = JFNKgamma_lin * JFNKresidual |
200 |
DO WHILE ( .NOT.krylovConverged ) |
DO WHILE ( .NOT.krylovConverged ) |
201 |
C solution vector sol = du/vIce |
C solution vector sol = du/vIce |
202 |
C residual vector (rhs) Fu = u/vIceRes |
C residual vector (rhs) Fu = u/vIceRes |
203 |
C output work vectors wk1, -> input work vector wk2 |
C output work vectors wk1, -> input work vector wk2 |
204 |
C |
|
205 |
CALL SEAICE_FGMRES_DRIVER( |
CALL SEAICE_FGMRES_DRIVER( |
206 |
I uIceRes, vIceRes, |
I uIceRes, vIceRes, |
207 |
U duIce, dvIce, iCode, |
U duIce, dvIce, iCode, |
208 |
I FGMRESeps, iOutFGMRES, |
I FGMRESeps, iOutFGMRES, |
209 |
I newtonIter, krylovIter, myTime, myIter, myThid ) |
I newtonIter, krylovIter, myTime, myIter, myThid ) |
211 |
C or product of matrix (Jacobian) times vector. For iCode = 0, terminate |
C or product of matrix (Jacobian) times vector. For iCode = 0, terminate |
212 |
C iteration |
C iteration |
213 |
IF (iCode.EQ.1) THEN |
IF (iCode.EQ.1) THEN |
214 |
C Call preconditioner |
C Call preconditioner |
215 |
IF ( SOLV_MAX_ITERS .GT. 0 ) |
IF ( SOLV_MAX_ITERS .GT. 0 ) |
216 |
& CALL SEAICE_PRECONDITIONER( |
& CALL SEAICE_PRECONDITIONER( |
217 |
U duIce, dvIce, |
U duIce, dvIce, |
218 |
I zetaPre, etaPre, etaZpre, dwatPre, |
I zetaPre, etaPre, etaZpre, dwatPre, |
219 |
I newtonIter, krylovIter, myTime, myIter, myThid ) |
I newtonIter, krylovIter, myTime, myIter, myThid ) |
220 |
ELSEIF (iCode.GE.2) THEN |
ELSEIF (iCode.GE.2) THEN |
221 |
C Compute Jacobian times vector |
C Compute Jacobian times vector |
222 |
CALL SEAICE_JACVEC( |
CALL SEAICE_JACVEC( |
223 |
I uIce, vIce, uIceRes, vIceRes, |
I uIce, vIce, uIceRes, vIceRes, |
224 |
U duIce, dvIce, |
U duIce, dvIce, |
225 |
I newtonIter, krylovIter, myTime, myIter, myThid ) |
I newtonIter, krylovIter, myTime, myIter, myThid ) |
226 |
ENDIF |
ENDIF |
227 |
krylovConverged = iCode.EQ.0 |
krylovConverged = iCode.EQ.0 |
231 |
C some output diagnostics |
C some output diagnostics |
232 |
IF ( debugLevel.GE.debLevA ) THEN |
IF ( debugLevel.GE.debLevA ) THEN |
233 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
234 |
totalNewtonItersLoc = |
totalNewtonItersLoc = |
235 |
& SEAICEnewtonIterMax*(myIter-nIter0)+newtonIter |
& SEAICEnewtonIterMax*(myIter-nIter0)+newtonIter |
236 |
WRITE(msgBuf,'(2A,2(1XI6),2E12.5)') |
WRITE(msgBuf,'(2A,2(1XI6),2E12.5)') |
237 |
& ' S/R SEAICE_JFNK: Newton iterate / total, ', |
& ' S/R SEAICE_JFNK: Newton iterate / total, ', |
238 |
& 'JFNKgamma_lin, initial norm = ', |
& 'JFNKgamma_lin, initial norm = ', |
239 |
& newtonIter, totalNewtonItersLoc, |
& newtonIter, totalNewtonItersLoc, |
241 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
242 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
243 |
WRITE(msgBuf,'(3(A,I6))') |
WRITE(msgBuf,'(3(A,I6))') |
244 |
& ' S/R SEAICE_JFNK: Newton iterate / total = ',newtonIter, |
& ' S/R SEAICE_JFNK: Newton iterate / total = ',newtonIter, |
245 |
& ' / ', totalNewtonItersLoc, |
& ' / ', totalNewtonItersLoc, |
246 |
& ', Nb. of FGMRES iterations = ', krylovIter |
& ', Nb. of FGMRES iterations = ', krylovIter |
247 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
264 |
C at the beginning of the Newton iteration, thereby saving us from |
C at the beginning of the Newton iteration, thereby saving us from |
265 |
C the extra call of seaice_jfnk_update, but unfortunately that |
C the extra call of seaice_jfnk_update, but unfortunately that |
266 |
C changes the results, so we leave the stuff here for now. |
C changes the results, so we leave the stuff here for now. |
267 |
CALL SEAICE_JFNK_UPDATE( |
CALL SEAICE_JFNK_UPDATE( |
268 |
I duIce, dvIce, |
I duIce, dvIce, |
269 |
U uIce, vIce, JFNKresidual, |
U uIce, vIce, JFNKresidual, |
270 |
O uIceRes, vIceRes, |
O uIceRes, vIceRes, |
271 |
I newtonIter, myTime, myIter, myThid ) |
I newtonIter, myTime, myIter, myThid ) |
272 |
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 |
273 |
DO bj=myByLo(myThid),myByHi(myThid) |
DO bj=myByLo(myThid),myByHi(myThid) |
274 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
DO bi=myBxLo(myThid),myBxHi(myThid) |
275 |
DO J=1-Oly,sNy+Oly |
DO J=1-OLy,sNy+OLy |
276 |
DO I=1-Olx,sNx+Olx |
DO I=1-OLx,sNx+OLx |
277 |
duIce(I,J,bi,bj)= 0. _d 0 |
duIce(I,J,bi,bj)= 0. _d 0 |
278 |
dvIce(I,J,bi,bj)= 0. _d 0 |
dvIce(I,J,bi,bj)= 0. _d 0 |
279 |
ENDDO |
ENDDO |
283 |
ENDIF |
ENDIF |
284 |
C end of Newton iterate |
C end of Newton iterate |
285 |
ENDDO |
ENDDO |
286 |
C |
|
287 |
C-- Output diagnostics |
C-- Output diagnostics |
288 |
C |
|
289 |
IF ( SEAICE_monFreq .GT. 0. _d 0 ) THEN |
IF ( SEAICE_monFreq .GT. 0. _d 0 ) THEN |
290 |
C Count iterations |
C Count iterations |
291 |
totalJFNKtimeSteps = totalJFNKtimeSteps + 1 |
totalJFNKtimeSteps = totalJFNKtimeSteps + 1 |
294 |
C Record failure |
C Record failure |
295 |
totalKrylovFails = totalKrylovFails + krylovFails |
totalKrylovFails = totalKrylovFails + krylovFails |
296 |
IF ( newtonIter .EQ. SEAICEnewtonIterMax ) THEN |
IF ( newtonIter .EQ. SEAICEnewtonIterMax ) THEN |
297 |
totalNewtonFails = totalNewtonFails + 1 |
totalNewtonFails = totalNewtonFails + 1 |
298 |
ENDIF |
ENDIF |
299 |
ENDIF |
ENDIF |
300 |
C Decide whether it is time to dump and reset the counter |
C Decide whether it is time to dump and reset the counter |
301 |
writeNow = DIFFERENT_MULTIPLE(SEAICE_monFreq, |
writeNow = DIFFERENT_MULTIPLE(SEAICE_monFreq, |
302 |
& myTime+deltaTClock, deltaTClock) |
& myTime+deltaTClock, deltaTClock) |
303 |
#ifdef ALLOW_CAL |
#ifdef ALLOW_CAL |
304 |
IF ( useCAL ) THEN |
IF ( useCAL ) THEN |
305 |
CALL CAL_TIME2DUMP( |
CALL CAL_TIME2DUMP( |
306 |
I zeroRL, SEAICE_monFreq, deltaTClock, |
I zeroRL, SEAICE_monFreq, deltaTClock, |
307 |
U writeNow, |
U writeNow, |
308 |
I myTime+deltaTclock, myIter+1, myThid ) |
I myTime+deltaTclock, myIter+1, myThid ) |
310 |
#endif |
#endif |
311 |
IF ( writeNow ) THEN |
IF ( writeNow ) THEN |
312 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
313 |
WRITE(msgBuf,'(A)') |
WRITE(msgBuf,'(A)') |
314 |
&' // =======================================================' |
&' // =======================================================' |
315 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
316 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
317 |
WRITE(msgBuf,'(A)') ' // Begin JFNK statistics' |
WRITE(msgBuf,'(A)') ' // Begin JFNK statistics' |
318 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
319 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
320 |
WRITE(msgBuf,'(A)') |
WRITE(msgBuf,'(A)') |
321 |
&' // =======================================================' |
&' // =======================================================' |
322 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
323 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
324 |
WRITE(msgBuf,'(A,I10)') |
WRITE(msgBuf,'(A,I10)') |
325 |
& ' %JFNK_MON: time step = ', myIter+1 |
& ' %JFNK_MON: time step = ', myIter+1 |
326 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
327 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
328 |
WRITE(msgBuf,'(A,I10)') |
WRITE(msgBuf,'(A,I10)') |
329 |
& ' %JFNK_MON: Nb. of time steps = ', totalJFNKtimeSteps |
& ' %JFNK_MON: Nb. of time steps = ', totalJFNKtimeSteps |
330 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
331 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
332 |
WRITE(msgBuf,'(A,I10)') |
WRITE(msgBuf,'(A,I10)') |
333 |
& ' %JFNK_MON: Nb. of Newton steps = ', totalNewtonIters |
& ' %JFNK_MON: Nb. of Newton steps = ', totalNewtonIters |
334 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
335 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
336 |
WRITE(msgBuf,'(A,I10)') |
WRITE(msgBuf,'(A,I10)') |
337 |
& ' %JFNK_MON: Nb. of Krylov steps = ', totalKrylovIters |
& ' %JFNK_MON: Nb. of Krylov steps = ', totalKrylovIters |
338 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
339 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
340 |
WRITE(msgBuf,'(A,I10)') |
WRITE(msgBuf,'(A,I10)') |
341 |
& ' %JFNK_MON: Nb. of Newton failures = ', totalNewtonFails |
& ' %JFNK_MON: Nb. of Newton failures = ', totalNewtonFails |
342 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
343 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
344 |
WRITE(msgBuf,'(A,I10)') |
WRITE(msgBuf,'(A,I10)') |
345 |
& ' %JFNK_MON: Nb. of Krylov failures = ', totalKrylovFails |
& ' %JFNK_MON: Nb. of Krylov failures = ', totalKrylovFails |
346 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
347 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
348 |
WRITE(msgBuf,'(A)') |
WRITE(msgBuf,'(A)') |
349 |
&' // =======================================================' |
&' // =======================================================' |
350 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
351 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
352 |
WRITE(msgBuf,'(A)') ' // End JFNK statistics' |
WRITE(msgBuf,'(A)') ' // End JFNK statistics' |
353 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
354 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
355 |
WRITE(msgBuf,'(A)') |
WRITE(msgBuf,'(A)') |
356 |
&' // =======================================================' |
&' // =======================================================' |
357 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
358 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
369 |
IF ( debugLevel.GE.debLevA ) THEN |
IF ( debugLevel.GE.debLevA ) THEN |
370 |
IF ( newtonIter .EQ. SEAICEnewtonIterMax ) THEN |
IF ( newtonIter .EQ. SEAICEnewtonIterMax ) THEN |
371 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
372 |
WRITE(msgBuf,'(A,I10)') |
WRITE(msgBuf,'(A,I10)') |
373 |
& ' S/R SEAICE_JFNK: JFNK did not converge in timestep ', |
& ' S/R SEAICE_JFNK: JFNK did not converge in timestep ', |
374 |
& myIter+1 |
& myIter+1 |
375 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
378 |
ENDIF |
ENDIF |
379 |
IF ( krylovFails .GT. 0 ) THEN |
IF ( krylovFails .GT. 0 ) THEN |
380 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
381 |
WRITE(msgBuf,'(A,I4,A,I10)') |
WRITE(msgBuf,'(A,I4,A,I10)') |
382 |
& ' S/R SEAICE_JFNK: FGMRES did not converge ', |
& ' S/R SEAICE_JFNK: FGMRES did not converge ', |
383 |
& krylovFails, ' times in timestep ', myIter+1 |
& krylovFails, ' times in timestep ', myIter+1 |
384 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
386 |
_END_MASTER( myThid ) |
_END_MASTER( myThid ) |
387 |
ENDIF |
ENDIF |
388 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
389 |
WRITE(msgBuf,'(A,I6,A,I10)') |
WRITE(msgBuf,'(A,I6,A,I10)') |
390 |
& ' S/R SEAICE_JFNK: Total number FGMRES iterations = ', |
& ' S/R SEAICE_JFNK: Total number FGMRES iterations = ', |
391 |
& totalKrylovItersLoc, ' in timestep ', myIter+1 |
& totalKrylovItersLoc, ' in timestep ', myIter+1 |
392 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
402 |
C !ROUTINE: SEAICE_JFNK_UPDATE |
C !ROUTINE: SEAICE_JFNK_UPDATE |
403 |
C !INTERFACE: |
C !INTERFACE: |
404 |
|
|
405 |
SUBROUTINE SEAICE_JFNK_UPDATE( |
SUBROUTINE SEAICE_JFNK_UPDATE( |
406 |
I duIce, dvIce, |
I duIce, dvIce, |
407 |
U uIce, vIce, JFNKresidual, |
U uIce, vIce, JFNKresidual, |
408 |
O uIceRes, vIceRes, |
O uIceRes, vIceRes, |
409 |
I newtonIter, myTime, myIter, myThid ) |
I newtonIter, myTime, myIter, myThid ) |
462 |
_RL resLoc, facLS |
_RL resLoc, facLS |
463 |
LOGICAL doLineSearch |
LOGICAL doLineSearch |
464 |
C nVec :: size of the input vector(s) |
C nVec :: size of the input vector(s) |
465 |
C vector version of the residuals |
C resTmp :: vector version of the residuals |
466 |
INTEGER nVec |
INTEGER nVec |
467 |
PARAMETER ( nVec = 2*sNx*sNy ) |
PARAMETER ( nVec = 2*sNx*sNy ) |
468 |
_RL resTmp (nVec,1,nSx,nSy) |
_RL resTmp (nVec,1,nSx,nSy) |
469 |
C |
|
470 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
471 |
CEOP |
CEOP |
472 |
|
|
476 |
facLS = 1. _d 0 |
facLS = 1. _d 0 |
477 |
doLineSearch = .TRUE. |
doLineSearch = .TRUE. |
478 |
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 |
|
479 |
C Create update |
C Create update |
480 |
DO bj=myByLo(myThid),myByHi(myThid) |
DO bj=myByLo(myThid),myByHi(myThid) |
481 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
DO bi=myBxLo(myThid),myBxHi(myThid) |
482 |
DO J=1-Oly,sNy+Oly |
DO J=1-OLy,sNy+OLy |
483 |
DO I=1-Olx,sNx+Olx |
DO I=1-OLx,sNx+OLx |
484 |
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) |
485 |
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) |
486 |
ENDDO |
ENDDO |
489 |
ENDDO |
ENDDO |
490 |
C Compute current residual F(u), (includes re-computation of global |
C Compute current residual F(u), (includes re-computation of global |
491 |
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) |
492 |
CALL SEAICE_CALC_RESIDUAL( |
CALL SEAICE_CALC_RESIDUAL( |
493 |
I uIce, vIce, |
I uIce, vIce, |
494 |
O uIceRes, vIceRes, |
O uIceRes, vIceRes, |
495 |
I newtonIter, 0, myTime, myIter, myThid ) |
I newtonIter, 0, myTime, myIter, myThid ) |
496 |
C Important: Compute the norm of the residual using the same scalar |
C Important: Compute the norm of the residual using the same scalar |
497 |
C product that SEAICE_FGMRES does |
C product that SEAICE_FGMRES does |
498 |
CALL SEAICE_MAP2VEC(nVec,uIceRes,vIceRes,resTmp,.TRUE.,myThid) |
CALL SEAICE_MAP2VEC(nVec,uIceRes,vIceRes,resTmp,.TRUE.,myThid) |
499 |
CALL SEAICE_SCALPROD(nVec,1,1,1,resTmp,resTmp,resLoc,myThid) |
CALL SEAICE_SCALPROD(nVec,1,1,1,resTmp,resTmp,resLoc,myThid) |
500 |
resLoc = SQRT(resLoc) |
resLoc = SQRT(resLoc) |
501 |
|
C Determine, if we need more iterations |
502 |
|
doLineSearch = resLoc .GE. JFNKresidual |
503 |
|
C Limit the maximum number of iterations arbitrarily to four |
504 |
|
doLineSearch = doLineSearch .AND. l .LT. 4 |
505 |
|
C For the first iteration du/vIce = 0 and there will be no |
506 |
|
C improvement of the residual possible, so we do only the first |
507 |
|
C iteration |
508 |
|
IF ( newtonIter .EQ. 1 ) doLineSearch = .FALSE. |
509 |
|
C Only start a linesearch after some Newton iterations |
510 |
|
IF ( newtonIter .LE. SEAICE_JFNK_lsIter ) doLineSearch = .FALSE. |
511 |
|
C Increment counter |
512 |
|
l = l + 1 |
513 |
C some output diagnostics |
C some output diagnostics |
514 |
IF ( debugLevel.GE.debLevA .AND. doLineSearch ) THEN |
IF ( debugLevel.GE.debLevA .AND. doLineSearch ) THEN |
515 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
516 |
WRITE(msgBuf,'(2A,2(1XI6),3E12.5)') |
WRITE(msgBuf,'(2A,2(1XI6),3E12.5)') |
517 |
& ' S/R SEAICE_JFNK_UPDATE: Newton iter, LSiter, ', |
& ' S/R SEAICE_JFNK_UPDATE: Newton iter, LSiter, ', |
518 |
& 'facLS, JFNKresidual, resLoc = ', |
& 'facLS, JFNKresidual, resLoc = ', |
519 |
& newtonIter, l, facLS, JFNKresidual, resLoc |
& newtonIter, l, facLS, JFNKresidual, resLoc |