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

source: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf.F90 @ 2606

Last change on this file since 2606 was 2606, checked in by trackstand2, 13 years ago

Module arrays made allocatable

  • 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 :  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   PUBLIC   trc_zdf_alloc    ! called by nemogcm.F90
33
34   INTEGER ::   nzdf = 0               ! type vertical diffusion algorithm used
35      !                                ! defined from ln_zdf...  namlist logicals)
36   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:) ::  r2dt   ! vertical profile time-step, = 2 rdttra
37      !                                ! except at nit000 (=rdttra) if neuler=0
38
39   !! * Substitutions
40#  include "domzgr_substitute.h90"
41#  include "zdfddm_substitute.h90"
42#  include "vectopt_loop_substitute.h90"
43   !!----------------------------------------------------------------------
44   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
45   !! $Id$
46   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
47   !!----------------------------------------------------------------------
48
49CONTAINS
50   
51   FUNCTION trc_zdf_alloc()
52      !!----------------------------------------------------------------------
53      !!                  ***  ROUTINE trc_zdf_alloc  ***
54      !!----------------------------------------------------------------------
55      INTEGER :: trc_zdf_alloc
56      !!----------------------------------------------------------------------
57
58      ALLOCATE(r2dt(jpk), Stat=trc_zdf_alloc)
59
60      IF(trc_zdf_alloc /= 0)THEN
61         CALL ctl_warn('trc_zdf_alloc : failed to allocate array.')
62      END IF
63
64   END FUNCTION trc_zdf_alloc
65
66
67   SUBROUTINE trc_zdf( kt )
68      !!----------------------------------------------------------------------
69      !!                  ***  ROUTINE trc_zdf  ***
70      !!
71      !! ** Purpose :   compute the vertical ocean tracer physics.
72      !!---------------------------------------------------------------------
73      INTEGER, INTENT( in ) ::  kt      ! ocean time-step index
74      !
75      INTEGER               ::  jk, jn
76      CHARACTER (len=22)    :: charout
77      REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::   ztrtrd   ! 4D workspace
78      !!---------------------------------------------------------------------
79
80      IF( kt == nit000 )   CALL zdf_ctl          ! initialisation & control of options
81
82#if ! defined key_pisces
83      IF( neuler == 0 .AND. kt == nit000 ) THEN     ! at nit000
84         r2dt(:) =  rdttrc(:)           ! = rdttrc (restarting with Euler time stepping)
85      ELSEIF( kt <= nit000 + nn_dttrc ) THEN          ! at nit000 or nit000+1
86         r2dt(:) = 2. * rdttrc(:)       ! = 2 rdttrc (leapfrog)
87      ENDIF
88#else
89      r2dt(:) =  rdttrc(:)              ! = rdttrc (for PISCES use Euler time stepping)
90#endif
91
92      IF( l_trdtrc )  THEN
93         ALLOCATE( ztrtrd(jpi,jpj,jpk,jptra) )   ! temporary save of trends
94         ztrtrd(:,:,:,:)  = tra(:,:,:,:)
95      ENDIF
96
97      SELECT CASE ( nzdf )                       ! compute lateral mixing trend and add it to the general trend
98      CASE ( -1 )                                       ! esopa: test all possibility with control print
99         CALL tra_zdf_exp( kt, 'TRC', r2dt, nn_trczdf_exp, trb, tra, jptra ) 
100         WRITE(charout, FMT="('zdf1 ')") ;  CALL prt_ctl_trc_info(charout)
101                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
102         CALL tra_zdf_imp( kt, 'TRC', r2dt,                trb, tra, jptra ) 
103         WRITE(charout, FMT="('zdf2 ')") ;  CALL prt_ctl_trc_info(charout)
104                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
105      CASE ( 0 ) ;  CALL tra_zdf_exp( kt, 'TRC', r2dt, nn_trczdf_exp, trb, tra, jptra )    !   explicit scheme
106      CASE ( 1 ) ;  CALL tra_zdf_imp( kt, 'TRC', r2dt,                trb, tra, jptra )    !   implicit scheme         
107
108      END SELECT
109
110      IF( l_trdtra )   THEN                      ! save the vertical diffusive trends for further diagnostics
111         DO jn = 1, jptra
112            DO jk = 1, jpkm1
113               ztrtrd(:,:,jk,jn) = ( ( tra(:,:,jk,jn) - trb(:,:,jk,jn) ) / r2dt(jk) ) - ztrtrd(:,:,jk,jn)
114            END DO
115            CALL trd_tra( kt, 'TRC', jn, jptra_trd_zdf, ztrtrd(:,:,:,jn) )
116         END DO
117         DEALLOCATE( ztrtrd )
118      ENDIF
119
120      !                                          ! print mean trends (used for debugging)
121      IF( ln_ctl )   THEN
122         WRITE(charout, FMT="('zdf ')") ;  CALL prt_ctl_trc_info(charout)
123                                           CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
124      END IF
125      !
126   END SUBROUTINE trc_zdf
127
128
129   SUBROUTINE zdf_ctl
130      !!----------------------------------------------------------------------
131      !!                 ***  ROUTINE zdf_ctl  ***
132      !!
133      !! ** Purpose :   Choose the vertical mixing scheme
134      !!
135      !! ** Method  :   Set nzdf from ln_zdfexp
136      !!      nzdf = 0   explicit (time-splitting) scheme (ln_trczdf_exp=T)
137      !!           = 1   implicit (euler backward) scheme (ln_trczdf_exp=F)
138      !!      NB: The implicit scheme is required when using :
139      !!             - rotated lateral mixing operator
140      !!             - TKE, GLS or KPP vertical mixing scheme
141      !!----------------------------------------------------------------------
142
143      !  Define the vertical tracer physics scheme
144      ! ==========================================
145
146      ! Choice from ln_zdfexp already read in namelist in zdfini module
147      IF( ln_trczdf_exp ) THEN           ! use explicit scheme
148         nzdf = 0
149      ELSE                               ! use implicit scheme
150         nzdf = 1
151      ENDIF
152
153      ! Force implicit schemes
154      IF( ln_trcldf_iso                               )   nzdf = 1      ! iso-neutral lateral physics
155      IF( ln_trcldf_hor .AND. ln_sco                  )   nzdf = 1      ! horizontal lateral physics in s-coordinate
156#if defined key_zdftke || defined key_zdfgls || defined key_zdfkpp
157                                                          nzdf = 1      ! TKE, GLS or KPP physics       
158#endif
159      IF( ln_trczdf_exp .AND. nzdf == 1 )   THEN
160         CALL ctl_stop( 'trc_zdf : If using the rotated lateral mixing operator or TKE, GLS or KPP vertical scheme ', &
161            &           '          the implicit scheme is required, set ln_trczdf_exp = .false.' )
162      ENDIF
163
164      ! Test: esopa
165      IF( lk_esopa )    nzdf = -1                      ! All schemes used
166
167      IF(lwp) THEN
168         WRITE(numout,*)
169         WRITE(numout,*) 'trc:zdf_ctl : vertical passive tracer physics scheme'
170         WRITE(numout,*) '~~~~~~~~~~~'
171         IF( nzdf == -1 )   WRITE(numout,*) '              ESOPA test All scheme used'
172         IF( nzdf ==  0 )   WRITE(numout,*) '              Explicit time-splitting scheme'
173         IF( nzdf ==  1 )   WRITE(numout,*) '              Implicit (euler backward) scheme'
174      ENDIF
175
176   END SUBROUTINE zdf_ctl
177#else
178   !!----------------------------------------------------------------------
179   !!   Default option                                         Empty module
180   !!----------------------------------------------------------------------
181CONTAINS
182   SUBROUTINE trc_zdf( kt )
183      INTEGER, INTENT(in) :: kt 
184      WRITE(*,*) 'trc_zdf: You should not have seen this print! error?', kt
185   END SUBROUTINE trc_zdf
186#endif
187   !!==============================================================================
188END MODULE trczdf
Note: See TracBrowser for help on using the repository browser.