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 12340 for NEMO/branches/2019/dev_r11943_MERGE_2019/src/OCE/ISF/isfcpl.F90 – NEMO

Ignore:
Timestamp:
2020-01-27T15:31:53+01:00 (4 years ago)
Author:
acc
Message:

Branch 2019/dev_r11943_MERGE_2019. This commit introduces basic do loop macro
substitution to the 2019 option 1, merge branch. These changes have been SETTE
tested. The only addition is the do_loop_substitute.h90 file in the OCE directory but
the macros defined therein are used throughout the code to replace identifiable, 2D-
and 3D- nested loop opening and closing statements with single-line alternatives. Code
indents are also adjusted accordingly.

The following explanation is taken from comments in the new header file:

This header file contains preprocessor definitions and macros used in the do-loop
substitutions introduced between version 4.0 and 4.2. The primary aim of these macros
is to assist in future applications of tiling to improve performance. This is expected
to be achieved by alternative versions of these macros in selected locations. The
initial introduction of these macros simply replaces all identifiable nested 2D- and
3D-loops with single line statements (and adjusts indenting accordingly). Do loops
are identifiable if they comform to either:

DO jk = ....

DO jj = .... DO jj = ...

DO ji = .... DO ji = ...
. OR .
. .

END DO END DO

END DO END DO

END DO

and white-space variants thereof.

Additionally, only loops with recognised jj and ji loops limits are treated; these are:
Lower limits of 1, 2 or fs_2
Upper limits of jpi, jpim1 or fs_jpim1 (for ji) or jpj, jpjm1 or fs_jpjm1 (for jj)

The macro naming convention takes the form: DO_2D_BT_LR where:

B is the Bottom offset from the PE's inner domain;
T is the Top offset from the PE's inner domain;
L is the Left offset from the PE's inner domain;
R is the Right offset from the PE's inner domain

So, given an inner domain of 2,jpim1 and 2,jpjm1, a typical example would replace:

DO jj = 2, jpj

DO ji = 1, jpim1
.
.

END DO

END DO

with:

DO_2D_01_10
.
.
END_2D

similar conventions apply to the 3D loops macros. jk loop limits are retained
through macro arguments and are not restricted. This includes the possibility of
strides for which an extra set of DO_3DS macros are defined.

In the example definition below the inner PE domain is defined by start indices of
(kIs, kJs) and end indices of (kIe, KJe)

#define DO_2D_00_00 DO jj = kJs, kJe ; DO ji = kIs, kIe
#define END_2D END DO ; END DO

TO DO:


Only conventional nested loops have been identified and replaced by this step. There are constructs such as:

DO jk = 2, jpkm1

z2d(:,:) = z2d(:,:) + e3w(:,:,jk,Kmm) * z3d(:,:,jk) * wmask(:,:,jk)

END DO

which may need to be considered.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • NEMO/branches/2019/dev_r11943_MERGE_2019/src/OCE/ISF/isfcpl.F90

    r12077 r12340  
    4040   END TYPE 
    4141   ! 
     42   !! * Substitutions 
     43#  include "do_loop_substitute.h90" 
    4244   !!---------------------------------------------------------------------- 
    4345   !! NEMO/OCE 4.0 , NEMO Consortium (2018) 
     
    360362      ! ----------------------------------------------------------------------------------------- 
    361363      ! case we open a cell but no neigbour cells available to get an estimate of T and S 
    362       DO jk = 1,jpk-1 
    363          DO jj = 1,jpj 
    364             DO ji = 1,jpi 
    365                IF (tmask(ji,jj,jk) == 1._wp .AND. ts(ji,jj,jk,2,Kmm) == 0._wp)              & 
    366                   &   CALL ctl_stop('STOP', 'failing to fill all new weet cell,     & 
    367                   &                          try increase nn_drown or activate XXXX & 
    368                   &                         in your domain cfg computation'         ) 
    369             END DO 
    370          END DO 
    371       END DO 
     364      DO_3D_11_11( 1,jpk-1 ) 
     365         IF (tmask(ji,jj,jk) == 1._wp .AND. ts(ji,jj,jk,2,Kmm) == 0._wp)              & 
     366            &   CALL ctl_stop('STOP', 'failing to fill all new weet cell,     & 
     367            &                          try increase nn_drown or activate XXXX & 
     368            &                         in your domain cfg computation'         ) 
     369      END_3D 
    372370      !  
    373371   END SUBROUTINE isfcpl_tra 
     
    404402      DO jk = 1, jpk                                 ! Horizontal slab 
    405403         ! 1.1: get volume flux before coupling (>0 out) 
    406          DO jj = 2, jpjm1 
    407             DO ji = 2, jpim1 
    408                zqvolb(ji,jj,jk) =  (   e2u(ji,jj) * ze3u_b(ji,jj,jk) * uu(ji,jj,jk,Kmm) - e2u(ji-1,jj  ) * ze3u_b(ji-1,jj  ,jk) * uu(ji-1,jj  ,jk,Kmm)    & 
    409                   &                  + e1v(ji,jj) * ze3v_b(ji,jj,jk) * vv(ji,jj,jk,Kmm) - e1v(ji  ,jj-1) * ze3v_b(ji  ,jj-1,jk) * vv(ji  ,jj-1,jk,Kmm)  ) & 
    410                   &                * ztmask_b(ji,jj,jk) 
    411             END DO 
    412          ENDDO 
     404         DO_2D_00_00 
     405            zqvolb(ji,jj,jk) =  (   e2u(ji,jj) * ze3u_b(ji,jj,jk) * uu(ji,jj,jk,Kmm) - e2u(ji-1,jj  ) * ze3u_b(ji-1,jj  ,jk) * uu(ji-1,jj  ,jk,Kmm)    & 
     406               &                  + e1v(ji,jj) * ze3v_b(ji,jj,jk) * vv(ji,jj,jk,Kmm) - e1v(ji  ,jj-1) * ze3v_b(ji  ,jj-1,jk) * vv(ji  ,jj-1,jk,Kmm)  ) & 
     407               &                * ztmask_b(ji,jj,jk) 
     408         END_2D 
    413409         ! 
    414410         ! 1.2: get volume flux after coupling (>0 out) 
     
    418414         vv(:,:,jk,Kmm) = vv(:,:,jk,Kmm) * vmask(:,:,jk) 
    419415         ! compute volume flux divergence after coupling 
    420          DO jj = 2, jpjm1 
    421             DO ji = 2, jpim1 
    422                zqvoln(ji,jj,jk) = (   e2u(ji,jj) * e3u(ji,jj,jk,Kmm) * uu(ji,jj,jk,Kmm) - e2u(ji-1,jj  ) * e3u(ji-1,jj  ,jk,Kmm) * uu(ji-1,jj  ,jk,Kmm)    & 
    423                   &                 + e1v(ji,jj) * e3v(ji,jj,jk,Kmm) * vv(ji,jj,jk,Kmm) - e1v(ji  ,jj-1) * e3v(ji  ,jj-1,jk,Kmm) * vv(ji  ,jj-1,jk,Kmm)  ) & 
    424                   &               * tmask(ji,jj,jk) 
    425             END DO 
    426          ENDDO 
     416         DO_2D_00_00 
     417            zqvoln(ji,jj,jk) = (   e2u(ji,jj) * e3u(ji,jj,jk,Kmm) * uu(ji,jj,jk,Kmm) - e2u(ji-1,jj  ) * e3u(ji-1,jj  ,jk,Kmm) * uu(ji-1,jj  ,jk,Kmm)    & 
     418               &                 + e1v(ji,jj) * e3v(ji,jj,jk,Kmm) * vv(ji,jj,jk,Kmm) - e1v(ji  ,jj-1) * e3v(ji  ,jj-1,jk,Kmm) * vv(ji  ,jj-1,jk,Kmm)  ) & 
     419               &               * tmask(ji,jj,jk) 
     420         END_2D 
    427421         ! 
    428422         ! 1.3: get 3d volume flux difference (before - after cpl) (>0 out) 
     
    433427      ! 2.0: include the contribution of the vertical velocity in the volume flux correction 
    434428      ! 
    435       DO jj = 2, jpjm1 
    436          DO ji = 2, jpim1 
    437             ! 
    438             ikt = mikt(ji,jj) 
    439             IF ( ikt > 1 .AND. ssmask(ji,jj) == 1 ) THEN 
    440                risfcpl_vol(ji,jj,ikt) = risfcpl_vol(ji,jj,ikt) + SUM(zqvolb(ji,jj,1:ikt-1))  ! test sign 
    441             ENDIF 
    442             ! 
    443          END DO 
    444       ENDDO 
     429      DO_2D_00_00 
     430         ! 
     431         ikt = mikt(ji,jj) 
     432         IF ( ikt > 1 .AND. ssmask(ji,jj) == 1 ) THEN 
     433            risfcpl_vol(ji,jj,ikt) = risfcpl_vol(ji,jj,ikt) + SUM(zqvolb(ji,jj,1:ikt-1))  ! test sign 
     434         ENDIF 
     435         ! 
     436      END_2D 
    445437      ! 
    446438      CALL lbc_lnk( 'iscpl', risfcpl_vol, 'T', 1. ) 
Note: See TracChangeset for help on using the changeset viewer.