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/2011/dev_r2802_TOP_substepping/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: branches/2011/dev_r2802_TOP_substepping/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf.F90 @ 2830

Last change on this file since 2830 was 2830, checked in by kpedwards, 13 years ago

Updates to average physics variables for TOP substepping.

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