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/TOP/PISCES/P4Z/p4zbc.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/TOP/PISCES/P4Z/p4zbc.F90

    r12258 r12340  
    4848   !! * Substitutions 
    4949#  include "vectopt_loop_substitute.h90" 
     50#  include "do_loop_substitute.h90" 
    5051   !!---------------------------------------------------------------------- 
    5152   !! NEMO/TOP 4.0 , NEMO Consortium (2018) 
     
    111112      IF( ll_river ) THEN 
    112113          jl = n_trc_indcbc(jpno3) 
    113           DO jj = 1, jpj 
    114              DO ji = 1, jpi 
    115                 DO jk = 1, nk_rnf(ji,jj) 
    116                    zcoef = rn_rfact / ( e1e2t(ji,jj) * h_rnf(ji,jj) * rn_cbc_time ) * tmask(ji,jj,1) 
    117                    zrivdin = rf_trcfac(jl) * sf_trccbc(jl)%fnow(ji,jj,1) * zcoef 
    118                    tr(ji,jj,jk,jptal,Krhs) = tr(ji,jj,jk,jptal,Krhs) - rno3 * zrivdin * rfact 
    119                ENDDO 
    120              END DO 
    121           END DO 
     114          DO_2D_11_11 
     115             DO jk = 1, nk_rnf(ji,jj) 
     116                zcoef = rn_rfact / ( e1e2t(ji,jj) * h_rnf(ji,jj) * rn_cbc_time ) * tmask(ji,jj,1) 
     117                zrivdin = rf_trcfac(jl) * sf_trccbc(jl)%fnow(ji,jj,1) * zcoef 
     118                tr(ji,jj,jk,jptal,Krhs) = tr(ji,jj,jk,jptal,Krhs) - rno3 * zrivdin * rfact 
     119            ENDDO 
     120          END_2D 
    122121      ENDIF 
    123122       
     
    146145         ALLOCATE( zironice(jpi,jpj) ) 
    147146         ! 
    148          DO jj = 1, jpj 
    149             DO ji = 1, jpi 
    150                zdep    = rfact / e3t(ji,jj,1,Kmm) 
    151                zwflux  = fmmflx(ji,jj) / 1000._wp 
    152                zironice(ji,jj) =  MAX( -0.99 * tr(ji,jj,1,jpfer,Kbb), -zwflux * icefeinput * zdep ) 
    153             END DO 
    154          END DO 
     147         DO_2D_11_11 
     148            zdep    = rfact / e3t(ji,jj,1,Kmm) 
     149            zwflux  = fmmflx(ji,jj) / 1000._wp 
     150            zironice(ji,jj) =  MAX( -0.99 * tr(ji,jj,1,jpfer,Kbb), -zwflux * icefeinput * zdep ) 
     151         END_2D 
    155152         ! 
    156153         tr(:,:,1,jpfer,Krhs) = tr(:,:,1,jpfer,Krhs) + zironice(:,:) 
     
    300297         IF(lwp) WRITE(numout,*) 
    301298         IF(lwp) WRITE(numout,*) ' Level corresponding to 50m depth ',  ik50,' ', gdept_1d(ik50+1) 
    302          DO jk = 1, ik50 
    303             DO jj = 2, jpjm1 
    304                DO ji = fs_2, fs_jpim1 
    305                   ze3t   = e3t_0(ji,jj,jk) 
    306                   zsurfc =  e1u(ji,jj) * ( 1. - umask(ji  ,jj  ,jk) )   & 
    307                           + e1u(ji,jj) * ( 1. - umask(ji-1,jj  ,jk) )   & 
    308                           + e2v(ji,jj) * ( 1. - vmask(ji  ,jj  ,jk) )   & 
    309                           + e2v(ji,jj) * ( 1. - vmask(ji  ,jj-1,jk) ) 
    310                   zsurfp = zsurfc * ze3t / e1e2t(ji,jj) 
    311                   ! estimation of the coastal slope : 5 km off the coast 
    312                   ze3t2 = ze3t * ze3t 
    313                   zcslp = SQRT( ( distcoast*distcoast + ze3t2 ) / ze3t2 ) 
    314                   ! 
    315                   zcmask(ji,jj,jk) = zcmask(ji,jj,jk) + zcslp * zsurfp 
    316                END DO 
    317             END DO 
    318          END DO 
     299         DO_3D_00_00( 1, ik50 ) 
     300            ze3t   = e3t_0(ji,jj,jk) 
     301            zsurfc =  e1u(ji,jj) * ( 1. - umask(ji  ,jj  ,jk) )   & 
     302                    + e1u(ji,jj) * ( 1. - umask(ji-1,jj  ,jk) )   & 
     303                    + e2v(ji,jj) * ( 1. - vmask(ji  ,jj  ,jk) )   & 
     304                    + e2v(ji,jj) * ( 1. - vmask(ji  ,jj-1,jk) ) 
     305            zsurfp = zsurfc * ze3t / e1e2t(ji,jj) 
     306            ! estimation of the coastal slope : 5 km off the coast 
     307            ze3t2 = ze3t * ze3t 
     308            zcslp = SQRT( ( distcoast*distcoast + ze3t2 ) / ze3t2 ) 
     309            ! 
     310            zcmask(ji,jj,jk) = zcmask(ji,jj,jk) + zcslp * zsurfp 
     311         END_3D 
    319312         ! 
    320313         CALL lbc_lnk( 'p4zbc', zcmask , 'T', 1. )      ! lateral boundary conditions on cmask   (sign unchanged) 
    321314         ! 
    322          DO jk = 1, jpk 
    323             DO jj = 1, jpj 
    324                DO ji = 1, jpi 
    325                   zexpide   = MIN( 8.,( gdept(ji,jj,jk,Kmm) / 500. )**(-1.5) ) 
    326                   zdenitide = -0.9543 + 0.7662 * LOG( zexpide ) - 0.235 * LOG( zexpide )**2 
    327                   zcmask(ji,jj,jk) = zcmask(ji,jj,jk) * MIN( 1., EXP( zdenitide ) / 0.5 ) 
    328                END DO 
    329             END DO 
    330          END DO 
     315         DO_3D_11_11( 1, jpk ) 
     316            zexpide   = MIN( 8.,( gdept(ji,jj,jk,Kmm) / 500. )**(-1.5) ) 
     317            zdenitide = -0.9543 + 0.7662 * LOG( zexpide ) - 0.235 * LOG( zexpide )**2 
     318            zcmask(ji,jj,jk) = zcmask(ji,jj,jk) * MIN( 1., EXP( zdenitide ) / 0.5 ) 
     319         END_3D 
    331320         ! Coastal supply of iron 
    332321         ! ------------------------- 
Note: See TracChangeset for help on using the changeset viewer.