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/2012/dev_r3309_LOCEAN12_Ediag/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: branches/2012/dev_r3309_LOCEAN12_Ediag/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf.F90 @ 3318

Last change on this file since 3318 was 3318, checked in by gm, 12 years ago

Ediag branche: #927 split TRA/DYN trd computation

  • Property svn:keywords set to Id
File size: 8.7 KB
Line 
1MODULE trczdf
2   !!==============================================================================
3   !!                 ***  MODULE  trczdf  ***
4   !! Ocean Passive tracers : vertical diffusive trends
5   !!=====================================================================
6   !! History :  1.0  ! 2005-11  (G. Madec)  Original code
7   !!            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       ! trends: ocean variables
22   USE trdtra        ! trends: tracer manager
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      IF( trc_zdf_alloc /= 0 )   CALL ctl_warn('trc_zdf_alloc : failed to allocate array.')
53   END FUNCTION trc_zdf_alloc
54
55
56   SUBROUTINE trc_zdf( kt )
57      !!----------------------------------------------------------------------
58      !!                  ***  ROUTINE trc_zdf  ***
59      !!
60      !! ** Purpose :   compute the vertical ocean tracer physics.
61      !!---------------------------------------------------------------------
62      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
63      !
64      INTEGER            ::  jk, jn
65      CHARACTER (len=22) :: charout
66      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::   ztrtrd   ! 4D workspace
67      !!---------------------------------------------------------------------
68      !
69      IF( nn_timing == 1 )  CALL timing_start('trc_zdf')
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 + 1 ) THEN          ! at nittrc000 or nittrc000+1
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         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_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_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
121   SUBROUTINE zdf_ctl
122      !!----------------------------------------------------------------------
123      !!                 ***  ROUTINE zdf_ctl  ***
124      !!
125      !! ** Purpose :   Choose the vertical mixing scheme
126      !!
127      !! ** Method  :   Set nzdf from ln_zdfexp
128      !!      nzdf = 0   explicit (time-splitting) scheme (ln_trczdf_exp=T)
129      !!           = 1   implicit (euler backward) scheme (ln_trczdf_exp=F)
130      !!      NB: The implicit scheme is required when using :
131      !!             - rotated lateral mixing operator
132      !!             - TKE, GLS or KPP vertical mixing scheme
133      !!----------------------------------------------------------------------
134
135      !  Define the vertical tracer physics scheme
136      ! ==========================================
137
138      ! Choice from ln_zdfexp already read in namelist in zdfini module
139      IF( ln_trczdf_exp ) THEN           ! use explicit scheme
140         nzdf = 0
141      ELSE                               ! use implicit scheme
142         nzdf = 1
143      ENDIF
144
145      ! Force implicit schemes
146      IF( ln_trcldf_iso                               )   nzdf = 1      ! iso-neutral lateral physics
147      IF( ln_trcldf_hor .AND. ln_sco                  )   nzdf = 1      ! horizontal lateral physics in s-coordinate
148#if defined key_zdftke || defined key_zdfgls || defined key_zdfkpp
149                                                          nzdf = 1      ! TKE, GLS or KPP physics       
150#endif
151      IF( ln_trczdf_exp .AND. nzdf == 1 )   THEN
152         CALL ctl_stop( 'trc_zdf : If using the rotated lateral mixing operator or TKE, GLS or KPP vertical scheme ', &
153            &           '          the implicit scheme is required, set ln_trczdf_exp = .false.' )
154      ENDIF
155
156      ! Test: esopa
157      IF( lk_esopa )    nzdf = -1                      ! All schemes used
158
159      IF(lwp) THEN
160         WRITE(numout,*)
161         WRITE(numout,*) 'trc:zdf_ctl : vertical passive tracer physics scheme'
162         WRITE(numout,*) '~~~~~~~~~~~'
163         IF( nzdf == -1 )   WRITE(numout,*) '              ESOPA test All scheme used'
164         IF( nzdf ==  0 )   WRITE(numout,*) '              Explicit time-splitting scheme'
165         IF( nzdf ==  1 )   WRITE(numout,*) '              Implicit (euler backward) scheme'
166      ENDIF
167
168   END SUBROUTINE zdf_ctl
169#else
170   !!----------------------------------------------------------------------
171   !!   Default option                                         Empty module
172   !!----------------------------------------------------------------------
173CONTAINS
174   SUBROUTINE trc_zdf( kt )
175      INTEGER, INTENT(in) :: kt 
176      WRITE(*,*) 'trc_zdf: You should not have seen this print! error?', kt
177   END SUBROUTINE trc_zdf
178#endif
179   !!==============================================================================
180END MODULE trczdf
Note: See TracBrowser for help on using the repository browser.