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/C14 – 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/C14
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • NEMO/branches/2019/dev_r11943_MERGE_2019/src/TOP/C14/trcatm_c14.F90

    r10069 r12340  
    2121   PUBLIC   trc_atm_c14_ini     ! called in trcini_c14.F90 
    2222   ! 
     23   !! * Substitutions 
     24#  include "do_loop_substitute.h90" 
    2325   !!---------------------------------------------------------------------- 
    2426   !! NEMO/TOP 4.0 , NEMO Consortium (2018) 
     
    118120            IF( ierr3 /= 0 )   CALL ctl_stop( 'STOP', 'trc_atm_c14_ini: unable to allocate fareaz' ) 
    119121      ! 
    120             DO jj = 1 , jpj                       ! from C14b package 
    121               DO ji = 1 , jpi 
    122                  IF( gphit(ji,jj) >= yn40 ) THEN 
    123                     fareaz(ji,jj,1) = 0. 
    124                     fareaz(ji,jj,2) = 0. 
    125                     fareaz(ji,jj,3) = 1. 
    126                  ELSE IF( gphit(ji,jj ) <= ys40) THEN 
    127                     fareaz(ji,jj,1) = 1. 
    128                     fareaz(ji,jj,2) = 0. 
    129                     fareaz(ji,jj,3) = 0. 
    130                  ELSE IF( gphit(ji,jj) >= yn20 ) THEN 
    131                     fareaz(ji,jj,1) = 0. 
    132                     fareaz(ji,jj,2) = 2. * ( 1. - gphit(ji,jj) / yn40 ) 
    133                     fareaz(ji,jj,3) = 2. * gphit(ji,jj) / yn40 - 1. 
    134                  ELSE IF( gphit(ji,jj) <= ys20 ) THEN 
    135                     fareaz(ji,jj,1) = 2. * gphit(ji,jj) / ys40 - 1. 
    136                     fareaz(ji,jj,2) = 2. * ( 1. - gphit(ji,jj) / ys40 ) 
    137                     fareaz(ji,jj,3) = 0. 
    138                  ELSE 
    139                     fareaz(ji,jj,1) = 0. 
    140                     fareaz(ji,jj,2) = 1. 
    141                     fareaz(ji,jj,3) = 0. 
    142                  ENDIF 
    143               END DO 
    144            END DO 
     122            DO_2D_11_11 
     123              IF( gphit(ji,jj) >= yn40 ) THEN 
     124                 fareaz(ji,jj,1) = 0. 
     125                 fareaz(ji,jj,2) = 0. 
     126                 fareaz(ji,jj,3) = 1. 
     127              ELSE IF( gphit(ji,jj ) <= ys40) THEN 
     128                 fareaz(ji,jj,1) = 1. 
     129                 fareaz(ji,jj,2) = 0. 
     130                 fareaz(ji,jj,3) = 0. 
     131              ELSE IF( gphit(ji,jj) >= yn20 ) THEN 
     132                 fareaz(ji,jj,1) = 0. 
     133                 fareaz(ji,jj,2) = 2. * ( 1. - gphit(ji,jj) / yn40 ) 
     134                 fareaz(ji,jj,3) = 2. * gphit(ji,jj) / yn40 - 1. 
     135              ELSE IF( gphit(ji,jj) <= ys20 ) THEN 
     136                 fareaz(ji,jj,1) = 2. * gphit(ji,jj) / ys40 - 1. 
     137                 fareaz(ji,jj,2) = 2. * ( 1. - gphit(ji,jj) / ys40 ) 
     138                 fareaz(ji,jj,3) = 0. 
     139              ELSE 
     140                 fareaz(ji,jj,1) = 0. 
     141                 fareaz(ji,jj,2) = 1. 
     142                 fareaz(ji,jj,3) = 0. 
     143              ENDIF 
     144            END_2D 
    145145      ! 
    146146         ENDIF 
  • NEMO/branches/2019/dev_r11943_MERGE_2019/src/TOP/C14/trcsms_c14.F90

    r11949 r12340  
    2626   PUBLIC   trc_sms_c14       ! called in trcsms.F90 
    2727 
     28   !! * Substitutions 
     29#  include "do_loop_substitute.h90" 
    2830   !!---------------------------------------------------------------------- 
    2931   !! NEMO/TOP 4.0 , NEMO Consortium (2018) 
     
    7880      ! ------------------------------------------------------------------- 
    7981 
    80       DO jj = 1, jpj 
    81          DO ji = 1, jpi   
    82             IF( tmask(ji,jj,1) >  0. ) THEN 
    83                ! 
    84                zt   = MIN( 40. , ts(ji,jj,1,jp_tem,Kmm) ) 
    85                ! 
    86                !  Computation of solubility zsol in [mol/(L * atm)] 
    87                !   after Wanninkhof (2014) referencing Weiss (1974) 
    88                ztp  = ( zt + 273.16 ) * 0.01 
    89                zsk  = 0.027766 + ztp * ( -0.025888 + 0.0050578 * ztp )   ! [mol/(L * atm)] 
    90                zsol = EXP( -58.0931 + 90.5069 / ztp  + 22.2940 * LOG( ztp ) + zsk * ts(ji,jj,1,jp_sal,Kmm) ) 
    91                ! convert solubilities [mol/(L * atm)] -> [mol/(m^3 * ppm)] 
    92                zsol = zsol * 1.e-03 
     82      DO_2D_11_11 
     83         IF( tmask(ji,jj,1) >  0. ) THEN 
     84            ! 
     85            zt   = MIN( 40. , ts(ji,jj,1,jp_tem,Kmm) ) 
     86            ! 
     87            !  Computation of solubility zsol in [mol/(L * atm)] 
     88            !   after Wanninkhof (2014) referencing Weiss (1974) 
     89            ztp  = ( zt + 273.16 ) * 0.01 
     90            zsk  = 0.027766 + ztp * ( -0.025888 + 0.0050578 * ztp )   ! [mol/(L * atm)] 
     91            zsol = EXP( -58.0931 + 90.5069 / ztp  + 22.2940 * LOG( ztp ) + zsk * ts(ji,jj,1,jp_sal,Kmm) ) 
     92            ! convert solubilities [mol/(L * atm)] -> [mol/(m^3 * ppm)] 
     93            zsol = zsol * 1.e-03 
    9394 
    94                ! Computes the Schmidt number of CO2 in seawater 
    95                !               Wanninkhof-2014 
    96                zsch = 2116.8 + zt * ( -136.25 + zt * (4.7353 + zt * (-0.092307 + 0.0007555 * zt ) ) ) 
     95            ! Computes the Schmidt number of CO2 in seawater 
     96            !               Wanninkhof-2014 
     97            zsch = 2116.8 + zt * ( -136.25 + zt * (4.7353 + zt * (-0.092307 + 0.0007555 * zt ) ) ) 
    9798 
    98                ! Wanninkhof Piston velocity: zpv in units [m/s] 
    99                zv2 = xkwind * (wndm(ji,jj) * wndm(ji,jj))              ! wind speed module at T points 
    100                ! chemical enhancement (Wanninkhof & Knox, 1996) 
    101                IF( ln_chemh ) zv2 = zv2 + 2.5 * ( 0.5246 + zt * (0.016256 + 0.00049946  * zt ) ) 
    102                zv2 = zv2/360000._wp                                    ! conversion cm/h -> m/s 
    103                ! 
    104                zpv  = ( zv2 * SQRT( 660./ zsch ) ) * ( 1. - fr_i(ji,jj) ) * tmask(ji,jj,1) 
     99            ! Wanninkhof Piston velocity: zpv in units [m/s] 
     100            zv2 = xkwind * (wndm(ji,jj) * wndm(ji,jj))              ! wind speed module at T points 
     101            ! chemical enhancement (Wanninkhof & Knox, 1996) 
     102            IF( ln_chemh ) zv2 = zv2 + 2.5 * ( 0.5246 + zt * (0.016256 + 0.00049946  * zt ) ) 
     103            zv2 = zv2/360000._wp                                    ! conversion cm/h -> m/s 
     104            ! 
     105            zpv  = ( zv2 * SQRT( 660./ zsch ) ) * ( 1. - fr_i(ji,jj) ) * tmask(ji,jj,1) 
    105106 
    106                ! CO2 piston velocity (m/s) 
    107                exch_co2(ji,jj)= zpv 
    108                ! CO2 invasion rate (mol/ppm/m2/s) = 1st part of 14C/C exchange velocity 
    109                exch_c14(ji,jj)= zpv * zsol 
    110             ELSE 
    111                exch_co2(ji,jj) = 0._wp 
    112                exch_c14(ji,jj) = 0._wp 
    113             ENDIF 
    114          END DO 
    115       END DO 
     107            ! CO2 piston velocity (m/s) 
     108            exch_co2(ji,jj)= zpv 
     109            ! CO2 invasion rate (mol/ppm/m2/s) = 1st part of 14C/C exchange velocity 
     110            exch_c14(ji,jj)= zpv * zsol 
     111         ELSE 
     112            exch_co2(ji,jj) = 0._wp 
     113            exch_c14(ji,jj) = 0._wp 
     114         ENDIF 
     115      END_2D 
    116116 
    117117      ! Exchange velocity for 14C/C ratio (m/s) 
     
    127127      ! 
    128128      ! Add the surface flux to the trend of jp_c14 
    129       DO jj = 1, jpj 
    130          DO ji = 1, jpi 
    131             tr(ji,jj,1,jp_c14,Krhs) = tr(ji,jj,1,jp_c14,Krhs) + qtr_c14(ji,jj) / e3t(ji,jj,1,Kmm)  
    132          END DO 
    133       END DO 
     129      DO_2D_11_11 
     130         tr(ji,jj,1,jp_c14,Krhs) = tr(ji,jj,1,jp_c14,Krhs) + qtr_c14(ji,jj) / e3t(ji,jj,1,Kmm)  
     131      END_2D 
    134132      ! 
    135133      ! Computation of decay effects on jp_c14 
    136       DO jk = 1, jpk 
    137          DO jj = 1, jpj 
    138             DO ji = 1, jpi 
    139                ! 
    140                tr(ji,jj,jk,jp_c14,Krhs) = tr(ji,jj,jk,jp_c14,Krhs) - rlam14 * tr(ji,jj,jk,jp_c14,Kbb) * tmask(ji,jj,jk)  
    141                ! 
    142             END DO 
    143          END DO 
    144       END DO 
     134      DO_3D_11_11( 1, jpk ) 
     135         ! 
     136         tr(ji,jj,jk,jp_c14,Krhs) = tr(ji,jj,jk,jp_c14,Krhs) - rlam14 * tr(ji,jj,jk,jp_c14,Kbb) * tmask(ji,jj,jk)  
     137         ! 
     138      END_3D 
    145139      ! 
    146140      IF( lrst_trc ) THEN 
  • NEMO/branches/2019/dev_r11943_MERGE_2019/src/TOP/C14/trcwri_c14.F90

    r11949 r12340  
    2323   !   Standard ratio: 1.176E-12 ; Avogadro's nbr = 6.022E+23 at/mol ; bomb C14 traditionally reported as 1.E+26 atoms 
    2424   REAL(wp), PARAMETER  :: atomc14 = 1.176 * 6.022E-15   ! conversion factor  
     25   !! * Substitutions 
     26#  include "do_loop_substitute.h90" 
    2527 
    2628 
     
    5860         zz3d(:,:,:) = 0._wp 
    5961         ! 
    60          DO jk = 1, jpkm1 
    61             DO jj = 1, jpj 
    62                DO ji = 1, jpi 
    63                   IF( tmask(ji,jj,jk) > 0._wp) THEN 
    64                      z3d (ji,jj,jk) = tr(ji,jj,jk,jp_c14,Kmm) 
    65                      zz3d(ji,jj,jk) = LOG( z3d(ji,jj,jk) ) 
    66                   ENDIF 
    67                ENDDO 
    68             ENDDO 
    69          ENDDO 
     62         DO_3D_11_11( 1, jpkm1 ) 
     63            IF( tmask(ji,jj,jk) > 0._wp) THEN 
     64               z3d (ji,jj,jk) = tr(ji,jj,jk,jp_c14,Kmm) 
     65               zz3d(ji,jj,jk) = LOG( z3d(ji,jj,jk) ) 
     66            ENDIF 
     67         END_3D 
    7068         zres(:,:) = z3d(:,:,1) 
    7169 
     
    7371         z2d(:,:) =0._wp 
    7472         jk = 1 
    75          DO jj = 1, jpj 
    76             DO ji = 1, jpi 
    77                ztemp = zres(ji,jj) / c14sbc(ji,jj) 
    78                IF( ztemp > 0._wp .AND. tmask(ji,jj,jk) > 0._wp ) z2d(ji,jj) = LOG( ztemp ) 
    79             ENDDO 
    80          ENDDO 
     73         DO_2D_11_11 
     74            ztemp = zres(ji,jj) / c14sbc(ji,jj) 
     75            IF( ztemp > 0._wp .AND. tmask(ji,jj,jk) > 0._wp ) z2d(ji,jj) = LOG( ztemp ) 
     76         END_2D 
    8177         ! 
    8278         z3d(:,:,:) = 1.d03 * ( z3d(:,:,:) - 1._wp ) 
     
    131127#endif 
    132128 
     129   !! * Substitutions 
     130#  include "do_loop_substitute.h90" 
    133131   !!---------------------------------------------------------------------- 
    134132   !! NEMO/TOP 4.0 , NEMO Consortium (2018) 
Note: See TracChangeset for help on using the changeset viewer.