| 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 Adams-Bashforth extrapolation factors |
| 80 |
|
_RL abFac, abAlpha |
| 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 Adams-Bashforth-2 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 Adams-Bashforth extrapolation factors |
| 122 |
|
abFac = 0. _d 0 |
| 123 |
|
IF ( SEAICEuseAB2 ) THEN |
| 124 |
|
IF ( myIter.EQ.nIter0 .AND. SEAICEmomStartAB.EQ.0 ) THEN |
| 125 |
|
abFac = 0. _d 0 |
| 126 |
|
ELSE |
| 127 |
|
abFac = 0.5 _d 0 + SEAICE_abEps |
| 128 |
|
ENDIF |
| 129 |
|
ENDIF |
| 130 |
|
abAlpha = 1. _d 0 + abFac |
| 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) * abAlpha |
| 146 |
|
& + ( uIce(I,J,bi,bj) - uIceNm1(I,J,bi,bj) ) * abFac |
| 147 |
|
dvIcNm1(I,J,bi,bj) = vIce(I,J,bi,bj) * abAlpha |
| 148 |
|
& + ( vIce(I,J,bi,bj) - vIceNm1(I,J,bi,bj) ) * abFac |
| 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 |
|
IF ( .NOT.SEAICEuseIMEX ) THEN |
| 154 |
C Compute things that do no change during the Newton iteration: |
C Compute things that do no change during the Newton iteration: |
| 155 |
C sea-surface tilt and wind stress: |
C sea-surface tilt and wind stress: |
| 156 |
C FORCEX/Y0 - mass*(u/vIceNm1)/deltaT |
C FORCEX/Y0 - mass*(abA*u/vIceNm1+abB*(u/vIceNm1-u/vIceNm2))/deltaT |
| 157 |
DO J=1-Oly,sNy+Oly |
DO J=1-OLy,sNy+OLy |
| 158 |
DO I=1-Olx,sNx+Olx |
DO I=1-OLx,sNx+OLx |
| 159 |
FORCEX(I,J,bi,bj) = FORCEX0(I,J,bi,bj) |
FORCEX(I,J,bi,bj) = FORCEX0(I,J,bi,bj) |
| 160 |
& + seaiceMassU(I,J,bi,bj)*uIceNm1(I,J,bi,bj)*recip_deltaT |
& + seaiceMassU(I,J,bi,bj)*duIcNm1(I,J,bi,bj)*recip_deltaT |
| 161 |
FORCEY(I,J,bi,bj) = FORCEY0(I,J,bi,bj) |
FORCEY(I,J,bi,bj) = FORCEY0(I,J,bi,bj) |
| 162 |
& + seaiceMassV(I,J,bi,bj)*vIceNm1(I,J,bi,bj)*recip_deltaT |
& + seaiceMassV(I,J,bi,bj)*dvIcNm1(I,J,bi,bj)*recip_deltaT |
| 163 |
ENDDO |
ENDDO |
| 164 |
ENDDO |
ENDDO |
| 165 |
|
ENDIF |
| 166 |
ENDDO |
ENDDO |
| 167 |
ENDDO |
ENDDO |
| 168 |
C Start nonlinear Newton iteration: outer loop iteration |
C Start nonlinear Newton iteration: outer loop iteration |
| 171 |
newtonIter = newtonIter + 1 |
newtonIter = newtonIter + 1 |
| 172 |
C Compute initial residual F(u), (includes computation of global |
C Compute initial residual F(u), (includes computation of global |
| 173 |
C variables DWATN, zeta, and eta) |
C variables DWATN, zeta, and eta) |
| 174 |
IF ( newtonIter .EQ. 1 ) CALL SEAICE_JFNK_UPDATE( |
IF ( newtonIter .EQ. 1 ) CALL SEAICE_JFNK_UPDATE( |
| 175 |
I duIce, dvIce, |
I duIce, dvIce, |
| 176 |
U uIce, vIce, JFNKresidual, |
U uIce, vIce, JFNKresidual, |
| 177 |
O uIceRes, vIceRes, |
O uIceRes, vIceRes, |
| 178 |
I newtonIter, myTime, myIter, myThid ) |
I newtonIter, myTime, myIter, myThid ) |
| 180 |
C constant for the preconditioner |
C constant for the preconditioner |
| 181 |
DO bj=myByLo(myThid),myByHi(myThid) |
DO bj=myByLo(myThid),myByHi(myThid) |
| 182 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
DO bi=myBxLo(myThid),myBxHi(myThid) |
| 183 |
DO j=1-Oly,sNy+Oly |
DO j=1-OLy,sNy+OLy |
| 184 |
DO i=1-Olx,sNx+Olx |
DO i=1-OLx,sNx+OLx |
| 185 |
zetaPre(I,J,bi,bj) = zeta(I,J,bi,bj) |
zetaPre(I,J,bi,bj) = zeta(I,J,bi,bj) |
| 186 |
etaPre(I,J,bi,bj) = eta(I,J,bi,bj) |
etaPre(I,J,bi,bj) = eta(I,J,bi,bj) |
| 187 |
etaZPre(I,J,bi,bj) = etaZ(I,J,bi,bj) |
etaZPre(I,J,bi,bj) = etaZ(I,J,bi,bj) |
| 194 |
JFNKgamma_lin = JFNKgamma_lin_max |
JFNKgamma_lin = JFNKgamma_lin_max |
| 195 |
IF ( newtonIter.GT.1.AND.newtonIter.LE.SEAICE_JFNK_tolIter |
IF ( newtonIter.GT.1.AND.newtonIter.LE.SEAICE_JFNK_tolIter |
| 196 |
& .AND.JFNKresidual.LT.JFNKres_t ) THEN |
& .AND.JFNKresidual.LT.JFNKres_t ) THEN |
| 197 |
C Eisenstat, 1996, equ.(2.6) |
C Eisenstat and Walker (1996), eq.(2.6) |
| 198 |
phi_e = 1. _d 0 |
JFNKgamma_lin = SEAICE_JFNKphi |
| 199 |
alp_e = 1. _d 0 |
& *( JFNKresidual/JFNKresidualKm1 )**SEAICE_JFNKalpha |
|
JFNKgamma_lin = phi_e*( JFNKresidual/JFNKresidualKm1 )**alp_e |
|
| 200 |
JFNKgamma_lin = min(JFNKgamma_lin_max, JFNKgamma_lin) |
JFNKgamma_lin = min(JFNKgamma_lin_max, JFNKgamma_lin) |
| 201 |
JFNKgamma_lin = max(JFNKgamma_lin_min, JFNKgamma_lin) |
JFNKgamma_lin = max(JFNKgamma_lin_min, JFNKgamma_lin) |
| 202 |
ENDIF |
ENDIF |
| 203 |
C save the residual for the next iteration |
C save the residual for the next iteration |
| 204 |
JFNKresidualKm1 = JFNKresidual |
JFNKresidualKm1 = JFNKresidual |
| 205 |
C |
|
| 206 |
C The Krylov iteration using FGMRES, the preconditioner is LSOR |
C The Krylov iteration using FGMRES, the preconditioner is LSOR |
| 207 |
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 |
| 208 |
C down. |
C down. |
| 210 |
C in that routine |
C in that routine |
| 211 |
krylovIter = 0 |
krylovIter = 0 |
| 212 |
iCode = 0 |
iCode = 0 |
| 213 |
C |
|
| 214 |
JFNKconverged = JFNKresidual.LT.JFNKtol |
JFNKconverged = JFNKresidual.LT.JFNKtol |
| 215 |
C |
|
| 216 |
C do Krylov loop only if convergence is not reached |
C do Krylov loop only if convergence is not reached |
| 217 |
C |
|
| 218 |
IF ( .NOT.JFNKconverged ) THEN |
IF ( .NOT.JFNKconverged ) THEN |
| 219 |
C |
|
| 220 |
C start Krylov iteration (FGMRES) |
C start Krylov iteration (FGMRES) |
| 221 |
C |
|
| 222 |
krylovConverged = .FALSE. |
krylovConverged = .FALSE. |
| 223 |
FGMRESeps = JFNKgamma_lin * JFNKresidual |
FGMRESeps = JFNKgamma_lin * JFNKresidual |
| 224 |
DO WHILE ( .NOT.krylovConverged ) |
DO WHILE ( .NOT.krylovConverged ) |
| 225 |
C solution vector sol = du/vIce |
C solution vector sol = du/vIce |
| 226 |
C residual vector (rhs) Fu = u/vIceRes |
C residual vector (rhs) Fu = u/vIceRes |
| 227 |
C output work vectors wk1, -> input work vector wk2 |
C output work vectors wk1, -> input work vector wk2 |
| 228 |
C |
|
| 229 |
CALL SEAICE_FGMRES_DRIVER( |
CALL SEAICE_FGMRES_DRIVER( |
| 230 |
I uIceRes, vIceRes, |
I uIceRes, vIceRes, |
| 231 |
U duIce, dvIce, iCode, |
U duIce, dvIce, iCode, |
| 232 |
I FGMRESeps, iOutFGMRES, |
I FGMRESeps, iOutFGMRES, |
| 233 |
I newtonIter, krylovIter, myTime, myIter, myThid ) |
I newtonIter, krylovIter, myTime, myIter, myThid ) |
| 235 |
C or product of matrix (Jacobian) times vector. For iCode = 0, terminate |
C or product of matrix (Jacobian) times vector. For iCode = 0, terminate |
| 236 |
C iteration |
C iteration |
| 237 |
IF (iCode.EQ.1) THEN |
IF (iCode.EQ.1) THEN |
| 238 |
C Call preconditioner |
C Call preconditioner |
| 239 |
IF ( SOLV_MAX_ITERS .GT. 0 ) |
IF ( SOLV_MAX_ITERS .GT. 0 ) |
| 240 |
& CALL SEAICE_PRECONDITIONER( |
& CALL SEAICE_PRECONDITIONER( |
| 241 |
U duIce, dvIce, |
U duIce, dvIce, |
| 242 |
I zetaPre, etaPre, etaZpre, dwatPre, |
I zetaPre, etaPre, etaZpre, dwatPre, |
| 243 |
I newtonIter, krylovIter, myTime, myIter, myThid ) |
I newtonIter, krylovIter, myTime, myIter, myThid ) |
| 244 |
ELSEIF (iCode.GE.2) THEN |
ELSEIF (iCode.GE.2) THEN |
| 245 |
C Compute Jacobian times vector |
C Compute Jacobian times vector |
| 246 |
CALL SEAICE_JACVEC( |
CALL SEAICE_JACVEC( |
| 247 |
I uIce, vIce, uIceRes, vIceRes, |
I uIce, vIce, uIceRes, vIceRes, |
| 248 |
U duIce, dvIce, |
U duIce, dvIce, |
| 249 |
I newtonIter, krylovIter, myTime, myIter, myThid ) |
I newtonIter, krylovIter, myTime, myIter, myThid ) |
| 250 |
ENDIF |
ENDIF |
| 251 |
krylovConverged = iCode.EQ.0 |
krylovConverged = iCode.EQ.0 |
| 255 |
C some output diagnostics |
C some output diagnostics |
| 256 |
IF ( debugLevel.GE.debLevA ) THEN |
IF ( debugLevel.GE.debLevA ) THEN |
| 257 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
| 258 |
totalNewtonItersLoc = |
totalNewtonItersLoc = |
| 259 |
& SEAICEnewtonIterMax*(myIter-nIter0)+newtonIter |
& SEAICEnewtonIterMax*(myIter-nIter0)+newtonIter |
| 260 |
WRITE(msgBuf,'(2A,2(1XI6),2E12.5)') |
WRITE(msgBuf,'(2A,2(1XI6),2E12.5)') |
| 261 |
& ' S/R SEAICE_JFNK: Newton iterate / total, ', |
& ' S/R SEAICE_JFNK: Newton iterate / total, ', |
| 262 |
& 'JFNKgamma_lin, initial norm = ', |
& 'JFNKgamma_lin, initial norm = ', |
| 263 |
& newtonIter, totalNewtonItersLoc, |
& newtonIter, totalNewtonItersLoc, |
| 265 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
| 266 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
| 267 |
WRITE(msgBuf,'(3(A,I6))') |
WRITE(msgBuf,'(3(A,I6))') |
| 268 |
& ' S/R SEAICE_JFNK: Newton iterate / total = ',newtonIter, |
& ' S/R SEAICE_JFNK: Newton iterate / total = ',newtonIter, |
| 269 |
& ' / ', totalNewtonItersLoc, |
& ' / ', totalNewtonItersLoc, |
| 270 |
& ', Nb. of FGMRES iterations = ', krylovIter |
& ', Nb. of FGMRES iterations = ', krylovIter |
| 271 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
| 288 |
C at the beginning of the Newton iteration, thereby saving us from |
C at the beginning of the Newton iteration, thereby saving us from |
| 289 |
C the extra call of seaice_jfnk_update, but unfortunately that |
C the extra call of seaice_jfnk_update, but unfortunately that |
| 290 |
C changes the results, so we leave the stuff here for now. |
C changes the results, so we leave the stuff here for now. |
| 291 |
CALL SEAICE_JFNK_UPDATE( |
CALL SEAICE_JFNK_UPDATE( |
| 292 |
I duIce, dvIce, |
I duIce, dvIce, |
| 293 |
U uIce, vIce, JFNKresidual, |
U uIce, vIce, JFNKresidual, |
| 294 |
O uIceRes, vIceRes, |
O uIceRes, vIceRes, |
| 295 |
I newtonIter, myTime, myIter, myThid ) |
I newtonIter, myTime, myIter, myThid ) |
| 296 |
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 |
| 297 |
DO bj=myByLo(myThid),myByHi(myThid) |
DO bj=myByLo(myThid),myByHi(myThid) |
| 298 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
DO bi=myBxLo(myThid),myBxHi(myThid) |
| 299 |
DO J=1-Oly,sNy+Oly |
DO J=1-OLy,sNy+OLy |
| 300 |
DO I=1-Olx,sNx+Olx |
DO I=1-OLx,sNx+OLx |
| 301 |
duIce(I,J,bi,bj)= 0. _d 0 |
duIce(I,J,bi,bj)= 0. _d 0 |
| 302 |
dvIce(I,J,bi,bj)= 0. _d 0 |
dvIce(I,J,bi,bj)= 0. _d 0 |
| 303 |
ENDDO |
ENDDO |
| 307 |
ENDIF |
ENDIF |
| 308 |
C end of Newton iterate |
C end of Newton iterate |
| 309 |
ENDDO |
ENDDO |
| 310 |
C |
|
| 311 |
C-- Output diagnostics |
C-- Output diagnostics |
| 312 |
C |
|
| 313 |
IF ( SEAICE_monFreq .GT. 0. _d 0 ) THEN |
IF ( SEAICE_monFreq .GT. 0. _d 0 ) THEN |
| 314 |
C Count iterations |
C Count iterations |
| 315 |
totalJFNKtimeSteps = totalJFNKtimeSteps + 1 |
totalJFNKtimeSteps = totalJFNKtimeSteps + 1 |
| 318 |
C Record failure |
C Record failure |
| 319 |
totalKrylovFails = totalKrylovFails + krylovFails |
totalKrylovFails = totalKrylovFails + krylovFails |
| 320 |
IF ( newtonIter .EQ. SEAICEnewtonIterMax ) THEN |
IF ( newtonIter .EQ. SEAICEnewtonIterMax ) THEN |
| 321 |
totalNewtonFails = totalNewtonFails + 1 |
totalNewtonFails = totalNewtonFails + 1 |
| 322 |
ENDIF |
ENDIF |
| 323 |
ENDIF |
ENDIF |
| 324 |
C Decide whether it is time to dump and reset the counter |
C Decide whether it is time to dump and reset the counter |
| 325 |
writeNow = DIFFERENT_MULTIPLE(SEAICE_monFreq, |
writeNow = DIFFERENT_MULTIPLE(SEAICE_monFreq, |
| 326 |
& myTime+deltaTClock, deltaTClock) |
& myTime+deltaTClock, deltaTClock) |
| 327 |
#ifdef ALLOW_CAL |
#ifdef ALLOW_CAL |
| 328 |
IF ( useCAL ) THEN |
IF ( useCAL ) THEN |
| 329 |
CALL CAL_TIME2DUMP( |
CALL CAL_TIME2DUMP( |
| 330 |
I zeroRL, SEAICE_monFreq, deltaTClock, |
I zeroRL, SEAICE_monFreq, deltaTClock, |
| 331 |
U writeNow, |
U writeNow, |
| 332 |
I myTime+deltaTclock, myIter+1, myThid ) |
I myTime+deltaTclock, myIter+1, myThid ) |
| 334 |
#endif |
#endif |
| 335 |
IF ( writeNow ) THEN |
IF ( writeNow ) THEN |
| 336 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
| 337 |
WRITE(msgBuf,'(A)') |
WRITE(msgBuf,'(A)') |
| 338 |
&' // =======================================================' |
&' // =======================================================' |
| 339 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
| 340 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
| 341 |
WRITE(msgBuf,'(A)') ' // Begin JFNK statistics' |
WRITE(msgBuf,'(A)') ' // Begin JFNK statistics' |
| 342 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
| 343 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
| 344 |
WRITE(msgBuf,'(A)') |
WRITE(msgBuf,'(A)') |
| 345 |
&' // =======================================================' |
&' // =======================================================' |
| 346 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
| 347 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
| 348 |
WRITE(msgBuf,'(A,I10)') |
WRITE(msgBuf,'(A,I10)') |
| 349 |
& ' %JFNK_MON: time step = ', myIter+1 |
& ' %JFNK_MON: time step = ', myIter+1 |
| 350 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
| 351 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
| 352 |
WRITE(msgBuf,'(A,I10)') |
WRITE(msgBuf,'(A,I10)') |
| 353 |
& ' %JFNK_MON: Nb. of time steps = ', totalJFNKtimeSteps |
& ' %JFNK_MON: Nb. of time steps = ', totalJFNKtimeSteps |
| 354 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
| 355 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
| 356 |
WRITE(msgBuf,'(A,I10)') |
WRITE(msgBuf,'(A,I10)') |
| 357 |
& ' %JFNK_MON: Nb. of Newton steps = ', totalNewtonIters |
& ' %JFNK_MON: Nb. of Newton steps = ', totalNewtonIters |
| 358 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
| 359 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
| 360 |
WRITE(msgBuf,'(A,I10)') |
WRITE(msgBuf,'(A,I10)') |
| 361 |
& ' %JFNK_MON: Nb. of Krylov steps = ', totalKrylovIters |
& ' %JFNK_MON: Nb. of Krylov steps = ', totalKrylovIters |
| 362 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
| 363 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
| 364 |
WRITE(msgBuf,'(A,I10)') |
WRITE(msgBuf,'(A,I10)') |
| 365 |
& ' %JFNK_MON: Nb. of Newton failures = ', totalNewtonFails |
& ' %JFNK_MON: Nb. of Newton failures = ', totalNewtonFails |
| 366 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
| 367 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
| 368 |
WRITE(msgBuf,'(A,I10)') |
WRITE(msgBuf,'(A,I10)') |
| 369 |
& ' %JFNK_MON: Nb. of Krylov failures = ', totalKrylovFails |
& ' %JFNK_MON: Nb. of Krylov failures = ', totalKrylovFails |
| 370 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
| 371 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
| 372 |
WRITE(msgBuf,'(A)') |
WRITE(msgBuf,'(A)') |
| 373 |
&' // =======================================================' |
&' // =======================================================' |
| 374 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
| 375 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
| 376 |
WRITE(msgBuf,'(A)') ' // End JFNK statistics' |
WRITE(msgBuf,'(A)') ' // End JFNK statistics' |
| 377 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
| 378 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
| 379 |
WRITE(msgBuf,'(A)') |
WRITE(msgBuf,'(A)') |
| 380 |
&' // =======================================================' |
&' // =======================================================' |
| 381 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
| 382 |
& SQUEEZE_RIGHT, myThid ) |
& SQUEEZE_RIGHT, myThid ) |
| 393 |
IF ( debugLevel.GE.debLevA ) THEN |
IF ( debugLevel.GE.debLevA ) THEN |
| 394 |
IF ( newtonIter .EQ. SEAICEnewtonIterMax ) THEN |
IF ( newtonIter .EQ. SEAICEnewtonIterMax ) THEN |
| 395 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
| 396 |
WRITE(msgBuf,'(A,I10)') |
WRITE(msgBuf,'(A,I10)') |
| 397 |
& ' S/R SEAICE_JFNK: JFNK did not converge in timestep ', |
& ' S/R SEAICE_JFNK: JFNK did not converge in timestep ', |
| 398 |
& myIter+1 |
& myIter+1 |
| 399 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
| 402 |
ENDIF |
ENDIF |
| 403 |
IF ( krylovFails .GT. 0 ) THEN |
IF ( krylovFails .GT. 0 ) THEN |
| 404 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
| 405 |
WRITE(msgBuf,'(A,I4,A,I10)') |
WRITE(msgBuf,'(A,I4,A,I10)') |
| 406 |
& ' S/R SEAICE_JFNK: FGMRES did not converge ', |
& ' S/R SEAICE_JFNK: FGMRES did not converge ', |
| 407 |
& krylovFails, ' times in timestep ', myIter+1 |
& krylovFails, ' times in timestep ', myIter+1 |
| 408 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
| 410 |
_END_MASTER( myThid ) |
_END_MASTER( myThid ) |
| 411 |
ENDIF |
ENDIF |
| 412 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
| 413 |
WRITE(msgBuf,'(A,I6,A,I10)') |
WRITE(msgBuf,'(A,I6,A,I10)') |
| 414 |
& ' S/R SEAICE_JFNK: Total number FGMRES iterations = ', |
& ' S/R SEAICE_JFNK: Total number FGMRES iterations = ', |
| 415 |
& totalKrylovItersLoc, ' in timestep ', myIter+1 |
& totalKrylovItersLoc, ' in timestep ', myIter+1 |
| 416 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
| 426 |
C !ROUTINE: SEAICE_JFNK_UPDATE |
C !ROUTINE: SEAICE_JFNK_UPDATE |
| 427 |
C !INTERFACE: |
C !INTERFACE: |
| 428 |
|
|
| 429 |
SUBROUTINE SEAICE_JFNK_UPDATE( |
SUBROUTINE SEAICE_JFNK_UPDATE( |
| 430 |
I duIce, dvIce, |
I duIce, dvIce, |
| 431 |
U uIce, vIce, JFNKresidual, |
U uIce, vIce, JFNKresidual, |
| 432 |
O uIceRes, vIceRes, |
O uIceRes, vIceRes, |
| 433 |
I newtonIter, myTime, myIter, myThid ) |
I newtonIter, myTime, myIter, myThid ) |
| 486 |
_RL resLoc, facLS |
_RL resLoc, facLS |
| 487 |
LOGICAL doLineSearch |
LOGICAL doLineSearch |
| 488 |
C nVec :: size of the input vector(s) |
C nVec :: size of the input vector(s) |
| 489 |
C vector version of the residuals |
C resTmp :: vector version of the residuals |
| 490 |
INTEGER nVec |
INTEGER nVec |
| 491 |
PARAMETER ( nVec = 2*sNx*sNy ) |
PARAMETER ( nVec = 2*sNx*sNy ) |
| 492 |
_RL resTmp (nVec,1,nSx,nSy) |
_RL resTmp (nVec,1,nSx,nSy) |
| 493 |
C |
|
| 494 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
| 495 |
CEOP |
CEOP |
| 496 |
|
|
| 500 |
facLS = 1. _d 0 |
facLS = 1. _d 0 |
| 501 |
doLineSearch = .TRUE. |
doLineSearch = .TRUE. |
| 502 |
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 |
|
| 503 |
C Create update |
C Create update |
| 504 |
DO bj=myByLo(myThid),myByHi(myThid) |
DO bj=myByLo(myThid),myByHi(myThid) |
| 505 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
DO bi=myBxLo(myThid),myBxHi(myThid) |
| 506 |
DO J=1-Oly,sNy+Oly |
DO J=1-OLy,sNy+OLy |
| 507 |
DO I=1-Olx,sNx+Olx |
DO I=1-OLx,sNx+OLx |
| 508 |
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) |
| 509 |
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) |
| 510 |
ENDDO |
ENDDO |
| 513 |
ENDDO |
ENDDO |
| 514 |
C Compute current residual F(u), (includes re-computation of global |
C Compute current residual F(u), (includes re-computation of global |
| 515 |
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) |
| 516 |
CALL SEAICE_CALC_RESIDUAL( |
CALL SEAICE_CALC_RESIDUAL( |
| 517 |
I uIce, vIce, |
I uIce, vIce, |
| 518 |
O uIceRes, vIceRes, |
O uIceRes, vIceRes, |
| 519 |
I newtonIter, 0, myTime, myIter, myThid ) |
I newtonIter, 0, myTime, myIter, myThid ) |
| 520 |
C Important: Compute the norm of the residual using the same scalar |
C Important: Compute the norm of the residual using the same scalar |
| 521 |
C product that SEAICE_FGMRES does |
C product that SEAICE_FGMRES does |
| 522 |
CALL SEAICE_MAP2VEC(nVec,uIceRes,vIceRes,resTmp,.TRUE.,myThid) |
CALL SEAICE_MAP2VEC(nVec,uIceRes,vIceRes,resTmp,.TRUE.,myThid) |
| 523 |
CALL SEAICE_SCALPROD(nVec,1,1,1,resTmp,resTmp,resLoc,myThid) |
CALL SEAICE_SCALPROD(nVec,1,1,1,resTmp,resTmp,resLoc,myThid) |
| 524 |
resLoc = SQRT(resLoc) |
resLoc = SQRT(resLoc) |
| 525 |
|
C Determine, if we need more iterations |
| 526 |
|
doLineSearch = resLoc .GE. JFNKresidual |
| 527 |
|
C Limit the maximum number of iterations arbitrarily to four |
| 528 |
|
doLineSearch = doLineSearch .AND. l .LT. 4 |
| 529 |
|
C For the first iteration du/vIce = 0 and there will be no |
| 530 |
|
C improvement of the residual possible, so we do only the first |
| 531 |
|
C iteration |
| 532 |
|
IF ( newtonIter .EQ. 1 ) doLineSearch = .FALSE. |
| 533 |
|
C Only start a linesearch after some Newton iterations |
| 534 |
|
IF ( newtonIter .LE. SEAICE_JFNK_lsIter ) doLineSearch = .FALSE. |
| 535 |
|
C Increment counter |
| 536 |
|
l = l + 1 |
| 537 |
C some output diagnostics |
C some output diagnostics |
| 538 |
IF ( debugLevel.GE.debLevA .AND. doLineSearch ) THEN |
IF ( debugLevel.GE.debLevA .AND. doLineSearch ) THEN |
| 539 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
| 540 |
WRITE(msgBuf,'(2A,2(1XI6),3E12.5)') |
WRITE(msgBuf,'(2A,2(1XI6),3E12.5)') |
| 541 |
& ' S/R SEAICE_JFNK_UPDATE: Newton iter, LSiter, ', |
& ' S/R SEAICE_JFNK_UPDATE: Newton iter, LSiter, ', |
| 542 |
& 'facLS, JFNKresidual, resLoc = ', |
& 'facLS, JFNKresidual, resLoc = ', |
| 543 |
& newtonIter, l, facLS, JFNKresidual, resLoc |
& newtonIter, l, facLS, JFNKresidual, resLoc |
| 553 |
C This is the new residual |
C This is the new residual |
| 554 |
JFNKresidual = resLoc |
JFNKresidual = resLoc |
| 555 |
|
|
| 556 |
#endif /* SEAICE_ALLOW_DYNAMICS and SEAICE_CGRID and SEAICE_ALLOW_JFNK */ |
#endif /* SEAICE_ALLOW_JFNK */ |
| 557 |
|
|
| 558 |
RETURN |
RETURN |
| 559 |
END |
END |