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.
sedsfc.F90 in NEMO/branches/2019/dev_r11943_MERGE_2019/src/TOP/PISCES/SED – NEMO

source: NEMO/branches/2019/dev_r11943_MERGE_2019/src/TOP/PISCES/SED/sedsfc.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: 2.6 KB
Line 
1MODULE sedsfc
2   !!======================================================================
3   !!              ***  MODULE  sedsfc  ***
4   !!    Sediment : Data at sediment surface
5   !!=====================================================================
6   !! * Modules used
7   USE sed     ! sediment global variable
8   USE sedarr
9   USE seddta
10
11   PUBLIC sed_sfc
12
13   !! * Substitutions
14#  include "do_loop_substitute.h90"
15   !! $Id$
16CONTAINS
17
18   SUBROUTINE sed_sfc( kt, Kbb )
19      !!---------------------------------------------------------------------
20      !!                  ***  ROUTINE sed_sfc ***
21      !!
22      !! ** Purpose :  Give data from sediment model to tracer model
23      !!
24      !!
25      !!   History :
26      !!        !  06-04 (C. Ethe)  Orginal code
27      !!----------------------------------------------------------------------
28      !!* Arguments
29      INTEGER, INTENT(in) ::  kt              ! time step
30      INTEGER, INTENT(in) ::  Kbb             ! time index
31
32      ! * local variables
33      INTEGER :: ji, jj, ikt     ! dummy loop indices
34
35      !------------------------------------------------------------------------
36      ! reading variables
37
38      IF( ln_timing )  CALL timing_start('sed_sfc')
39
40      CALL unpack_arr ( jpoce, trc_data(1:jpi,1:jpj,1), iarroce(1:jpoce), pwcp(1:jpoce,1,jwalk) )
41      CALL unpack_arr ( jpoce, trc_data(1:jpi,1:jpj,2), iarroce(1:jpoce), pwcp(1:jpoce,1,jwdic) )
42      CALL unpack_arr ( jpoce, trc_data(1:jpi,1:jpj,3), iarroce(1:jpoce), pwcp(1:jpoce,1,jwno3) )
43      CALL unpack_arr ( jpoce, trc_data(1:jpi,1:jpj,4), iarroce(1:jpoce), pwcp(1:jpoce,1,jwpo4) )
44      CALL unpack_arr ( jpoce, trc_data(1:jpi,1:jpj,5), iarroce(1:jpoce), pwcp(1:jpoce,1,jwoxy) )
45      CALL unpack_arr ( jpoce, trc_data(1:jpi,1:jpj,6), iarroce(1:jpoce), pwcp(1:jpoce,1,jwsil) )
46      CALL unpack_arr ( jpoce, trc_data(1:jpi,1:jpj,7), iarroce(1:jpoce), pwcp(1:jpoce,1,jwnh4) )
47      CALL unpack_arr ( jpoce, trc_data(1:jpi,1:jpj,8), iarroce(1:jpoce), pwcp(1:jpoce,1,jwfe2) )
48
49
50      DO_2D_11_11
51         ikt = mbkt(ji,jj)
52         IF ( tmask(ji,jj,ikt) == 1 ) THEN
53            tr(ji,jj,ikt,jptal,Kbb) = trc_data(ji,jj,1)
54            tr(ji,jj,ikt,jpdic,Kbb) = trc_data(ji,jj,2)
55            tr(ji,jj,ikt,jpno3,Kbb) = trc_data(ji,jj,3) * 7.625
56            tr(ji,jj,ikt,jppo4,Kbb) = trc_data(ji,jj,4) * 122.
57            tr(ji,jj,ikt,jpoxy,Kbb) = trc_data(ji,jj,5)
58            tr(ji,jj,ikt,jpsil,Kbb) = trc_data(ji,jj,6)
59            tr(ji,jj,ikt,jpnh4,Kbb) = trc_data(ji,jj,7) * 7.625
60            tr(ji,jj,ikt,jpfer,Kbb) = trc_data(ji,jj,8)
61         ENDIF
62      END_2D
63
64      IF( ln_timing )  CALL timing_stop('sed_sfc')
65
66   END SUBROUTINE sed_sfc
67
68END MODULE sedsfc
Note: See TracBrowser for help on using the repository browser.