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/SBC/sbcblk_algo_coare3p6.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/SBC/sbcblk_algo_coare3p6.F90

    r12182 r12340  
    4444 
    4545   PUBLIC :: SBCBLK_ALGO_COARE3P6_INIT, TURB_COARE3P6 
     46   !! * Substitutions 
     47#  include "do_loop_substitute.h90" 
    4648 
    4749   !! COARE own values for given constants: 
     
    429431      !!---------------------------------------------------------------------------------- 
    430432      ! 
    431       DO jj = 1, jpj 
    432          DO ji = 1, jpi 
    433             ! 
    434             zta = pzeta(ji,jj) 
    435             ! 
    436             zphi_m = ABS(1. - 15.*zta)**.25    !!Kansas unstable 
    437             ! 
    438             zpsi_k = 2.*LOG((1. + zphi_m)/2.) + LOG((1. + zphi_m*zphi_m)/2.)   & 
    439                & - 2.*ATAN(zphi_m) + 0.5*rpi 
    440             ! 
    441             zphi_c = ABS(1. - 10.15*zta)**.3333                   !!Convective 
    442             ! 
    443             zpsi_c = 1.5*LOG((1. + zphi_c + zphi_c*zphi_c)/3.) & 
    444                &     - 1.7320508*ATAN((1. + 2.*zphi_c)/1.7320508) + 1.813799447 
    445             ! 
    446             zf = zta*zta 
    447             zf = zf/(1. + zf) 
    448             zc = MIN(50._wp, 0.35_wp*zta) 
    449             zstab = 0.5 + SIGN(0.5_wp, zta) 
    450             ! 
    451             psi_m_coare(ji,jj) = (1. - zstab) * ( (1. - zf)*zpsi_k + zf*zpsi_c ) & ! (zta < 0) 
    452                &                -   zstab     * ( 1. + 1.*zta     &                ! (zta > 0) 
    453                &                         + 0.6667*(zta - 14.28)/EXP(zc) + 8.525 )   !     " 
    454             ! 
    455          END DO 
    456       END DO 
     433      DO_2D_11_11 
     434         ! 
     435         zta = pzeta(ji,jj) 
     436         ! 
     437         zphi_m = ABS(1. - 15.*zta)**.25    !!Kansas unstable 
     438         ! 
     439         zpsi_k = 2.*LOG((1. + zphi_m)/2.) + LOG((1. + zphi_m*zphi_m)/2.)   & 
     440            & - 2.*ATAN(zphi_m) + 0.5*rpi 
     441         ! 
     442         zphi_c = ABS(1. - 10.15*zta)**.3333                   !!Convective 
     443         ! 
     444         zpsi_c = 1.5*LOG((1. + zphi_c + zphi_c*zphi_c)/3.) & 
     445            &     - 1.7320508*ATAN((1. + 2.*zphi_c)/1.7320508) + 1.813799447 
     446         ! 
     447         zf = zta*zta 
     448         zf = zf/(1. + zf) 
     449         zc = MIN(50._wp, 0.35_wp*zta) 
     450         zstab = 0.5 + SIGN(0.5_wp, zta) 
     451         ! 
     452         psi_m_coare(ji,jj) = (1. - zstab) * ( (1. - zf)*zpsi_k + zf*zpsi_c ) & ! (zta < 0) 
     453            &                -   zstab     * ( 1. + 1.*zta     &                ! (zta > 0) 
     454            &                         + 0.6667*(zta - 14.28)/EXP(zc) + 8.525 )   !     " 
     455         ! 
     456      END_2D 
    457457      ! 
    458458   END FUNCTION psi_m_coare 
     
    482482      REAL(wp) :: zta, zphi_h, zphi_c, zpsi_k, zpsi_c, zf, zc, zstab 
    483483      ! 
    484       DO jj = 1, jpj 
    485          DO ji = 1, jpi 
    486             ! 
    487             zta = pzeta(ji,jj) 
    488             ! 
    489             zphi_h = (ABS(1. - 15.*zta))**.5  !! Kansas unstable   (zphi_h = zphi_m**2 when unstable, zphi_m when stable) 
    490             ! 
    491             zpsi_k = 2.*LOG((1. + zphi_h)/2.) 
    492             ! 
    493             zphi_c = (ABS(1. - 34.15*zta))**.3333   !! Convective 
    494             ! 
    495             zpsi_c = 1.5*LOG((1. + zphi_c + zphi_c*zphi_c)/3.) & 
    496                &    -1.7320508*ATAN((1. + 2.*zphi_c)/1.7320508) + 1.813799447 
    497             ! 
    498             zf = zta*zta 
    499             zf = zf/(1. + zf) 
    500             zc = MIN(50._wp,0.35_wp*zta) 
    501             zstab = 0.5 + SIGN(0.5_wp, zta) 
    502             ! 
    503             psi_h_coare(ji,jj) = (1. - zstab) * ( (1. - zf)*zpsi_k + zf*zpsi_c ) & 
    504                &                -   zstab     * ( (ABS(1. + 2.*zta/3.))**1.5     & 
    505                &                           + .6667*(zta - 14.28)/EXP(zc) + 8.525 ) 
    506             ! 
    507          END DO 
    508       END DO 
     484      DO_2D_11_11 
     485         ! 
     486         zta = pzeta(ji,jj) 
     487         ! 
     488         zphi_h = (ABS(1. - 15.*zta))**.5  !! Kansas unstable   (zphi_h = zphi_m**2 when unstable, zphi_m when stable) 
     489         ! 
     490         zpsi_k = 2.*LOG((1. + zphi_h)/2.) 
     491         ! 
     492         zphi_c = (ABS(1. - 34.15*zta))**.3333   !! Convective 
     493         ! 
     494         zpsi_c = 1.5*LOG((1. + zphi_c + zphi_c*zphi_c)/3.) & 
     495            &    -1.7320508*ATAN((1. + 2.*zphi_c)/1.7320508) + 1.813799447 
     496         ! 
     497         zf = zta*zta 
     498         zf = zf/(1. + zf) 
     499         zc = MIN(50._wp,0.35_wp*zta) 
     500         zstab = 0.5 + SIGN(0.5_wp, zta) 
     501         ! 
     502         psi_h_coare(ji,jj) = (1. - zstab) * ( (1. - zf)*zpsi_k + zf*zpsi_c ) & 
     503            &                -   zstab     * ( (ABS(1. + 2.*zta/3.))**1.5     & 
     504            &                           + .6667*(zta - 14.28)/EXP(zc) + 8.525 ) 
     505         ! 
     506      END_2D 
    509507      ! 
    510508   END FUNCTION psi_h_coare 
Note: See TracChangeset for help on using the changeset viewer.