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.
zdfevd.F90 in NEMO/branches/2019/dev_r11943_MERGE_2019/src/OCE/ZDF – NEMO

source: NEMO/branches/2019/dev_r11943_MERGE_2019/src/OCE/ZDF/zdfevd.F90 @ 12340

Last change on this file since 12340 was 12340, checked in by acc, 4 years ago

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.

  • Property svn:keywords set to Id
File size: 5.5 KB
Line 
1MODULE zdfevd
2   !!======================================================================
3   !!                       ***  MODULE  zdfevd  ***
4   !! Ocean physics: parameterization of convection through an enhancement
5   !!                of vertical eddy mixing coefficient
6   !!======================================================================
7   !! History :  OPA  !  1997-06  (G. Madec, A. Lazar)  Original code
8   !!   NEMO     1.0  !  2002-06  (G. Madec)  F90: Free form and module
9   !!            3.2  !  2009-03  (M. Leclair, G. Madec, R. Benshila) test on both before & after
10   !!            4.0  !  2017-04  (G. Madec)  evd applied on avm (at t-point)
11   !!----------------------------------------------------------------------
12
13   !!----------------------------------------------------------------------
14   !!   zdf_evd       : increase the momentum and tracer Kz at the location of
15   !!                   statically unstable portion of the water column (ln_zdfevd=T)
16   !!----------------------------------------------------------------------
17   USE oce             ! ocean dynamics and tracers variables
18   USE dom_oce         ! ocean space and time domain variables
19   USE zdf_oce         ! ocean vertical physics variables
20   USE trd_oce         ! trends: ocean variables
21   USE trdtra          ! trends manager: tracers
22   !
23   USE in_out_manager  ! I/O manager
24   USE iom             ! for iom_put
25   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
26   USE timing          ! Timing
27
28   IMPLICIT NONE
29   PRIVATE
30
31   PUBLIC   zdf_evd    ! called by step.F90
32
33   !! * Substitutions
34#  include "do_loop_substitute.h90"
35   !!----------------------------------------------------------------------
36   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
37   !! $Id$
38   !! Software governed by the CeCILL license (see ./LICENSE)
39   !!----------------------------------------------------------------------
40CONTAINS
41
42   SUBROUTINE zdf_evd( kt, Kmm, Krhs, p_avm, p_avt )
43      !!----------------------------------------------------------------------
44      !!                  ***  ROUTINE zdf_evd  ***
45      !!                   
46      !! ** Purpose :   Local increased the vertical eddy viscosity and diffu-
47      !!      sivity coefficients when a static instability is encountered.
48      !!
49      !! ** Method  :   tracer (and momentum if nn_evdm=1) vertical mixing
50      !!              coefficients are set to rn_evd (namelist parameter)
51      !!              if the water column is statically unstable.
52      !!                The test of static instability is performed using
53      !!              Brunt-Vaisala frequency (rn2 < -1.e-12) of to successive
54      !!              time-step (Leap-Frog environnement): before and
55      !!              now time-step.
56      !!
57      !! ** Action  :   avt, avm   enhanced where static instability occurs
58      !!----------------------------------------------------------------------
59      INTEGER                    , INTENT(in   ) ::   kt             ! ocean time-step indexocean time step
60      INTEGER                    , INTENT(in   ) ::   Kmm, Krhs      ! time level indices
61      REAL(wp), DIMENSION(:,:,:) , INTENT(inout) ::   p_avm, p_avt   !  momentum and tracer Kz (w-points)
62      !
63      INTEGER ::   ji, jj, jk   ! dummy loop indices
64      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zavt_evd, zavm_evd
65      !!----------------------------------------------------------------------
66      !
67      IF( kt == nit000 ) THEN
68         IF(lwp) WRITE(numout,*)
69         IF(lwp) WRITE(numout,*) 'zdf_evd : Enhanced Vertical Diffusion (evd)'
70         IF(lwp) WRITE(numout,*) '~~~~~~~ '
71         IF(lwp) WRITE(numout,*)
72      ENDIF
73      !
74      !
75      zavt_evd(:,:,:) = p_avt(:,:,:)         ! set avt prior to evd application
76      !
77      SELECT CASE ( nn_evdm )
78      !
79      CASE ( 1 )           !==  enhance tracer & momentum Kz  ==!   (if rn2<-1.e-12)
80         !
81         zavm_evd(:,:,:) = p_avm(:,:,:)      ! set avm prior to evd application
82         !
83!! change last digits results
84!         WHERE( MAX( rn2(2:jpi,2:jpj,2:jpkm1), rn2b(2:jpi,2:jpj,2:jpkm1) )  <= -1.e-12 ) THEN
85!            p_avt(2:jpi,2:jpj,2:jpkm1) = rn_evd * wmask(2:jpi,2:jpj,2:jpkm1)
86!            p_avm(2:jpi,2:jpj,2:jpkm1) = rn_evd * wmask(2:jpi,2:jpj,2:jpkm1)
87!         END WHERE
88         !
89         DO_3D_00_00( 1, jpkm1 )
90            IF(  MIN( rn2(ji,jj,jk), rn2b(ji,jj,jk) ) <= -1.e-12 ) THEN
91               p_avt(ji,jj,jk) = rn_evd * wmask(ji,jj,jk)
92               p_avm(ji,jj,jk) = rn_evd * wmask(ji,jj,jk)
93            ENDIF
94         END_3D
95         !
96         zavm_evd(:,:,:) = p_avm(:,:,:) - zavm_evd(:,:,:)   ! change in avm due to evd
97         CALL iom_put( "avm_evd", zavm_evd )                ! output this change
98         !
99      CASE DEFAULT         !==  enhance tracer Kz  ==!   (if rn2<-1.e-12)
100!! change last digits results
101!         WHERE( MAX( rn2(2:jpi,2:jpj,2:jpkm1), rn2b(2:jpi,2:jpj,2:jpkm1) )  <= -1.e-12 )
102!            p_avt(2:jpi,2:jpj,2:jpkm1) = rn_evd * wmask(2:jpi,2:jpj,2:jpkm1)
103!         END WHERE
104
105         DO_3D_00_00( 1, jpkm1 )
106            IF(  MIN( rn2(ji,jj,jk), rn2b(ji,jj,jk) ) <= -1.e-12 )   &
107               p_avt(ji,jj,jk) = rn_evd * wmask(ji,jj,jk)
108         END_3D
109         !
110      END SELECT 
111      !
112      zavt_evd(:,:,:) = p_avt(:,:,:) - zavt_evd(:,:,:)   ! change in avt due to evd
113      CALL iom_put( "avt_evd", zavt_evd )              ! output this change
114      IF( l_trdtra ) CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_tem, jptra_evd, zavt_evd )
115      !
116   END SUBROUTINE zdf_evd
117
118   !!======================================================================
119END MODULE zdfevd
Note: See TracBrowser for help on using the repository browser.