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

source: NEMO/branches/2019/dev_r11943_MERGE_2019/src/OCE/ZDF/zdfswm.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: 4.2 KB
Line 
1MODULE zdfswm
2   !!======================================================================
3   !!                       ***  MODULE  zdfswm  ***
4   !! vertical physics :   surface wave-induced mixing
5   !!======================================================================
6   !! History :  3.6  !  2014-10  (E. Clementi)  Original code
7   !!            4.0  !  2017-04  (G. Madec)  debug + simplifications
8   !!----------------------------------------------------------------------
9
10   !!----------------------------------------------------------------------
11   !!   zdf_swm      : update Kz due to surface wave-induced mixing
12   !!   zdf_swm_init : initilisation
13   !!----------------------------------------------------------------------
14   USE dom_oce        ! ocean domain variable
15   USE zdf_oce        ! vertical physics: mixing coefficients
16   USE sbc_oce        ! Surface boundary condition: ocean fields
17   USE sbcwave        ! wave module
18   !
19   USE in_out_manager ! I/O manager
20   USE lbclnk         ! ocean lateral boundary conditions (or mpp link) 
21   USE lib_mpp        ! distribued memory computing library
22   
23   IMPLICIT NONE
24   PRIVATE
25
26   PUBLIC zdf_swm         ! routine called in zdp_phy
27   PUBLIC zdf_swm_init    ! routine called in zdf_phy_init
28
29   !! * Substitutions
30#  include "do_loop_substitute.h90"
31   !!----------------------------------------------------------------------
32   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
33   !! $Id$
34   !! Software governed by the CeCILL license (see ./LICENSE)
35   !!----------------------------------------------------------------------
36CONTAINS
37
38   SUBROUTINE zdf_swm( kt, Kmm, p_avm, p_avt, p_avs )
39      !!---------------------------------------------------------------------
40      !!                     ***  ROUTINE zdf_swm ***
41      !!
42      !! ** Purpose :Compute the swm term (qbv) to be added to
43      !!             vertical viscosity and diffusivity coeffs. 
44      !!
45      !! ** Method  :   Compute the swm term Bv (zqb) and added it to
46      !!               vertical viscosity and diffusivity coefficients
47      !!                   zqb = alpha * A * Us(0) * exp (3 * k * z)
48      !!               where alpha is set here to 1
49      !!             
50      !! ** action  :    avt, avs, avm updated by the surface wave-induced mixing
51      !!                               (inner domain only)
52      !!               
53      !! reference : Qiao et al. GRL, 2004
54      !!---------------------------------------------------------------------
55      INTEGER                    , INTENT(in   ) ::   kt             ! ocean time step
56      INTEGER                    , INTENT(in   ) ::   Kmm            ! time level index
57      REAL(wp), DIMENSION(:,:,:) , INTENT(inout) ::   p_avm          ! momentum Kz (w-points)
58      REAL(wp), DIMENSION(:,:,:) , INTENT(inout) ::   p_avt, p_avs   ! tracer   Kz (w-points)
59      !
60      INTEGER ::   ji, jj, jk   ! dummy loop indices
61      REAL(wp)::   zcoef, zqb   ! local scalar
62      !!---------------------------------------------------------------------
63      !
64      zcoef = 1._wp * 0.353553_wp
65      DO_3D_00_00( 2, jpkm1 )
66         zqb = zcoef * hsw(ji,jj) * tsd2d(ji,jj) * EXP( -3. * wnum(ji,jj) * gdepw(ji,jj,jk,Kmm) ) * wmask(ji,jj,jk)
67         !
68         p_avt(ji,jj,jk) = p_avt(ji,jj,jk) + zqb
69         p_avs(ji,jj,jk) = p_avs(ji,jj,jk) + zqb
70         p_avm(ji,jj,jk) = p_avm(ji,jj,jk) + zqb
71      END_3D
72      !
73   END SUBROUTINE zdf_swm
74   
75   
76   SUBROUTINE zdf_swm_init
77      !!---------------------------------------------------------------------
78      !!                     ***  ROUTINE zdf_swm_init ***
79      !!
80      !! ** Purpose :   surface wave-induced mixing initialisation 
81      !!
82      !! ** Method  :   check the availability of surface wave fields
83      !!---------------------------------------------------------------------
84      !
85      IF(lwp) THEN                  ! Control print
86         WRITE(numout,*)
87         WRITE(numout,*) 'zdf_swm_init : surface wave-driven mixing'
88         WRITE(numout,*) '~~~~~~~~~~~~'
89      ENDIF
90      IF(  .NOT.ln_wave .OR.   &
91         & .NOT.ln_sdw    )   CALL ctl_stop ( 'zdf_swm_init: ln_zdfswm=T but ln_wave and ln_sdw /= T')
92      !
93   END SUBROUTINE zdf_swm_init
94
95   !!======================================================================
96END MODULE zdfswm
Note: See TracBrowser for help on using the repository browser.