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/DEV_r2006_merge_TRA_TRC/NEMO/TOP_SRC/TRP – NEMO

source: branches/DEV_r2006_merge_TRA_TRC/NEMO/TOP_SRC/TRP/trczdf.F90 @ 2030

Last change on this file since 2030 was 2030, checked in by cetlod, 14 years ago

Apply the merge to passive tracers, see ticket:693

File size: 8.3 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   !!----------------------------------------------------------------------
14   !!   trc_ldf     : update the tracer trend with the lateral diffusion
15   !!       ldf_ctl : initialization, namelist read, and parameters control
16   !!----------------------------------------------------------------------
17   USE oce_trc         ! ocean dynamics and active tracers
18   USE trc             ! ocean passive tracers variables
19   USE trcnam_trp      ! passive tracers transport namelist variables
20   USE trazdf_exp      ! vertical diffusion: explicit (tra_zdf_exp     routine)
21   USE trazdf_imp      ! vertical diffusion: implicit (tra_zdf_imp     routine)
22   USE prtctl_trc      ! Print control
23   USE in_out_manager  ! I/O manager
24   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
25   USE trdmod_oce
26   USE trdtra
27
28   IMPLICIT NONE
29   PRIVATE
30
31   PUBLIC   trc_zdf    ! called by step.F90
32
33   INTEGER ::   nzdf = 0               ! type vertical diffusion algorithm used
34      !                                ! defined from ln_zdf...  namlist logicals)
35   REAL(wp), DIMENSION(jpk) ::  r2dt   ! vertical profile time-step, = 2 rdttra
36      !                                ! except at nit000 (=rdttra) if neuler=0
37
38   !! * Substitutions
39#  include "domzgr_substitute.h90"
40#  include "zdfddm_substitute.h90"
41#  include "vectopt_loop_substitute.h90"
42   !!----------------------------------------------------------------------
43   !!  OPA 9.0 , LOCEAN-IPSL (2005)
44   !! $Id: trazdf.F90 1533 2009-07-24 09:54:48Z ctlod $
45   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
46   !!----------------------------------------------------------------------
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), DIMENSION(:,:,:,:), ALLOCATABLE ::   ztrtrd   ! 4D workspace
61      !!---------------------------------------------------------------------
62
63      IF( kt == nittrc000 )   CALL zdf_ctl          ! initialisation & control of options
64
65      IF( neuler == 0 .AND. kt == nittrc000 ) THEN     ! at nit000
66         r2dt(:) =  rdttra(:) * FLOAT(nn_dttrc)          ! = rdtra (restarting with Euler time stepping)
67      ELSEIF( kt <= nittrc000 + nn_dttrc ) THEN          ! at nit000 or nit000+1
68         r2dt(:) = 2. * rdttra(:) * FLOAT(nn_dttrc)      ! = 2 rdttra (leapfrog)
69      ENDIF
70
71      IF( l_trdtrc )  THEN
72         ALLOCATE( ztrtrd(jpi,jpj,jpk,jptra) )   ! temporary save of trends
73         ztrtrd(:,:,:,:)  = tra(:,:,:,:)
74      ENDIF
75
76      SELECT CASE ( nzdf )                       ! compute lateral mixing trend and add it to the general trend
77      CASE ( -1 )                                       ! esopa: test all possibility with control print
78                    CALL tra_zdf_exp( kt , 'TRC', r2dt, nn_trczdf_exp,  &
79                    &                 trb, tra, jptra                   ) 
80                    WRITE(charout, FMT="('zdf1 ')") ;  CALL prt_ctl_trc_info(charout)
81                                                       CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
82                    !
83                    CALL tra_zdf_imp( kt , 'TRC', r2dt,                 &
84                    &                 trb, tra, jptra                   ) 
85                    WRITE(charout, FMT="('zdf2 ')") ;  CALL prt_ctl_trc_info(charout)
86                                                       CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
87      CASE ( 0 ) ;  CALL tra_zdf_exp( kt , 'TRC', r2dt, nn_trczdf_exp,  &
88                    &                 trb, tra  , jptra                 )    !   explicit scheme
89      CASE ( 1 ) ;  CALL tra_zdf_imp( kt , 'TRC', r2dt,                 &
90                    &                 trb, tra  , jptra                 )    !   implicit scheme
91
92      END SELECT
93
94      IF( l_trdtra )   THEN                      ! save the vertical diffusive trends for further diagnostics
95         DO jn = 1, jptra
96            DO jk = 1, jpkm1
97               ztrtrd(:,:,jk,jn) = ( ( tra(:,:,jk,jn) - trb(:,:,jk,jn) ) / r2dt(jk) ) - ztrtrd(:,:,jk,jn)
98            END DO
99            CALL trd_tra( kt, 'TRC', jn, jptra_trd_zdf, ztrtrd(:,:,:,jn) )
100         END DO
101         DEALLOCATE( ztrtrd )
102      ENDIF
103
104      !                                          ! print mean trends (used for debugging)
105      IF( ln_ctl )   THEN
106         WRITE(charout, FMT="('zdf ')") ;  CALL prt_ctl_trc_info(charout)
107                                           CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
108      END IF
109      !
110   END SUBROUTINE trc_zdf
111
112
113   SUBROUTINE zdf_ctl
114      !!----------------------------------------------------------------------
115      !!                 ***  ROUTINE zdf_ctl  ***
116      !!
117      !! ** Purpose :   Choose the vertical mixing scheme
118      !!
119      !! ** Method  :   Set nzdf from ln_zdfexp
120      !!      nzdf = 0   explicit (time-splitting) scheme (ln_trczdf_exp=T)
121      !!           = 1   implicit (euler backward) scheme (ln_trczdf_exp=F)
122      !!      NB: rotation of lateral mixing operator or TKE or KPP scheme,
123      !!      the implicit scheme is required.
124      !!----------------------------------------------------------------------
125
126      !  Define the vertical tracer physics scheme
127      ! ==========================================
128
129      ! Choice from ln_zdfexp already read in namelist in zdfini module
130      IF( ln_trczdf_exp ) THEN           ! use explicit scheme
131         nzdf = 0
132      ELSE                               ! use implicit scheme
133         nzdf = 1
134      ENDIF
135
136      ! Force implicit schemes
137      IF( ln_trcldf_iso                               )   nzdf = 1      ! iso-neutral lateral physics
138      IF( ln_trcldf_hor .AND. ln_sco                  )   nzdf = 1      ! horizontal lateral physics in s-coordinate
139#if defined key_zdftke || defined key_zdftke_old || defined key_zdfkpp
140                                                          nzdf = 1      ! TKE or KPP physics       
141#endif
142      IF( ln_trczdf_exp .AND. nzdf == 1 )   THEN
143         CALL ctl_stop( 'trc_zdf : If using the rotation of lateral mixing operator or TKE ', &
144            &           '          or KPP scheme, the implicit scheme is required, set ln_trczdf_exp = .false.' )
145      ENDIF
146
147      ! Test: esopa
148      IF( lk_esopa )    nzdf = -1                      ! All schemes used
149
150      IF(lwp) THEN
151         WRITE(numout,*)
152         WRITE(numout,*) 'trc:zdf_ctl : vertical passive tracer physics scheme'
153         WRITE(numout,*) '~~~~~~~~~~~'
154         IF( nzdf == -1 )   WRITE(numout,*) '              ESOPA test All scheme used'
155         IF( nzdf ==  0 )   WRITE(numout,*) '              Explicit time-splitting scheme'
156         IF( nzdf ==  1 )   WRITE(numout,*) '              Implicit (euler backward) scheme'
157      ENDIF
158
159   END SUBROUTINE zdf_ctl
160#else
161   !!----------------------------------------------------------------------
162   !!   Default option                                         Empty module
163   !!----------------------------------------------------------------------
164CONTAINS
165   SUBROUTINE trc_zdf( kt )
166      INTEGER, INTENT(in) :: kt 
167      WRITE(*,*) 'trc_zdf: You should not have seen this print! error?', kt
168   END SUBROUTINE trc_zdf
169#endif
170   !!==============================================================================
171END MODULE trczdf
Note: See TracBrowser for help on using the repository browser.