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_crs.F90 in branches/UKMO/dev_r10171_test_crs_AMM7/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: branches/UKMO/dev_r10171_test_crs_AMM7/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf_crs.F90 @ 10207

Last change on this file since 10207 was 10207, checked in by cmao, 6 years ago

remove svn keyword

  • Property svn:executable set to *
File size: 9.2 KB
Line 
1MODULE trczdf_crs
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_crs      ! vertical diffusion: implicit (tra_zdf_imp     routine)
21   USE trd_oce
22   USE trdtra
23   USE prtctl_trc      ! Print control
24   USE timing
25
26   IMPLICIT NONE
27   PRIVATE
28
29   PUBLIC   trc_zdf_crs          ! called by step.F90
30   PUBLIC   trc_zdf_alloc_crs    ! 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_crs()
49      !!----------------------------------------------------------------------
50      !!                  ***  ROUTINE trc_zdf_alloc  ***
51      !!----------------------------------------------------------------------
52      ALLOCATE( r2dt(jpk) , STAT=trc_zdf_alloc_crs )
53      !
54      IF( trc_zdf_alloc_crs /= 0 )   CALL ctl_warn('trc_zdf_alloc_crs : failed to allocate array.')
55      !
56   END FUNCTION trc_zdf_alloc_crs
57
58
59   SUBROUTINE trc_zdf_crs( 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!cbr bug
76!#if ! defined key_pisces
77!      IF( neuler == 0 .AND. kt == nittrc000 ) THEN     ! at nittrc000
78!         r2dt(:) =  rdttrc(:)           ! = rdttrc (restarting with Euler time stepping)
79!      ELSEIF( kt <= nittrc000 + 1 ) THEN          ! at nittrc000 or nittrc000+1
80!         r2dt(:) = 2. * rdttrc(:)       ! = 2 rdttrc (leapfrog)
81!      ENDIF
82!#else
83!      r2dt(:) =  rdttrc(:)              ! = rdttrc (for PISCES use Euler time stepping)
84!#endif
85      IF( ln_top_euler) THEN
86         r2dt(:) =  rdttrc(:)              ! = rdttrc (use Euler time stepping)
87      ELSE
88         IF( neuler == 0 .AND. kt == nittrc000 ) THEN     ! at nittrc000
89            r2dt(:) =  rdttrc(:)           ! = rdttrc (restarting with Euler time stepping)
90         ELSEIF( kt <= nittrc000 + 1 ) THEN          ! at nittrc000 or nittrc000+1
91            r2dt(:) = 2. * rdttrc(:)       ! = 2 rdttrc (leapfrog)
92         ENDIF
93      ENDIF
94
95      IF( l_trdtrc )  THEN
96         CALL wrk_alloc( jpi, jpj, jpk, jptra, ztrtrd )
97         ztrtrd(:,:,:,:)  = tra(:,:,:,:)
98      ENDIF
99!      WRITE(numout,*) 'nzdf', nzdf
100      SELECT CASE ( nzdf )                       ! compute lateral mixing trend and add it to the general trend
101      CASE ( -1 )                                       ! esopa: test all possibility with control print
102         CALL tra_zdf_exp( kt, nittrc000, 'TRC', r2dt, nn_trczdf_exp, trb, tra, jptra ) 
103         WRITE(charout, FMT="('zdf1 ')") ;  CALL prt_ctl_trc_info(charout)
104                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
105         CALL tra_zdf_imp_crs( kt, nittrc000, 'TRC', r2dt,                trb, tra, jptra ) 
106         WRITE(charout, FMT="('zdf2 ')") ;  CALL prt_ctl_trc_info(charout)
107                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
108      CASE ( 0 ) ;  CALL tra_zdf_exp( kt, nittrc000, 'TRC', r2dt, nn_trczdf_exp, trb, tra, jptra )    !   explicit scheme
109      CASE ( 1 ) ;  CALL tra_zdf_imp_crs( kt, nittrc000, 'TRC', r2dt,                trb, tra, jptra )    !   implicit scheme         
110      END SELECT
111
112      IF( l_trdtra )   THEN                      ! save the vertical diffusive trends for further diagnostics
113         DO jn = 1, jptra
114            DO jk = 1, jpkm1
115               ztrtrd(:,:,jk,jn) = ( ( tra(:,:,jk,jn) - trb(:,:,jk,jn) ) / r2dt(jk) ) - ztrtrd(:,:,jk,jn)
116            END DO
117            CALL trd_tra( kt, 'TRC', jn, jptra_zdf, ztrtrd(:,:,:,jn) )
118         END DO
119         CALL wrk_dealloc( jpi, jpj, jpk, jptra, ztrtrd )
120      ENDIF
121      !                                          ! print mean trends (used for debugging)
122      IF( ln_ctl )   THEN
123         WRITE(charout, FMT="('zdf ')") ;  CALL prt_ctl_trc_info(charout)
124                                           CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
125      END IF
126      !
127      IF( nn_timing == 1 )  CALL timing_stop('trc_zdf')
128      !
129   END SUBROUTINE trc_zdf_crs
130
131
132   SUBROUTINE zdf_ctl
133      !!----------------------------------------------------------------------
134      !!                 ***  ROUTINE zdf_ctl  ***
135      !!
136      !! ** Purpose :   Choose the vertical mixing scheme
137      !!
138      !! ** Method  :   Set nzdf from ln_zdfexp
139      !!      nzdf = 0   explicit (time-splitting) scheme (ln_trczdf_exp=T)
140      !!           = 1   implicit (euler backward) scheme (ln_trczdf_exp=F)
141      !!      NB: The implicit scheme is required when using :
142      !!             - rotated lateral mixing operator
143      !!             - TKE, GLS or KPP vertical mixing scheme
144      !!----------------------------------------------------------------------
145
146      !  Define the vertical tracer physics scheme
147      ! ==========================================
148
149      ! Choice from ln_zdfexp already read in namelist in zdfini module
150      IF( ln_trczdf_exp ) THEN           ! use explicit scheme
151         nzdf = 0
152      ELSE                               ! use implicit scheme
153         nzdf = 1
154      ENDIF
155
156      ! Force implicit schemes
157      IF( ln_trcldf_iso                               )   nzdf = 1      ! iso-neutral lateral physics
158      IF( ln_trcldf_hor .AND. ln_sco                  )   nzdf = 1      ! horizontal lateral physics in s-coordinate
159#if defined key_zdftke || defined key_zdfgls || defined key_zdfkpp
160                                                          nzdf = 1      ! TKE, GLS or KPP physics       
161#endif
162      IF( ln_trczdf_exp .AND. nzdf == 1 )   THEN
163         CALL ctl_stop( 'trc_zdf : If using the rotated lateral mixing operator or TKE, GLS or KPP vertical scheme ', &
164            &           '          the implicit scheme is required, set ln_trczdf_exp = .false.' )
165      ENDIF
166
167      ! Test: esopa
168      IF( lk_esopa )    nzdf = -1                      ! All schemes used
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 == -1 )   WRITE(numout,*) '              ESOPA test All scheme used'
175         IF( nzdf ==  0 )   WRITE(numout,*) '              Explicit time-splitting scheme'
176         IF( nzdf ==  1 )   WRITE(numout,*) '              Implicit (euler backward) scheme'
177      ENDIF
178
179   END SUBROUTINE zdf_ctl
180#else
181   !!----------------------------------------------------------------------
182   !!   Default option                                         Empty module
183   !!----------------------------------------------------------------------
184CONTAINS
185   SUBROUTINE trc_zdf_crs( kt )
186      INTEGER, INTENT(in) :: kt 
187      WRITE(*,*) 'trc_zdf: You should not have seen this print! error?', kt
188   END SUBROUTINE trc_zdf_crs
189#endif
190   !!==============================================================================
191END MODULE trczdf_crs
Note: See TracBrowser for help on using the repository browser.