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.
trazdf_exp.F90 in branches/2011/dev_r2802_TOP_substepping/NEMOGCM/NEMO/OPA_SRC/TRA – NEMO

source: branches/2011/dev_r2802_TOP_substepping/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf_exp.F90 @ 2830

Last change on this file since 2830 was 2830, checked in by kpedwards, 13 years ago

Updates to average physics variables for TOP substepping.

  • Property svn:keywords set to Id
File size: 8.7 KB
Line 
1MODULE trazdf_exp
2   !!==============================================================================
3   !!                    ***  MODULE  trazdf_exp  ***
4   !! Ocean  tracers:  vertical component of the tracer mixing trend using
5   !!                  a split-explicit time-stepping
6   !!==============================================================================
7   !! History :  OPA  !  1990-10  (B. Blanke)  Original code
8   !!            7.0  !  1991-11  (G. Madec)
9   !!                 !  1992-06  (M. Imbard)  correction on tracer trend loops
10   !!                 !  1996-01  (G. Madec)  statement function for e3
11   !!                 !  1997-05  (G. Madec)  vertical component of isopycnal
12   !!                 !  1997-07  (G. Madec)  geopotential diffusion in s-coord
13   !!                 !  2000-08  (G. Madec)  double diffusive mixing
14   !!   NEMO     1.0  !  2002-08  (G. Madec)  F90: Free form and module
15   !!             -   !  2004-08  (C. Talandier) New trends organisation
16   !!             -   !  2005-11  (G. Madec)  New organisation
17   !!            3.0  !  2008-04  (G. Madec)  leap-frog time stepping done in trazdf
18   !!            3.3  !  2010-06  (C. Ethe, G. Madec) Merge TRA-TRC
19   !!----------------------------------------------------------------------
20
21   !!----------------------------------------------------------------------
22   !!   tra_zdf_exp  : compute the tracer the vertical diffusion trend using a
23   !!                  split-explicit time stepping and provide the after tracer
24   !!----------------------------------------------------------------------
25   USE oce             ! ocean dynamics and active tracers
26   USE dom_oce         ! ocean space and time domain
27   USE domvvl          ! variable volume levels
28   USE zdf_oce         ! ocean vertical physics
29   USE zdfddm          ! ocean vertical physics: double diffusion
30   USE trc_oce         ! share passive tracers/Ocean variables
31   USE in_out_manager  ! I/O manager
32   USE lib_mpp         ! MPP library
33#if defined key_top
34   USE trc, ONLY: nittrc000  !get first time step for passive tracers
35#endif
36
37   IMPLICIT NONE
38   PRIVATE
39
40   PUBLIC   tra_zdf_exp   ! routine called by step.F90
41
42   !! * Substitutions
43#  include "domzgr_substitute.h90"
44#  include "zdfddm_substitute.h90"
45#  include "vectopt_loop_substitute.h90"
46   !!----------------------------------------------------------------------
47   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
48   !! $Id$
49   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
50   !!----------------------------------------------------------------------
51CONTAINS
52
53   SUBROUTINE tra_zdf_exp( kt, cdtype, p2dt, kn_zdfexp,   &
54      &                                ptb , pta      , kjpt )
55      !!----------------------------------------------------------------------
56      !!                  ***  ROUTINE tra_zdf_exp  ***
57      !!                   
58      !! ** Purpose :   Compute the after tracer fields due to the vertical
59      !!      tracer mixing alone, and then due to the whole tracer trend.
60      !!
61      !! ** Method  : - The after tracer fields due to the vertical diffusion
62      !!      of tracers alone is given by:
63      !!                zwx = ptb + p2dt difft
64      !!      where difft = dz( avt dz(ptb) ) = 1/e3t dk+1( avt/e3w dk(ptb) )
65      !!           (if lk_zdfddm=T use avs on salinity and passive tracers instead of avt)
66      !!      difft is evaluated with an Euler split-explit scheme using a
67      !!      no flux boundary condition at both surface and bottomi boundaries.
68      !!      (N.B. bottom condition is applied through the masked field avt).
69      !!              - the after tracer fields due to the whole trend is
70      !!      obtained in leap-frog environment by :
71      !!          pta = zwx + p2dt pta
72      !!              - in case of variable level thickness (lk_vvl=T) the
73      !!     the leap-frog is applied on thickness weighted tracer. That is:
74      !!          pta = [ ptb*e3tb + e3tn*( zwx - ptb + p2dt pta ) ] / e3tn
75      !!
76      !! ** Action : - after tracer fields pta
77      !!---------------------------------------------------------------------
78      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
79      USE wrk_nemo, ONLY:   zwx => wrk_3d_6, zwy => wrk_3d_7     ! 3D workspace
80      !
81      INTEGER                              , INTENT(in   ) ::   kt          ! ocean time-step index
82      CHARACTER(len=3)                     , INTENT(in   ) ::   cdtype      ! =TRA or TRC (tracer indicator)
83      INTEGER                              , INTENT(in   ) ::   kjpt        ! number of tracers
84      INTEGER                              , INTENT(in   ) ::   kn_zdfexp   ! number of sub-time step
85      REAL(wp), DIMENSION(        jpk     ), INTENT(in   ) ::   p2dt        ! vertical profile of tracer time-step
86      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   ) ::   ptb         ! before and now tracer fields
87      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta         ! tracer trend
88      !
89      INTEGER  ::  ji, jj, jk, jn, jl        ! dummy loop indices
90      REAL(wp) ::  zlavmr, zave3r, ze3tr     ! local scalars
91      REAL(wp) ::  ztra, ze3tb               !   -      -
92      !!---------------------------------------------------------------------
93
94      IF( wrk_in_use(3, 6,7) ) THEN
95         CALL ctl_stop('tra_zdf_exp: requested workspace arrays unavailable')   ;   RETURN
96      ENDIF
97
98#if defined key_top
99      IF( kt == nit000 .OR. (kt == nittrc000 .AND. cdtype == 'TRC'))  THEN
100#else
101      IF( kt == nit000 )  THEN
102#endif
103         IF(lwp) WRITE(numout,*)
104         IF(lwp) WRITE(numout,*) 'tra_zdf_exp : explicit vertical mixing on ', cdtype
105         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
106      ENDIF
107
108      ! Initializations
109      ! ---------------
110      zlavmr = 1. / float( kn_zdfexp )         ! Local constant
111      !
112      !
113      DO jn = 1, kjpt                          ! loop over tracers
114         !
115         zwy(:,:, 1 ) = 0.e0     ! surface boundary conditions: no flux
116         zwy(:,:,jpk) = 0.e0     ! bottom  boundary conditions: no flux
117         !
118         zwx(:,:,:)   = ptb(:,:,:,jn)  ! zwx array set to before tracer values
119
120         ! Split-explicit loop  (after tracer due to the vertical diffusion alone)
121         ! -------------------
122         !
123         DO jl = 1, kn_zdfexp
124            !                     ! first vertical derivative
125            DO jk = 2, jpk
126               DO jj = 2, jpjm1 
127                  DO ji = fs_2, fs_jpim1   ! vector opt.
128                     zave3r = 1.e0 / fse3w_n(ji,jj,jk) 
129                     IF( cdtype == 'TRA' .AND. jn == jp_tem ) THEN  ! temperature : use of avt
130                        zwy(ji,jj,jk) =   avt(ji,jj,jk) * ( zwx(ji,jj,jk-1) - zwx(ji,jj,jk) ) * zave3r
131                     ELSE                                           ! salinity or pass. tracer : use of avs
132                        zwy(ji,jj,jk) = fsavs(ji,jj,jk) * ( zwx(ji,jj,jk-1) - zwx(ji,jj,jk) ) * zave3r
133                     END IF
134                  END DO
135               END DO
136            END DO
137            !
138            DO jk = 1, jpkm1      ! second vertical derivative   ==> tracer at kt+l*2*rdt/nn_zdfexp
139               DO jj = 2, jpjm1 
140                  DO ji = fs_2, fs_jpim1   ! vector opt.
141                     ze3tr = zlavmr / fse3t_n(ji,jj,jk)
142                     zwx(ji,jj,jk) = zwx(ji,jj,jk) + p2dt(jk) * ( zwy(ji,jj,jk) - zwy(ji,jj,jk+1) ) * ze3tr
143                  END DO
144               END DO
145            END DO
146            !
147         END DO
148
149         ! After tracer due to all trends
150         ! ------------------------------
151         IF( lk_vvl ) THEN          ! variable level thickness : leap-frog on tracer*e3t
152            DO jk = 1, jpkm1
153               DO jj = 2, jpjm1 
154                  DO ji = fs_2, fs_jpim1   ! vector opt.
155                     ze3tb = fse3t_b(ji,jj,jk) / fse3t(ji,jj,jk)                          ! before e3t
156                     ztra  = zwx(ji,jj,jk) - ptb(ji,jj,jk,jn) + p2dt(jk) * pta(ji,jj,jk,jn)       ! total trends * 2*rdt
157                     pta(ji,jj,jk,jn) = ( ze3tb * ptb(ji,jj,jk,jn) + ztra ) * tmask(ji,jj,jk)
158                  END DO
159               END DO
160            END DO
161         ELSE                       ! fixed level thickness : leap-frog on tracers
162            DO jk = 1, jpkm1
163               DO jj = 2, jpjm1 
164                  DO ji = fs_2, fs_jpim1   ! vector opt.
165                     pta(ji,jj,jk,jn) = ( zwx(ji,jj,jk) + p2dt(jk) * pta(ji,jj,jk,jn) ) * tmask(ji,jj,jk)
166                  END DO
167               END DO
168            END DO
169         ENDIF
170         !
171      END DO
172      !
173      IF( wrk_not_released(3, 6,7) )   CALL ctl_stop('tra_zdf_exp: failed to release workspace arrays')
174      !
175   END SUBROUTINE tra_zdf_exp
176
177   !!==============================================================================
178END MODULE trazdf_exp
Note: See TracBrowser for help on using the repository browser.