1 | MODULE ldfslp |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE ldfslp *** |
---|
4 | !! Ocean physics: slopes of neutral surfaces |
---|
5 | !!====================================================================== |
---|
6 | !! History : OPA ! 1994-12 (G. Madec, M. Imbard) Original code |
---|
7 | !! 8.0 ! 1997-06 (G. Madec) optimization, lbc |
---|
8 | !! 8.1 ! 1999-10 (A. Jouzeau) NEW profile in the mixed layer |
---|
9 | !! NEMO 1.0 ! 2002-10 (G. Madec) Free form, F90 |
---|
10 | !! - ! 2005-10 (A. Beckmann) correction for s-coordinates |
---|
11 | !! 3.3 ! 2010-10 (G. Nurser, C. Harris, G. Madec) add Griffies operator |
---|
12 | !! - ! 2010-11 (F. Dupond, G. Madec) bug correction in slopes just below the ML |
---|
13 | !! 3.7 ! 2013-12 (F. Lemarie, G. Madec) add limiter on triad slopes |
---|
14 | !!---------------------------------------------------------------------- |
---|
15 | |
---|
16 | !!---------------------------------------------------------------------- |
---|
17 | !! ldf_slp : calculates the slopes of neutral surface (Madec operator) |
---|
18 | !! ldf_slp_triad : calculates the triads of isoneutral slopes (Griffies operator) |
---|
19 | !! ldf_slp_mxl : calculates the slopes at the base of the mixed layer (Madec operator) |
---|
20 | !! ldf_slp_init : initialization of the slopes computation |
---|
21 | !!---------------------------------------------------------------------- |
---|
22 | USE oce ! ocean dynamics and tracers |
---|
23 | USE dom_oce ! ocean space and time domain |
---|
24 | ! USE ldfdyn ! lateral diffusion: eddy viscosity coef. |
---|
25 | USE phycst ! physical constants |
---|
26 | USE zdfmxl ! mixed layer depth |
---|
27 | USE eosbn2 ! equation of states |
---|
28 | ! |
---|
29 | USE in_out_manager ! I/O manager |
---|
30 | USE prtctl ! Print control |
---|
31 | USE lbclnk ! ocean lateral boundary conditions (or mpp link) |
---|
32 | USE lib_mpp ! distribued memory computing library |
---|
33 | USE lib_fortran ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined) |
---|
34 | USE timing ! Timing |
---|
35 | |
---|
36 | IMPLICIT NONE |
---|
37 | PRIVATE |
---|
38 | |
---|
39 | PUBLIC ldf_slp ! routine called by step.F90 |
---|
40 | PUBLIC ldf_slp_triad ! routine called by step.F90 |
---|
41 | PUBLIC ldf_slp_init ! routine called by nemogcm.F90 |
---|
42 | |
---|
43 | LOGICAL , PUBLIC :: l_ldfslp = .FALSE. !: slopes flag |
---|
44 | |
---|
45 | LOGICAL , PUBLIC :: ln_traldf_iso = .TRUE. !: iso-neutral direction (nam_traldf namelist) |
---|
46 | LOGICAL , PUBLIC :: ln_traldf_triad = .FALSE. !: griffies triad scheme (nam_traldf namelist) |
---|
47 | LOGICAL , PUBLIC :: ln_dynldf_iso !: iso-neutral direction (nam_dynldf namelist) |
---|
48 | |
---|
49 | LOGICAL , PUBLIC :: ln_triad_iso = .FALSE. !: pure horizontal mixing in ML (nam_traldf namelist) |
---|
50 | LOGICAL , PUBLIC :: ln_botmix_triad = .FALSE. !: mixing on bottom (nam_traldf namelist) |
---|
51 | REAL(wp), PUBLIC :: rn_sw_triad = 1._wp !: =1 switching triads ; =0 all four triads used (nam_traldf namelist) |
---|
52 | REAL(wp), PUBLIC :: rn_slpmax = 0.01_wp !: slope limit (nam_traldf namelist) |
---|
53 | |
---|
54 | LOGICAL , PUBLIC :: l_grad_zps = .FALSE. !: special treatment for Horz Tgradients w partial steps (triad operator) |
---|
55 | |
---|
56 | ! !! Classic operator (Madec) |
---|
57 | REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: uslp, wslpi !: i_slope at U- and W-points |
---|
58 | REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: vslp, wslpj !: j-slope at V- and W-points |
---|
59 | ! !! triad operator (Griffies) |
---|
60 | REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: wslp2 !: wslp**2 from Griffies quarter cells |
---|
61 | REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:,:,:) :: triadi_g, triadj_g !: skew flux slopes relative to geopotentials |
---|
62 | REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:,:,:) :: triadi , triadj !: isoneutral slopes relative to model-coordinate |
---|
63 | ! !! both operators |
---|
64 | REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: ah_wslp2 !: ah * slope^2 at w-point |
---|
65 | REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: akz !: stabilizing vertical diffusivity |
---|
66 | |
---|
67 | ! !! Madec operator |
---|
68 | REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: omlmask ! mask of the surface mixed layer at T-pt |
---|
69 | REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: uslpml, wslpiml ! i_slope at U- and W-points just below the mixed layer |
---|
70 | REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: vslpml, wslpjml ! j_slope at V- and W-points just below the mixed layer |
---|
71 | |
---|
72 | REAL(wp), ALLOCATABLE, DIMENSION(:, :) :: zslpml_hmlpu, zslpml_hmlpv |
---|
73 | REAL(wp), ALLOCATABLE, DIMENSION(:, :, :) :: zgru, zwz, zdzr |
---|
74 | REAL(wp), ALLOCATABLE, DIMENSION(:, :, :) :: zgrv, zww |
---|
75 | |
---|
76 | REAL(wp), ALLOCATABLE, DIMENSION(:, :) :: z1_mlbw |
---|
77 | REAL(wp), ALLOCATABLE, DIMENSION(:, :, :) :: zalbet |
---|
78 | REAL(wp), ALLOCATABLE, DIMENSION(:, :, :, :) :: zdxrho , zdyrho, zdzrho ! Horizontal and vertical density gradients |
---|
79 | REAL(wp), ALLOCATABLE, DIMENSION(:, :, :, :) :: zti_mlb, ztj_mlb ! for Griffies operator only |
---|
80 | |
---|
81 | |
---|
82 | REAL(wp) :: repsln = 1.e-25_wp ! tiny value used as minium of di(rho), dj(rho) and dk(rho) |
---|
83 | |
---|
84 | !! * Substitutions |
---|
85 | # include "vectopt_loop_substitute.h90" |
---|
86 | !!---------------------------------------------------------------------- |
---|
87 | !! NEMO/OCE 4.0 , NEMO Consortium (2018) |
---|
88 | !! $Id$ |
---|
89 | !! Software governed by the CeCILL license (see ./LICENSE) |
---|
90 | !!---------------------------------------------------------------------- |
---|
91 | CONTAINS |
---|
92 | |
---|
93 | SUBROUTINE ldf_slp( kt, prd, pn2 ) |
---|
94 | !!---------------------------------------------------------------------- |
---|
95 | !! *** ROUTINE ldf_slp *** |
---|
96 | !! |
---|
97 | !! ** Purpose : Compute the slopes of neutral surface (slope of isopycnal |
---|
98 | !! surfaces referenced locally) (ln_traldf_iso=T). |
---|
99 | !! |
---|
100 | !! ** Method : The slope in the i-direction is computed at U- and |
---|
101 | !! W-points (uslp, wslpi) and the slope in the j-direction is |
---|
102 | !! computed at V- and W-points (vslp, wslpj). |
---|
103 | !! They are bounded by 1/100 over the whole ocean, and within the |
---|
104 | !! surface layer they are bounded by the distance to the surface |
---|
105 | !! ( slope<= depth/l where l is the length scale of horizontal |
---|
106 | !! diffusion (here, aht=2000m2/s ==> l=20km with a typical velocity |
---|
107 | !! of 10cm/s) |
---|
108 | !! A horizontal shapiro filter is applied to the slopes |
---|
109 | !! ln_sco=T, s-coordinate, add to the previously computed slopes |
---|
110 | !! the slope of the model level surface. |
---|
111 | !! macro-tasked on horizontal slab (jk-loop) (2, jpk-1) |
---|
112 | !! [slopes already set to zero at level 1, and to zero or the ocean |
---|
113 | !! bottom slope (ln_sco=T) at level jpk in inildf] |
---|
114 | !! |
---|
115 | !! ** Action : - uslp, wslpi, and vslp, wslpj, the i- and j-slopes |
---|
116 | !! of now neutral surfaces at u-, w- and v- w-points, resp. |
---|
117 | !!---------------------------------------------------------------------- |
---|
118 | INTEGER , INTENT(in) :: kt ! ocean time-step index |
---|
119 | REAL(wp), INTENT(in), DIMENSION(:,:,:) :: prd ! in situ density |
---|
120 | REAL(wp), INTENT(in), DIMENSION(:,:,:) :: pn2 ! Brunt-Vaisala frequency (locally ref.) |
---|
121 | !! |
---|
122 | INTEGER :: ji , jj , jk ! dummy loop indices |
---|
123 | INTEGER :: ii0, ii1 ! temporary integer |
---|
124 | INTEGER :: ij0, ij1 ! temporary integer |
---|
125 | REAL(wp) :: zeps, zm1_g, zm1_2g, z1_16, zcofw, z1_slpmax ! local scalars |
---|
126 | REAL(wp) :: zci, zfi, zau, zbu, zai, zbi ! - - |
---|
127 | REAL(wp) :: zcj, zfj, zav, zbv, zaj, zbj ! - - |
---|
128 | REAL(wp) :: zck, zfk, zbw ! - - |
---|
129 | REAL(wp) :: zdepu, zdepv ! - - |
---|
130 | ! REAL(wp), DIMENSION(jpi,jpj) :: zslpml_hmlpu, zslpml_hmlpv |
---|
131 | ! REAL(wp), DIMENSION(jpi,jpj,jpk) :: zgru, zwz, zdzr |
---|
132 | ! REAL(wp), DIMENSION(jpi,jpj,jpk) :: zgrv, zww |
---|
133 | !!---------------------------------------------------------------------- |
---|
134 | ! |
---|
135 | IF( ln_timing ) CALL timing_start('ldf_slp') |
---|
136 | ! |
---|
137 | zeps = 1.e-20_wp !== Local constant initialization ==! |
---|
138 | z1_16 = 1.0_wp / 16._wp |
---|
139 | zm1_g = -1.0_wp / grav |
---|
140 | zm1_2g = -0.5_wp / grav |
---|
141 | z1_slpmax = 1._wp / rn_slpmax |
---|
142 | ! |
---|
143 | zww(:,:,:) = 0._wp |
---|
144 | zwz(:,:,:) = 0._wp |
---|
145 | ! |
---|
146 | DO jk = 1, jpk !== i- & j-gradient of density ==! |
---|
147 | DO jj = 1, jpjm1 |
---|
148 | DO ji = 1, fs_jpim1 ! vector opt. |
---|
149 | zgru(ji,jj,jk) = umask(ji,jj,jk) * ( prd(ji+1,jj ,jk) - prd(ji,jj,jk) ) |
---|
150 | zgrv(ji,jj,jk) = vmask(ji,jj,jk) * ( prd(ji ,jj+1,jk) - prd(ji,jj,jk) ) |
---|
151 | END DO |
---|
152 | END DO |
---|
153 | END DO |
---|
154 | IF( ln_zps ) THEN ! partial steps correction at the bottom ocean level |
---|
155 | DO jj = 1, jpjm1 |
---|
156 | DO ji = 1, jpim1 |
---|
157 | zgru(ji,jj,mbku(ji,jj)) = gru(ji,jj) |
---|
158 | zgrv(ji,jj,mbkv(ji,jj)) = grv(ji,jj) |
---|
159 | END DO |
---|
160 | END DO |
---|
161 | ENDIF |
---|
162 | IF( ln_zps .AND. ln_isfcav ) THEN ! partial steps correction at the bottom ocean level |
---|
163 | DO jj = 1, jpjm1 |
---|
164 | DO ji = 1, jpim1 |
---|
165 | IF( miku(ji,jj) > 1 ) zgru(ji,jj,miku(ji,jj)) = grui(ji,jj) |
---|
166 | IF( mikv(ji,jj) > 1 ) zgrv(ji,jj,mikv(ji,jj)) = grvi(ji,jj) |
---|
167 | END DO |
---|
168 | END DO |
---|
169 | ENDIF |
---|
170 | ! |
---|
171 | zdzr(:,:,1) = 0._wp !== Local vertical density gradient at T-point == ! (evaluated from N^2) |
---|
172 | DO jk = 2, jpkm1 |
---|
173 | ! ! zdzr = d/dz(prd)= - ( prd ) / grav * mk(pn2) -- at t point |
---|
174 | ! ! trick: tmask(ik ) = 0 => all pn2 = 0 => zdzr = 0 |
---|
175 | ! ! else tmask(ik+1) = 0 => pn2(ik+1) = 0 => zdzr divides by 1 |
---|
176 | ! ! umask(ik+1) /= 0 => all pn2 /= 0 => zdzr divides by 2 |
---|
177 | ! ! NB: 1/(tmask+1) = (1-.5*tmask) substitute a / by a * ==> faster |
---|
178 | zdzr(:,:,jk) = zm1_g * ( prd(:,:,jk) + 1._wp ) & |
---|
179 | & * ( pn2(:,:,jk) + pn2(:,:,jk+1) ) * ( 1._wp - 0.5_wp * tmask(:,:,jk+1) ) |
---|
180 | END DO |
---|
181 | ! |
---|
182 | ! !== Slopes just below the mixed layer ==! |
---|
183 | CALL ldf_slp_mxl( prd, pn2, zgru, zgrv, zdzr ) ! output: uslpml, vslpml, wslpiml, wslpjml |
---|
184 | |
---|
185 | |
---|
186 | ! I. slopes at u and v point | uslp = d/di( prd ) / d/dz( prd ) |
---|
187 | ! =========================== | vslp = d/dj( prd ) / d/dz( prd ) |
---|
188 | ! |
---|
189 | IF ( ln_isfcav ) THEN |
---|
190 | DO jj = 2, jpjm1 |
---|
191 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
192 | zslpml_hmlpu(ji,jj) = uslpml(ji,jj) / ( MAX(hmlpt (ji,jj), hmlpt (ji+1,jj ), 5._wp) & |
---|
193 | & - MAX(risfdep(ji,jj), risfdep(ji+1,jj ) ) ) |
---|
194 | zslpml_hmlpv(ji,jj) = vslpml(ji,jj) / ( MAX(hmlpt (ji,jj), hmlpt (ji ,jj+1), 5._wp) & |
---|
195 | & - MAX(risfdep(ji,jj), risfdep(ji ,jj+1) ) ) |
---|
196 | END DO |
---|
197 | END DO |
---|
198 | ELSE |
---|
199 | DO jj = 2, jpjm1 |
---|
200 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
201 | zslpml_hmlpu(ji,jj) = uslpml(ji,jj) / MAX(hmlpt(ji,jj), hmlpt(ji+1,jj ), 5._wp) |
---|
202 | zslpml_hmlpv(ji,jj) = vslpml(ji,jj) / MAX(hmlpt(ji,jj), hmlpt(ji ,jj+1), 5._wp) |
---|
203 | END DO |
---|
204 | END DO |
---|
205 | END IF |
---|
206 | |
---|
207 | DO jk = 2, jpkm1 !* Slopes at u and v points |
---|
208 | DO jj = 2, jpjm1 |
---|
209 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
210 | ! ! horizontal and vertical density gradient at u- and v-points |
---|
211 | zau = zgru(ji,jj,jk) * r1_e1u(ji,jj) |
---|
212 | zav = zgrv(ji,jj,jk) * r1_e2v(ji,jj) |
---|
213 | zbu = 0.5_wp * ( zdzr(ji,jj,jk) + zdzr(ji+1,jj ,jk) ) |
---|
214 | zbv = 0.5_wp * ( zdzr(ji,jj,jk) + zdzr(ji ,jj+1,jk) ) |
---|
215 | ! ! bound the slopes: abs(zw.)<= 1/100 and zb..<0 |
---|
216 | ! ! + kxz max= ah slope max =< e1 e3 /(pi**2 2 dt) |
---|
217 | zbu = MIN( zbu, - z1_slpmax * ABS( zau ) , -7.e+3_wp/e3u_n(ji,jj,jk)* ABS( zau ) ) |
---|
218 | zbv = MIN( zbv, - z1_slpmax * ABS( zav ) , -7.e+3_wp/e3v_n(ji,jj,jk)* ABS( zav ) ) |
---|
219 | ! ! uslp and vslp output in zwz and zww, resp. |
---|
220 | zfi = MAX( omlmask(ji,jj,jk), omlmask(ji+1,jj,jk) ) |
---|
221 | zfj = MAX( omlmask(ji,jj,jk), omlmask(ji,jj+1,jk) ) |
---|
222 | ! thickness of water column between surface and level k at u/v point |
---|
223 | zdepu = 0.5_wp * ( ( gdept_n (ji,jj,jk) + gdept_n (ji+1,jj,jk) ) & |
---|
224 | - 2 * MAX( risfdep(ji,jj), risfdep(ji+1,jj) ) - e3u_n(ji,jj,miku(ji,jj)) ) |
---|
225 | zdepv = 0.5_wp * ( ( gdept_n (ji,jj,jk) + gdept_n (ji,jj+1,jk) ) & |
---|
226 | - 2 * MAX( risfdep(ji,jj), risfdep(ji,jj+1) ) - e3v_n(ji,jj,mikv(ji,jj)) ) |
---|
227 | ! |
---|
228 | zwz(ji,jj,jk) = ( ( 1._wp - zfi) * zau / ( zbu - zeps ) & |
---|
229 | & + zfi * zdepu * zslpml_hmlpu(ji,jj) ) * umask(ji,jj,jk) |
---|
230 | zww(ji,jj,jk) = ( ( 1._wp - zfj) * zav / ( zbv - zeps ) & |
---|
231 | & + zfj * zdepv * zslpml_hmlpv(ji,jj) ) * vmask(ji,jj,jk) |
---|
232 | !!gm modif to suppress omlmask.... (as in Griffies case) |
---|
233 | ! ! ! jk must be >= ML level for zf=1. otherwise zf=0. |
---|
234 | ! zfi = REAL( 1 - 1/(1 + jk / MAX( nmln(ji+1,jj), nmln(ji,jj) ) ), wp ) |
---|
235 | ! zfj = REAL( 1 - 1/(1 + jk / MAX( nmln(ji,jj+1), nmln(ji,jj) ) ), wp ) |
---|
236 | ! zci = 0.5 * ( gdept_n(ji+1,jj,jk)+gdept_n(ji,jj,jk) ) / MAX( hmlpt(ji,jj), hmlpt(ji+1,jj), 10. ) ) |
---|
237 | ! zcj = 0.5 * ( gdept_n(ji,jj+1,jk)+gdept_n(ji,jj,jk) ) / MAX( hmlpt(ji,jj), hmlpt(ji,jj+1), 10. ) ) |
---|
238 | ! zwz(ji,jj,jk) = ( zfi * zai / ( zbi - zeps ) + ( 1._wp - zfi ) * wslpiml(ji,jj) * zci ) * tmask(ji,jj,jk) |
---|
239 | ! zww(ji,jj,jk) = ( zfj * zaj / ( zbj - zeps ) + ( 1._wp - zfj ) * wslpjml(ji,jj) * zcj ) * tmask(ji,jj,jk) |
---|
240 | !!gm end modif |
---|
241 | END DO |
---|
242 | END DO |
---|
243 | END DO |
---|
244 | CALL lbc_lnk_multi( 'ldfslp', zwz, 'U', -1., zww, 'V', -1. ) ! lateral boundary conditions |
---|
245 | ! |
---|
246 | ! !* horizontal Shapiro filter |
---|
247 | DO jk = 2, jpkm1 |
---|
248 | DO jj = 2, jpjm1, MAX(1, jpj-3) ! rows jj=2 and =jpjm1 only |
---|
249 | DO ji = 2, jpim1 |
---|
250 | uslp(ji,jj,jk) = z1_16 * ( zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk) & |
---|
251 | & + zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk) & |
---|
252 | & + 2.*( zwz(ji ,jj-1,jk) + zwz(ji-1,jj ,jk) & |
---|
253 | & + zwz(ji+1,jj ,jk) + zwz(ji ,jj+1,jk) ) & |
---|
254 | & + 4.* zwz(ji ,jj ,jk) ) |
---|
255 | vslp(ji,jj,jk) = z1_16 * ( zww(ji-1,jj-1,jk) + zww(ji+1,jj-1,jk) & |
---|
256 | & + zww(ji-1,jj+1,jk) + zww(ji+1,jj+1,jk) & |
---|
257 | & + 2.*( zww(ji ,jj-1,jk) + zww(ji-1,jj ,jk) & |
---|
258 | & + zww(ji+1,jj ,jk) + zww(ji ,jj+1,jk) ) & |
---|
259 | & + 4.* zww(ji,jj ,jk) ) |
---|
260 | END DO |
---|
261 | END DO |
---|
262 | DO jj = 3, jpj-2 ! other rows |
---|
263 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
264 | uslp(ji,jj,jk) = z1_16 * ( zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk) & |
---|
265 | & + zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk) & |
---|
266 | & + 2.*( zwz(ji ,jj-1,jk) + zwz(ji-1,jj ,jk) & |
---|
267 | & + zwz(ji+1,jj ,jk) + zwz(ji ,jj+1,jk) ) & |
---|
268 | & + 4.* zwz(ji ,jj ,jk) ) |
---|
269 | vslp(ji,jj,jk) = z1_16 * ( zww(ji-1,jj-1,jk) + zww(ji+1,jj-1,jk) & |
---|
270 | & + zww(ji-1,jj+1,jk) + zww(ji+1,jj+1,jk) & |
---|
271 | & + 2.*( zww(ji ,jj-1,jk) + zww(ji-1,jj ,jk) & |
---|
272 | & + zww(ji+1,jj ,jk) + zww(ji ,jj+1,jk) ) & |
---|
273 | & + 4.* zww(ji,jj ,jk) ) |
---|
274 | END DO |
---|
275 | END DO |
---|
276 | ! !* decrease along coastal boundaries |
---|
277 | DO jj = 2, jpjm1 |
---|
278 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
279 | uslp(ji,jj,jk) = uslp(ji,jj,jk) * ( umask(ji,jj+1,jk) + umask(ji,jj-1,jk ) ) * 0.5_wp & |
---|
280 | & * ( umask(ji,jj ,jk) + umask(ji,jj ,jk+1) ) * 0.5_wp |
---|
281 | vslp(ji,jj,jk) = vslp(ji,jj,jk) * ( vmask(ji+1,jj,jk) + vmask(ji-1,jj,jk ) ) * 0.5_wp & |
---|
282 | & * ( vmask(ji ,jj,jk) + vmask(ji ,jj,jk+1) ) * 0.5_wp |
---|
283 | END DO |
---|
284 | END DO |
---|
285 | END DO |
---|
286 | |
---|
287 | |
---|
288 | ! II. slopes at w point | wslpi = mij( d/di( prd ) / d/dz( prd ) |
---|
289 | ! =========================== | wslpj = mij( d/dj( prd ) / d/dz( prd ) |
---|
290 | ! |
---|
291 | DO jk = 2, jpkm1 |
---|
292 | DO jj = 2, jpjm1 |
---|
293 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
294 | ! !* Local vertical density gradient evaluated from N^2 |
---|
295 | zbw = zm1_2g * pn2 (ji,jj,jk) * ( prd (ji,jj,jk) + prd (ji,jj,jk-1) + 2. ) |
---|
296 | ! !* Slopes at w point |
---|
297 | ! ! i- & j-gradient of density at w-points |
---|
298 | zci = MAX( umask(ji-1,jj,jk ) + umask(ji,jj,jk ) & |
---|
299 | & + umask(ji-1,jj,jk-1) + umask(ji,jj,jk-1) , zeps ) * e1t(ji,jj) |
---|
300 | zcj = MAX( vmask(ji,jj-1,jk ) + vmask(ji,jj,jk-1) & |
---|
301 | & + vmask(ji,jj-1,jk-1) + vmask(ji,jj,jk ) , zeps ) * e2t(ji,jj) |
---|
302 | zai = ( zgru (ji-1,jj,jk ) + zgru (ji,jj,jk-1) & |
---|
303 | & + zgru (ji-1,jj,jk-1) + zgru (ji,jj,jk ) ) / zci * wmask (ji,jj,jk) |
---|
304 | zaj = ( zgrv (ji,jj-1,jk ) + zgrv (ji,jj,jk-1) & |
---|
305 | & + zgrv (ji,jj-1,jk-1) + zgrv (ji,jj,jk ) ) / zcj * wmask (ji,jj,jk) |
---|
306 | ! ! bound the slopes: abs(zw.)<= 1/100 and zb..<0. |
---|
307 | ! ! + kxz max= ah slope max =< e1 e3 /(pi**2 2 dt) |
---|
308 | zbi = MIN( zbw ,- 100._wp* ABS( zai ) , -7.e+3_wp/e3w_n(ji,jj,jk)* ABS( zai ) ) |
---|
309 | zbj = MIN( zbw , -100._wp* ABS( zaj ) , -7.e+3_wp/e3w_n(ji,jj,jk)* ABS( zaj ) ) |
---|
310 | ! ! wslpi and wslpj with ML flattening (output in zwz and zww, resp.) |
---|
311 | zfk = MAX( omlmask(ji,jj,jk), omlmask(ji,jj,jk-1) ) ! zfk=1 in the ML otherwise zfk=0 |
---|
312 | zck = ( gdepw_n(ji,jj,jk) - gdepw_n(ji,jj,mikt(ji,jj) ) ) / MAX( hmlp(ji,jj) - gdepw_n(ji,jj,mikt(ji,jj)), 10._wp ) |
---|
313 | zwz(ji,jj,jk) = ( zai / ( zbi - zeps ) * ( 1._wp - zfk ) + zck * wslpiml(ji,jj) * zfk ) * wmask(ji,jj,jk) |
---|
314 | zww(ji,jj,jk) = ( zaj / ( zbj - zeps ) * ( 1._wp - zfk ) + zck * wslpjml(ji,jj) * zfk ) * wmask(ji,jj,jk) |
---|
315 | |
---|
316 | !!gm modif to suppress omlmask.... (as in Griffies operator) |
---|
317 | ! ! ! jk must be >= ML level for zfk=1. otherwise zfk=0. |
---|
318 | ! zfk = REAL( 1 - 1/(1 + jk / nmln(ji+1,jj)), wp ) |
---|
319 | ! zck = gdepw(ji,jj,jk) / MAX( hmlp(ji,jj), 10. ) |
---|
320 | ! zwz(ji,jj,jk) = ( zfk * zai / ( zbi - zeps ) + ( 1._wp - zfk ) * wslpiml(ji,jj) * zck ) * tmask(ji,jj,jk) |
---|
321 | ! zww(ji,jj,jk) = ( zfk * zaj / ( zbj - zeps ) + ( 1._wp - zfk ) * wslpjml(ji,jj) * zck ) * tmask(ji,jj,jk) |
---|
322 | !!gm end modif |
---|
323 | END DO |
---|
324 | END DO |
---|
325 | END DO |
---|
326 | CALL lbc_lnk_multi( 'ldfslp', zwz, 'T', -1., zww, 'T', -1. ) ! lateral boundary conditions |
---|
327 | ! |
---|
328 | ! !* horizontal Shapiro filter |
---|
329 | DO jk = 2, jpkm1 |
---|
330 | DO jj = 2, jpjm1, MAX(1, jpj-3) ! rows jj=2 and =jpjm1 only |
---|
331 | DO ji = 2, jpim1 |
---|
332 | zcofw = wmask(ji,jj,jk) * z1_16 |
---|
333 | wslpi(ji,jj,jk) = ( zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk) & |
---|
334 | & + zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk) & |
---|
335 | & + 2.*( zwz(ji ,jj-1,jk) + zwz(ji-1,jj ,jk) & |
---|
336 | & + zwz(ji+1,jj ,jk) + zwz(ji ,jj+1,jk) ) & |
---|
337 | & + 4.* zwz(ji ,jj ,jk) ) * zcofw |
---|
338 | |
---|
339 | wslpj(ji,jj,jk) = ( zww(ji-1,jj-1,jk) + zww(ji+1,jj-1,jk) & |
---|
340 | & + zww(ji-1,jj+1,jk) + zww(ji+1,jj+1,jk) & |
---|
341 | & + 2.*( zww(ji ,jj-1,jk) + zww(ji-1,jj ,jk) & |
---|
342 | & + zww(ji+1,jj ,jk) + zww(ji ,jj+1,jk) ) & |
---|
343 | & + 4.* zww(ji ,jj ,jk) ) * zcofw |
---|
344 | END DO |
---|
345 | END DO |
---|
346 | DO jj = 3, jpj-2 ! other rows |
---|
347 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
348 | zcofw = wmask(ji,jj,jk) * z1_16 |
---|
349 | wslpi(ji,jj,jk) = ( zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk) & |
---|
350 | & + zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk) & |
---|
351 | & + 2.*( zwz(ji ,jj-1,jk) + zwz(ji-1,jj ,jk) & |
---|
352 | & + zwz(ji+1,jj ,jk) + zwz(ji ,jj+1,jk) ) & |
---|
353 | & + 4.* zwz(ji ,jj ,jk) ) * zcofw |
---|
354 | |
---|
355 | wslpj(ji,jj,jk) = ( zww(ji-1,jj-1,jk) + zww(ji+1,jj-1,jk) & |
---|
356 | & + zww(ji-1,jj+1,jk) + zww(ji+1,jj+1,jk) & |
---|
357 | & + 2.*( zww(ji ,jj-1,jk) + zww(ji-1,jj ,jk) & |
---|
358 | & + zww(ji+1,jj ,jk) + zww(ji ,jj+1,jk) ) & |
---|
359 | & + 4.* zww(ji ,jj ,jk) ) * zcofw |
---|
360 | END DO |
---|
361 | END DO |
---|
362 | ! !* decrease in vicinity of topography |
---|
363 | DO jj = 2, jpjm1 |
---|
364 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
365 | zck = ( umask(ji,jj,jk) + umask(ji-1,jj,jk) ) & |
---|
366 | & * ( vmask(ji,jj,jk) + vmask(ji,jj-1,jk) ) * 0.25 |
---|
367 | wslpi(ji,jj,jk) = wslpi(ji,jj,jk) * zck |
---|
368 | wslpj(ji,jj,jk) = wslpj(ji,jj,jk) * zck |
---|
369 | END DO |
---|
370 | END DO |
---|
371 | END DO |
---|
372 | |
---|
373 | ! IV. Lateral boundary conditions |
---|
374 | ! =============================== |
---|
375 | CALL lbc_lnk_multi( 'ldfslp', uslp , 'U', -1. , vslp , 'V', -1. , wslpi, 'W', -1., wslpj, 'W', -1. ) |
---|
376 | |
---|
377 | IF(ln_ctl) THEN |
---|
378 | CALL prt_ctl(tab3d_1=uslp , clinfo1=' slp - u : ', tab3d_2=vslp, clinfo2=' v : ', kdim=jpk) |
---|
379 | CALL prt_ctl(tab3d_1=wslpi, clinfo1=' slp - wi: ', tab3d_2=wslpj, clinfo2=' wj: ', kdim=jpk) |
---|
380 | ENDIF |
---|
381 | ! |
---|
382 | IF( ln_timing ) CALL timing_stop('ldf_slp') |
---|
383 | ! |
---|
384 | END SUBROUTINE ldf_slp |
---|
385 | |
---|
386 | |
---|
387 | SUBROUTINE ldf_slp_triad ( kt ) |
---|
388 | !!---------------------------------------------------------------------- |
---|
389 | !! *** ROUTINE ldf_slp_triad *** |
---|
390 | !! |
---|
391 | !! ** Purpose : Compute the squared slopes of neutral surfaces (slope |
---|
392 | !! of iso-pycnal surfaces referenced locally) (ln_traldf_triad=T) |
---|
393 | !! at W-points using the Griffies quarter-cells. |
---|
394 | !! |
---|
395 | !! ** Method : calculates alpha and beta at T-points |
---|
396 | !! |
---|
397 | !! ** Action : - triadi_g, triadj_g T-pts i- and j-slope triads relative to geopot. (used for eiv) |
---|
398 | !! - triadi , triadj T-pts i- and j-slope triads relative to model-coordinate |
---|
399 | !! - wslp2 squared slope of neutral surfaces at w-points. |
---|
400 | !!---------------------------------------------------------------------- |
---|
401 | INTEGER, INTENT( in ) :: kt ! ocean time-step index |
---|
402 | !! |
---|
403 | INTEGER :: ji, jj, jk, jl, ip, jp, kp ! dummy loop indices |
---|
404 | INTEGER :: iku, ikv ! local integer |
---|
405 | REAL(wp) :: zfacti, zfactj ! local scalars |
---|
406 | REAL(wp) :: znot_thru_surface ! local scalars |
---|
407 | REAL(wp) :: zdit, zdis, zdkt, zbu, zbti, zisw |
---|
408 | REAL(wp) :: zdjt, zdjs, zdks, zbv, zbtj, zjsw |
---|
409 | REAL(wp) :: zdxrho_raw, zti_coord, zti_raw, zti_lim, zti_g_raw, zti_g_lim |
---|
410 | REAL(wp) :: zdyrho_raw, ztj_coord, ztj_raw, ztj_lim, ztj_g_raw, ztj_g_lim |
---|
411 | REAL(wp) :: zdzrho_raw |
---|
412 | REAL(wp) :: zbeta0, ze3_e1, ze3_e2 |
---|
413 | ! REAL(wp), DIMENSION(jpi,jpj) :: z1_mlbw |
---|
414 | ! REAL(wp), DIMENSION(jpi,jpj,jpk) :: zalbet |
---|
415 | ! REAL(wp), DIMENSION(jpi,jpj,jpk,0:1) :: zdxrho , zdyrho, zdzrho ! Horizontal and vertical density gradients |
---|
416 | ! REAL(wp), DIMENSION(jpi,jpj,0:1,0:1) :: zti_mlb, ztj_mlb ! for Griffies operator only |
---|
417 | !!---------------------------------------------------------------------- |
---|
418 | ! |
---|
419 | IF( ln_timing ) CALL timing_start('ldf_slp_triad') |
---|
420 | ! |
---|
421 | !--------------------------------! |
---|
422 | ! Some preliminary calculation ! |
---|
423 | !--------------------------------! |
---|
424 | ! |
---|
425 | DO jl = 0, 1 !== unmasked before density i- j-, k-gradients ==! |
---|
426 | ! |
---|
427 | ip = jl ; jp = jl ! guaranteed nonzero gradients ( absolute value larger than repsln) |
---|
428 | DO jk = 1, jpkm1 ! done each pair of triad |
---|
429 | DO jj = 1, jpjm1 ! NB: not masked ==> a minimum value is set |
---|
430 | DO ji = 1, fs_jpim1 ! vector opt. |
---|
431 | zdit = ( tsb(ji+1,jj,jk,jp_tem) - tsb(ji,jj,jk,jp_tem) ) ! i-gradient of T & S at u-point |
---|
432 | zdis = ( tsb(ji+1,jj,jk,jp_sal) - tsb(ji,jj,jk,jp_sal) ) |
---|
433 | zdjt = ( tsb(ji,jj+1,jk,jp_tem) - tsb(ji,jj,jk,jp_tem) ) ! j-gradient of T & S at v-point |
---|
434 | zdjs = ( tsb(ji,jj+1,jk,jp_sal) - tsb(ji,jj,jk,jp_sal) ) |
---|
435 | zdxrho_raw = ( - rab_b(ji+ip,jj ,jk,jp_tem) * zdit + rab_b(ji+ip,jj ,jk,jp_sal) * zdis ) * r1_e1u(ji,jj) |
---|
436 | zdyrho_raw = ( - rab_b(ji ,jj+jp,jk,jp_tem) * zdjt + rab_b(ji ,jj+jp,jk,jp_sal) * zdjs ) * r1_e2v(ji,jj) |
---|
437 | zdxrho(ji+ip,jj ,jk,1-ip) = SIGN( MAX( repsln, ABS( zdxrho_raw ) ), zdxrho_raw ) ! keep the sign |
---|
438 | zdyrho(ji ,jj+jp,jk,1-jp) = SIGN( MAX( repsln, ABS( zdyrho_raw ) ), zdyrho_raw ) |
---|
439 | END DO |
---|
440 | END DO |
---|
441 | END DO |
---|
442 | ! |
---|
443 | IF( ln_zps .AND. l_grad_zps ) THEN ! partial steps: correction of i- & j-grad on bottom |
---|
444 | DO jj = 1, jpjm1 |
---|
445 | DO ji = 1, jpim1 |
---|
446 | iku = mbku(ji,jj) ; ikv = mbkv(ji,jj) ! last ocean level (u- & v-points) |
---|
447 | zdit = gtsu(ji,jj,jp_tem) ; zdjt = gtsv(ji,jj,jp_tem) ! i- & j-gradient of Temperature |
---|
448 | zdis = gtsu(ji,jj,jp_sal) ; zdjs = gtsv(ji,jj,jp_sal) ! i- & j-gradient of Salinity |
---|
449 | zdxrho_raw = ( - rab_b(ji+ip,jj ,iku,jp_tem) * zdit + rab_b(ji+ip,jj ,iku,jp_sal) * zdis ) * r1_e1u(ji,jj) |
---|
450 | zdyrho_raw = ( - rab_b(ji ,jj+jp,ikv,jp_tem) * zdjt + rab_b(ji ,jj+jp,ikv,jp_sal) * zdjs ) * r1_e2v(ji,jj) |
---|
451 | zdxrho(ji+ip,jj ,iku,1-ip) = SIGN( MAX( repsln, ABS( zdxrho_raw ) ), zdxrho_raw ) ! keep the sign |
---|
452 | zdyrho(ji ,jj+jp,ikv,1-jp) = SIGN( MAX( repsln, ABS( zdyrho_raw ) ), zdyrho_raw ) |
---|
453 | END DO |
---|
454 | END DO |
---|
455 | ENDIF |
---|
456 | ! |
---|
457 | END DO |
---|
458 | |
---|
459 | DO kp = 0, 1 !== unmasked before density i- j-, k-gradients ==! |
---|
460 | DO jk = 1, jpkm1 ! done each pair of triad |
---|
461 | DO jj = 1, jpj ! NB: not masked ==> a minimum value is set |
---|
462 | DO ji = 1, jpi ! vector opt. |
---|
463 | IF( jk+kp > 1 ) THEN ! k-gradient of T & S a jk+kp |
---|
464 | zdkt = ( tsb(ji,jj,jk+kp-1,jp_tem) - tsb(ji,jj,jk+kp,jp_tem) ) |
---|
465 | zdks = ( tsb(ji,jj,jk+kp-1,jp_sal) - tsb(ji,jj,jk+kp,jp_sal) ) |
---|
466 | ELSE |
---|
467 | zdkt = 0._wp ! 1st level gradient set to zero |
---|
468 | zdks = 0._wp |
---|
469 | ENDIF |
---|
470 | zdzrho_raw = ( - rab_b(ji,jj,jk+kp,jp_tem) * zdkt & |
---|
471 | & + rab_b(ji,jj,jk+kp,jp_sal) * zdks & |
---|
472 | & ) / e3w_n(ji,jj,jk+kp) |
---|
473 | zdzrho(ji,jj,jk,kp) = - MIN( - repsln , zdzrho_raw ) ! force zdzrho >= repsln |
---|
474 | END DO |
---|
475 | END DO |
---|
476 | END DO |
---|
477 | END DO |
---|
478 | ! |
---|
479 | DO jj = 1, jpj !== Reciprocal depth of the w-point below ML base ==! |
---|
480 | DO ji = 1, jpi |
---|
481 | jk = MIN( nmln(ji,jj), mbkt(ji,jj) ) + 1 ! MIN in case ML depth is the ocean depth |
---|
482 | z1_mlbw(ji,jj) = 1._wp / gdepw_n(ji,jj,jk) |
---|
483 | END DO |
---|
484 | END DO |
---|
485 | ! |
---|
486 | ! !== intialisations to zero ==! |
---|
487 | ! |
---|
488 | wslp2 (:,:,:) = 0._wp ! wslp2 will be cumulated 3D field set to zero |
---|
489 | triadi_g(:,:,1,:,:) = 0._wp ; triadi_g(:,:,jpk,:,:) = 0._wp ! set surface and bottom slope to zero |
---|
490 | triadj_g(:,:,1,:,:) = 0._wp ; triadj_g(:,:,jpk,:,:) = 0._wp |
---|
491 | !!gm _iso set to zero missing |
---|
492 | triadi (:,:,1,:,:) = 0._wp ; triadj (:,:,jpk,:,:) = 0._wp ! set surface and bottom slope to zero |
---|
493 | triadj (:,:,1,:,:) = 0._wp ; triadj (:,:,jpk,:,:) = 0._wp |
---|
494 | |
---|
495 | !-------------------------------------! |
---|
496 | ! Triads just below the Mixed Layer ! |
---|
497 | !-------------------------------------! |
---|
498 | ! |
---|
499 | DO jl = 0, 1 ! calculate slope of the 4 triads immediately ONE level below mixed-layer base |
---|
500 | DO kp = 0, 1 ! with only the slope-max limit and MASKED |
---|
501 | DO jj = 1, jpjm1 |
---|
502 | DO ji = 1, fs_jpim1 |
---|
503 | ip = jl ; jp = jl |
---|
504 | ! |
---|
505 | jk = nmln(ji+ip,jj) + 1 |
---|
506 | IF( jk > mbkt(ji+ip,jj) ) THEN ! ML reaches bottom |
---|
507 | zti_mlb(ji+ip,jj ,1-ip,kp) = 0.0_wp |
---|
508 | ELSE |
---|
509 | ! Add s-coordinate slope at t-points (do this by *subtracting* gradient of depth) |
---|
510 | zti_g_raw = ( zdxrho(ji+ip,jj,jk-kp,1-ip) / zdzrho(ji+ip,jj,jk-kp,kp) & |
---|
511 | & - ( gdept_n(ji+1,jj,jk-kp) - gdept_n(ji,jj,jk-kp) ) * r1_e1u(ji,jj) ) * umask(ji,jj,jk) |
---|
512 | ze3_e1 = e3w_n(ji+ip,jj,jk-kp) * r1_e1u(ji,jj) |
---|
513 | zti_mlb(ji+ip,jj ,1-ip,kp) = SIGN( MIN( rn_slpmax, 5.0_wp * ze3_e1 , ABS( zti_g_raw ) ), zti_g_raw ) |
---|
514 | ENDIF |
---|
515 | ! |
---|
516 | jk = nmln(ji,jj+jp) + 1 |
---|
517 | IF( jk > mbkt(ji,jj+jp) ) THEN !ML reaches bottom |
---|
518 | ztj_mlb(ji ,jj+jp,1-jp,kp) = 0.0_wp |
---|
519 | ELSE |
---|
520 | ztj_g_raw = ( zdyrho(ji,jj+jp,jk-kp,1-jp) / zdzrho(ji,jj+jp,jk-kp,kp) & |
---|
521 | & - ( gdept_n(ji,jj+1,jk-kp) - gdept_n(ji,jj,jk-kp) ) / e2v(ji,jj) ) * vmask(ji,jj,jk) |
---|
522 | ze3_e2 = e3w_n(ji,jj+jp,jk-kp) / e2v(ji,jj) |
---|
523 | ztj_mlb(ji ,jj+jp,1-jp,kp) = SIGN( MIN( rn_slpmax, 5.0_wp * ze3_e2 , ABS( ztj_g_raw ) ), ztj_g_raw ) |
---|
524 | ENDIF |
---|
525 | END DO |
---|
526 | END DO |
---|
527 | END DO |
---|
528 | END DO |
---|
529 | |
---|
530 | !-------------------------------------! |
---|
531 | ! Triads with surface limits ! |
---|
532 | !-------------------------------------! |
---|
533 | ! |
---|
534 | DO kp = 0, 1 ! k-index of triads |
---|
535 | DO jl = 0, 1 |
---|
536 | ip = jl ; jp = jl ! i- and j-indices of triads (i-k and j-k planes) |
---|
537 | DO jk = 1, jpkm1 |
---|
538 | ! Must mask contribution to slope from dz/dx at constant s for triads jk=1,kp=0 that poke up though ocean surface |
---|
539 | znot_thru_surface = REAL( 1-1/(jk+kp), wp ) !jk+kp=1,=0.; otherwise=1.0 |
---|
540 | DO jj = 1, jpjm1 |
---|
541 | DO ji = 1, fs_jpim1 ! vector opt. |
---|
542 | ! |
---|
543 | ! Calculate slope relative to geopotentials used for GM skew fluxes |
---|
544 | ! Add s-coordinate slope at t-points (do this by *subtracting* gradient of depth) |
---|
545 | ! Limit by slope *relative to geopotentials* by rn_slpmax, and mask by psi-point |
---|
546 | ! masked by umask taken at the level of dz(rho) |
---|
547 | ! |
---|
548 | ! raw slopes: unmasked unbounded slopes (relative to geopotential (zti_g) and model surface (zti) |
---|
549 | ! |
---|
550 | zti_raw = zdxrho(ji+ip,jj ,jk,1-ip) / zdzrho(ji+ip,jj ,jk,kp) ! unmasked |
---|
551 | ztj_raw = zdyrho(ji ,jj+jp,jk,1-jp) / zdzrho(ji ,jj+jp,jk,kp) |
---|
552 | ! |
---|
553 | ! Must mask contribution to slope for triad jk=1,kp=0 that poke up though ocean surface |
---|
554 | zti_coord = znot_thru_surface * ( gdept_n(ji+1,jj ,jk) - gdept_n(ji,jj,jk) ) * r1_e1u(ji,jj) |
---|
555 | ztj_coord = znot_thru_surface * ( gdept_n(ji ,jj+1,jk) - gdept_n(ji,jj,jk) ) * r1_e2v(ji,jj) ! unmasked |
---|
556 | zti_g_raw = zti_raw - zti_coord ! ref to geopot surfaces |
---|
557 | ztj_g_raw = ztj_raw - ztj_coord |
---|
558 | ! additional limit required in bilaplacian case |
---|
559 | ze3_e1 = e3w_n(ji+ip,jj ,jk+kp) * r1_e1u(ji,jj) |
---|
560 | ze3_e2 = e3w_n(ji ,jj+jp,jk+kp) * r1_e2v(ji,jj) |
---|
561 | ! NB: hard coded factor 5 (can be a namelist parameter...) |
---|
562 | zti_g_lim = SIGN( MIN( rn_slpmax, 5.0_wp * ze3_e1, ABS( zti_g_raw ) ), zti_g_raw ) |
---|
563 | ztj_g_lim = SIGN( MIN( rn_slpmax, 5.0_wp * ze3_e2, ABS( ztj_g_raw ) ), ztj_g_raw ) |
---|
564 | ! |
---|
565 | ! Below ML use limited zti_g as is & mask |
---|
566 | ! Inside ML replace by linearly reducing sx_mlb towards surface & mask |
---|
567 | ! |
---|
568 | zfacti = REAL( 1 - 1/(1 + (jk+kp-1)/nmln(ji+ip,jj)), wp ) ! k index of uppermost point(s) of triad is jk+kp-1 |
---|
569 | zfactj = REAL( 1 - 1/(1 + (jk+kp-1)/nmln(ji,jj+jp)), wp ) ! must be .ge. nmln(ji,jj) for zfact=1 |
---|
570 | ! ! otherwise zfact=0 |
---|
571 | zti_g_lim = ( zfacti * zti_g_lim & |
---|
572 | & + ( 1._wp - zfacti ) * zti_mlb(ji+ip,jj,1-ip,kp) & |
---|
573 | & * gdepw_n(ji+ip,jj,jk+kp) * z1_mlbw(ji+ip,jj) ) * umask(ji,jj,jk+kp) |
---|
574 | ztj_g_lim = ( zfactj * ztj_g_lim & |
---|
575 | & + ( 1._wp - zfactj ) * ztj_mlb(ji,jj+jp,1-jp,kp) & |
---|
576 | & * gdepw_n(ji,jj+jp,jk+kp) * z1_mlbw(ji,jj+jp) ) * vmask(ji,jj,jk+kp) |
---|
577 | ! |
---|
578 | triadi_g(ji+ip,jj ,jk,1-ip,kp) = zti_g_lim |
---|
579 | triadj_g(ji ,jj+jp,jk,1-jp,kp) = ztj_g_lim |
---|
580 | ! |
---|
581 | ! Get coefficients of isoneutral diffusion tensor |
---|
582 | ! 1. Utilise gradients *relative* to s-coordinate, so add t-point slopes (*subtract* depth gradients) |
---|
583 | ! 2. We require that isoneutral diffusion gives no vertical buoyancy flux |
---|
584 | ! i.e. 33 term = (real slope* 31, 13 terms) |
---|
585 | ! To do this, retain limited sx**2 in vertical flux, but divide by real slope for 13/31 terms |
---|
586 | ! Equivalent to tapering A_iso = sx_limited**2/(real slope)**2 |
---|
587 | ! |
---|
588 | zti_lim = ( zti_g_lim + zti_coord ) * umask(ji,jj,jk+kp) ! remove coordinate slope => relative to coordinate surfaces |
---|
589 | ztj_lim = ( ztj_g_lim + ztj_coord ) * vmask(ji,jj,jk+kp) |
---|
590 | ! |
---|
591 | IF( ln_triad_iso ) THEN |
---|
592 | zti_raw = zti_lim*zti_lim / zti_raw |
---|
593 | ztj_raw = ztj_lim*ztj_lim / ztj_raw |
---|
594 | zti_raw = SIGN( MIN( ABS(zti_lim), ABS( zti_raw ) ), zti_raw ) |
---|
595 | ztj_raw = SIGN( MIN( ABS(ztj_lim), ABS( ztj_raw ) ), ztj_raw ) |
---|
596 | zti_lim = zfacti * zti_lim + ( 1._wp - zfacti ) * zti_raw |
---|
597 | ztj_lim = zfactj * ztj_lim + ( 1._wp - zfactj ) * ztj_raw |
---|
598 | ENDIF |
---|
599 | ! ! switching triad scheme |
---|
600 | zisw = (1._wp - rn_sw_triad ) + rn_sw_triad & |
---|
601 | & * 2._wp * ABS( 0.5_wp - kp - ( 0.5_wp - ip ) * SIGN( 1._wp , zdxrho(ji+ip,jj,jk,1-ip) ) ) |
---|
602 | zjsw = (1._wp - rn_sw_triad ) + rn_sw_triad & |
---|
603 | & * 2._wp * ABS( 0.5_wp - kp - ( 0.5_wp - jp ) * SIGN( 1._wp , zdyrho(ji,jj+jp,jk,1-jp) ) ) |
---|
604 | ! |
---|
605 | triadi(ji+ip,jj ,jk,1-ip,kp) = zti_lim * zisw |
---|
606 | triadj(ji ,jj+jp,jk,1-jp,kp) = ztj_lim * zjsw |
---|
607 | ! |
---|
608 | zbu = e1e2u(ji ,jj ) * e3u_n(ji ,jj ,jk ) |
---|
609 | zbv = e1e2v(ji ,jj ) * e3v_n(ji ,jj ,jk ) |
---|
610 | zbti = e1e2t(ji+ip,jj ) * e3w_n(ji+ip,jj ,jk+kp) |
---|
611 | zbtj = e1e2t(ji ,jj+jp) * e3w_n(ji ,jj+jp,jk+kp) |
---|
612 | ! |
---|
613 | wslp2(ji+ip,jj,jk+kp) = wslp2(ji+ip,jj,jk+kp) + 0.25_wp * zbu / zbti * zti_g_lim*zti_g_lim ! masked |
---|
614 | wslp2(ji,jj+jp,jk+kp) = wslp2(ji,jj+jp,jk+kp) + 0.25_wp * zbv / zbtj * ztj_g_lim*ztj_g_lim |
---|
615 | END DO |
---|
616 | END DO |
---|
617 | END DO |
---|
618 | END DO |
---|
619 | END DO |
---|
620 | ! |
---|
621 | wslp2(:,:,1) = 0._wp ! force the surface wslp to zero |
---|
622 | |
---|
623 | CALL lbc_lnk( 'ldfslp', wslp2, 'W', 1. ) ! lateral boundary confition on wslp2 only ==>>> gm : necessary ? to be checked |
---|
624 | ! |
---|
625 | IF( ln_timing ) CALL timing_stop('ldf_slp_triad') |
---|
626 | ! |
---|
627 | END SUBROUTINE ldf_slp_triad |
---|
628 | |
---|
629 | |
---|
630 | SUBROUTINE ldf_slp_mxl( prd, pn2, p_gru, p_grv, p_dzr ) |
---|
631 | !!---------------------------------------------------------------------- |
---|
632 | !! *** ROUTINE ldf_slp_mxl *** |
---|
633 | !! |
---|
634 | !! ** Purpose : Compute the slopes of iso-neutral surface just below |
---|
635 | !! the mixed layer. |
---|
636 | !! |
---|
637 | !! ** Method : The slope in the i-direction is computed at u- & w-points |
---|
638 | !! (uslpml, wslpiml) and the slope in the j-direction is computed |
---|
639 | !! at v- and w-points (vslpml, wslpjml) with the same bounds as |
---|
640 | !! in ldf_slp. |
---|
641 | !! |
---|
642 | !! ** Action : uslpml, wslpiml : i- & j-slopes of neutral surfaces |
---|
643 | !! vslpml, wslpjml just below the mixed layer |
---|
644 | !! omlmask : mixed layer mask |
---|
645 | !!---------------------------------------------------------------------- |
---|
646 | REAL(wp), DIMENSION(:,:,:), INTENT(in) :: prd ! in situ density |
---|
647 | REAL(wp), DIMENSION(:,:,:), INTENT(in) :: pn2 ! Brunt-Vaisala frequency (locally ref.) |
---|
648 | REAL(wp), DIMENSION(:,:,:), INTENT(in) :: p_gru, p_grv ! i- & j-gradient of density (u- & v-pts) |
---|
649 | REAL(wp), DIMENSION(:,:,:), INTENT(in) :: p_dzr ! z-gradient of density (T-point) |
---|
650 | !! |
---|
651 | INTEGER :: ji , jj , jk ! dummy loop indices |
---|
652 | INTEGER :: iku, ikv, ik, ikm1 ! local integers |
---|
653 | REAL(wp) :: zeps, zm1_g, zm1_2g, z1_slpmax ! local scalars |
---|
654 | REAL(wp) :: zci, zfi, zau, zbu, zai, zbi ! - - |
---|
655 | REAL(wp) :: zcj, zfj, zav, zbv, zaj, zbj ! - - |
---|
656 | REAL(wp) :: zck, zfk, zbw ! - - |
---|
657 | !!---------------------------------------------------------------------- |
---|
658 | ! |
---|
659 | zeps = 1.e-20_wp !== Local constant initialization ==! |
---|
660 | zm1_g = -1.0_wp / grav |
---|
661 | zm1_2g = -0.5_wp / grav |
---|
662 | z1_slpmax = 1._wp / rn_slpmax |
---|
663 | ! |
---|
664 | uslpml (1,:) = 0._wp ; uslpml (jpi,:) = 0._wp |
---|
665 | vslpml (1,:) = 0._wp ; vslpml (jpi,:) = 0._wp |
---|
666 | wslpiml(1,:) = 0._wp ; wslpiml(jpi,:) = 0._wp |
---|
667 | wslpjml(1,:) = 0._wp ; wslpjml(jpi,:) = 0._wp |
---|
668 | ! |
---|
669 | ! !== surface mixed layer mask ! |
---|
670 | DO jk = 1, jpk ! =1 inside the mixed layer, =0 otherwise |
---|
671 | DO jj = 1, jpj |
---|
672 | DO ji = 1, jpi |
---|
673 | ik = nmln(ji,jj) - 1 |
---|
674 | IF( jk <= ik ) THEN ; omlmask(ji,jj,jk) = 1._wp |
---|
675 | ELSE ; omlmask(ji,jj,jk) = 0._wp |
---|
676 | ENDIF |
---|
677 | END DO |
---|
678 | END DO |
---|
679 | END DO |
---|
680 | |
---|
681 | |
---|
682 | ! Slopes of isopycnal surfaces just before bottom of mixed layer |
---|
683 | ! -------------------------------------------------------------- |
---|
684 | ! The slope are computed as in the 3D case. |
---|
685 | ! A key point here is the definition of the mixed layer at u- and v-points. |
---|
686 | ! It is assumed to be the maximum of the two neighbouring T-point mixed layer depth. |
---|
687 | ! Otherwise, a n2 value inside the mixed layer can be involved in the computation |
---|
688 | ! of the slope, resulting in a too steep diagnosed slope and thus a spurious eddy |
---|
689 | ! induce velocity field near the base of the mixed layer. |
---|
690 | !----------------------------------------------------------------------- |
---|
691 | ! |
---|
692 | DO jj = 2, jpjm1 |
---|
693 | DO ji = 2, jpim1 |
---|
694 | ! !== Slope at u- & v-points just below the Mixed Layer ==! |
---|
695 | ! |
---|
696 | ! !- vertical density gradient for u- and v-slopes (from dzr at T-point) |
---|
697 | iku = MIN( MAX( 1, nmln(ji,jj) , nmln(ji+1,jj) ) , jpkm1 ) ! ML (MAX of T-pts, bound by jpkm1) |
---|
698 | ikv = MIN( MAX( 1, nmln(ji,jj) , nmln(ji,jj+1) ) , jpkm1 ) ! |
---|
699 | zbu = 0.5_wp * ( p_dzr(ji,jj,iku) + p_dzr(ji+1,jj ,iku) ) |
---|
700 | zbv = 0.5_wp * ( p_dzr(ji,jj,ikv) + p_dzr(ji ,jj+1,ikv) ) |
---|
701 | ! !- horizontal density gradient at u- & v-points |
---|
702 | zau = p_gru(ji,jj,iku) * r1_e1u(ji,jj) |
---|
703 | zav = p_grv(ji,jj,ikv) * r1_e2v(ji,jj) |
---|
704 | ! !- bound the slopes: abs(zw.)<= 1/100 and zb..<0 |
---|
705 | ! kxz max= ah slope max =< e1 e3 /(pi**2 2 dt) |
---|
706 | zbu = MIN( zbu , - z1_slpmax * ABS( zau ) , -7.e+3_wp/e3u_n(ji,jj,iku)* ABS( zau ) ) |
---|
707 | zbv = MIN( zbv , - z1_slpmax * ABS( zav ) , -7.e+3_wp/e3v_n(ji,jj,ikv)* ABS( zav ) ) |
---|
708 | ! !- Slope at u- & v-points (uslpml, vslpml) |
---|
709 | uslpml(ji,jj) = zau / ( zbu - zeps ) * umask(ji,jj,iku) |
---|
710 | vslpml(ji,jj) = zav / ( zbv - zeps ) * vmask(ji,jj,ikv) |
---|
711 | ! |
---|
712 | ! !== i- & j-slopes at w-points just below the Mixed Layer ==! |
---|
713 | ! |
---|
714 | ik = MIN( nmln(ji,jj) + 1, jpk ) |
---|
715 | ikm1 = MAX( 1, ik-1 ) |
---|
716 | ! !- vertical density gradient for w-slope (from N^2) |
---|
717 | zbw = zm1_2g * pn2 (ji,jj,ik) * ( prd (ji,jj,ik) + prd (ji,jj,ikm1) + 2. ) |
---|
718 | ! !- horizontal density i- & j-gradient at w-points |
---|
719 | zci = MAX( umask(ji-1,jj,ik ) + umask(ji,jj,ik ) & |
---|
720 | & + umask(ji-1,jj,ikm1) + umask(ji,jj,ikm1) , zeps ) * e1t(ji,jj) |
---|
721 | zcj = MAX( vmask(ji,jj-1,ik ) + vmask(ji,jj,ik ) & |
---|
722 | & + vmask(ji,jj-1,ikm1) + vmask(ji,jj,ikm1) , zeps ) * e2t(ji,jj) |
---|
723 | zai = ( p_gru(ji-1,jj,ik ) + p_gru(ji,jj,ik) & |
---|
724 | & + p_gru(ji-1,jj,ikm1) + p_gru(ji,jj,ikm1 ) ) / zci * tmask(ji,jj,ik) |
---|
725 | zaj = ( p_grv(ji,jj-1,ik ) + p_grv(ji,jj,ik ) & |
---|
726 | & + p_grv(ji,jj-1,ikm1) + p_grv(ji,jj,ikm1) ) / zcj * tmask(ji,jj,ik) |
---|
727 | ! !- bound the slopes: abs(zw.)<= 1/100 and zb..<0. |
---|
728 | ! kxz max= ah slope max =< e1 e3 /(pi**2 2 dt) |
---|
729 | zbi = MIN( zbw , -100._wp* ABS( zai ) , -7.e+3_wp/e3w_n(ji,jj,ik)* ABS( zai ) ) |
---|
730 | zbj = MIN( zbw , -100._wp* ABS( zaj ) , -7.e+3_wp/e3w_n(ji,jj,ik)* ABS( zaj ) ) |
---|
731 | ! !- i- & j-slope at w-points (wslpiml, wslpjml) |
---|
732 | wslpiml(ji,jj) = zai / ( zbi - zeps ) * tmask (ji,jj,ik) |
---|
733 | wslpjml(ji,jj) = zaj / ( zbj - zeps ) * tmask (ji,jj,ik) |
---|
734 | END DO |
---|
735 | END DO |
---|
736 | !!gm this lbc_lnk should be useless.... |
---|
737 | CALL lbc_lnk_multi( 'ldfslp', uslpml , 'U', -1. , vslpml , 'V', -1. , wslpiml, 'W', -1. , wslpjml, 'W', -1. ) |
---|
738 | ! |
---|
739 | END SUBROUTINE ldf_slp_mxl |
---|
740 | |
---|
741 | |
---|
742 | SUBROUTINE ldf_slp_init |
---|
743 | !!---------------------------------------------------------------------- |
---|
744 | !! *** ROUTINE ldf_slp_init *** |
---|
745 | !! |
---|
746 | !! ** Purpose : Initialization for the isopycnal slopes computation |
---|
747 | !! |
---|
748 | !! ** Method : |
---|
749 | !!---------------------------------------------------------------------- |
---|
750 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
751 | INTEGER :: ierr ! local integer |
---|
752 | !!---------------------------------------------------------------------- |
---|
753 | ! |
---|
754 | IF(lwp) THEN |
---|
755 | WRITE(numout,*) |
---|
756 | WRITE(numout,*) 'ldf_slp_init : direction of lateral mixing' |
---|
757 | WRITE(numout,*) '~~~~~~~~~~~~' |
---|
758 | ENDIF |
---|
759 | ! |
---|
760 | ALLOCATE( ah_wslp2(jpi,jpj,jpk) , akz(jpi,jpj,jpk) , STAT=ierr ) |
---|
761 | IF( ierr > 0 ) CALL ctl_stop( 'STOP', 'ldf_slp_init : unable to allocate ah_slp2 or akz' ) |
---|
762 | ALLOCATE(zslpml_hmlpu(jpi,jpj), zslpml_hmlpv(jpi,jpj)) |
---|
763 | ALLOCATE(zgru(jpi,jpj,jpk), zwz(jpi,jpj,jpk), zdzr(jpi,jpj,jpk)) |
---|
764 | ALLOCATE(zgrv(jpi,jpj,jpk), zww(jpi,jpj,jpk)) |
---|
765 | |
---|
766 | ! |
---|
767 | IF( ln_traldf_triad ) THEN ! Griffies operator : triad of slopes |
---|
768 | IF(lwp) WRITE(numout,*) ' ==>>> triad) operator (Griffies)' |
---|
769 | ALLOCATE( triadi_g(jpi,jpj,jpk,0:1,0:1) , triadj_g(jpi,jpj,jpk,0:1,0:1) , & |
---|
770 | & triadi (jpi,jpj,jpk,0:1,0:1) , triadj (jpi,jpj,jpk,0:1,0:1) , & |
---|
771 | & wslp2 (jpi,jpj,jpk) , STAT=ierr ) |
---|
772 | IF( ierr > 0 ) CALL ctl_stop( 'STOP', 'ldf_slp_init : unable to allocate Griffies operator slope' ) |
---|
773 | IF( ln_dynldf_iso ) CALL ctl_stop( 'ldf_slp_init: Griffies operator on momentum not supported' ) |
---|
774 | ! |
---|
775 | ELSE ! Madec operator : slopes at u-, v-, and w-points |
---|
776 | IF(lwp) WRITE(numout,*) ' ==>>> iso operator (Madec)' |
---|
777 | ALLOCATE( omlmask(jpi,jpj,jpk) , & |
---|
778 | & uslp(jpi,jpj,jpk) , uslpml(jpi,jpj) , wslpi(jpi,jpj,jpk) , wslpiml(jpi,jpj) , & |
---|
779 | & vslp(jpi,jpj,jpk) , vslpml(jpi,jpj) , wslpj(jpi,jpj,jpk) , wslpjml(jpi,jpj) , STAT=ierr ) |
---|
780 | IF( ierr > 0 ) CALL ctl_stop( 'STOP', 'ldf_slp_init : unable to allocate Madec operator slope ' ) |
---|
781 | |
---|
782 | ALLOCATE(z1_mlbw(jpi,jpj)) |
---|
783 | ALLOCATE(zalbet(jpi,jpj,jpk)) |
---|
784 | ALLOCATE(zdxrho(jpi,jpj,jpk,0:1) , zdyrho(jpi,jpj,jpk,0:1), zdzrho(jpi,jpj,jpk,0:1) ) |
---|
785 | ALLOCATE(zti_mlb(jpi,jpj,0:1,0:1), ztj_mlb(jpi,jpj,0:1,0:1)) |
---|
786 | |
---|
787 | ! Direction of lateral diffusion (tracers and/or momentum) |
---|
788 | ! ------------------------------ |
---|
789 | uslp (:,:,:) = 0._wp ; uslpml (:,:) = 0._wp ! set the slope to zero (even in s-coordinates) |
---|
790 | vslp (:,:,:) = 0._wp ; vslpml (:,:) = 0._wp |
---|
791 | wslpi(:,:,:) = 0._wp ; wslpiml(:,:) = 0._wp |
---|
792 | wslpj(:,:,:) = 0._wp ; wslpjml(:,:) = 0._wp |
---|
793 | |
---|
794 | !!gm I no longer understand this..... |
---|
795 | !!gm IF( (ln_traldf_hor .OR. ln_dynldf_hor) .AND. .NOT. (.NOT.ln_linssh .AND. ln_rstart) ) THEN |
---|
796 | ! IF(lwp) WRITE(numout,*) ' Horizontal mixing in s-coordinate: slope = slope of s-surfaces' |
---|
797 | ! |
---|
798 | ! ! geopotential diffusion in s-coordinates on tracers and/or momentum |
---|
799 | ! ! The slopes of s-surfaces are computed once (no call to ldfslp in step) |
---|
800 | ! ! The slopes for momentum diffusion are i- or j- averaged of those on tracers |
---|
801 | ! |
---|
802 | ! ! set the slope of diffusion to the slope of s-surfaces |
---|
803 | ! ! ( c a u t i o n : minus sign as dep has positive value ) |
---|
804 | ! DO jk = 1, jpk |
---|
805 | ! DO jj = 2, jpjm1 |
---|
806 | ! DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
807 | ! uslp (ji,jj,jk) = - ( gdept_n(ji+1,jj,jk) - gdept_n(ji ,jj ,jk) ) * r1_e1u(ji,jj) * umask(ji,jj,jk) |
---|
808 | ! vslp (ji,jj,jk) = - ( gdept_n(ji,jj+1,jk) - gdept_n(ji ,jj ,jk) ) * r1_e2v(ji,jj) * vmask(ji,jj,jk) |
---|
809 | ! wslpi(ji,jj,jk) = - ( gdepw_n(ji+1,jj,jk) - gdepw_n(ji-1,jj,jk) ) * r1_e1t(ji,jj) * wmask(ji,jj,jk) * 0.5 |
---|
810 | ! wslpj(ji,jj,jk) = - ( gdepw_n(ji,jj+1,jk) - gdepw_n(ji,jj-1,jk) ) * r1_e2t(ji,jj) * wmask(ji,jj,jk) * 0.5 |
---|
811 | ! END DO |
---|
812 | ! END DO |
---|
813 | ! END DO |
---|
814 | ! CALL lbc_lnk_multi( 'ldfslp', uslp , 'U', -1. ; CALL lbc_lnk( 'ldfslp', vslp , 'V', -1., wslpi, 'W', -1., wslpj, 'W', -1. ) |
---|
815 | !!gm ENDIF |
---|
816 | ENDIF |
---|
817 | ! |
---|
818 | END SUBROUTINE ldf_slp_init |
---|
819 | |
---|
820 | !!====================================================================== |
---|
821 | END MODULE ldfslp |
---|