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/2015/dev_r5721_CNRS9_NOC3_LDF/NEMOGCM/NEMO/OPA_SRC/TRA – NEMO

source: branches/2015/dev_r5721_CNRS9_NOC3_LDF/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf.F90 @ 5758

Last change on this file since 5758 was 5758, checked in by gm, 9 years ago

#1593: LDF-ADV, step II.1: phasing the improvements/simplifications of diffusive trend (see wiki)

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