1 | MODULE trdmld |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE trdmld *** |
---|
4 | !! Ocean diagnostics: mixed layer T-S trends |
---|
5 | !!===================================================================== |
---|
6 | #if defined key_trdmld || defined key_esopa |
---|
7 | !!---------------------------------------------------------------------- |
---|
8 | !! 'key_trdmld' mixed layer trend diagnostics |
---|
9 | !!---------------------------------------------------------------------- |
---|
10 | !! trd_mld : T and S trends averaged over the mixed layer |
---|
11 | !!---------------------------------------------------------------------- |
---|
12 | !! * Modules used |
---|
13 | USE oce ! ocean dynamics and tracers variables |
---|
14 | USE dom_oce ! ocean space and time domain variables |
---|
15 | USE ldftra_oce ! ocean active tracers: lateral physics |
---|
16 | USE trdtra_oce ! ocean active tracer trend variables |
---|
17 | USE zdf_oce ! ocean vertical physics |
---|
18 | USE in_out_manager ! I/O manager |
---|
19 | |
---|
20 | USE phycst ! Define parameters for the routines |
---|
21 | USE daymod ! calendar |
---|
22 | USE dianam ! build the name of file (routine) |
---|
23 | USE ldfslp ! iso-neutral slopes |
---|
24 | USE zdfmxl |
---|
25 | USE zdfddm |
---|
26 | USE ioipsl |
---|
27 | USE lbclnk |
---|
28 | #if defined key_dimgout |
---|
29 | USE diawri, ONLY : dia_wri_dimg |
---|
30 | #endif |
---|
31 | |
---|
32 | IMPLICIT NONE |
---|
33 | PRIVATE |
---|
34 | |
---|
35 | !! * Accessibility |
---|
36 | PUBLIC trd_mld ! routine called by step.F90 |
---|
37 | |
---|
38 | !! * Shared module variables |
---|
39 | LOGICAL, PUBLIC, PARAMETER :: lk_trdmld = .TRUE. !: momentum trend flag |
---|
40 | |
---|
41 | !! * Module variables |
---|
42 | INTEGER, DIMENSION(jpi,jpj) :: & |
---|
43 | nmld, & ! mixed layer depth |
---|
44 | nbol |
---|
45 | |
---|
46 | INTEGER :: & |
---|
47 | nh_t, nmoymltrd, & ! ??? |
---|
48 | nidtrd,nhoridtrd, & |
---|
49 | ndextrd1(jpi*jpj),ndimtrd1 |
---|
50 | |
---|
51 | REAL(wp), DIMENSION(jpi,jpj) :: & |
---|
52 | rmld , & ! mld depth (m) corresponding to nmld |
---|
53 | tml , sml , & ! average T and S over mixed layer |
---|
54 | tmlb , smlb , & ! before tml and sml (kt-1) |
---|
55 | tmlbb , smlbb, & ! tml and sml at begining of the nwrite-1 |
---|
56 | ! ! timestep averaging period |
---|
57 | tmlbn , smlbn, & ! after tml and sml at time step after the |
---|
58 | ! ! begining of the NWRITE-1 timesteps |
---|
59 | tmltrdm, smltrdm ! |
---|
60 | |
---|
61 | ! REAL(wp), DIMENSION(jpi,jpj,jpltrd) :: & ! Must be jpk for mpp lbc_lnk |
---|
62 | ! TO BE FIXED ??? |
---|
63 | REAL(wp), DIMENSION(jpi,jpj,jpk) :: & |
---|
64 | tmltrd , & ! total cumulative trends of temperature and |
---|
65 | smltrd ! salinity over nwrite-1 time steps |
---|
66 | |
---|
67 | INTEGER :: iyear,imon,iday |
---|
68 | CHARACTER(LEN=80) :: clname, cltext, clmode |
---|
69 | |
---|
70 | !! * Substitutions |
---|
71 | # include "domzgr_substitute.h90" |
---|
72 | # include "ldftra_substitute.h90" |
---|
73 | # include "zdfddm_substitute.h90" |
---|
74 | !!---------------------------------------------------------------------- |
---|
75 | !! OPA 9.0 , LODYC-IPSL (2003) |
---|
76 | !!---------------------------------------------------------------------- |
---|
77 | |
---|
78 | CONTAINS |
---|
79 | |
---|
80 | SUBROUTINE trd_mld( kt ) |
---|
81 | !!---------------------------------------------------------------------- |
---|
82 | !! *** ROUTINE trd_mld *** |
---|
83 | !! |
---|
84 | !! ** Purpose : computation of vertically integrated T and S budgets |
---|
85 | !! from ocean surface down to control surface (NetCDF output) |
---|
86 | !! |
---|
87 | !! ** Method/usage : |
---|
88 | !! integration done over nwrite-1 time steps |
---|
89 | !! Control surface can be either a mixed layer depth (time varying) |
---|
90 | !! or a fixed surface (jk level or bowl). |
---|
91 | !! Choose control surface with nctls in namelist NAMDIA. |
---|
92 | !! nctls = 0 : use mixed layer with density criterion |
---|
93 | !! nctls = 1 : read index from file 'ctlsurf_idx' |
---|
94 | !! nctls > 1 : use fixed level surface jk = nctls |
---|
95 | !! Note: in the remainder of the routine, the volume between the |
---|
96 | !! surface and the control surface is called "mixed-layer" |
---|
97 | !! Method check : if the control surface is fixed, the residual dh/dt |
---|
98 | !! entrainment should be zero |
---|
99 | !! |
---|
100 | !! ** Action : |
---|
101 | !! /commld/ : rmld mld depth corresponding to nmld |
---|
102 | !! tml average T over mixed layer |
---|
103 | !! tmlb tml at kt-1 |
---|
104 | !! tmlbb tml at begining of the NWRITE-1 |
---|
105 | !! time steps averaging period |
---|
106 | !! tmlbn tml at time step after the |
---|
107 | !! begining of the NWRITE-1 time |
---|
108 | !! steps averaging period |
---|
109 | !! |
---|
110 | !! mixed layer trends : |
---|
111 | !! |
---|
112 | !! tmltrd (,,1) = zonal advection |
---|
113 | !! tmltrd (,,2) = meridional advection |
---|
114 | !! tmltrd (,,3) = vertical advection |
---|
115 | !! tmltrd (,,4) = lateral diffusion (horiz. component+Beckman) |
---|
116 | !! tmltrd (,,5) = forcing |
---|
117 | !! tmltrd (,,6) = entrainment due to vertical diffusion (TKE) |
---|
118 | !! if iso tmltrd (,,7) = lateral diffusion (vertical component) |
---|
119 | !! tmltrd (,,8) = eddy induced zonal advection |
---|
120 | !! tmltrd (,,9) = eddy induced meridional advection |
---|
121 | !! tmltrd (,,10) = eddy induced vertical advection |
---|
122 | !! |
---|
123 | !! tmltrdm(,) : total cumulative trends over nwrite-1 time steps |
---|
124 | !! ztmltot(,) : dT/dt over the NWRITE-1 time steps |
---|
125 | !! averaging period (including Asselin |
---|
126 | !! terms) |
---|
127 | !! ztmlres(,) : residual = dh/dt entrainment |
---|
128 | !! |
---|
129 | !! trends output in netCDF format using ioipsl |
---|
130 | !! |
---|
131 | !! History : |
---|
132 | !! ! 95-04 (J. Vialard) Original code |
---|
133 | !! ! 97-02 (E. Guilyardi) Adaptation global + base cmo |
---|
134 | !! ! 99-09 (E. Guilyardi) Re-writing + netCDF output |
---|
135 | !! 8.5 ! 02-06 (G. Madec) F90: Free form and module |
---|
136 | !!---------------------------------------------------------------------- |
---|
137 | !! * Arguments |
---|
138 | INTEGER, INTENT( in ) :: kt ! ocean time-step index |
---|
139 | |
---|
140 | !! * Local declarations |
---|
141 | INTEGER :: ilseq |
---|
142 | INTEGER :: ji, jj, jk, jl, ik, ikb, idebug, isum, it |
---|
143 | INTEGER, DIMENSION(jpi,jpj) :: zvlmsk |
---|
144 | |
---|
145 | REAL(wp) :: zmean, zavt, zjulian, zsto, zout |
---|
146 | REAL(wp) ,DIMENSION(jpi,jpj,jpktrd) :: zwkx |
---|
147 | REAL(wp) ,DIMENSION(jpi,jpj) :: & |
---|
148 | & ztmltot, ztmlres, z2d, zsmltot, zsmlres |
---|
149 | |
---|
150 | CHARACTER (len=21) :: & |
---|
151 | clold ='OLD' , & ! open specifier (direct access files) |
---|
152 | clunf ='UNFORMATTED', & ! open specifier (direct access files) |
---|
153 | clseq ='SEQUENTIAL' ! open specifier (direct access files) |
---|
154 | CHARACTER (len=80) :: clname |
---|
155 | CHARACTER (len=40) :: clhstnam |
---|
156 | CHARACTER (len=40) :: clop |
---|
157 | CHARACTER (len=12) :: clmxl |
---|
158 | |
---|
159 | NAMELIST/namtrd/ ntrd, nctls |
---|
160 | !!---------------------------------------------------------------------- |
---|
161 | |
---|
162 | ! =================== |
---|
163 | ! 0. initialization |
---|
164 | ! =================== |
---|
165 | |
---|
166 | ! Open specifier |
---|
167 | ilseq = 1 |
---|
168 | idebug = 0 ! set it to 1 in case of problem to have more print |
---|
169 | |
---|
170 | IF( kt == nit000 ) THEN |
---|
171 | ! namelist namtrd : trend diagnostic |
---|
172 | REWIND( numnam ) |
---|
173 | READ ( numnam, namtrd ) |
---|
174 | |
---|
175 | IF(lwp) THEN |
---|
176 | WRITE(numout,*) 'namtrd' |
---|
177 | WRITE(numout,*) ' ' |
---|
178 | WRITE(numout,*) ' time step frequency trend ntrd = ',ntrd |
---|
179 | WRITE(numout,*) ' control surface for trends nctls = ',nctls |
---|
180 | WRITE(numout,*) ' ' |
---|
181 | ENDIF |
---|
182 | |
---|
183 | ! cumulated trends array init |
---|
184 | nmoymltrd = 0 |
---|
185 | tmltrdm(:,:) = 0. |
---|
186 | smltrdm(:,:) = 0. |
---|
187 | ENDIF |
---|
188 | |
---|
189 | ! set before values of vertically average T and S |
---|
190 | |
---|
191 | IF( kt > nit000 ) THEN |
---|
192 | tmlb(:,:) = tml(:,:) |
---|
193 | smlb(:,:) = sml(:,:) |
---|
194 | ENDIF |
---|
195 | |
---|
196 | ! read control surface from file ctlsurf_idx |
---|
197 | |
---|
198 | IF( kt == nit000 .and. nctls == - 1 ) THEN |
---|
199 | clname ='ctlsurf_idx' |
---|
200 | CALL ctlopn(numbol,clname,clold,clunf,clseq, & |
---|
201 | ilseq,numout,lwp,1) |
---|
202 | REWIND (numbol) |
---|
203 | READ(numbol) nbol |
---|
204 | ENDIF |
---|
205 | |
---|
206 | IF( idebug /= 0 ) THEN |
---|
207 | WRITE(numout,*) ' debuging trd_mld: 0. done ' |
---|
208 | CALL FLUSH(numout) |
---|
209 | ENDIF |
---|
210 | |
---|
211 | |
---|
212 | ! ======================================================== |
---|
213 | ! I. definition of control surface and associated fields |
---|
214 | ! ======================================================== |
---|
215 | |
---|
216 | ! I.1 set nmld(ji,jj) = index of first T point below control surface |
---|
217 | ! ------------------- or outside mixed-layer |
---|
218 | |
---|
219 | ! clmxl = legend root for netCDF output |
---|
220 | |
---|
221 | IF( nctls == 0 ) THEN |
---|
222 | ! control surface = mixed-layer with density criterion |
---|
223 | ! (array nmln computed in zdfmxl.F90) |
---|
224 | nmld(:,:) = nmln(:,:) |
---|
225 | clmxl = 'Mixed Layer ' |
---|
226 | ELSE IF( nctls == 1 ) THEN |
---|
227 | ! control surface = read index from file |
---|
228 | nmld(:,:) = nbol(:,:) |
---|
229 | clmxl = ' Bowl ' |
---|
230 | ELSE IF( nctls >= 2 ) THEN |
---|
231 | ! control surface = model level |
---|
232 | nctls = MIN( nctls, jpktrd - 1 ) |
---|
233 | nmld(:,:) = nctls + 1 |
---|
234 | WRITE(clmxl,'(A9,I2,1X)') 'Levels 1-', nctls |
---|
235 | ENDIF |
---|
236 | |
---|
237 | ! Check of validity : nmld(ji,jj) =< jpktrd |
---|
238 | isum = 0 |
---|
239 | |
---|
240 | IF( jpktrd < jpk ) THEN |
---|
241 | DO jj = 1, jpj |
---|
242 | DO ji = 1, jpi |
---|
243 | IF( nmld(ji,jj) <= jpktrd ) THEN |
---|
244 | zvlmsk(ji,jj) = tmask(ji,jj,1) |
---|
245 | ELSE |
---|
246 | isum = isum + 1 |
---|
247 | zvlmsk(ji,jj) = 0. |
---|
248 | ENDIF |
---|
249 | END DO |
---|
250 | END DO |
---|
251 | ENDIF |
---|
252 | |
---|
253 | IF( idebug /= 0 ) THEN |
---|
254 | ! CALL prihre (zvlmsk,jpi,jpj,1,jpi,2,1,jpj,2,3,numout) |
---|
255 | WRITE(numout,*) ' debuging trd_mld: I.1 done ' |
---|
256 | CALL FLUSH(numout) |
---|
257 | ENDIF |
---|
258 | |
---|
259 | |
---|
260 | ! I.2 probability density function of presence in mixed-layer |
---|
261 | ! -------------------------------- |
---|
262 | ! (i.e. weight of each grid point in vertical integration : zwkx(ji,jj,jk) |
---|
263 | |
---|
264 | |
---|
265 | ! initialize zwkx with vertical scale factor in mixed-layer |
---|
266 | |
---|
267 | zwkx(:,:,:) = 0.e0 |
---|
268 | DO jk = 1, jpktrd |
---|
269 | DO jj = 1,jpj |
---|
270 | DO ji = 1,jpi |
---|
271 | IF( jk - nmld(ji,jj) < 0. ) zwkx(ji,jj,jk) = fse3t(ji,jj,jk) * tmask(ji,jj,jk) |
---|
272 | END DO |
---|
273 | END DO |
---|
274 | END DO |
---|
275 | |
---|
276 | ! compute mixed-layer depth : rmld |
---|
277 | |
---|
278 | rmld(:,:) = 0. |
---|
279 | DO jk = 1, jpktrd |
---|
280 | rmld(:,:) = rmld(:,:) + zwkx(:,:,jk) |
---|
281 | END DO |
---|
282 | |
---|
283 | ! compute PDF |
---|
284 | |
---|
285 | DO jk = 1, jpktrd |
---|
286 | zwkx(:,:,jk) = zwkx(:,:,jk) / MAX( 1., rmld(:,:) ) |
---|
287 | END DO |
---|
288 | |
---|
289 | IF( idebug /= 0 ) THEN |
---|
290 | WRITE(numout,*) ' debuging trd_mld: I.2 done ' |
---|
291 | CALL FLUSH(numout) |
---|
292 | ENDIF |
---|
293 | |
---|
294 | |
---|
295 | ! I.3 vertically integrated T and S |
---|
296 | ! --------------------------------- |
---|
297 | |
---|
298 | tml(:,:) = 0. |
---|
299 | sml(:,:) = 0. |
---|
300 | |
---|
301 | DO jk = 1, jpktrd - 1 |
---|
302 | tml(:,:) = tml(:,:) + zwkx(:,:,jk) * tn(:,:,jk) |
---|
303 | sml(:,:) = sml(:,:) + zwkx(:,:,jk) * sn(:,:,jk) |
---|
304 | END DO |
---|
305 | |
---|
306 | IF(idebug /= 0) THEN |
---|
307 | WRITE(numout,*) ' debuging trd_mld: I.3 done' |
---|
308 | CALL FLUSH(numout) |
---|
309 | ENDIF |
---|
310 | |
---|
311 | |
---|
312 | ! =================================== |
---|
313 | ! II. netCDF output initialization |
---|
314 | ! =================================== |
---|
315 | |
---|
316 | #if defined key_dimgout |
---|
317 | |
---|
318 | #else |
---|
319 | #include "trdmld_ncinit.h90" |
---|
320 | #endif |
---|
321 | |
---|
322 | IF( idebug /= 0 ) THEN |
---|
323 | WRITE(numout,*) ' debuging trd_mld: II. done' |
---|
324 | CALL FLUSH(numout) |
---|
325 | ENDIF |
---|
326 | |
---|
327 | ! ==================================================== |
---|
328 | ! III. vertical integration of trends in mixed-layer |
---|
329 | ! ==================================================== |
---|
330 | |
---|
331 | |
---|
332 | ! III.0 initializations |
---|
333 | ! --------------------- |
---|
334 | |
---|
335 | tmltrd(:,:,:) = 0.e0 |
---|
336 | smltrd(:,:,:) = 0.e0 |
---|
337 | |
---|
338 | IF( idebug /= 0 ) THEN |
---|
339 | WRITE(numout,*) ' debuging trd_mld: III.0 done' |
---|
340 | CALL FLUSH(numout) |
---|
341 | ENDIF |
---|
342 | |
---|
343 | |
---|
344 | ! III.1 vertical integration of 3D trends |
---|
345 | ! --------------------------------------- |
---|
346 | |
---|
347 | DO jk = 1,jpktrd |
---|
348 | |
---|
349 | ! Temperature |
---|
350 | tmltrd(:,:,1) = tmltrd(:,:,1) + ttrdh(:,:,jk,1) * zwkx(:,:,jk) ! zonal advection |
---|
351 | tmltrd(:,:,2) = tmltrd(:,:,2) + ttrdh(:,:,jk,2) * zwkx(:,:,jk) ! meridional advection |
---|
352 | tmltrd(:,:,3) = tmltrd(:,:,3) + ttrd (:,:,jk,2) * zwkx(:,:,jk) ! vertical advection |
---|
353 | tmltrd(:,:,4) = tmltrd(:,:,4) + ttrd (:,:,jk,3) * zwkx(:,:,jk) ! lateral diffusion (hor. part) |
---|
354 | tmltrd(:,:,5) = tmltrd(:,:,5) + ttrd (:,:,jk,7) * zwkx(:,:,jk) ! forcing (penetrative) |
---|
355 | IF( l_traldf_iso ) THEN |
---|
356 | tmltrd(:,:,7) = tmltrd(:,:,7) + ttrd (:,:,jk,4) * zwkx(:,:,jk) ! lateral diffusion (explicit |
---|
357 | ! ! vert. part (isopycnal diff.) |
---|
358 | ENDIF |
---|
359 | !#if defined key_traldf_eiv |
---|
360 | ! tmltrd(:,:,8 ) = tmltrdg(:,:,8) + ttrdh(:,:,jk,3) * zwkx(:,:,jk) ! eddy induced zonal advection |
---|
361 | ! tmltrd(:,:,9 ) = tmltrdg(:,:,9) + ttrdh(:,:,jk,4) * zwkx(:,:,jk) ! eddy induced merid. advection |
---|
362 | ! tmltrd(:,:,10) = tmltrdg(:,:,10) + ttrd(:,:,jk,6) * zwkx(:,:,jk) ! eddy induced vert. advection |
---|
363 | !#endif |
---|
364 | |
---|
365 | ! Salinity |
---|
366 | smltrd(:,:,1) = smltrd(:,:,1) + strdh(:,:,jk,1) * zwkx(:,:,jk) ! zonal advection |
---|
367 | smltrd(:,:,2) = smltrd(:,:,2) + strdh(:,:,jk,2) * zwkx(:,:,jk) ! meridional advection |
---|
368 | smltrd(:,:,3) = smltrd(:,:,3) + strd (:,:,jk,2) * zwkx(:,:,jk) ! vertical advection |
---|
369 | smltrd(:,:,4) = smltrd(:,:,4) + strd (:,:,jk,3) * zwkx(:,:,jk) ! lateral diffusion (hor. part) |
---|
370 | IF( l_traldf_iso ) THEN |
---|
371 | smltrd(:,:,7) = smltrd(:,:,7) + strd (:,:,jk,4) * zwkx(:,:,jk) ! lateral diffusion (explicit |
---|
372 | ! ! vert. part (isopycnal diff.) |
---|
373 | ENDIF |
---|
374 | !#if defined key_traldf_eiv |
---|
375 | ! smltrd(:,:,8) = smltrdg(:,:,8) + strdh(:,:,jk,3) * zwkx(:,:,jk) ! eddy induced zonal advection |
---|
376 | ! smltrd(:,:,9) = smltrdg(:,:,9) + strdh(:,:,jk,4) * zwkx(:,:,jk) ! eddy induced merid. advection |
---|
377 | ! smltrd(:,:,10) = smltrdg(:,:,10) + strd(:,:,jk,6) * zwkx(:,:,jk) ! eddy induced vert. advection |
---|
378 | !#endif |
---|
379 | |
---|
380 | END DO |
---|
381 | |
---|
382 | |
---|
383 | IF( idebug /= 0 ) THEN |
---|
384 | IF(lwp) WRITE(numout,*) ' debuging trd_mld: III.1 done' |
---|
385 | CALL FLUSH(numout) |
---|
386 | ENDIF |
---|
387 | |
---|
388 | |
---|
389 | ! III.2 trends terms at upper and lower boundaries of mixed-layer |
---|
390 | ! --------------------------------------------------------------- |
---|
391 | |
---|
392 | DO jj = 1,jpj |
---|
393 | DO ji = 1,jpi |
---|
394 | |
---|
395 | ik = nmld(ji,jj) |
---|
396 | |
---|
397 | ! Temperature |
---|
398 | |
---|
399 | ! forcing (non penetrative) |
---|
400 | tmltrd(ji,jj,5) = tmltrd(ji,jj,5) + flxtrd(ji,jj,1) * zwkx(ji,jj,1) |
---|
401 | ! entrainment due to vertical diffusion |
---|
402 | ! - due to vertical mixing scheme (TKE) |
---|
403 | zavt = avt(ji,jj,ik) |
---|
404 | tmltrd(ji,jj,6) = - 1. * zavt / fse3w(ji,jj,ik) * tmask(ji,jj,ik) & |
---|
405 | * ( tn(ji,jj,ik-1) - tn(ji,jj,ik) ) & |
---|
406 | / MAX( 1., rmld(ji,jj) ) * tmask(ji,jj,1) |
---|
407 | |
---|
408 | ! Salinity |
---|
409 | |
---|
410 | ! forcing |
---|
411 | smltrd(ji,jj,5) = flxtrd(ji,jj,2) * zwkx(ji,jj,1) |
---|
412 | ! entrainment due to vertical diffusion |
---|
413 | ! - due to vertical mixing scheme (TKE) |
---|
414 | zavt = fsavs(ji,jj,ik) |
---|
415 | smltrd(ji,jj,6) = -1. * zavt / fse3w(ji,jj,ik) * tmask(ji,jj,ik) & |
---|
416 | & * ( sn(ji,jj,ik-1) - sn(ji,jj,ik) ) & |
---|
417 | & / MAX( 1., rmld(ji,jj) ) * tmask(ji,jj,1) |
---|
418 | END DO |
---|
419 | END DO |
---|
420 | |
---|
421 | IF( l_traldf_iso ) THEN |
---|
422 | !!Clem On retire de la diffusion verticale TOTALE calculee par tmltrd(:,:,7) |
---|
423 | !!Clem ds trazdf.isopycnal et implicit, la partie verticale due au Kz afin de ne garder |
---|
424 | !!Clem effectivement que la diffusion verticale isopycnale (ie composante de la |
---|
425 | !!Clem diff isopycnale sur la verticale) : |
---|
426 | tmltrd(:,:,7) = tmltrd(:,:,7) - tmltrd(:,:,6) ! - due to isopycnal mixing scheme (implicit part) |
---|
427 | smltrd(:,:,7) = smltrd(:,:,7) - smltrd(:,:,6) ! - due to isopycnal mixing scheme (implicit part) |
---|
428 | ENDIF |
---|
429 | |
---|
430 | ! Boundary conditions |
---|
431 | DO jk = 1, jpltrd |
---|
432 | CALL lbc_lnk( tmltrd, 'T', 1. ) |
---|
433 | CALL lbc_lnk( smltrd, 'T', 1. ) |
---|
434 | END DO |
---|
435 | |
---|
436 | IF( idebug /= 0 ) THEN |
---|
437 | WRITE(numout,*) ' debuging trd_mld: III.2 done' |
---|
438 | CALL FLUSH(numout) |
---|
439 | ENDIF |
---|
440 | |
---|
441 | #if defined key_trabbl_dif |
---|
442 | ! III.3 trends terms from beckman over-flow parameterization |
---|
443 | ! ---------------------------------------------------------- |
---|
444 | |
---|
445 | DO jj = 1,jpj |
---|
446 | DO ji = 1,jpi |
---|
447 | ikb = MAX( mbathy(ji,jj)-1, 1 ) |
---|
448 | ! beckmann component -> horiz. part of lateral diffusion |
---|
449 | tmltrd(ji,jj,4) = tmltrd(ji,jj,4) + bbltrd(ji,jj,1) * zwkx(ji,jj,ikb) |
---|
450 | smltrd(ji,jj,4) = smltrd(ji,jj,4) + bbltrd(ji,jj,2) * zwkx(ji,jj,ikb) |
---|
451 | END DO |
---|
452 | END DO |
---|
453 | |
---|
454 | #endif |
---|
455 | |
---|
456 | IF( idebug /= 0 ) THEN |
---|
457 | WRITE(numout,*) ' debuging trd_mld: III.3 done' |
---|
458 | CALL FLUSH(numout) |
---|
459 | ENDIF |
---|
460 | |
---|
461 | |
---|
462 | ! ================================= |
---|
463 | ! IV. Cumulated trends |
---|
464 | ! ================================= |
---|
465 | |
---|
466 | |
---|
467 | |
---|
468 | ! IV.1 set `before' mixed layer values for kt = nit000+1 |
---|
469 | ! -------------------------------------------------------- |
---|
470 | |
---|
471 | IF( kt == nit000+1 ) THEN |
---|
472 | tmlbb(:,:) = tmlb(:,:) |
---|
473 | tmlbn(:,:) = tml (:,:) |
---|
474 | smlbb(:,:) = smlb(:,:) |
---|
475 | smlbn(:,:) = sml (:,:) |
---|
476 | ENDIF |
---|
477 | |
---|
478 | IF( idebug /= 0 ) THEN |
---|
479 | WRITE(numout,*) ' debuging trd_mld: IV.1 done' |
---|
480 | CALL FLUSH(numout) |
---|
481 | ENDIF |
---|
482 | |
---|
483 | |
---|
484 | ! IV.2 cumulated trends over analysis period (kt=2 to nwrite) |
---|
485 | ! ---------------------- |
---|
486 | |
---|
487 | ! trends cumulated over nwrite-2 time steps |
---|
488 | |
---|
489 | IF( kt >= nit000+2 ) THEN |
---|
490 | nmoymltrd = nmoymltrd + 1 |
---|
491 | DO jl = 1, jpltrd |
---|
492 | tmltrdm(:,:) = tmltrdm(:,:) + tmltrd(:,:,jl) |
---|
493 | smltrdm(:,:) = smltrdm(:,:) + smltrd(:,:,jl) |
---|
494 | END DO |
---|
495 | ENDIF |
---|
496 | |
---|
497 | IF( idebug /= 0 ) THEN |
---|
498 | WRITE(numout,*) ' debuging trd_mld: IV.2 done' |
---|
499 | CALL FLUSH(numout) |
---|
500 | ENDIF |
---|
501 | |
---|
502 | |
---|
503 | ! ============================================= |
---|
504 | ! V. Output in netCDF + residual computation |
---|
505 | ! ============================================= |
---|
506 | |
---|
507 | ztmltot(:,:) = 0. |
---|
508 | zsmltot(:,:) = 0. |
---|
509 | ztmlres(:,:) = 0. |
---|
510 | zsmlres(:,:) = 0. |
---|
511 | |
---|
512 | IF( MOD( kt - nit000+1, nwrite ) == 0 ) THEN |
---|
513 | |
---|
514 | ! V.1 compute total trend |
---|
515 | ! ------------------------ |
---|
516 | |
---|
517 | zmean = float(nmoymltrd) |
---|
518 | |
---|
519 | ztmltot(:,:) = ( tml(:,:) - tmlbn(:,:) + tmlb(:,:) - tmlbb(:,:) ) / (zmean * 2. * rdt) |
---|
520 | zsmltot(:,:) = ( sml(:,:) - smlbn(:,:) + smlb(:,:) - smlbb(:,:) ) / (zmean * 2. * rdt) |
---|
521 | |
---|
522 | IF(idebug /= 0) THEN |
---|
523 | WRITE(numout,*) ' zmean = ',zmean |
---|
524 | WRITE(numout,*) ' debuging trd_mld: V.1 done' |
---|
525 | CALL FLUSH(numout) |
---|
526 | ENDIF |
---|
527 | |
---|
528 | |
---|
529 | ! V.2 compute residual |
---|
530 | ! --------------------- |
---|
531 | |
---|
532 | ztmlres(:,:) = ztmltot(:,:) - tmltrdm(:,:) / zmean |
---|
533 | zsmlres(:,:) = zsmltot(:,:) - smltrdm(:,:) / zmean |
---|
534 | |
---|
535 | |
---|
536 | ! Boundary conditions |
---|
537 | |
---|
538 | CALL lbc_lnk( ztmltot, 'T', 1. ) |
---|
539 | CALL lbc_lnk( ztmlres, 'T', 1. ) |
---|
540 | CALL lbc_lnk( zsmltot, 'T', 1. ) |
---|
541 | CALL lbc_lnk( zsmlres, 'T', 1. ) |
---|
542 | |
---|
543 | IF( idebug /= 0 ) THEN |
---|
544 | WRITE(numout,*) ' debuging trd_mld: V.2 done' |
---|
545 | CALL FLUSH(numout) |
---|
546 | ENDIF |
---|
547 | |
---|
548 | |
---|
549 | ! V.3 time evolution array swap |
---|
550 | ! ------------------------------ |
---|
551 | |
---|
552 | tmlbb(:,:) = tmlb(:,:) |
---|
553 | tmlbn(:,:) = tml (:,:) |
---|
554 | smlbb(:,:) = smlb(:,:) |
---|
555 | smlbn(:,:) = sml (:,:) |
---|
556 | |
---|
557 | IF( idebug /= 0 ) THEN |
---|
558 | WRITE(numout,*) ' debuging trd_mld: V.3 done' |
---|
559 | CALL FLUSH(numout) |
---|
560 | ENDIF |
---|
561 | |
---|
562 | |
---|
563 | ! V.4 zero cumulative array |
---|
564 | ! --------------------------- |
---|
565 | |
---|
566 | nmoymltrd = 0 |
---|
567 | |
---|
568 | tmltrdm(:,:) = 0. |
---|
569 | smltrdm(:,:) = 0. |
---|
570 | |
---|
571 | IF(idebug /= 0) THEN |
---|
572 | WRITE(numout,*) ' debuging trd_mld: IV.4 done' |
---|
573 | CALL FLUSH(numout) |
---|
574 | ENDIF |
---|
575 | |
---|
576 | ENDIF |
---|
577 | |
---|
578 | ! IV.5 write trends to output |
---|
579 | ! --------------------------- |
---|
580 | |
---|
581 | #if defined key_dimgout |
---|
582 | ! code for dimg mpp output |
---|
583 | IF ( MOD(kt,nwrite) == 0 ) THEN |
---|
584 | WRITE(clmode,'(f5.1,a)' ) nwrite*rdt/86400.,' days average' |
---|
585 | iyear = ndastp/10000 |
---|
586 | imon = (ndastp-iyear*10000)/100 |
---|
587 | iday = ndastp - imon*100 - iyear*10000 |
---|
588 | WRITE(clname,9000) TRIM(cexper),'MLDiags',iyear,imon,iday |
---|
589 | cltext=TRIM(cexper)//' mld diags'//TRIM(clmode) |
---|
590 | CALL dia_wri_dimg (clname, cltext, smltrd, jpltrd, '2') |
---|
591 | 9000 FORMAT(a,"_",a,"_y",i4.4,"m",i2.2,"d",i2.2,".dimgproc") |
---|
592 | END IF |
---|
593 | |
---|
594 | #else |
---|
595 | IF( kt >= nit000+1 ) THEN |
---|
596 | |
---|
597 | #include "trdmld_ncwrite.h90" |
---|
598 | |
---|
599 | IF( idebug /= 0 ) THEN |
---|
600 | WRITE(numout,*) ' debuging trd_mld: IV.5 done' |
---|
601 | CALL FLUSH(numout) |
---|
602 | ENDIF |
---|
603 | |
---|
604 | ENDIF |
---|
605 | |
---|
606 | IF( kt == nitend ) CALL histclo( nidtrd ) |
---|
607 | #endif |
---|
608 | |
---|
609 | END SUBROUTINE trd_mld |
---|
610 | |
---|
611 | #else |
---|
612 | !!---------------------------------------------------------------------- |
---|
613 | !! Default option : Empty module |
---|
614 | !!---------------------------------------------------------------------- |
---|
615 | LOGICAL, PUBLIC, PARAMETER :: lk_trdmld = .FALSE. !: momentum trend flag |
---|
616 | CONTAINS |
---|
617 | SUBROUTINE trd_mld( kt ) ! Empty routine |
---|
618 | WRITE(*,*) 'trd_mld: You should not have seen this print! error?', kt |
---|
619 | END SUBROUTINE trd_mld |
---|
620 | #endif |
---|
621 | |
---|
622 | !!====================================================================== |
---|
623 | END MODULE trdmld |
---|