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/TRP/trcsbc.F90 – NEMO

Ignore:
Timestamp:
2020-01-27T15:31:53+01:00 (5 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/TRP/trcsbc.F90

    r12236 r12340  
    3030   !! * Substitutions 
    3131#  include "vectopt_loop_substitute.h90" 
     32#  include "do_loop_substitute.h90" 
    3233   !!---------------------------------------------------------------------- 
    3334   !! NEMO/TOP 4.0 , NEMO Consortium (2018) 
     
    120121         ! 
    121122         DO jn = 1, jptra 
    122             DO jj = 2, jpj 
    123                DO ji = fs_2, fs_jpim1   ! vector opt. 
    124                   sbc_trc(ji,jj,jn) = zsfx(ji,jj) * r1_rau0 * ptr(ji,jj,1,jn,Kmm) 
    125                END DO 
    126             END DO 
     123            DO_2D_01_00 
     124               sbc_trc(ji,jj,jn) = zsfx(ji,jj) * r1_rau0 * ptr(ji,jj,1,jn,Kmm) 
     125            END_2D 
    127126         END DO 
    128127         ! 
     
    130129         ! 
    131130         DO jn = 1, jptra 
    132             DO jj = 2, jpj 
    133                DO ji = fs_2, fs_jpim1   ! vector opt. 
    134                   sbc_trc(ji,jj,jn) = ( zsfx(ji,jj) + fmmflx(ji,jj) ) * r1_rau0 * ptr(ji,jj,1,jn,Kmm) 
    135                END DO 
    136             END DO 
     131            DO_2D_01_00 
     132               sbc_trc(ji,jj,jn) = ( zsfx(ji,jj) + fmmflx(ji,jj) ) * r1_rau0 * ptr(ji,jj,1,jn,Kmm) 
     133            END_2D 
    137134         END DO 
    138135         ! 
     
    140137         ! 
    141138         DO jn = 1, jptra 
    142             DO jj = 2, jpj 
    143                DO ji = fs_2, fs_jpim1   ! vector opt. 
    144                   zse3t = 1. / e3t(ji,jj,1,Kmm) 
    145                   ! tracer flux at the ice/ocean interface (tracer/m2/s) 
    146                   zftra = - trc_i(ji,jj,jn) * fmmflx(ji,jj) ! uptake of tracer in the sea ice 
    147                   !                                         ! only used in the levitating sea ice case 
    148                   ! tracer flux only       : add concentration dilution term in net tracer flux, no F-M in volume flux 
    149                   ! tracer and mass fluxes : no concentration dilution term in net tracer flux, F-M term in volume flux 
    150                   ztfx  = zftra                        ! net tracer flux 
    151                   ! 
    152                   zdtra = r1_rau0 * ( ztfx + ( zsfx(ji,jj) + fmmflx(ji,jj) ) * ptr(ji,jj,1,jn,Kmm) )  
    153                   IF ( zdtra < 0. ) THEN 
    154                      zdtra  = MAX(zdtra, -ptr(ji,jj,1,jn,Kmm) * e3t(ji,jj,1,Kmm) / r2dttrc )   ! avoid negative concentrations to arise 
    155                   ENDIF 
    156                   sbc_trc(ji,jj,jn) =  zdtra  
    157                END DO 
    158             END DO 
     139            DO_2D_01_00 
     140               zse3t = 1. / e3t(ji,jj,1,Kmm) 
     141               ! tracer flux at the ice/ocean interface (tracer/m2/s) 
     142               zftra = - trc_i(ji,jj,jn) * fmmflx(ji,jj) ! uptake of tracer in the sea ice 
     143               !                                         ! only used in the levitating sea ice case 
     144               ! tracer flux only       : add concentration dilution term in net tracer flux, no F-M in volume flux 
     145               ! tracer and mass fluxes : no concentration dilution term in net tracer flux, F-M term in volume flux 
     146               ztfx  = zftra                        ! net tracer flux 
     147               ! 
     148               zdtra = r1_rau0 * ( ztfx + ( zsfx(ji,jj) + fmmflx(ji,jj) ) * ptr(ji,jj,1,jn,Kmm) )  
     149               IF ( zdtra < 0. ) THEN 
     150                  zdtra  = MAX(zdtra, -ptr(ji,jj,1,jn,Kmm) * e3t(ji,jj,1,Kmm) / r2dttrc )   ! avoid negative concentrations to arise 
     151               ENDIF 
     152               sbc_trc(ji,jj,jn) =  zdtra  
     153            END_2D 
    159154         END DO 
    160155      END SELECT 
     
    166161         IF( l_trdtrc )   ztrtrd(:,:,:) = ptr(:,:,:,jn,Krhs)  ! save trends 
    167162         ! 
    168          DO jj = 2, jpj 
    169             DO ji = fs_2, fs_jpim1   ! vector opt. 
    170                zse3t = zfact / e3t(ji,jj,1,Kmm) 
    171                ptr(ji,jj,1,jn,Krhs) = ptr(ji,jj,1,jn,Krhs) + ( sbc_trc_b(ji,jj,jn) + sbc_trc(ji,jj,jn) ) * zse3t 
    172             END DO 
    173          END DO 
     163         DO_2D_01_00 
     164            zse3t = zfact / e3t(ji,jj,1,Kmm) 
     165            ptr(ji,jj,1,jn,Krhs) = ptr(ji,jj,1,jn,Krhs) + ( sbc_trc_b(ji,jj,jn) + sbc_trc(ji,jj,jn) ) * zse3t 
     166         END_2D 
    174167         ! 
    175168         IF( l_trdtrc ) THEN 
Note: See TracChangeset for help on using the changeset viewer.