source: NEMO/branches/2019/dev_r11943_MERGE_2019/src/OCE/ISF/isfhdiv.F90 @ 12340

Last change on this file since 12340 was 12340, checked in by acc, 13 months 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.

File size: 6.4 KB
Line 
1MODULE isfhdiv
2   !!======================================================================
3   !!                       ***  MODULE  isfhdiv  ***
4   !! ice shelf horizontal divergence module :  update the horizontal divergence
5   !!                   with the ice shelf melt and coupling correction
6   !!======================================================================
7   !! History :  4.0  !  2019-09  (P. Mathiot) Original code
8   !!----------------------------------------------------------------------
9
10   !!----------------------------------------------------------------------
11   !!   isf_hdiv    : update the horizontal divergence with the ice shelf
12   !!                 melt and coupling correction
13   !!----------------------------------------------------------------------
14
15   USE isf_oce                ! ice shelf
16
17   USE dom_oce                ! time and space domain
18   USE phycst , ONLY: r1_rau0 ! physical constant
19   USE in_out_manager         !
20
21   IMPLICIT NONE
22
23   PRIVATE
24
25   PUBLIC isf_hdiv
26   !! * Substitutions
27#  include "do_loop_substitute.h90"
28
29CONTAINS
30
31   SUBROUTINE isf_hdiv( kt, Kmm, phdiv )
32      !!----------------------------------------------------------------------
33      !!                  ***  SUBROUTINE isf_hdiv  ***
34      !!       
35      !! ** Purpose :   update the horizontal divergence with the ice shelf contribution
36      !!                (parametrisation, explicit, ice sheet coupling conservation
37      !!                 increment)
38      !!
39      !!----------------------------------------------------------------------
40      REAL(wp), DIMENSION(:,:,:), INTENT( inout ) ::   phdiv   ! horizontal divergence
41      !!----------------------------------------------------------------------
42      INTEGER, INTENT(in) :: kt
43      INTEGER, INTENT(in) :: Kmm      !  ocean time level index
44      !
45      IF ( ln_isf ) THEN
46         !
47         ! ice shelf cavity contribution
48         IF ( ln_isfcav_mlt ) CALL isf_hdiv_mlt(misfkt_cav, misfkb_cav, rhisf_tbl_cav, rfrac_tbl_cav, fwfisf_cav, fwfisf_cav_b, phdiv)
49         !
50         ! ice shelf parametrisation contribution
51         IF ( ln_isfpar_mlt ) CALL isf_hdiv_mlt(misfkt_par, misfkb_par, rhisf_tbl_par, rfrac_tbl_par, fwfisf_par, fwfisf_par_b, phdiv)
52         !
53         ! ice sheet coupling contribution
54         IF ( ln_isfcpl .AND. kt /= 0 ) THEN
55            !
56            ! Dynamical stability at start up after change in under ice shelf cavity geometry is achieve by correcting the divergence.
57            ! This is achieved by applying a volume flux in order to keep the horizontal divergence after remapping
58            ! the same as at the end of the latest time step. So correction need to be apply at nit000 (euler time step) and
59            ! half of it at nit000+1 (leap frog time step).
60            IF ( kt == nit000   ) CALL isf_hdiv_cpl(Kmm, risfcpl_vol       , phdiv)
61            IF ( kt == nit000+1 ) CALL isf_hdiv_cpl(Kmm, risfcpl_vol*0.5_wp, phdiv)
62            !
63            ! correct divergence every time step to remove any trend due to coupling
64            ! conservation option
65            IF ( ln_isfcpl_cons ) CALL isf_hdiv_cpl(Kmm, risfcpl_cons_vol, phdiv)
66            !
67         END IF
68         !
69      END IF
70      !
71   END SUBROUTINE isf_hdiv
72
73   SUBROUTINE isf_hdiv_mlt(ktop, kbot, phtbl, pfrac, pfwf, pfwf_b, phdiv)
74      !!----------------------------------------------------------------------
75      !!                  ***  SUBROUTINE sbc_isf_div  ***
76      !!       
77      !! ** Purpose :   update the horizontal divergence with the ice shelf inflow
78      !!
79      !! ** Method  :   pfwf is positive (outflow) and expressed as kg/m2/s
80      !!                increase the divergence
81      !!
82      !! ** Action  :   phdivn   increased by the ice shelf outflow
83      !!----------------------------------------------------------------------
84      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) :: phdiv
85      !!----------------------------------------------------------------------
86      INTEGER , DIMENSION(jpi,jpj), INTENT(in   ) :: ktop , kbot
87      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: pfrac, phtbl
88      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: pfwf , pfwf_b
89      !!----------------------------------------------------------------------
90      INTEGER  ::   ji, jj, jk   ! dummy loop indices
91      INTEGER  ::   ikt, ikb 
92      REAL(wp), DIMENSION(jpi,jpj) :: zhdiv
93      !!----------------------------------------------------------------------
94      !
95      !==   fwf distributed over several levels   ==!
96      !
97      ! compute integrated divergence correction
98      zhdiv(:,:) = 0.5_wp * ( pfwf(:,:) + pfwf_b(:,:) ) * r1_rau0 / phtbl(:,:)
99      !
100      ! update divergence at each level affected by ice shelf top boundary layer
101      DO_2D_11_11
102         ikt = ktop(ji,jj)
103         ikb = kbot(ji,jj)
104         ! level fully include in the ice shelf boundary layer
105         DO jk = ikt, ikb - 1
106            phdiv(ji,jj,jk) = phdiv(ji,jj,jk) + zhdiv(ji,jj)
107         END DO
108         ! level partially include in ice shelf boundary layer
109         phdiv(ji,jj,ikb) = phdiv(ji,jj,ikb) + zhdiv(ji,jj) * pfrac(ji,jj)
110      END_2D
111      !
112   END SUBROUTINE isf_hdiv_mlt
113
114   SUBROUTINE isf_hdiv_cpl(Kmm, pqvol, phdiv)
115      !!----------------------------------------------------------------------
116      !!                  ***  SUBROUTINE isf_hdiv_cpl  ***
117      !!       
118      !! ** Purpose :   update the horizontal divergence with the ice shelf
119      !!                coupling conservation increment
120      !!
121      !! ** Method  :   pqvol is positive (outflow) and expressed as m3/s
122      !!                increase the divergence
123      !!
124      !! ** Action  :   phdivn   increased by the ice shelf outflow
125      !!
126      !!----------------------------------------------------------------------
127      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) :: phdiv
128      !!----------------------------------------------------------------------
129      INTEGER,                          INTENT(in)    :: Kmm     ! ocean time level index
130      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) :: pqvol
131      !!----------------------------------------------------------------------
132      INTEGER :: jk
133      !!----------------------------------------------------------------------
134      !
135      DO jk=1,jpk 
136         phdiv(:,:,jk) =  phdiv(:,:,jk) + pqvol(:,:,jk) * r1_e1e2t(:,:) / e3t(:,:,jk,Kmm)
137      END DO
138      !
139   END SUBROUTINE isf_hdiv_cpl
140
141END MODULE isfhdiv
Note: See TracBrowser for help on using the repository browser.