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

source: NEMO/branches/2019/dev_r11943_MERGE_2019/src/OCE/C1D/dyncor_c1d.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.9 KB
Line 
1MODULE dyncor_c1d
2   !!======================================================================
3   !!                     ***  MODULE  dyncor_c1d  ***
4   !! Ocean Dynamics :   Coriolis term in 1D configuration
5   !!=====================================================================
6   !! History :  2.0  !  2004-09  (C. Ethe)  Original code
7   !!            3.0  !  2008-04  (G. Madec)  style only
8   !!----------------------------------------------------------------------
9#if defined key_c1d
10   !!----------------------------------------------------------------------
11   !!   'key_c1d'                                          1D Configuration
12   !!----------------------------------------------------------------------
13   !!   cor_c1d       : Coriolis factor at T-point (1D configuration)
14   !!   dyn_cor_c1d   : vorticity trend due to Coriolis at T-point
15   !!----------------------------------------------------------------------
16   USE oce            ! ocean dynamics and tracers
17   USE dom_oce        ! ocean space and time domain
18   USE phycst         ! physical constants
19   !
20   USE in_out_manager ! I/O manager
21   USE prtctl         ! Print control
22
23   USE sbcwave        ! Surface Waves (add Stokes-Coriolis force)
24   USE sbc_oce , ONLY : ln_stcor    ! use Stoke-Coriolis force
25   
26   IMPLICIT NONE
27   PRIVATE
28
29   PUBLIC   cor_c1d      ! called by nemogcm.F90
30   PUBLIC   dyn_cor_c1d  ! called by step1d.F90
31
32   !! * Substitutions
33#  include "vectopt_loop_substitute.h90"
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 cor_c1d
43      !!----------------------------------------------------------------------
44      !!                   ***  ROUTINE cor_c1d  ***
45      !!
46      !! ** Purpose : set the Coriolis factor at T-point
47      !!----------------------------------------------------------------------
48      REAL(wp) ::   zphi0, zbeta, zf0   ! local scalars
49      !!----------------------------------------------------------------------
50
51      IF(lwp) WRITE(numout,*)
52      IF(lwp) WRITE(numout,*) 'cor_c1d : Coriolis factor at T-point'
53      IF(lwp) WRITE(numout,*) '~~~~~~~'
54
55      !
56   END SUBROUTINE cor_c1d
57
58
59   SUBROUTINE dyn_cor_c1d( kt, Kmm, puu, pvv, Krhs )
60      !!----------------------------------------------------------------------
61      !!                   ***  ROUTINE dyn_cor_c1d  ***
62      !!
63      !! ** Purpose :   Compute the now Coriolis trend and add it to
64      !!               the general trend of the momentum equation in 1D case.
65      !!----------------------------------------------------------------------
66      INTEGER                             , INTENT(in   ) ::   kt        ! ocean time-step index
67      INTEGER                             , INTENT(in   ) ::   Kmm, Krhs ! ocean time level indices
68      REAL(wp), DIMENSION(jpi,jpj,jpk,jpt), INTENT(inout) ::   puu, pvv  ! ocean velocities and RHS of momentum equation
69      !!
70      INTEGER ::   ji, jj, jk   ! dummy loop indices
71      !!----------------------------------------------------------------------
72      !
73      IF( kt == nit000 ) THEN
74         IF(lwp) WRITE(numout,*)
75         IF(lwp) WRITE(numout,*) 'dyn_cor_c1d : total vorticity trend in 1D'
76         IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
77      ENDIF
78      !
79      IF( ln_stcor ) THEN
80         DO_3D_00_00( 1, jpkm1 )
81            puu(ji,jj,jk,Krhs) = puu(ji,jj,jk,Krhs) + ff_t(ji,jj) * (pvv(ji,jj,jk,Kmm) + vsd(ji,jj,jk))
82            pvv(ji,jj,jk,Krhs) = pvv(ji,jj,jk,Krhs) - ff_t(ji,jj) * (puu(ji,jj,jk,Kmm) + usd(ji,jj,jk))
83         END_3D
84      ELSE
85         DO_3D_00_00( 1, jpkm1 )
86            puu(ji,jj,jk,Krhs) = puu(ji,jj,jk,Krhs) + ff_t(ji,jj) * pvv(ji,jj,jk,Kmm)
87            pvv(ji,jj,jk,Krhs) = pvv(ji,jj,jk,Krhs) - ff_t(ji,jj) * puu(ji,jj,jk,Kmm)
88         END_3D
89      END IF
90     
91      !
92      IF(sn_cfctl%l_prtctl)   CALL prt_ctl( tab3d_1=puu(:,:,:,Krhs), clinfo1=' cor  - Ua: ', mask1=umask,  &
93         &                                  tab3d_2=pvv(:,:,:,Krhs), clinfo2=' Va: '       , mask2=vmask )
94      !
95   END SUBROUTINE dyn_cor_c1d
96
97#else
98   !!----------------------------------------------------------------------
99   !!   Default key                                     NO 1D Configuration
100   !!----------------------------------------------------------------------
101CONTAINS
102   SUBROUTINE cor_c1d              ! Empty routine
103       IMPLICIT NONE
104   END SUBROUTINE cor_c1d   
105   SUBROUTINE dyn_cor_c1d ( kt )      ! Empty routine
106      IMPLICIT NONE
107      INTEGER, INTENT( in ) :: kt
108      WRITE(*,*) 'dyn_cor_c1d: You should not have seen this print! error?', kt
109   END SUBROUTINE dyn_cor_c1d
110#endif
111
112   !!=====================================================================
113END MODULE dyncor_c1d
Note: See TracBrowser for help on using the repository browser.