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

source: NEMO/branches/2019/dev_r11943_MERGE_2019/src/OCE/TRA/traisf.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.

File size: 7.2 KB
Line 
1MODULE traisf
2   !!==============================================================================
3   !!                       ***  MODULE  traisf  ***
4   !! Ocean active tracers:  ice shelf boundary condition
5   !!==============================================================================
6   !! History :    4.0  !  2019-09  (P. Mathiot) original file
7   !!----------------------------------------------------------------------
8
9   !!----------------------------------------------------------------------
10   !!   tra_isf       : update the tracer trend at ocean surface
11   !!----------------------------------------------------------------------
12   USE isf_oce                                     ! Ice shelf variables
13   USE dom_oce , ONLY : e3t, r1_e1e2t            ! ocean space domain variables
14   USE isfutils, ONLY : debug                      ! debug option
15   USE timing  , ONLY : timing_start, timing_stop  ! Timing
16   USE in_out_manager                              ! I/O manager
17
18   IMPLICIT NONE
19   PRIVATE
20
21   PUBLIC   tra_isf   ! routine called by step.F90
22
23   !! * Substitutions
24#  include "vectopt_loop_substitute.h90"
25#  include "do_loop_substitute.h90"
26   !!----------------------------------------------------------------------
27   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
28   !! $Id: trasbc.F90 10499 2019-01-10 15:12:24Z deazer $
29   !! Software governed by the CeCILL license (see ./LICENSE)
30   !!----------------------------------------------------------------------
31CONTAINS
32
33   SUBROUTINE tra_isf ( kt, Kmm, pts, Krhs )
34      !!----------------------------------------------------------------------
35      !!                  ***  ROUTINE tra_isf  ***
36      !!                   
37      !! ** Purpose :  Compute the temperature trend due to the ice shelf melting (qhoce + qhc)
38      !!
39      !! ** Action  : - update pts(:,:,:,:,Krhs) for cav, par and cpl case
40      !!----------------------------------------------------------------------
41      INTEGER                                  , INTENT(in   ) :: kt        ! ocean time step
42      INTEGER                                  , INTENT(in   ) :: Kmm, Krhs ! ocean time level indices
43      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts,jpt), INTENT(inout) :: pts       ! active tracers and RHS of tracer equation
44      !!----------------------------------------------------------------------
45      !
46      IF( ln_timing )   CALL timing_start('tra_isf')
47      !
48      IF( kt == nit000 ) THEN
49         IF(lwp) WRITE(numout,*)
50         IF(lwp) WRITE(numout,*) 'tra_isf : Ice shelf heat fluxes'
51         IF(lwp) WRITE(numout,*) '~~~~~~~ '
52      ENDIF
53      !
54      ! cavity case
55      IF ( ln_isfcav_mlt ) CALL tra_isf_mlt(misfkt_cav, misfkb_cav, rhisf_tbl_cav, rfrac_tbl_cav, risf_cav_tsc, risf_cav_tsc_b, pts(:,:,:,:,Krhs))
56      !
57      ! parametrisation case
58      IF ( ln_isfpar_mlt ) CALL tra_isf_mlt(misfkt_par, misfkb_par, rhisf_tbl_par, rfrac_tbl_par, risf_par_tsc, risf_par_tsc_b, pts(:,:,:,:,Krhs))
59      !
60      ! ice sheet coupling case
61      IF ( ln_isfcpl ) THEN
62         !
63         ! Dynamical stability at start up after change in under ice shelf cavity geometry is achieve by correcting the divergence.
64         ! This is achieved by applying a volume flux in order to keep the horizontal divergence after remapping
65         ! the same as at the end of the latest time step. So correction need to be apply at nit000 (euler time step) and
66         ! half of it at nit000+1 (leap frog time step).
67         ! in accordance to this, the heat content flux due to injected water need to be added in the temperature and salt trend
68         ! at time step nit000 and nit000+1
69         IF ( kt == nit000  ) CALL tra_isf_cpl(Kmm, risfcpl_tsc       , pts(:,:,:,:,Krhs))
70         IF ( kt == nit000+1) CALL tra_isf_cpl(Kmm, risfcpl_tsc*0.5_wp, pts(:,:,:,:,Krhs))
71         !
72         ! ensure 0 trend due to unconservation of the ice shelf coupling
73         IF ( ln_isfcpl_cons ) CALL tra_isf_cpl(Kmm, risfcpl_cons_tsc, pts(:,:,:,:,Krhs))
74         !
75      END IF
76      !
77      IF ( ln_isfdebug ) THEN
78         CALL debug('tra_isf: pts(:,:,:,:,Krhs) T', pts(:,:,:,1,Krhs))
79         CALL debug('tra_isf: pts(:,:,:,:,Krhs) S', pts(:,:,:,2,Krhs))
80      END IF
81      !
82      IF( ln_timing )   CALL timing_stop('tra_isf')
83      !
84   END SUBROUTINE tra_isf
85   !
86   SUBROUTINE tra_isf_mlt(ktop, kbot, phtbl, pfrac, ptsc, ptsc_b, pts)
87      !!----------------------------------------------------------------------
88      !!                  ***  ROUTINE tra_isf_mlt  ***
89      !!
90      !! *** Purpose :  Compute the temperature trend due to the ice shelf melting (qhoce + qhc) for cav or par case
91      !!
92      !! *** Action :: Update pts(:,:,:,:,Krhs) with the surface boundary condition trend
93      !!
94      !!----------------------------------------------------------------------
95      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(inout) :: pts
96      !!----------------------------------------------------------------------
97      INTEGER , DIMENSION(jpi,jpj)     , INTENT(in   ) :: ktop , kbot
98      REAL(wp), DIMENSION(jpi,jpj)     , INTENT(in   ) :: phtbl, pfrac
99      REAL(wp), DIMENSION(jpi,jpj,jpts), INTENT(in   ) :: ptsc , ptsc_b
100      !!----------------------------------------------------------------------
101      INTEGER                      :: ji,jj,jk  ! loop index   
102      INTEGER                      :: ikt, ikb  ! top and bottom level of the tbl
103      REAL(wp), DIMENSION(jpi,jpj) :: ztc       ! total ice shelf tracer trend
104      !!----------------------------------------------------------------------
105      !
106      ! compute 2d total trend due to isf
107      ztc(:,:) = 0.5_wp * ( ptsc(:,:,jp_tem) + ptsc_b(:,:,jp_tem) ) / phtbl(:,:)
108      !
109      ! update pts(:,:,:,:,Krhs)
110      DO_2D_11_11
111         !
112         ikt = ktop(ji,jj)
113         ikb = kbot(ji,jj)
114         !
115         ! level fully include in the ice shelf boundary layer
116         DO jk = ikt, ikb - 1
117            pts(ji,jj,jk,jp_tem) = pts(ji,jj,jk,jp_tem) + ztc(ji,jj)
118         END DO
119         !
120         ! level partially include in ice shelf boundary layer
121         pts(ji,jj,ikb,jp_tem) = pts(ji,jj,ikb,jp_tem) + ztc(ji,jj) * pfrac(ji,jj)
122         !
123      END_2D
124      !
125   END SUBROUTINE tra_isf_mlt
126   !
127   SUBROUTINE tra_isf_cpl( Kmm, ptsc, ptsa )
128      !!----------------------------------------------------------------------
129      !!                  ***  ROUTINE tra_isf_cpl  ***
130      !!
131      !! *** Action :: Update pts(:,:,:,:,Krhs) with the ice shelf coupling trend
132      !!
133      !!----------------------------------------------------------------------
134      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(inout) :: ptsa
135      !!----------------------------------------------------------------------
136      INTEGER                              , INTENT(in   ) :: Kmm   ! ocean time level index
137      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(in   ) :: ptsc
138      !!----------------------------------------------------------------------
139      INTEGER :: jk
140      !!----------------------------------------------------------------------
141      !
142      DO jk = 1,jpk
143         ptsa(:,:,jk,jp_tem) = ptsa(:,:,jk,jp_tem) + ptsc(:,:,jk,jp_tem) * r1_e1e2t(:,:) / e3t(:,:,jk,Kmm)
144         ptsa(:,:,jk,jp_sal) = ptsa(:,:,jk,jp_sal) + ptsc(:,:,jk,jp_sal) * r1_e1e2t(:,:) / e3t(:,:,jk,Kmm)
145      END DO
146      !
147   END SUBROUTINE tra_isf_cpl
148   !
149END MODULE traisf
Note: See TracBrowser for help on using the repository browser.