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/NERC/dev_r5518_GO6_CO2_cmip/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: branches/NERC/dev_r5518_GO6_CO2_cmip/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf.F90

Last change on this file was 9163, checked in by frrh, 6 years ago

Add code from Julien Palmieri's Met Office GMED ticket 338.
This incorporates code from branches/NERC/dev_r5518_GO6_package_trdtrc
revisions 8454:9020 inclusive.

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