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/UKMO/dev_r5518_clean_shutdown/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: branches/UKMO/dev_r5518_clean_shutdown/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf.F90 @ 5674

Last change on this file since 5674 was 5674, checked in by dancopsey, 9 years ago

Stripped out SVN keywords.

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 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   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), POINTER, DIMENSION(:,:,:,:) ::   ztrtrd   ! 4D workspace
69      !!---------------------------------------------------------------------
70      !
71      IF( nn_timing == 1 )  CALL timing_start('trc_zdf')
72      !
73      IF( kt == nittrc000 )   CALL zdf_ctl          ! initialisation & control of options
74
75      IF( ( neuler == 0 .AND. kt == nittrc000 ) .OR. ln_top_euler ) THEN     ! at nittrc000
76         r2dt(:) =  rdttrc(:)           ! = rdttrc (use or restarting with Euler time stepping)
77      ELSEIF( kt <= nittrc000 + nn_dttrc ) THEN          ! at nittrc000 or nittrc000+1
78         r2dt(:) = 2. * rdttrc(:)       ! = 2 rdttrc (leapfrog)
79      ENDIF
80
81      IF( l_trdtrc )  THEN
82         CALL wrk_alloc( jpi, jpj, jpk, jptra, ztrtrd )
83         ztrtrd(:,:,:,:)  = tra(:,:,:,:)
84      ENDIF
85
86      SELECT CASE ( nzdf )                       ! compute lateral mixing trend and add it to the general trend
87      CASE ( -1 )                                       ! esopa: test all possibility with control print
88         CALL tra_zdf_exp( kt, nittrc000, 'TRC', r2dt, nn_trczdf_exp, trb, tra, jptra ) 
89         WRITE(charout, FMT="('zdf1 ')") ;  CALL prt_ctl_trc_info(charout)
90                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
91         CALL tra_zdf_imp( kt, nittrc000, 'TRC', r2dt,                trb, tra, jptra ) 
92         WRITE(charout, FMT="('zdf2 ')") ;  CALL prt_ctl_trc_info(charout)
93                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
94      CASE ( 0 ) ;  CALL tra_zdf_exp( kt, nittrc000, 'TRC', r2dt, nn_trczdf_exp, trb, tra, jptra )    !   explicit scheme
95      CASE ( 1 ) ;  CALL tra_zdf_imp( kt, nittrc000, 'TRC', r2dt,                trb, tra, jptra )    !   implicit scheme         
96
97      END SELECT
98
99      IF( l_trdtrc )   THEN                      ! save the vertical diffusive trends for further diagnostics
100         DO jn = 1, jptra
101            DO jk = 1, jpkm1
102               ztrtrd(:,:,jk,jn) = ( ( tra(:,:,jk,jn) - trb(:,:,jk,jn) ) / r2dt(jk) ) - ztrtrd(:,:,jk,jn)
103            END DO
104            CALL trd_tra( kt, 'TRC', jn, jptra_zdf, ztrtrd(:,:,:,jn) )
105         END DO
106         CALL wrk_dealloc( jpi, jpj, jpk, jptra, ztrtrd )
107      ENDIF
108      !                                          ! print mean trends (used for debugging)
109      IF( ln_ctl )   THEN
110         WRITE(charout, FMT="('zdf ')") ;  CALL prt_ctl_trc_info(charout)
111                                           CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
112      END IF
113      !
114      IF( nn_timing == 1 )  CALL timing_stop('trc_zdf')
115      !
116   END SUBROUTINE trc_zdf
117
118
119   SUBROUTINE zdf_ctl
120      !!----------------------------------------------------------------------
121      !!                 ***  ROUTINE zdf_ctl  ***
122      !!
123      !! ** Purpose :   Choose the vertical mixing scheme
124      !!
125      !! ** Method  :   Set nzdf from ln_zdfexp
126      !!      nzdf = 0   explicit (time-splitting) scheme (ln_trczdf_exp=T)
127      !!           = 1   implicit (euler backward) scheme (ln_trczdf_exp=F)
128      !!      NB: The implicit scheme is required when using :
129      !!             - rotated lateral mixing operator
130      !!             - TKE, GLS or KPP vertical mixing scheme
131      !!----------------------------------------------------------------------
132
133      !  Define the vertical tracer physics scheme
134      ! ==========================================
135
136      ! Choice from ln_zdfexp already read in namelist in zdfini module
137      IF( ln_trczdf_exp ) THEN           ! use explicit scheme
138         nzdf = 0
139      ELSE                               ! use implicit scheme
140         nzdf = 1
141      ENDIF
142
143      ! Force implicit schemes
144      IF( ln_trcldf_iso                               )   nzdf = 1      ! iso-neutral lateral physics
145      IF( ln_trcldf_hor .AND. ln_sco                  )   nzdf = 1      ! horizontal lateral physics in s-coordinate
146#if defined key_zdftke || defined key_zdfgls || defined key_zdfkpp
147                                                          nzdf = 1      ! TKE, GLS or KPP physics       
148#endif
149      IF( ln_trczdf_exp .AND. nzdf == 1 )   THEN
150         CALL ctl_stop( 'trc_zdf : If using the rotated lateral mixing operator or TKE, GLS or KPP vertical scheme ', &
151            &           '          the implicit scheme is required, set ln_trczdf_exp = .false.' )
152      ENDIF
153
154      ! Test: esopa
155      IF( lk_esopa )    nzdf = -1                      ! All schemes used
156
157      IF(lwp) THEN
158         WRITE(numout,*)
159         WRITE(numout,*) 'trc:zdf_ctl : vertical passive tracer physics scheme'
160         WRITE(numout,*) '~~~~~~~~~~~'
161         IF( nzdf == -1 )   WRITE(numout,*) '              ESOPA test All scheme used'
162         IF( nzdf ==  0 )   WRITE(numout,*) '              Explicit time-splitting scheme'
163         IF( nzdf ==  1 )   WRITE(numout,*) '              Implicit (euler backward) scheme'
164      ENDIF
165
166   END SUBROUTINE zdf_ctl
167#else
168   !!----------------------------------------------------------------------
169   !!   Default option                                         Empty module
170   !!----------------------------------------------------------------------
171CONTAINS
172   SUBROUTINE trc_zdf( kt )
173      INTEGER, INTENT(in) :: kt 
174      WRITE(*,*) 'trc_zdf: You should not have seen this print! error?', kt
175   END SUBROUTINE trc_zdf
176#endif
177   !!==============================================================================
178END MODULE trczdf
Note: See TracBrowser for help on using the repository browser.