New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 111 for trunk/NEMO/OPA_SRC/SOL/solsor.F90 – NEMO

Ignore:
Timestamp:
2004-06-28T15:22:55+02:00 (20 years ago)
Author:
opalod
Message:

CT : UPDATE070 : Optimisation of the Red-Black SOR algorithm convergence

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEMO/OPA_SRC/SOL/solsor.F90

    r95 r111  
    7676         !                                                    ! ============== 
    7777 
    78          CALL lbc_lnk( gcx, c_solver_pt, 1. )   ! applied the lateral boubary conditions 
     78         CALL lbc_lnk( gcx, c_solver_pt, 1. )   ! applied the lateral boundary conditions 
    7979          
    8080         ! Residus 
    8181         ! ------- 
    8282 
    83          zres2 = 0.e0 
    84  
    8583         ! Guess black update 
    86         DO jj = 2, jpjm1 
     84         DO jj = 2, jpjm1 
    8785            ishift = MOD( jj-ijmppodd, 2 ) 
    8886            DO ji = 2+ishift, jpim1, 2 
     
    9391                  &   - gcp(ji,jj,4) * gcx(ji  ,jj+1) 
    9492               ! Estimate of the residual 
    95                zres  = ztmp - gcx(ji,jj) 
    96                zres2 = zres2 + zres * gcdmat(ji,jj) * zres 
     93               zres = ztmp - gcx(ji,jj) 
    9794               gcr(ji,jj) = zres * gcdmat(ji,jj) * zres 
    9895               ! Guess update 
     
    113110                  &   - gcp(ji,jj,4) * gcx(ji  ,jj+1)  
    114111               ! Estimate of the residual 
    115                zres  = ztmp - gcx(ji,jj) 
    116                zres2 = zres2 + zres * gcdmat(ji,jj) * zres 
     112               zres = ztmp - gcx(ji,jj) 
    117113               gcr(ji,jj) = zres * gcdmat(ji,jj) * zres 
    118114               ! Guess update 
    119                gcx(ji,jj) = sor * ztmp  + (1-sor) * gcx(ji,jj) 
     115               gcx(ji,jj) = sor * ztmp + (1-sor) * gcx(ji,jj) 
    120116            END DO 
    121117         END DO 
     
    123119         CALL lbc_lnk( gcx, c_solver_pt, 1. )   ! applied the lateral boubary conditions 
    124120 
    125          ! relative precision 
    126          rnorme = zres2 
    127 !!!!     IF( lk_mpp )   CALL mpp_sum( rnorme )   ! sum over the global domain 
    128 !i 
    129          zres2 = MAXVAL( gcr(2:jpim1,2:jpjm1) ) 
     121         ! test of convergence 
     122         IF ( jn > nmin .AND. MOD( jn-nmin, nmod ) == 0 ) then 
    130123 
    131          IF( lk_mpp )   CALL mpp_max( zres2 )   ! sum over the global domain 
    132 !i 
    133          ! test of convergence 
    134          ! old test (either res<resmax or jn=nmax) 
    135          !           IF( res < resmax .OR. jn == nmax ) THEN 
    136                      IF( zres2 < 1.e-10 .OR. jn == nmax ) THEN 
    137          ! relative precision 
    138          !        IF( rnorme < epsr .OR. jn == nmax ) THEN 
    139          !           res = SQRT( rnorme ) 
    140             res = SQRT( zres2 ) 
    141             niter = jn 
    142             ncut = 999 
    143          !  write(numout,*) 'solsor : res max = ', zres2, 'niter= ', niter 
    144          ENDIF 
     124            SELECT CASE ( nsol_arp ) 
     125            CASE ( 1 )                 ! relative precision 
     126               rnorme = SUM( gcr(2:jpim1,2:jpjm1) ) 
     127               IF( lk_mpp )   CALL mpp_sum( rnorme )   ! sum over the global domain 
     128               ! test of convergence 
     129               IF( rnorme < epsr .OR. jn == nmax ) THEN 
     130                  res = SQRT( rnorme ) 
     131                  niter = jn 
     132                  ncut = 999 
     133               ENDIF 
     134            CASE ( 0 )                 ! absolute precision (maximum value of the residual) 
     135               zres2 = MAXVAL( gcr(2:jpim1,2:jpjm1) ) 
     136               IF( lk_mpp )   CALL mpp_max( zres2 )   ! max over the global domain 
     137               ! test of convergence 
     138               IF( zres2 < resmax .OR. jn == nmax ) THEN 
     139                  res = SQRT( zres2 ) 
     140                  niter = jn 
     141                  ncut = 999 
     142               ENDIF 
     143            END CASE 
    145144          
    146145         !**** 
     
    149148         !**** 
    150149          
     150         ENDIF 
    151151         ! indicator of non-convergence or explosion 
    152152         IF( jn == nmax .OR. SQRT(epsr)/eps > 1.e+20 ) kindic = -2 
Note: See TracChangeset for help on using the changeset viewer.