1 | MODULE 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_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 domvvl ! variable volume |
---|
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 trd_oce |
---|
23 | USE trdtra |
---|
24 | USE prtctl_trc ! Print control |
---|
25 | |
---|
26 | IMPLICIT NONE |
---|
27 | PRIVATE |
---|
28 | |
---|
29 | PUBLIC trc_zdf ! called by step.F90 |
---|
30 | PUBLIC trc_zdf_alloc ! 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 | !!---------------------------------------------------------------------- |
---|
46 | CONTAINS |
---|
47 | |
---|
48 | INTEGER FUNCTION trc_zdf_alloc() |
---|
49 | !!---------------------------------------------------------------------- |
---|
50 | !! *** ROUTINE trc_zdf_alloc *** |
---|
51 | !!---------------------------------------------------------------------- |
---|
52 | ALLOCATE( r2dt(jpk) , STAT=trc_zdf_alloc ) |
---|
53 | ! |
---|
54 | IF( trc_zdf_alloc /= 0 ) CALL ctl_warn('trc_zdf_alloc : failed to allocate array.') |
---|
55 | ! |
---|
56 | END FUNCTION trc_zdf_alloc |
---|
57 | |
---|
58 | |
---|
59 | SUBROUTINE trc_zdf( 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 | |
---|
76 | IF( ( neuler == 0 .AND. kt == nittrc000 ) .OR. ln_top_euler ) THEN ! at nittrc000 |
---|
77 | r2dt(:) = rdttrc(:) ! = rdttrc (use or restarting with Euler time stepping) |
---|
78 | ELSEIF( kt <= nittrc000 + nn_dttrc ) THEN ! at nittrc000 or nittrc000+1 |
---|
79 | r2dt(:) = 2. * rdttrc(:) ! = 2 rdttrc (leapfrog) |
---|
80 | ENDIF |
---|
81 | |
---|
82 | IF( l_trdtrc ) THEN |
---|
83 | CALL wrk_alloc( jpi, jpj, jpk, jptra, ztrtrd ) |
---|
84 | ztrtrd(:,:,:,:) = tra(:,:,:,:) |
---|
85 | ENDIF |
---|
86 | |
---|
87 | SELECT CASE ( nzdf ) ! compute lateral mixing trend and add it to the general trend |
---|
88 | CASE ( -1 ) ! esopa: test all possibility with control print |
---|
89 | CALL tra_zdf_exp( kt, nittrc000, 'TRC', r2dt, nn_trczdf_exp, trb, tra, jptra ) |
---|
90 | WRITE(charout, FMT="('zdf1 ')") ; CALL prt_ctl_trc_info(charout) |
---|
91 | CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' ) |
---|
92 | CALL tra_zdf_imp( kt, nittrc000, 'TRC', r2dt, trb, tra, jptra ) |
---|
93 | WRITE(charout, FMT="('zdf2 ')") ; CALL prt_ctl_trc_info(charout) |
---|
94 | CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' ) |
---|
95 | CASE ( 0 ) ; CALL tra_zdf_exp( kt, nittrc000, 'TRC', r2dt, nn_trczdf_exp, trb, tra, jptra ) ! explicit scheme |
---|
96 | CASE ( 1 ) ; CALL tra_zdf_imp( kt, nittrc000, 'TRC', r2dt, trb, tra, jptra ) ! implicit scheme |
---|
97 | |
---|
98 | END SELECT |
---|
99 | |
---|
100 | IF( l_trdtrc ) THEN ! save the vertical diffusive trends for further diagnostics |
---|
101 | !! JPALM -- 18-08-2017 -- vvl case, do as done by G Nurser in trazdf |
---|
102 | IF( lk_vvl ) THEN |
---|
103 | DO jn = 1, jptra |
---|
104 | DO jk = 1, jpkm1 |
---|
105 | ztrtrd(:,:,jk,jn) = ( ( tra(:,:,jk,jn)*fse3t_a(:,:,jk) - & |
---|
106 | trn(:,:,jk,jn)*fse3t_b(:,:,jk) ) & |
---|
107 | / (fse3t_n(:,:,jk)*r2dtra(jk)) ) - ztrtrd(:,:,jk,jn) |
---|
108 | END DO |
---|
109 | END DO |
---|
110 | ELSE |
---|
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_zdf, ztrtrd(:,:,:,jn) ) |
---|
116 | END DO |
---|
117 | ENDIF |
---|
118 | CALL wrk_dealloc( jpi, jpj, jpk, jptra, ztrtrd ) |
---|
119 | ENDIF |
---|
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 | IF( nn_timing == 1 ) CALL timing_stop('trc_zdf') |
---|
127 | ! |
---|
128 | END SUBROUTINE trc_zdf |
---|
129 | |
---|
130 | |
---|
131 | SUBROUTINE zdf_ctl |
---|
132 | !!---------------------------------------------------------------------- |
---|
133 | !! *** ROUTINE zdf_ctl *** |
---|
134 | !! |
---|
135 | !! ** Purpose : Choose the vertical mixing scheme |
---|
136 | !! |
---|
137 | !! ** Method : Set nzdf from ln_zdfexp |
---|
138 | !! nzdf = 0 explicit (time-splitting) scheme (ln_trczdf_exp=T) |
---|
139 | !! = 1 implicit (euler backward) scheme (ln_trczdf_exp=F) |
---|
140 | !! NB: The implicit scheme is required when using : |
---|
141 | !! - rotated lateral mixing operator |
---|
142 | !! - TKE, GLS or KPP vertical mixing scheme |
---|
143 | !!---------------------------------------------------------------------- |
---|
144 | |
---|
145 | ! Define the vertical tracer physics scheme |
---|
146 | ! ========================================== |
---|
147 | |
---|
148 | ! Choice from ln_zdfexp already read in namelist in zdfini module |
---|
149 | IF( ln_trczdf_exp ) THEN ! use explicit scheme |
---|
150 | nzdf = 0 |
---|
151 | ELSE ! use implicit scheme |
---|
152 | nzdf = 1 |
---|
153 | ENDIF |
---|
154 | |
---|
155 | ! Force implicit schemes |
---|
156 | IF( ln_trcldf_iso ) nzdf = 1 ! iso-neutral lateral physics |
---|
157 | IF( ln_trcldf_hor .AND. ln_sco ) nzdf = 1 ! horizontal lateral physics in s-coordinate |
---|
158 | #if defined key_zdftke || defined key_zdfgls || defined key_zdfkpp |
---|
159 | nzdf = 1 ! TKE, GLS or KPP physics |
---|
160 | #endif |
---|
161 | IF( ln_trczdf_exp .AND. nzdf == 1 ) THEN |
---|
162 | CALL ctl_stop( 'trc_zdf : If using the rotated lateral mixing operator or TKE, GLS or KPP vertical scheme ', & |
---|
163 | & ' the implicit scheme is required, set ln_trczdf_exp = .false.' ) |
---|
164 | ENDIF |
---|
165 | |
---|
166 | ! Test: esopa |
---|
167 | IF( lk_esopa ) nzdf = -1 ! All schemes used |
---|
168 | |
---|
169 | IF(lwp) THEN |
---|
170 | WRITE(numout,*) |
---|
171 | WRITE(numout,*) 'trc:zdf_ctl : vertical passive tracer physics scheme' |
---|
172 | WRITE(numout,*) '~~~~~~~~~~~' |
---|
173 | IF( nzdf == -1 ) WRITE(numout,*) ' ESOPA test All scheme used' |
---|
174 | IF( nzdf == 0 ) WRITE(numout,*) ' Explicit time-splitting scheme' |
---|
175 | IF( nzdf == 1 ) WRITE(numout,*) ' Implicit (euler backward) scheme' |
---|
176 | ENDIF |
---|
177 | |
---|
178 | END SUBROUTINE zdf_ctl |
---|
179 | #else |
---|
180 | !!---------------------------------------------------------------------- |
---|
181 | !! Default option Empty module |
---|
182 | !!---------------------------------------------------------------------- |
---|
183 | CONTAINS |
---|
184 | SUBROUTINE trc_zdf( kt ) |
---|
185 | INTEGER, INTENT(in) :: kt |
---|
186 | WRITE(*,*) 'trc_zdf: You should not have seen this print! error?', kt |
---|
187 | END SUBROUTINE trc_zdf |
---|
188 | #endif |
---|
189 | !!============================================================================== |
---|
190 | END MODULE trczdf |
---|