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 NEMO/branches/CNRS/dev_r6568_Subduction_Diagnostics/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: NEMO/branches/CNRS/dev_r6568_Subduction_Diagnostics/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf.F90 @ 10278

Last change on this file since 10278 was 6570, checked in by cetlod, 8 years ago

1st implementation of subduction diag

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