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/2016/dev_r6519_HPC_4/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: branches/2016/dev_r6519_HPC_4/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf.F90 @ 7037

Last change on this file since 7037 was 7037, checked in by mocavero, 8 years ago

ORCA2_LIM_PISCES hybrid version update

  • Property svn:keywords set to Id
File size: 8.4 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 trc           ! ocean passive tracers variables
17   USE oce_trc       ! ocean dynamics and active tracers
18   USE trd_oce       ! trends: ocean 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 trcldf        ! passive tracers: lateral diffusion
22   USE trdtra        ! trends manager: tracers
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_ini     ! called by nemogcm.F90
30   
31   !                                        !!** Vertical diffusion (nam_trczdf) **
32   LOGICAL , PUBLIC ::   ln_trczdf_exp       !: explicit vertical diffusion scheme flag
33   INTEGER , PUBLIC ::   nn_trczdf_exp       !: number of sub-time step (explicit time stepping)
34
35   INTEGER ::   nzdf = 0               ! type vertical diffusion algorithm used
36      !                                ! defined from ln_zdf...  namlist logicals)
37   REAL(wp) ::  r2dttrc   ! vertical profile time-step, = 2 rdt
38      !                   ! except at nittrc000 (=rdt) if neuler=0
39
40   !! * Substitutions
41#  include "zdfddm_substitute.h90"
42#  include "vectopt_loop_substitute.h90"
43   !!----------------------------------------------------------------------
44   !! NEMO/TOP 3.7 , NEMO Consortium (2015)
45   !! $Id$
46   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
47   !!----------------------------------------------------------------------
48CONTAINS
49
50   SUBROUTINE trc_zdf( kt )
51      !!----------------------------------------------------------------------
52      !!                  ***  ROUTINE trc_zdf  ***
53      !!
54      !! ** Purpose :   compute the vertical ocean tracer physics.
55      !!---------------------------------------------------------------------
56      INTEGER, INTENT( in ) ::  kt      ! ocean time-step index
57      !
58      INTEGER               ::  jk, jn
59      CHARACTER (len=22)    :: charout
60      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::   ztrtrd   ! 4D workspace
61      !!---------------------------------------------------------------------
62      !
63      IF( nn_timing == 1 )  CALL timing_start('trc_zdf')
64      !
65      IF( ( neuler == 0 .AND. kt == nittrc000 ) .OR. ln_top_euler ) THEN     ! at nittrc000
66         r2dttrc =  rdttrc           ! = rdttrc (use or restarting with Euler time stepping)
67      ELSEIF( kt <= nittrc000 + nn_dttrc ) THEN          ! at nittrc000 or nittrc000+1
68         r2dttrc = 2. * rdttrc       ! = 2 rdttrc (leapfrog)
69      ENDIF
70
71      IF( l_trdtrc )  THEN
72         CALL wrk_alloc( jpi, jpj, jpk, jptra, ztrtrd )
73!$OMP PARALLEL WORKSHARE
74         ztrtrd(:,:,:,:)  = tra(:,:,:,:)
75!$OMP END PARALLEL WORKSHARE
76      ENDIF
77
78      SELECT CASE ( nzdf )                       ! compute lateral mixing trend and add it to the general trend
79      CASE ( 0 ) ;  CALL tra_zdf_exp( kt, nittrc000, 'TRC', r2dttrc, nn_trczdf_exp, trb, tra, jptra )    !   explicit scheme
80      CASE ( 1 ) ;  CALL tra_zdf_imp( kt, nittrc000, 'TRC', r2dttrc,                trb, tra, jptra )    !   implicit scheme         
81      END SELECT
82
83      IF( l_trdtrc )   THEN                      ! save the vertical diffusive trends for further diagnostics
84         DO jn = 1, jptra
85!$OMP PARALLEL DO schedule(static) private(jk)
86            DO jk = 1, jpkm1
87               ztrtrd(:,:,jk,jn) = ( ( tra(:,:,jk,jn) - trb(:,:,jk,jn) ) / r2dttrc ) - ztrtrd(:,:,jk,jn)
88            END DO
89            CALL trd_tra( kt, 'TRC', jn, jptra_zdf, ztrtrd(:,:,:,jn) )
90         END DO
91         CALL wrk_dealloc( jpi, jpj, jpk, jptra, ztrtrd )
92      ENDIF
93      !                                          ! print mean trends (used for debugging)
94      IF( ln_ctl )   THEN
95         WRITE(charout, FMT="('zdf ')") ;  CALL prt_ctl_trc_info(charout)
96                                           CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
97      END IF
98      !
99      IF( nn_timing == 1 )  CALL timing_stop('trc_zdf')
100      !
101   END SUBROUTINE trc_zdf
102
103
104   SUBROUTINE trc_zdf_ini
105      !!----------------------------------------------------------------------
106      !!                 ***  ROUTINE trc_zdf_ini  ***
107      !!
108      !! ** Purpose :   Choose the vertical mixing scheme
109      !!
110      !! ** Method  :   Set nzdf from ln_zdfexp
111      !!      nzdf = 0   explicit (time-splitting) scheme (ln_trczdf_exp=T)
112      !!           = 1   implicit (euler backward) scheme (ln_trczdf_exp=F)
113      !!      NB: The implicit scheme is required when using :
114      !!             - rotated lateral mixing operator
115      !!             - TKE, GLS vertical mixing scheme
116      !!----------------------------------------------------------------------
117      INTEGER ::  ios                 ! Local integer output status for namelist read
118      !!
119      NAMELIST/namtrc_zdf/ ln_trczdf_exp  , nn_trczdf_exp
120      !!----------------------------------------------------------------------
121      !
122      REWIND( numnat_ref )             ! namtrc_zdf in reference namelist
123      READ  ( numnat_ref, namtrc_zdf, IOSTAT = ios, ERR = 905)
124905   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_zdf in reference namelist', lwp )
125      !
126      REWIND( numnat_cfg )             ! namtrc_zdf in configuration namelist
127      READ  ( numnat_cfg, namtrc_zdf, IOSTAT = ios, ERR = 906 )
128906   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_zdf in configuration namelist', lwp )
129      IF(lwm) WRITE ( numont, namtrc_zdf )
130      !
131      IF(lwp) THEN                     ! Control print
132         WRITE(numout,*)
133         WRITE(numout,*) '   Namelist namtrc_zdf : set vertical diffusion  parameters'
134         WRITE(numout,*) '      time splitting / backward scheme ln_trczdf_exp = ', ln_trczdf_exp
135         WRITE(numout,*) '      number of time step              nn_trczdf_exp = ', nn_trczdf_exp
136      ENDIF
137
138      !                                ! Define the vertical tracer physics scheme
139      IF( ln_trczdf_exp ) THEN   ;   nzdf = 0     ! explicit scheme
140      ELSE                       ;   nzdf = 1     ! implicit scheme
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 
147                                         nzdf = 1      ! TKE or GLS physics       
148#endif
149      IF( ln_trczdf_exp .AND. nzdf == 1 )  & 
150         CALL ctl_stop( 'trc_zdf : If using the rotated lateral mixing operator or TKE, GLS vertical scheme ', &
151            &           '          the implicit scheme is required, set ln_trczdf_exp = .false.' )
152
153      IF(lwp) THEN
154         WRITE(numout,*)
155         WRITE(numout,*) 'trc:zdf_ctl : vertical passive tracer physics scheme'
156         WRITE(numout,*) '~~~~~~~~~~~'
157         IF( nzdf ==  0 )   WRITE(numout,*) '              Explicit time-splitting scheme'
158         IF( nzdf ==  1 )   WRITE(numout,*) '              Implicit (euler backward) scheme'
159      ENDIF
160      !
161   END SUBROUTINE trc_zdf_ini
162   
163#else
164   !!----------------------------------------------------------------------
165   !!   Default option                                         Empty module
166   !!----------------------------------------------------------------------
167CONTAINS
168   SUBROUTINE trc_zdf( kt )
169      INTEGER, INTENT(in) :: kt 
170      WRITE(*,*) 'trc_zdf: You should not have seen this print! error?', kt
171   END SUBROUTINE trc_zdf
172#endif
173   !!==============================================================================
174END MODULE trczdf
Note: See TracBrowser for help on using the repository browser.