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_coare3p0.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_coare3p0.F90

    r12182 r12340  
    4444 
    4545   PUBLIC :: SBCBLK_ALGO_COARE3P0_INIT, TURB_COARE3P0 
     46   !! * Substitutions 
     47#  include "do_loop_substitute.h90" 
    4648 
    4749   !! COARE own values for given constants: 
     
    393395      !!------------------------------------------------------------------- 
    394396      ! 
    395       DO jj = 1, jpj 
    396          DO ji = 1, jpi 
    397             ! 
    398             zw = pwnd(ji,jj)   ! wind speed 
    399             ! 
    400             ! Charnock's constant, increases with the wind : 
    401             zgt10 = 0.5 + SIGN(0.5_wp,(zw - 10))  ! If zw<10. --> 0, else --> 1 
    402             zgt18 = 0.5 + SIGN(0.5_wp,(zw - 18.)) ! If zw<18. --> 0, else --> 1 
    403             ! 
    404             alfa_charn_3p0(ji,jj) =  (1. - zgt10)*0.011    &    ! wind is lower than 10 m/s 
    405                &     + zgt10*((1. - zgt18)*(0.011 + (0.018 - 0.011) & 
    406                &      *(zw - 10.)/(18. - 10.)) + zgt18*( 0.018 ) )    ! Hare et al. (1999) 
    407             ! 
    408          END DO 
    409       END DO 
     397      DO_2D_11_11 
     398         ! 
     399         zw = pwnd(ji,jj)   ! wind speed 
     400         ! 
     401         ! Charnock's constant, increases with the wind : 
     402         zgt10 = 0.5 + SIGN(0.5_wp,(zw - 10))  ! If zw<10. --> 0, else --> 1 
     403         zgt18 = 0.5 + SIGN(0.5_wp,(zw - 18.)) ! If zw<18. --> 0, else --> 1 
     404         ! 
     405         alfa_charn_3p0(ji,jj) =  (1. - zgt10)*0.011    &    ! wind is lower than 10 m/s 
     406            &     + zgt10*((1. - zgt18)*(0.011 + (0.018 - 0.011) & 
     407            &      *(zw - 10.)/(18. - 10.)) + zgt18*( 0.018 ) )    ! Hare et al. (1999) 
     408         ! 
     409      END_2D 
    410410      ! 
    411411   END FUNCTION alfa_charn_3p0 
     
    431431      !!---------------------------------------------------------------------------------- 
    432432      ! 
    433       DO jj = 1, jpj 
    434          DO ji = 1, jpi 
    435             ! 
    436             zta = pzeta(ji,jj) 
    437             ! 
    438             zphi_m = ABS(1. - 15.*zta)**.25    !!Kansas unstable 
    439             ! 
    440             zpsi_k = 2.*LOG((1. + zphi_m)/2.) + LOG((1. + zphi_m*zphi_m)/2.)   & 
    441                & - 2.*ATAN(zphi_m) + 0.5*rpi 
    442             ! 
    443             zphi_c = ABS(1. - 10.15*zta)**.3333                   !!Convective 
    444             ! 
    445             zpsi_c = 1.5*LOG((1. + zphi_c + zphi_c*zphi_c)/3.) & 
    446                &     - 1.7320508*ATAN((1. + 2.*zphi_c)/1.7320508) + 1.813799447 
    447             ! 
    448             zf = zta*zta 
    449             zf = zf/(1. + zf) 
    450             zc = MIN(50._wp, 0.35_wp*zta) 
    451             zstab = 0.5 + SIGN(0.5_wp, zta) 
    452             ! 
    453             psi_m_coare(ji,jj) = (1. - zstab) * ( (1. - zf)*zpsi_k + zf*zpsi_c ) & ! (zta < 0) 
    454                &                -   zstab     * ( 1. + 1.*zta     &                ! (zta > 0) 
    455                &                         + 0.6667*(zta - 14.28)/EXP(zc) + 8.525 )   !     " 
    456             ! 
    457          END DO 
    458       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 
    459457      ! 
    460458   END FUNCTION psi_m_coare 
     
    484482      REAL(wp) :: zta, zphi_h, zphi_c, zpsi_k, zpsi_c, zf, zc, zstab 
    485483      ! 
    486       DO jj = 1, jpj 
    487          DO ji = 1, jpi 
    488             ! 
    489             zta = pzeta(ji,jj) 
    490             ! 
    491             zphi_h = (ABS(1. - 15.*zta))**.5  !! Kansas unstable   (zphi_h = zphi_m**2 when unstable, zphi_m when stable) 
    492             ! 
    493             zpsi_k = 2.*LOG((1. + zphi_h)/2.) 
    494             ! 
    495             zphi_c = (ABS(1. - 34.15*zta))**.3333   !! Convective 
    496             ! 
    497             zpsi_c = 1.5*LOG((1. + zphi_c + zphi_c*zphi_c)/3.) & 
    498                &    -1.7320508*ATAN((1. + 2.*zphi_c)/1.7320508) + 1.813799447 
    499             ! 
    500             zf = zta*zta 
    501             zf = zf/(1. + zf) 
    502             zc = MIN(50._wp,0.35_wp*zta) 
    503             zstab = 0.5 + SIGN(0.5_wp, zta) 
    504             ! 
    505             psi_h_coare(ji,jj) = (1. - zstab) * ( (1. - zf)*zpsi_k + zf*zpsi_c ) & 
    506                &                -   zstab     * ( (ABS(1. + 2.*zta/3.))**1.5     & 
    507                &                           + .6667*(zta - 14.28)/EXP(zc) + 8.525 ) 
    508             ! 
    509          END DO 
    510       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 
    511507      ! 
    512508   END FUNCTION psi_h_coare 
Note: See TracChangeset for help on using the changeset viewer.