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

source: NEMO/branches/2019/dev_r11943_MERGE_2019/src/TOP/PISCES/P2Z/p2zsed.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: 6.5 KB
Line 
1MODULE p2zsed
2   !!======================================================================
3   !!                         ***  MODULE p2zsed  ***
4   !! TOP :   PISCES Compute loss of organic matter in the sediments
5   !!======================================================================
6   !! History :    -   !  1995-06 (M. Levy)  original code
7   !!              -   !  2000-12 (E. Kestenare)  clean up
8   !!             2.0  !  2007-12  (C. Deltel, G. Madec)  F90 + simplifications
9   !!----------------------------------------------------------------------
10   !!   p2z_sed        :  Compute loss of organic matter in the sediments
11   !!----------------------------------------------------------------------
12   USE oce_trc         !
13   USE trd_oce         !
14   USE trdtrc          !
15   USE trc             !
16   USE sms_pisces      !
17   !
18   USE lbclnk          !
19   USE iom             !
20   USE prtctl_trc      ! Print control for debbuging
21
22   IMPLICIT NONE
23   PRIVATE
24
25   PUBLIC   p2z_sed         ! called in ???
26   PUBLIC   p2z_sed_init    ! called in ???
27
28   REAL(wp), PUBLIC ::   sedlam      !: time coefficient of POC remineralization in sediments
29   REAL(wp), PUBLIC ::   sedlostpoc  !: mass of POC lost in sediments
30   REAL(wp), PUBLIC ::   vsed        !: detritus sedimentation speed [m/s]
31   REAL(wp), PUBLIC ::   xhr         !: coeff for martin''s remineralisation profile
32
33   !! * Substitutions
34#  include "do_loop_substitute.h90"
35   !!----------------------------------------------------------------------
36   !! NEMO/TOP 4.0 , NEMO Consortium (2018)
37   !! $Id$
38   !! Software governed by the CeCILL license (see ./LICENSE)
39   !!----------------------------------------------------------------------
40CONTAINS
41
42   SUBROUTINE p2z_sed( kt, Kmm, Krhs )
43      !!---------------------------------------------------------------------
44      !!                     ***  ROUTINE p2z_sed  ***
45      !!
46      !! ** Purpose :   compute the now trend due to the vertical sedimentation of
47      !!              detritus and add it to the general trend of detritus equations
48      !!
49      !! ** Method  :   this ROUTINE compute not exactly the advection but the
50      !!              transport term, i.e.  dz(wt) and dz(ws)., dz(wtr)
51      !!              using an upstream scheme
52      !!              the now vertical advection of tracers is given by:
53      !!                      dz(tr(:,:,:,:,Kmm) ww) = 1/bt dk+1( e1t e2t vsed (tr(:,:,:,:,Kmm)) )
54      !!              add this trend now to the general trend of tracer (ta,sa,tr(:,:,:,:,Krhs)):
55      !!                             tr(:,:,:,:,Krhs) = tr(:,:,:,:,Krhs) + dz(tr(:,:,:,:,Kmm) ww)
56      !!       
57      !!              IF 'key_diabio' is defined, the now vertical advection
58      !!              trend of passive tracers is saved for futher diagnostics.
59      !!---------------------------------------------------------------------
60      INTEGER, INTENT( in ) ::   kt         ! ocean time-step index     
61      INTEGER, INTENT( in ) ::   Kmm, Krhs  ! time level indices
62      !
63      INTEGER  ::   ji, jj, jk, jl, ierr
64      CHARACTER (len=25) :: charout
65      REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: zw2d
66      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zwork, ztra
67      !!---------------------------------------------------------------------
68      !
69      IF( ln_timing )   CALL timing_start('p2z_sed')
70      !
71      IF( kt == nittrc000 ) THEN
72         IF(lwp) WRITE(numout,*)
73         IF(lwp) WRITE(numout,*) ' p2z_sed: LOBSTER sedimentation'
74         IF(lwp) WRITE(numout,*) ' ~~~~~~~'
75      ENDIF
76
77      ! sedimentation of detritus  : upstream scheme
78      ! --------------------------------------------
79
80      ! for detritus sedimentation only - jpdet
81      zwork(:,:,1  ) = 0.e0      ! surface value set to zero
82      zwork(:,:,jpk) = 0.e0      ! bottom value  set to zero
83
84      ! tracer flux at w-point: we use -vsed (downward flux)  with simplification : no e1*e2
85      DO jk = 2, jpkm1
86         zwork(:,:,jk) = -vsed * tr(:,:,jk-1,jpdet,Kmm)
87      END DO
88
89      ! tracer flux divergence at t-point added to the general trend
90      DO_3D_11_11( 1, jpkm1 )
91         ztra(ji,jj,jk)  = - ( zwork(ji,jj,jk) - zwork(ji,jj,jk+1) ) / e3t(ji,jj,jk,Kmm)
92         tr(ji,jj,jk,jpdet,Krhs) = tr(ji,jj,jk,jpdet,Krhs) + ztra(ji,jj,jk) 
93      END_3D
94
95      IF( lk_iomput )  THEN
96         IF( iom_use( "TDETSED" ) ) THEN
97            ALLOCATE( zw2d(jpi,jpj) )
98            zw2d(:,:) =  ztra(:,:,1) * e3t(:,:,1,Kmm) * 86400._wp
99            DO jk = 2, jpkm1
100               zw2d(:,:) = zw2d(:,:) + ztra(:,:,jk) * e3t(:,:,jk,Kmm) * 86400._wp
101            END DO
102            CALL iom_put( "TDETSED", zw2d )
103            DEALLOCATE( zw2d )
104         ENDIF
105      ENDIF
106      !
107
108      IF(sn_cfctl%l_prttrc)   THEN  ! print mean trends (used for debugging)
109         WRITE(charout, FMT="('sed')")
110         CALL prt_ctl_trc_info(charout)
111         CALL prt_ctl_trc(tab4d=tr(:,:,:,:,Krhs), mask=tmask, clinfo=ctrcnm)
112      ENDIF
113      !
114      IF( ln_timing )   CALL timing_stop('p2z_sed')
115      !
116   END SUBROUTINE p2z_sed
117
118
119   SUBROUTINE p2z_sed_init
120      !!----------------------------------------------------------------------
121      !!                  ***  ROUTINE p2z_sed_init  ***
122      !!
123      !! ** Purpose :   Parameters from aphotic layers to sediment
124      !!
125      !! ** Method  :   Read the namlobsed namelist and check the parameters
126      !!
127      !!----------------------------------------------------------------------
128      INTEGER ::   ios   ! Local integer
129      !!
130      NAMELIST/namlobsed/ sedlam, sedlostpoc, vsed, xhr
131      !!----------------------------------------------------------------------
132      !
133      READ  ( numnatp_ref, namlobsed, IOSTAT = ios, ERR = 901)
134901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namlosed in reference namelist' )
135      READ  ( numnatp_cfg, namlobsed, IOSTAT = ios, ERR = 902 )
136902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namlobsed in configuration namelist' )
137      IF(lwm) WRITE ( numonp, namlobsed )
138      !
139      IF(lwp) THEN
140          WRITE(numout,*) '   Namelist namlobsed'
141          WRITE(numout,*) '      time coeff of POC in sediments                sedlam    =', sedlam
142          WRITE(numout,*) '      Sediment geol loss for POC                    sedlostpoc=', sedlostpoc
143          WRITE(numout,*) '      detritus sedimentation speed                  vsed      =', 86400 * vsed  , ' d'
144          WRITE(numout,*) '      coeff for martin''s remineralistion           xhr       =', xhr
145          WRITE(numout,*) ' '
146      ENDIF
147      !
148   END SUBROUTINE p2z_sed_init
149
150   !!======================================================================
151END MODULE p2zsed
Note: See TracBrowser for help on using the repository browser.