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.
trczdf.F90 in branches/2016/dev_v3_6_STABLE_r6506_AGRIF_LIM3/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: branches/2016/dev_v3_6_STABLE_r6506_AGRIF_LIM3/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf.F90 @ 7158

Last change on this file since 7158 was 7158, checked in by clem, 8 years ago

debug branch

  • Property svn:keywords set to Id
File size: 8.0 KB
Line 
1MODULE trczdf
2   !!==============================================================================
3   !!                 ***  MODULE  trczdf  ***
4   !! Ocean Passive tracers : vertical diffusive trends
5   !!=====================================================================
6   !! History :  9.0  ! 2005-11 (G. Madec)  Original code
7   !!       NEMO 3.0  ! 2008-01  (C. Ethe, G. Madec)  merge TRC-TRA
8   !!----------------------------------------------------------------------
9#if defined key_top
10   !!----------------------------------------------------------------------
11   !!   'key_top'                                                TOP models
12   !!----------------------------------------------------------------------
13   !!   trc_ldf     : update the tracer trend with the lateral diffusion
14   !!       ldf_ctl : initialization, namelist read, and parameters control
15   !!----------------------------------------------------------------------
16   USE oce_trc         ! ocean dynamics and active tracers
17   USE trc             ! ocean passive tracers variables
18   USE trcnam_trp      ! passive tracers transport namelist variables
19   USE trazdf_exp      ! vertical diffusion: explicit (tra_zdf_exp     routine)
20   USE trazdf_imp      ! vertical diffusion: implicit (tra_zdf_imp     routine)
21   USE trd_oce
22   USE trdtra
23   USE prtctl_trc      ! Print control
24
25   IMPLICIT NONE
26   PRIVATE
27
28   PUBLIC   trc_zdf          ! called by step.F90
29
30   INTEGER ::   nzdf = 0               ! type vertical diffusion algorithm used
31      !                                ! defined from ln_zdf...  namlist logicals)
32   REAL(wp) ::  r2dttrc   ! vertical profile time-step, = 2 rdt
33      !                   ! except at nittrc000 (=rdt) if neuler=0
34
35   !! * Substitutions
36#  include "domzgr_substitute.h90"
37#  include "zdfddm_substitute.h90"
38#  include "vectopt_loop_substitute.h90"
39   !!----------------------------------------------------------------------
40   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
41   !! $Id$
42   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
43   !!----------------------------------------------------------------------
44CONTAINS
45   
46
47   SUBROUTINE trc_zdf( kt )
48      !!----------------------------------------------------------------------
49      !!                  ***  ROUTINE trc_zdf  ***
50      !!
51      !! ** Purpose :   compute the vertical ocean tracer physics.
52      !!---------------------------------------------------------------------
53      INTEGER, INTENT( in ) ::  kt      ! ocean time-step index
54      !
55      INTEGER               ::  jk, jn
56      CHARACTER (len=22)    :: charout
57      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::   ztrtrd   ! 4D workspace
58      !!---------------------------------------------------------------------
59      !
60      IF( nn_timing == 1 )  CALL timing_start('trc_zdf')
61      !
62      IF( kt == nittrc000 )   CALL zdf_ctl          ! initialisation & control of options
63
64      IF( ( neuler == 0 .AND. kt == nittrc000 ) .OR. ln_top_euler ) THEN     ! at nittrc000
65         r2dttrc =  rdttrc           ! = rdttrc (use or restarting with Euler time stepping)
66      ELSEIF( kt <= nittrc000 + nn_dttrc ) THEN          ! at nittrc000 or nittrc000+1
67         r2dttrc = 2. * rdttrc       ! = 2 rdttrc (leapfrog)
68      ENDIF
69
70      IF( l_trdtrc )  THEN
71         CALL wrk_alloc( jpi, jpj, jpk, jptra, ztrtrd )
72         ztrtrd(:,:,:,:)  = tra(:,:,:,:)
73      ENDIF
74
75      SELECT CASE ( nzdf )                       ! compute lateral mixing trend and add it to the general trend
76      CASE ( -1 )                                       ! esopa: test all possibility with control print
77         CALL tra_zdf_exp( kt, nittrc000, 'TRC', r2dttrc, nn_trczdf_exp, trb, tra, jptra ) 
78         WRITE(charout, FMT="('zdf1 ')") ;  CALL prt_ctl_trc_info(charout)
79                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
80         CALL tra_zdf_imp( kt, nittrc000, 'TRC', r2dttrc,                trb, tra, jptra ) 
81         WRITE(charout, FMT="('zdf2 ')") ;  CALL prt_ctl_trc_info(charout)
82                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
83      CASE ( 0 ) ;  CALL tra_zdf_exp( kt, nittrc000, 'TRC', r2dttrc, nn_trczdf_exp, trb, tra, jptra )    !   explicit scheme
84      CASE ( 1 ) ;  CALL tra_zdf_imp( kt, nittrc000, 'TRC', r2dttrc,                trb, tra, jptra )    !   implicit scheme         
85
86      END SELECT
87
88      IF( l_trdtrc )   THEN                      ! save the vertical diffusive trends for further diagnostics
89         DO jn = 1, jptra
90            DO jk = 1, jpkm1
91               ztrtrd(:,:,jk,jn) = ( ( tra(:,:,jk,jn) - trb(:,:,jk,jn) ) / r2dttrc ) - ztrtrd(:,:,jk,jn)
92            END DO
93            CALL trd_tra( kt, 'TRC', jn, jptra_zdf, ztrtrd(:,:,:,jn) )
94         END DO
95         CALL wrk_dealloc( jpi, jpj, jpk, jptra, ztrtrd )
96      ENDIF
97      !                                          ! print mean trends (used for debugging)
98      IF( ln_ctl )   THEN
99         WRITE(charout, FMT="('zdf ')") ;  CALL prt_ctl_trc_info(charout)
100                                           CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
101      END IF
102      !
103      IF( nn_timing == 1 )  CALL timing_stop('trc_zdf')
104      !
105   END SUBROUTINE trc_zdf
106
107
108   SUBROUTINE zdf_ctl
109      !!----------------------------------------------------------------------
110      !!                 ***  ROUTINE zdf_ctl  ***
111      !!
112      !! ** Purpose :   Choose the vertical mixing scheme
113      !!
114      !! ** Method  :   Set nzdf from ln_zdfexp
115      !!      nzdf = 0   explicit (time-splitting) scheme (ln_trczdf_exp=T)
116      !!           = 1   implicit (euler backward) scheme (ln_trczdf_exp=F)
117      !!      NB: The implicit scheme is required when using :
118      !!             - rotated lateral mixing operator
119      !!             - TKE, GLS or KPP vertical mixing scheme
120      !!----------------------------------------------------------------------
121
122      !  Define the vertical tracer physics scheme
123      ! ==========================================
124
125      ! Choice from ln_zdfexp already read in namelist in zdfini module
126      IF( ln_trczdf_exp ) THEN           ! use explicit scheme
127         nzdf = 0
128      ELSE                               ! use implicit scheme
129         nzdf = 1
130      ENDIF
131
132      ! Force implicit schemes
133      IF( ln_trcldf_iso                               )   nzdf = 1      ! iso-neutral lateral physics
134      IF( ln_trcldf_hor .AND. ln_sco                  )   nzdf = 1      ! horizontal lateral physics in s-coordinate
135#if defined key_zdftke || defined key_zdfgls || defined key_zdfkpp
136                                                          nzdf = 1      ! TKE, GLS or KPP physics       
137#endif
138      IF( ln_trczdf_exp .AND. nzdf == 1 )   THEN
139         CALL ctl_stop( 'trc_zdf : If using the rotated lateral mixing operator or TKE, GLS or KPP vertical scheme ', &
140            &           '          the implicit scheme is required, set ln_trczdf_exp = .false.' )
141      ENDIF
142
143      ! Test: esopa
144      IF( lk_esopa )    nzdf = -1                      ! All schemes used
145
146      IF(lwp) THEN
147         WRITE(numout,*)
148         WRITE(numout,*) 'trc:zdf_ctl : vertical passive tracer physics scheme'
149         WRITE(numout,*) '~~~~~~~~~~~'
150         IF( nzdf == -1 )   WRITE(numout,*) '              ESOPA test All scheme used'
151         IF( nzdf ==  0 )   WRITE(numout,*) '              Explicit time-splitting scheme'
152         IF( nzdf ==  1 )   WRITE(numout,*) '              Implicit (euler backward) scheme'
153      ENDIF
154
155   END SUBROUTINE zdf_ctl
156#else
157   !!----------------------------------------------------------------------
158   !!   Default option                                         Empty module
159   !!----------------------------------------------------------------------
160CONTAINS
161   SUBROUTINE trc_zdf( kt )
162      INTEGER, INTENT(in) :: kt 
163      WRITE(*,*) 'trc_zdf: You should not have seen this print! error?', kt
164   END SUBROUTINE trc_zdf
165#endif
166   !!==============================================================================
167END MODULE trczdf
Note: See TracBrowser for help on using the repository browser.