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/CFC – 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.

Location:
NEMO/branches/2019/dev_r11943_MERGE_2019/src/TOP/CFC
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • NEMO/branches/2019/dev_r11943_MERGE_2019/src/TOP/CFC/trcini_cfc.F90

    r11949 r12340  
    2424   REAL(wp) ::   ylatn =  10.           ! 10 degrees north 
    2525 
     26   !! * Substitutions 
     27#  include "do_loop_substitute.h90" 
    2628   !!---------------------------------------------------------------------- 
    2729   !! NEMO/TOP 4.0 , NEMO Consortium (2018) 
     
    130132      !--------------------------------------------------------------------------------------- 
    131133      zyd = ylatn - ylats       
    132       DO jj = 1 , jpj 
    133          DO ji = 1 , jpi 
    134             IF(     gphit(ji,jj) >= ylatn ) THEN   ;   xphem(ji,jj) = 1.e0 
    135             ELSEIF( gphit(ji,jj) <= ylats ) THEN   ;   xphem(ji,jj) = 0.e0 
    136             ELSE                                   ;   xphem(ji,jj) = ( gphit(ji,jj) - ylats) / zyd 
    137             ENDIF 
    138          END DO 
    139       END DO 
     134      DO_2D_11_11 
     135         IF(     gphit(ji,jj) >= ylatn ) THEN   ;   xphem(ji,jj) = 1.e0 
     136         ELSEIF( gphit(ji,jj) <= ylats ) THEN   ;   xphem(ji,jj) = 0.e0 
     137         ELSE                                   ;   xphem(ji,jj) = ( gphit(ji,jj) - ylats) / zyd 
     138         ENDIF 
     139      END_2D 
    140140      ! 
    141141      IF(lwp) WRITE(numout,*) 'Initialization of CFC tracers done' 
  • NEMO/branches/2019/dev_r11943_MERGE_2019/src/TOP/CFC/trcsms_cfc.F90

    r12301 r12340  
    4747   REAL(wp) ::   xconv4 = 1.0e-12      ! conversion from mol/m3/atm to mol/m3/pptv  
    4848 
     49   !! * Substitutions 
     50#  include "do_loop_substitute.h90" 
    4951   !!---------------------------------------------------------------------- 
    5052   !! NEMO/TOP 4.0 , NEMO Consortium (2018) 
     
    123125          
    124126         !                                                         !------------! 
    125          DO jj = 1, jpj                                            !  i-j loop  ! 
    126             DO ji = 1, jpi                                         !------------! 
     127         DO_2D_11_11 
    127128  
    128                ! space interpolation 
    129                zpp_cfc  =       xphem(ji,jj)   * zpatm(1,jl)   & 
    130                   &     + ( 1.- xphem(ji,jj) ) * zpatm(2,jl) 
    131  
    132                ! Computation of concentration at equilibrium : in picomol/l 
    133                ! coefficient for solubility for CFC-11/12 in  mol/l/atm 
    134                IF( tmask(ji,jj,1) .GE. 0.5 ) THEN 
    135                   ztap  = ( ts(ji,jj,1,jp_tem,Kmm) + 273.16 ) * 0.01 
    136                   zdtap = sob(1,jl) + ztap * ( sob(2,jl) + ztap * sob(3,jl) )  
    137                   zsol  =  EXP( soa(1,jl) + soa(2,jl) / ztap + soa(3,jl) * LOG( ztap )   & 
    138                      &                    + soa(4,jl) * ztap * ztap + ts(ji,jj,1,jp_sal,Kmm) * zdtap )  
    139                ELSE 
    140                   zsol  = 0.e0 
    141                ENDIF 
    142                ! conversion from mol/l/atm to mol/m3/atm and from mol/m3/atm to mol/m3/pptv     
    143                zsol = xconv4 * xconv3 * zsol * tmask(ji,jj,1)   
    144                ! concentration at equilibrium 
    145                zca_cfc = xconv1 * zpp_cfc * zsol * tmask(ji,jj,1)              
    146    
    147                ! Computation of speed transfert 
    148                !    Schmidt number revised in Wanninkhof (2014) 
    149                zt1  = ts(ji,jj,1,jp_tem,Kmm) 
    150                zt2  = zt1 * zt1  
    151                zt3  = zt1 * zt2 
    152                zt4  = zt2 * zt2 
    153                zsch = sca(1,jl) + sca(2,jl) * zt1 + sca(3,jl) * zt2 + sca(4,jl) * zt3 + sca(5,jl) * zt4 
    154  
    155                !    speed transfert : formulae revised in Wanninkhof (2014) 
    156                zv2     = wndm(ji,jj) * wndm(ji,jj) 
    157                zsch    = zsch / 660. 
    158                zak_cfc = ( 0.251 * xconv2 * zv2 / SQRT(zsch) ) * tmask(ji,jj,1) 
    159  
    160                ! Input function  : speed *( conc. at equil - concen at surface ) 
    161                ! tr(:,:,:,:,Kmm) in pico-mol/l idem qtr; ak in en m/a 
    162                qtr_cfc(ji,jj,jl) = -zak_cfc * ( tr(ji,jj,1,jn,Kbb) - zca_cfc )   & 
    163                   &                         * tmask(ji,jj,1) * ( 1. - fr_i(ji,jj) ) 
    164                ! Add the surface flux to the trend 
    165                tr(ji,jj,1,jn,Krhs) = tr(ji,jj,1,jn,Krhs) + qtr_cfc(ji,jj,jl) / e3t(ji,jj,1,Kmm)  
    166  
    167                ! cumulation of surface flux at each time step 
    168                qint_cfc(ji,jj,jl) = qint_cfc(ji,jj,jl) + qtr_cfc(ji,jj,jl) * rdt 
    169                !                                               !----------------! 
    170             END DO                                             !  end i-j loop  ! 
    171          END DO                                                !----------------! 
     129            ! space interpolation 
     130            zpp_cfc  =       xphem(ji,jj)   * zpatm(1,jl)   & 
     131               &     + ( 1.- xphem(ji,jj) ) * zpatm(2,jl) 
     132 
     133            ! Computation of concentration at equilibrium : in picomol/l 
     134            ! coefficient for solubility for CFC-11/12 in  mol/l/atm 
     135            IF( tmask(ji,jj,1) .GE. 0.5 ) THEN 
     136               ztap  = ( ts(ji,jj,1,jp_tem,Kmm) + 273.16 ) * 0.01 
     137               zdtap = sob(1,jl) + ztap * ( sob(2,jl) + ztap * sob(3,jl) )  
     138               zsol  =  EXP( soa(1,jl) + soa(2,jl) / ztap + soa(3,jl) * LOG( ztap )   & 
     139                  &                    + soa(4,jl) * ztap * ztap + ts(ji,jj,1,jp_sal,Kmm) * zdtap )  
     140            ELSE 
     141               zsol  = 0.e0 
     142            ENDIF 
     143            ! conversion from mol/l/atm to mol/m3/atm and from mol/m3/atm to mol/m3/pptv     
     144            zsol = xconv4 * xconv3 * zsol * tmask(ji,jj,1)   
     145            ! concentration at equilibrium 
     146            zca_cfc = xconv1 * zpp_cfc * zsol * tmask(ji,jj,1)              
     147            ! Computation of speed transfert 
     148            !    Schmidt number revised in Wanninkhof (2014) 
     149            zt1  = ts(ji,jj,1,jp_tem,Kmm) 
     150            zt2  = zt1 * zt1  
     151            zt3  = zt1 * zt2 
     152            zt4  = zt2 * zt2 
     153            zsch = sca(1,jl) + sca(2,jl) * zt1 + sca(3,jl) * zt2 + sca(4,jl) * zt3 + sca(5,jl) * zt4 
     154 
     155            !    speed transfert : formulae revised in Wanninkhof (2014) 
     156            zv2     = wndm(ji,jj) * wndm(ji,jj) 
     157            zsch    = zsch / 660. 
     158            zak_cfc = ( 0.251 * xconv2 * zv2 / SQRT(zsch) ) * tmask(ji,jj,1) 
     159 
     160            ! Input function  : speed *( conc. at equil - concen at surface ) 
     161            ! tr(:,:,:,:,Kmm) in pico-mol/l idem qtr; ak in en m/a 
     162            qtr_cfc(ji,jj,jl) = -zak_cfc * ( tr(ji,jj,1,jn,Kbb) - zca_cfc )   & 
     163               &                         * tmask(ji,jj,1) * ( 1. - fr_i(ji,jj) ) 
     164            ! Add the surface flux to the trend 
     165            tr(ji,jj,1,jn,Krhs) = tr(ji,jj,1,jn,Krhs) + qtr_cfc(ji,jj,jl) / e3t(ji,jj,1,Kmm)  
     166 
     167            ! cumulation of surface flux at each time step 
     168            qint_cfc(ji,jj,jl) = qint_cfc(ji,jj,jl) + qtr_cfc(ji,jj,jl) * rdt 
     169            !                                               !----------------! 
     170         END_2D 
    172171         !                                                  !----------------! 
    173172      END DO                                                !  end CFC loop  ! 
Note: See TracChangeset for help on using the changeset viewer.