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/2015/dev_r5721_CNRS9_NOC3_LDF/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: branches/2015/dev_r5721_CNRS9_NOC3_LDF/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf.F90 @ 5766

Last change on this file since 5766 was 5766, checked in by cetlod, 9 years ago

LDF: phasing the improvements/simplifications of TOP component

  • Property svn:keywords set to Id
File size: 9.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_zdf     : update the tracer trend with the lateral diffusion
14   !!   trc_zdf_ini : 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 trazdf_exp      ! vertical diffusion: explicit (tra_zdf_exp     routine)
19   USE trazdf_imp      ! vertical diffusion: implicit (tra_zdf_imp     routine)
20   USE trcldf   
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   PUBLIC   trc_zdf_ini    ! called by nemogcm.F90
31   !                                        !!: ** Vertical diffusion
32   !                                        (nam_trczdf) **
33   LOGICAL , PUBLIC ::   ln_trczdf_exp       !: explicit vertical diffusion scheme flag
34   INTEGER , PUBLIC ::   nn_trczdf_exp       !: number of sub-time step (explicit time stepping)
35
36   INTEGER ::   nzdf = 0               ! type vertical diffusion algorithm used
37      !                                ! defined from ln_zdf...  namlist logicals)
38   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:) ::  r2dt   ! vertical profile time-step, = 2 rdttra
39      !                                                 ! except at nittrc000 (=rdttra) if neuler=0
40
41   !! * Substitutions
42#  include "domzgr_substitute.h90"
43#  include "zdfddm_substitute.h90"
44#  include "vectopt_loop_substitute.h90"
45   !!----------------------------------------------------------------------
46   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
47   !! $Id$
48   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
49   !!----------------------------------------------------------------------
50CONTAINS
51   
52   INTEGER FUNCTION trc_zdf_alloc()
53      !!----------------------------------------------------------------------
54      !!                  ***  ROUTINE trc_zdf_alloc  ***
55      !!----------------------------------------------------------------------
56      ALLOCATE( r2dt(jpk) , STAT=trc_zdf_alloc )
57      !
58      IF( trc_zdf_alloc /= 0 )   CALL ctl_warn('trc_zdf_alloc : failed to allocate array.')
59      !
60   END FUNCTION trc_zdf_alloc
61
62   SUBROUTINE trc_zdf( kt )
63      !!----------------------------------------------------------------------
64      !!                  ***  ROUTINE trc_zdf  ***
65      !!
66      !! ** Purpose :   compute the vertical ocean tracer physics.
67      !!---------------------------------------------------------------------
68      INTEGER, INTENT( in ) ::  kt      ! ocean time-step index
69      !
70      INTEGER               ::  jk, jn
71      CHARACTER (len=22)    :: charout
72      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::   ztrtrd   ! 4D workspace
73      !!---------------------------------------------------------------------
74      !
75      IF( nn_timing == 1 )  CALL timing_start('trc_zdf')
76      !
77      IF( ( neuler == 0 .AND. kt == nittrc000 ) .OR. ln_top_euler ) THEN     ! at nittrc000
78         r2dt(:) =  rdttrc(:)           ! = rdttrc (use or restarting with Euler time stepping)
79      ELSEIF( kt <= nittrc000 + nn_dttrc ) THEN          ! at nittrc000 or nittrc000+1
80         r2dt(:) = 2. * rdttrc(:)       ! = 2 rdttrc (leapfrog)
81      ENDIF
82
83      IF( l_trdtrc )  THEN
84         CALL wrk_alloc( jpi, jpj, jpk, jptra, ztrtrd )
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, nittrc000, '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, nittrc000, '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, nittrc000, 'TRC', r2dt, nn_trczdf_exp, trb, tra, jptra )    !   explicit scheme
97      CASE ( 1 ) ;  CALL tra_zdf_imp( kt, nittrc000, 'TRC', r2dt,                trb, tra, jptra )    !   implicit scheme         
98
99      END SELECT
100
101      IF( l_trdtrc )   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_zdf, ztrtrd(:,:,:,jn) )
107         END DO
108         CALL wrk_dealloc( jpi, jpj, jpk, jptra, ztrtrd )
109      ENDIF
110      !                                          ! print mean trends (used for debugging)
111      IF( ln_ctl )   THEN
112         WRITE(charout, FMT="('zdf ')") ;  CALL prt_ctl_trc_info(charout)
113                                           CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
114      END IF
115      !
116      IF( nn_timing == 1 )  CALL timing_stop('trc_zdf')
117      !
118   END SUBROUTINE trc_zdf
119
120   SUBROUTINE trc_zdf_ini
121      !!----------------------------------------------------------------------
122      !!                 ***  ROUTINE trc_zdf_ini  ***
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 vertical mixing scheme
132      !!----------------------------------------------------------------------
133      INTEGER ::  ios                 ! Local integer output status for namelist read
134      !
135      NAMELIST/namtrc_zdf/ ln_trczdf_exp  , nn_trczdf_exp
136      !!----------------------------------------------------------------------
137
138      !                                ! Vertical mixing
139      REWIND( numnat_ref )             ! namtrc_zdf in reference namelist
140      READ  ( numnat_ref, namtrc_zdf, IOSTAT = ios, ERR = 905)
141905   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_zdf in reference namelist', lwp )
142
143      REWIND( numnat_cfg )             ! namtrc_zdf in configuration namelist
144      READ  ( numnat_cfg, namtrc_zdf, IOSTAT = ios, ERR = 906 )
145906   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_zdf in configuration namelist', lwp )
146      IF(lwm) WRITE ( numont, namtrc_zdf )
147
148      IF(lwp) THEN                     !   ! Control print
149         WRITE(numout,*)
150         WRITE(numout,*) '   Namelist namtrc_zdf : set vertical diffusion  parameters'
151         WRITE(numout,*) '      time splitting / backward scheme ln_trczdf_exp = ', ln_trczdf_exp
152         WRITE(numout,*) '      number of time step              nn_trczdf_exp = ', nn_trczdf_exp
153      ENDIF
154
155      !  Define the vertical tracer physics scheme
156      IF( ln_trczdf_exp ) THEN  ;  nzdf = 0     ! explicit scheme
157      ELSE                      ;  nzdf = 1     ! implicit scheme
158      ENDIF
159
160      ! Force implicit schemes
161      IF( ln_trcldf_iso                               )   nzdf = 1      ! iso-neutral lateral physics
162      IF( ln_trcldf_hor .AND. ln_sco                  )   nzdf = 1      ! horizontal lateral physics in s-coordinate
163#if defined key_zdftke || defined key_zdfgls 
164                                                          nzdf = 1      ! TKE or GLS physics       
165#endif
166      IF( ln_trczdf_exp .AND. nzdf == 1 )  & 
167         CALL ctl_stop( 'trc_zdf : If using the rotated lateral mixing operator or TKE, GLS vertical scheme ', &
168            &           '          the implicit scheme is required, set ln_trczdf_exp = .false.' )
169
170      IF(lwp) THEN
171         WRITE(numout,*)
172         WRITE(numout,*) 'trc:zdf_ctl : vertical passive tracer physics scheme'
173         WRITE(numout,*) '~~~~~~~~~~~'
174         IF( nzdf ==  0 )   WRITE(numout,*) '              Explicit time-splitting scheme'
175         IF( nzdf ==  1 )   WRITE(numout,*) '              Implicit (euler backward) scheme'
176      ENDIF
177
178   END SUBROUTINE trc_zdf_ini
179#else
180   !!----------------------------------------------------------------------
181   !!   Default option                                         Empty module
182   !!----------------------------------------------------------------------
183CONTAINS
184   SUBROUTINE trc_zdf( kt )
185      INTEGER, INTENT(in) :: kt 
186      WRITE(*,*) 'trc_zdf: You should not have seen this print! error?', kt
187   END SUBROUTINE trc_zdf
188#endif
189   !!==============================================================================
190END MODULE trczdf
Note: See TracBrowser for help on using the repository browser.