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.F90 in branches/2017/dev_r7881_no_wrk_alloc/NEMOGCM/NEMO/OPA_SRC/TRA – NEMO

source: branches/2017/dev_r7881_no_wrk_alloc/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf.F90 @ 7910

Last change on this file since 7910 was 7910, checked in by timgraham, 7 years ago

All wrk_alloc removed

  • Property svn:keywords set to Id
File size: 7.1 KB
Line 
1MODULE trazdf
2   !!==============================================================================
3   !!                 ***  MODULE  trazdf  ***
4   !! Ocean active tracers:  vertical component of the tracer mixing trend
5   !!==============================================================================
6   !! History :  1.0  ! 2005-11  (G. Madec)  Original code
7   !!            3.0  ! 2008-01  (C. Ethe, G. Madec)  merge TRC-TRA
8   !!----------------------------------------------------------------------
9
10   !!----------------------------------------------------------------------
11   !!   tra_zdf       : Update the tracer trend with the vertical diffusion
12   !!   tra_zdf_init  : initialisation of the computation
13   !!----------------------------------------------------------------------
14   USE oce            ! ocean dynamics and tracers variables
15   USE dom_oce        ! ocean space and time domain variables
16   USE domvvl         ! variable volume
17   USE phycst         ! physical constant
18   USE zdf_oce        ! ocean vertical physics variables
19   USE sbc_oce        ! surface boundary condition: ocean
20   USE ldftra         ! lateral diffusion: eddy diffusivity
21   USE ldfslp         ! lateral diffusion: iso-neutral slope
22   USE trazdf_exp     ! vertical diffusion: explicit (tra_zdf_exp routine)
23   USE trazdf_imp     ! vertical diffusion: implicit (tra_zdf_imp routine)
24   USE trd_oce        ! trends: ocean variables
25   USE trdtra         ! trends: tracer trend manager
26   !
27   USE in_out_manager ! I/O manager
28   USE prtctl         ! Print control
29   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
30   USE lib_mpp        ! MPP library
31   USE timing         ! Timing
32
33   IMPLICIT NONE
34   PRIVATE
35
36   PUBLIC   tra_zdf        ! routine called by step.F90
37   PUBLIC   tra_zdf_init   ! routine called by nemogcm.F90
38
39   INTEGER ::   nzdf = 0   ! type vertical diffusion algorithm used (defined from ln_zdf...  namlist logicals)
40
41   !! * Substitutions
42#  include "zdfddm_substitute.h90"
43#  include "vectopt_loop_substitute.h90"
44   !!----------------------------------------------------------------------
45   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
46   !! $Id$
47   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
48   !!----------------------------------------------------------------------
49CONTAINS
50
51   SUBROUTINE tra_zdf( kt )
52      !!----------------------------------------------------------------------
53      !!                  ***  ROUTINE tra_zdf  ***
54      !!
55      !! ** Purpose :   compute the vertical ocean tracer physics.
56      !!---------------------------------------------------------------------
57      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
58      !
59      INTEGER  ::   jk                   ! Dummy loop indices
60      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ztrdt, ztrds   ! 3D workspace
61      !!---------------------------------------------------------------------
62      !
63      IF( nn_timing == 1 )  CALL timing_start('tra_zdf')
64      !
65      IF( neuler == 0 .AND. kt == nit000 ) THEN     ! at nit000
66         r2dt =  rdt                          ! = rdt (restarting with Euler time stepping)
67      ELSEIF( kt <= nit000 + 1) THEN                ! at nit000 or nit000+1
68         r2dt = 2. * rdt                      ! = 2 rdt (leapfrog)
69      ENDIF
70      !
71      IF( l_trdtra )   THEN                    !* Save ta and sa trends
72         ztrdt(:,:,:) = tsa(:,:,:,jp_tem)
73         ztrds(:,:,:) = tsa(:,:,:,jp_sal)
74      ENDIF
75      !
76      SELECT CASE ( nzdf )                       ! compute lateral mixing trend and add it to the general trend
77      CASE ( 0 )    ;    CALL tra_zdf_exp( kt, nit000, 'TRA', r2dt, nn_zdfexp, tsb, tsa, jpts )  !   explicit scheme
78      CASE ( 1 )    ;    CALL tra_zdf_imp( kt, nit000, 'TRA', r2dt,            tsb, tsa, jpts )  !   implicit scheme
79      END SELECT
80!!gm WHY here !   and I don't like that !
81      ! DRAKKAR SSS control {
82      ! JMM avoid negative salinities near river outlet ! Ugly fix
83      ! JMM : restore negative salinities to small salinities:
84      WHERE( tsa(:,:,:,jp_sal) < 0._wp )   tsa(:,:,:,jp_sal) = 0.1_wp
85!!gm
86
87      IF( l_trdtra )   THEN                      ! save the vertical diffusive trends for further diagnostics
88         DO jk = 1, jpkm1
89            ztrdt(:,:,jk) = ( ( tsa(:,:,jk,jp_tem) - tsb(:,:,jk,jp_tem) ) / r2dt ) - ztrdt(:,:,jk)
90            ztrds(:,:,jk) = ( ( tsa(:,:,jk,jp_sal) - tsb(:,:,jk,jp_sal) ) / r2dt ) - ztrds(:,:,jk)
91         END DO
92!!gm this should be moved in trdtra.F90 and done on all trends
93         CALL lbc_lnk( ztrdt, 'T', 1. )
94         CALL lbc_lnk( ztrds, 'T', 1. )
95!!gm
96         CALL trd_tra( kt, 'TRA', jp_tem, jptra_zdf, ztrdt )
97         CALL trd_tra( kt, 'TRA', jp_sal, jptra_zdf, ztrds )
98      ENDIF
99      !                                          ! print mean trends (used for debugging)
100      IF(ln_ctl)   CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' zdf  - Ta: ', mask1=tmask,               &
101         &                       tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
102      !
103      IF( nn_timing == 1 )  CALL timing_stop('tra_zdf')
104      !
105   END SUBROUTINE tra_zdf
106
107
108   SUBROUTINE tra_zdf_init
109      !!----------------------------------------------------------------------
110      !!                 ***  ROUTINE tra_zdf_init  ***
111      !!
112      !! ** Purpose :   Choose the vertical mixing scheme
113      !!
114      !! ** Method  :   Set nzdf from ln_zdfexp
115      !!      nzdf = 0   explicit (time-splitting) scheme (ln_zdfexp=T)
116      !!           = 1   implicit (euler backward) scheme (ln_zdfexp=F)
117      !!      NB: rotation of lateral mixing operator or TKE & GLS schemes,
118      !!          an implicit scheme is required.
119      !!----------------------------------------------------------------------
120      USE zdftke
121      USE zdfgls
122      !!----------------------------------------------------------------------
123      !
124      ! Choice from ln_zdfexp already read in namelist in zdfini module
125      IF( ln_zdfexp ) THEN   ;   nzdf = 0           ! use explicit scheme
126      ELSE                   ;   nzdf = 1           ! use implicit scheme
127      ENDIF
128      !
129      ! Force implicit schemes
130      IF( lk_zdftke .OR. lk_zdfgls   )   nzdf = 1   ! TKE, or GLS physics
131      IF( ln_traldf_iso              )   nzdf = 1   ! iso-neutral lateral physics
132      IF( ln_traldf_hor .AND. ln_sco )   nzdf = 1   ! horizontal lateral physics in s-coordinate
133      IF( ln_zdfexp .AND. nzdf == 1 )   CALL ctl_stop( 'tra_zdf : If using the rotation of lateral mixing operator',   &
134            &                         ' GLS or TKE scheme, the implicit scheme is required, set ln_zdfexp = .false.' )
135            !
136      IF(lwp) THEN
137         WRITE(numout,*)
138         WRITE(numout,*) 'tra_zdf_init : vertical tracer physics scheme'
139         WRITE(numout,*) '~~~~~~~~~~~'
140         IF( nzdf ==  0 )   WRITE(numout,*) '      ===>>   Explicit time-splitting scheme'
141         IF( nzdf ==  1 )   WRITE(numout,*) '      ===>>   Implicit (euler backward) scheme'
142      ENDIF
143      !
144   END SUBROUTINE tra_zdf_init
145
146   !!==============================================================================
147END MODULE trazdf
Note: See TracBrowser for help on using the repository browser.