Ignore:
Timestamp:
2020-01-27T15:31:53+01:00 (17 months 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.

Location:
NEMO/branches/2019/dev_r11943_MERGE_2019/src/NST
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • NEMO/branches/2019/dev_r11943_MERGE_2019/src/NST/agrif_oce_sponge.F90

    r12229 r12340  
    3131   PUBLIC interptsn_sponge, interpun_sponge, interpvn_sponge 
    3232 
     33   !! * Substitutions 
     34#  include "do_loop_substitute.h90" 
    3335   !!---------------------------------------------------------------------- 
    3436   !! NEMO/NST 4.0 , NEMO Consortium (2018) 
     
    267269         fspu(:,:) = 0._wp 
    268270         fspv(:,:) = 0._wp 
    269          DO jj = 2, jpjm1 
    270             DO ji = 2, jpim1   ! vector opt. 
    271                fspu(ji,jj) = 0.5_wp * ( ztabramp(ji,jj) + ztabramp(ji+1,jj  ) ) * ssumask(ji,jj) 
    272                fspv(ji,jj) = 0.5_wp * ( ztabramp(ji,jj) + ztabramp(ji  ,jj+1) ) * ssvmask(ji,jj) 
    273             END DO 
    274          END DO 
     271         DO_2D_00_00 
     272            fspu(ji,jj) = 0.5_wp * ( ztabramp(ji,jj) + ztabramp(ji+1,jj  ) ) * ssumask(ji,jj) 
     273            fspv(ji,jj) = 0.5_wp * ( ztabramp(ji,jj) + ztabramp(ji  ,jj+1) ) * ssvmask(ji,jj) 
     274         END_2D 
    275275         CALL lbc_lnk( 'agrif_Sponge', fspu, 'U', 1. )   ! Lateral boundary conditions 
    276276         CALL lbc_lnk( 'agrif_Sponge', fspv, 'V', 1. ) 
     
    283283         fspt(:,:) = 0._wp 
    284284         fspf(:,:) = 0._wp 
    285          DO jj = 2, jpjm1 
    286             DO ji = 2, jpim1   ! vector opt. 
    287                fspt(ji,jj) = ztabramp(ji,jj) * ssmask(ji,jj) 
    288                fspf(ji,jj) = 0.25_wp * ( ztabramp(ji  ,jj  ) + ztabramp(ji  ,jj+1)   & 
    289                                      &  +ztabramp(ji+1,jj+1) + ztabramp(ji+1,jj  ) ) & 
    290                                      &  * ssvmask(ji,jj) * ssvmask(ji,jj+1) 
    291             END DO 
    292          END DO 
     285         DO_2D_00_00 
     286            fspt(ji,jj) = ztabramp(ji,jj) * ssmask(ji,jj) 
     287            fspf(ji,jj) = 0.25_wp * ( ztabramp(ji  ,jj  ) + ztabramp(ji  ,jj+1)   & 
     288                                  &  +ztabramp(ji+1,jj+1) + ztabramp(ji+1,jj  ) ) & 
     289                                  &  * ssvmask(ji,jj) * ssvmask(ji,jj+1) 
     290         END_2D 
    293291         CALL lbc_lnk( 'agrif_Sponge', fspt, 'T', 1. )   ! Lateral boundary conditions 
    294292         CALL lbc_lnk( 'agrif_Sponge', fspf, 'F', 1. ) 
     
    299297#if defined key_vertical 
    300298      ! Remove vertical interpolation where not needed: 
    301       DO jj = 2, jpjm1 
    302          DO ji = 2, jpim1 
    303             IF ((fspu(ji-1,jj)==0._wp).AND.(fspu(ji,jj)==0._wp).AND. & 
    304             &   (fspv(ji,jj-1)==0._wp).AND.(fspv(ji,jj)==0._wp)) mbkt_parent(ji,jj) = 0 
     299      DO_2D_00_00 
     300         IF ((fspu(ji-1,jj)==0._wp).AND.(fspu(ji,jj)==0._wp).AND. & 
     301         &   (fspv(ji,jj-1)==0._wp).AND.(fspv(ji,jj)==0._wp)) mbkt_parent(ji,jj) = 0 
    305302! 
    306             IF ((fspt(ji+1,jj)==0._wp).AND.(fspt(ji,jj)==0._wp).AND. & 
    307             &   (fspf(ji,jj-1)==0._wp).AND.(fspf(ji,jj)==0._wp)) mbku_parent(ji,jj) = 0 
     303         IF ((fspt(ji+1,jj)==0._wp).AND.(fspt(ji,jj)==0._wp).AND. & 
     304         &   (fspf(ji,jj-1)==0._wp).AND.(fspf(ji,jj)==0._wp)) mbku_parent(ji,jj) = 0 
    308305! 
    309             IF ((fspt(ji,jj+1)==0._wp).AND.(fspt(ji,jj)==0._wp).AND. & 
    310             &   (fspf(ji-1,jj)==0._wp).AND.(fspf(ji,jj)==0._wp)) mbkv_parent(ji,jj) = 0 
     306         IF ((fspt(ji,jj+1)==0._wp).AND.(fspt(ji,jj)==0._wp).AND. & 
     307         &   (fspf(ji-1,jj)==0._wp).AND.(fspf(ji,jj)==0._wp)) mbkv_parent(ji,jj) = 0 
    311308! 
    312             IF ( ssmask(ji,jj) == 0._wp) mbkt_parent(ji,jj) = 0 
    313             IF (ssumask(ji,jj) == 0._wp) mbku_parent(ji,jj) = 0 
    314             IF (ssvmask(ji,jj) == 0._wp) mbkv_parent(ji,jj) = 0 
    315          END DO 
    316       END DO 
     309         IF ( ssmask(ji,jj) == 0._wp) mbkt_parent(ji,jj) = 0 
     310         IF (ssumask(ji,jj) == 0._wp) mbku_parent(ji,jj) = 0 
     311         IF (ssvmask(ji,jj) == 0._wp) mbkv_parent(ji,jj) = 0 
     312      END_2D 
    317313      ! 
    318314      ztabramp(:,:) = REAL( mbkt_parent(:,:), wp )   ;   CALL lbc_lnk( 'Agrif_Sponge', ztabramp, 'T', 1. ) 
  • NEMO/branches/2019/dev_r11943_MERGE_2019/src/NST/agrif_user.F90

    r12229 r12340  
    11#undef UPD_HIGH   /* MIX HIGH UPDATE */ 
    22#if defined key_agrif 
     3   !! * Substitutions 
     4#  include "do_loop_substitute.h90" 
    35   !!---------------------------------------------------------------------- 
    46   !! NEMO/NST 4.0 , NEMO Consortium (2018) 
     
    130132      ! TODO: Switch to linear interpolation of bathymetry in the s-coordinate case 
    131133      !       and no refinement 
    132       DO jj = 1, jpjm1 
    133          DO ji = 1, jpim1 
    134             mbku_parent(ji,jj) = MIN(  mbkt_parent(ji+1,jj  ) , mbkt_parent(ji,jj)  ) 
    135             mbkv_parent(ji,jj) = MIN(  mbkt_parent(ji  ,jj+1) , mbkt_parent(ji,jj)  ) 
    136          END DO 
    137       END DO 
     134      DO_2D_10_10 
     135         mbku_parent(ji,jj) = MIN(  mbkt_parent(ji+1,jj  ) , mbkt_parent(ji,jj)  ) 
     136         mbkv_parent(ji,jj) = MIN(  mbkt_parent(ji  ,jj+1) , mbkt_parent(ji,jj)  ) 
     137      END_2D 
    138138      IF ( ln_sco.AND.Agrif_Parent(ln_sco) ) THEN  
    139          DO jj = 1, jpjm1 
    140             DO ji = 1, jpim1 
    141                hu0_parent(ji,jj) = 0.5_wp * ( ht0_parent(ji,jj)+ht0_parent(ji+1,jj) ) 
    142                hv0_parent(ji,jj) = 0.5_wp * ( ht0_parent(ji,jj)+ht0_parent(ji,jj+1) ) 
    143             END DO 
    144          END DO 
     139         DO_2D_10_10 
     140            hu0_parent(ji,jj) = 0.5_wp * ( ht0_parent(ji,jj)+ht0_parent(ji+1,jj) ) 
     141            hv0_parent(ji,jj) = 0.5_wp * ( ht0_parent(ji,jj)+ht0_parent(ji,jj+1) ) 
     142         END_2D 
    145143      ELSE 
    146          DO jj = 1, jpjm1 
    147             DO ji = 1, jpim1 
    148                hu0_parent(ji,jj) = MIN( ht0_parent(ji,jj), ht0_parent(ji+1,jj)) 
    149                hv0_parent(ji,jj) = MIN( ht0_parent(ji,jj), ht0_parent(ji,jj+1)) 
    150             END DO 
    151          END DO 
     144         DO_2D_10_10 
     145            hu0_parent(ji,jj) = MIN( ht0_parent(ji,jj), ht0_parent(ji+1,jj)) 
     146            hv0_parent(ji,jj) = MIN( ht0_parent(ji,jj), ht0_parent(ji,jj+1)) 
     147         END_2D 
    152148 
    153149      ENDIF 
  • NEMO/branches/2019/dev_r11943_MERGE_2019/src/NST/vremap.F90

    r12229 r12340  
    2222   PUBLIC   reconstructandremap, remap_linear 
    2323 
     24   !! * Substitutions 
     25#  include "do_loop_substitute.h90" 
    2426   !!---------------------------------------------------------------------- 
    2527   !! NEMO/OCE 4.0 , NEMO Consortium (2018) 
Note: See TracChangeset for help on using the changeset viewer.