| 60 | 
 C     loop indices | 
 C     loop indices | 
| 61 | 
       INTEGER newtonIter | 
       INTEGER newtonIter | 
| 62 | 
       INTEGER krylovIter, krylovFails | 
       INTEGER krylovIter, krylovFails | 
| 63 | 
       INTEGER totalKrylovItersLoc | 
       INTEGER totalKrylovItersLoc, totalNewtonItersLoc | 
| 64 | 
 C     FGMRES flag that determines amount of output messages of fgmres | 
 C     FGMRES flag that determines amount of output messages of fgmres | 
| 65 | 
       INTEGER iOutFGMRES | 
       INTEGER iOutFGMRES | 
| 66 | 
 C     FGMRES flag that indicates what fgmres wants us to do next | 
 C     FGMRES flag that indicates what fgmres wants us to do next | 
| 67 | 
       INTEGER iCode | 
       INTEGER iCode | 
| 68 | 
       _RL     JFNKresidual, JFNKresidualTile(nSx,nSy) | 
       _RL     JFNKresidual | 
| 69 | 
       _RL     JFNKresidualKm1 | 
       _RL     JFNKresidualKm1 | 
| 70 | 
 C     parameters to compute convergence criterion | 
 C     parameters to compute convergence criterion | 
| 71 | 
       _RL     phi_e, alp_e, JFNKgamma_lin | 
       _RL     phi_e, alp_e, JFNKgamma_lin | 
| 90 | 
       _RL etaZPre (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) | 
       _RL etaZPre (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) | 
| 91 | 
       _RL dwatPre (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) | 
       _RL dwatPre (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) | 
| 92 | 
 CEOP | 
 CEOP | 
| 93 | 
  | 
       INTEGER n | 
| 94 | 
  | 
       _RL resTmp (nVec,1,nSx,nSy) | 
| 95 | 
  | 
  | 
| 96 | 
 C     Initialise | 
 C     Initialise | 
| 97 | 
       newtonIter          = 0 | 
       newtonIter          = 0 | 
| 162 | 
          ENDDO | 
          ENDDO | 
| 163 | 
         ENDDO | 
         ENDDO | 
| 164 | 
        ENDDO | 
        ENDDO | 
| 165 | 
 C      | 
 C     Important: Compute the norm of the residual using the same scalar | 
| 166 | 
        DO bj=myByLo(myThid),myByHi(myThid) | 
 C     product that SEAICE_FGMRES does | 
| 167 | 
         DO bi=myBxLo(myThid),myBxHi(myThid) | 
        CALL SEAICE_MAP2VEC(nVec,uIceRes,vIceRes,resTmp,.TRUE.,myThid) | 
| 168 | 
          JFNKresidualTile(bi,bj) = 0. _d 0 | 
        CALL SEAICE_SCALPROD( | 
| 169 | 
          DO J=1,sNy | 
      &      nVec,1,1,1,resTmp,resTmp,JFNKresidual,myThid) | 
 | 
           DO I=1,sNx | 
  | 
 | 
 #ifdef CG2D_SINGLECPU_SUM | 
  | 
 | 
            JFNKlocalBuf(I,J,bi,bj) =  | 
  | 
 | 
 #else | 
  | 
 | 
            JFNKresidualTile(bi,bj) = JFNKresidualTile(bi,bj) +  | 
  | 
 | 
 #endif | 
  | 
 | 
      &          uIceRes(I,J,bi,bj)*uIceRes(I,J,bi,bj) + | 
  | 
 | 
      &          vIceRes(I,J,bi,bj)*vIceRes(I,J,bi,bj) | 
  | 
 | 
           ENDDO | 
  | 
 | 
          ENDDO | 
  | 
 | 
         ENDDO | 
  | 
 | 
        ENDDO | 
  | 
 | 
        JFNKresidual = 0. _d 0 | 
  | 
 | 
 #ifdef CG2D_SINGLECPU_SUM | 
  | 
 | 
        CALL GLOBAL_SUM_SINGLECPU_RL( | 
  | 
 | 
      &         JFNKlocalBuf,JFNKresidual, 0, 0, myThid) | 
  | 
 | 
 #else | 
  | 
 | 
        CALL GLOBAL_SUM_TILE_RL( JFNKresidualTile,JFNKresidual,myThid ) | 
  | 
 | 
 #endif | 
  | 
| 170 | 
        JFNKresidual = SQRT(JFNKresidual) | 
        JFNKresidual = SQRT(JFNKresidual) | 
| 171 | 
 C     compute convergence criterion for linear preconditioned FGMRES | 
 C     compute convergence criterion for linear preconditioned FGMRES | 
| 172 | 
        JFNKgamma_lin = JFNKgamma_lin_max | 
        JFNKgamma_lin = JFNKgamma_lin_max | 
| 189 | 
 C     in that routine | 
 C     in that routine | 
| 190 | 
        krylovIter    = 0 | 
        krylovIter    = 0 | 
| 191 | 
        iCode         = 0 | 
        iCode         = 0 | 
 | 
        IF ( debugLevel.GE.debLevA ) THEN   | 
  | 
 | 
         _BEGIN_MASTER( myThid ) | 
  | 
 | 
         WRITE(msgBuf,'(2A,2(1XI6),2E12.5)')  | 
  | 
 | 
      &       ' S/R SEAICE_JFNK: newtonIter,', | 
  | 
 | 
      &       ' total newtonIter, JFNKgamma_lin, initial norm = ', | 
  | 
 | 
      &       newtonIter,SEAICEnewtonIterMax*(myIter-nIter0)+newtonIter,  | 
  | 
 | 
      &       JFNKgamma_lin, JFNKresidual | 
  | 
 | 
         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, | 
  | 
 | 
      &       SQUEEZE_RIGHT, myThid ) | 
  | 
 | 
         _END_MASTER( myThid ) | 
  | 
 | 
        ENDIF | 
  | 
| 192 | 
 C | 
 C | 
| 193 | 
        JFNKconverged = JFNKresidual.LT.JFNKtol | 
        JFNKconverged = JFNKresidual.LT.JFNKtol | 
| 194 | 
 C | 
 C | 
| 234 | 
 C     some output diagnostics | 
 C     some output diagnostics | 
| 235 | 
         IF ( debugLevel.GE.debLevA ) THEN | 
         IF ( debugLevel.GE.debLevA ) THEN | 
| 236 | 
          _BEGIN_MASTER( myThid ) | 
          _BEGIN_MASTER( myThid ) | 
| 237 | 
  | 
          totalNewtonItersLoc =  | 
| 238 | 
  | 
      &        SEAICEnewtonIterMax*(myIter-nIter0)+newtonIter | 
| 239 | 
  | 
          WRITE(msgBuf,'(2A,2(1XI6),2E12.5)')  | 
| 240 | 
  | 
      &        ' S/R SEAICE_JFNK: Newton iterate / total, ', | 
| 241 | 
  | 
      &        'JFNKgamma_lin, initial norm = ', | 
| 242 | 
  | 
      &        newtonIter, totalNewtonItersLoc, | 
| 243 | 
  | 
      &        JFNKgamma_lin,JFNKresidual | 
| 244 | 
  | 
          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, | 
| 245 | 
  | 
      &        SQUEEZE_RIGHT, myThid ) | 
| 246 | 
          WRITE(msgBuf,'(3(A,I6))') | 
          WRITE(msgBuf,'(3(A,I6))') | 
| 247 | 
      &        ' S/R SEAICE_JFNK: Newton iterate / total = ', newtonIter,  | 
      &        ' S/R SEAICE_JFNK: Newton iterate / total = ',newtonIter,  | 
| 248 | 
      &        ' / ', SEAICEnewtonIterMax*(myIter-nIter0)+newtonIter,  | 
      &        ' / ', totalNewtonItersLoc, | 
| 249 | 
      &        ', Nb. of FGMRES iterations = ', krylovIter | 
      &        ', Nb. of FGMRES iterations = ', krylovIter | 
| 250 | 
          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, | 
          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, | 
| 251 | 
      &        SQUEEZE_RIGHT, myThid ) | 
      &        SQUEEZE_RIGHT, myThid ) |