/[lmdze]/trunk/Sources/phylmd/phytrac.f
ViewVC logotype

Contents of /trunk/Sources/phylmd/phytrac.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 156 - (show annotations)
Thu Jul 16 17:39:10 2015 UTC (8 years, 10 months ago) by guez
File size: 15771 byte(s)
In procedure cltracrn, no need for local variable zx_trs, use directly
local_trs.

In (re)startphy.nc, agglomerate variables for different surface types
into a single variable with an added dimension.

In phyredem, bring together all definitions, do not use redef.

1 module phytrac_m
2
3 IMPLICIT none
4
5 private
6 public phytrac
7
8 contains
9
10 SUBROUTINE phytrac(itap, lmt_pas, julien, gmtime, firstcal, lafin, pdtphys, &
11 t_seri, paprs, pplay, pmfu, pmfd, pde_u, pen_d, coefh, fm_therm, &
12 entr_therm, yu1, yv1, ftsol, pctsrf, frac_impa, frac_nucl, pphis, da, &
13 phi, mp, upwd, dnwd, tr_seri, zmasse)
14
15 ! From phylmd/phytrac.F, version 1.15 2006/02/21 08:08:30 (SVN revision 679)
16
17 ! Authors: Fr\'ed\'eric Hourdin, Abderrahmane Idelkadi, Marie-Alice
18 ! Foujols, Olivia
19
20 ! Objet : moniteur g\'en\'eral des tendances des traceurs
21
22 ! L'appel de "phytrac" se fait avec "nqmx - 2" donc nous avons
23 ! bien les vrais traceurs, sans la vapeur d'eau ni l'eau liquide.
24
25 ! Modifications pour les traceurs :
26 ! - uniformisation des parametrisations dans phytrac
27 ! - stockage des moyennes des champs n\'ecessaires en mode traceur off-line
28
29 use abort_gcm_m, only: abort_gcm
30 use clesphys, only: ecrit_tra
31 use clesphys2, only: iflag_con
32 use cltrac_m, only: cltrac
33 use cltracrn_m, only: cltracrn
34 use ctherm, only: iflag_thermals
35 use cvltr_m, only: cvltr
36 use dimens_m, only: llm, nqmx
37 use dimphy, only: klon
38 use indicesol, only: nbsrf
39 use ini_histrac_m, only: ini_histrac
40 use initrrnpb_m, only: initrrnpb
41 use minmaxqfi_m, only: minmaxqfi
42 use nflxtr_m, only: nflxtr
43 use nr_util, only: assert
44 use o3_chem_m, only: o3_chem
45 use phyetat0_m, only: rlat
46 use press_coefoz_m, only: press_coefoz
47 use radiornpb_m, only: radiornpb
48 use regr_pr_comb_coefoz_m, only: regr_pr_comb_coefoz
49 use SUPHEC_M, only: rg
50
51 integer, intent(in):: itap ! number of calls to "physiq"
52 integer, intent(in):: lmt_pas ! number of time steps of "physics" per day
53 integer, intent(in):: julien !jour julien, 1 <= julien <= 360
54 real, intent(in):: gmtime ! heure de la journ\'ee en fraction de jour
55 logical, intent(in):: firstcal ! first call to "calfis"
56 logical, intent(in):: lafin ! fin de la physique
57 real, intent(in):: pdtphys ! pas d'integration pour la physique (s)
58 real, intent(in):: t_seri(klon, llm) ! temperature, in K
59
60 real, intent(in):: paprs(klon, llm+1)
61 ! (pression pour chaque inter-couche, en Pa)
62
63 real, intent(in):: pplay(klon, llm)
64 ! (pression pour le mileu de chaque couche, en Pa)
65
66 ! convection:
67
68 REAL, intent(in):: pmfu(klon, llm) ! flux de masse dans le panache montant
69
70 REAL, intent(in):: pmfd(klon, llm)
71 ! flux de masse dans le panache descendant
72
73 REAL pde_u(klon, llm) ! flux detraine dans le panache montant
74 REAL pen_d(klon, llm) ! flux entraine dans le panache descendant
75 REAL coefh(klon, llm) ! coeff melange couche limite
76
77 ! thermiques:
78 real fm_therm(klon, llm+1), entr_therm(klon, llm)
79
80 ! Couche limite:
81 REAL yu1(klon) ! vents au premier niveau
82 REAL yv1(klon) ! vents au premier niveau
83
84 ! Arguments n\'ecessaires pour les sources et puits de traceur :
85 real, intent(in):: ftsol(klon, nbsrf) ! Temperature du sol (surf)(Kelvin)
86 real pctsrf(klon, nbsrf) ! Pourcentage de sol f(nature du sol)
87
88 ! Lessivage pour le on-line
89 REAL frac_impa(klon, llm) ! fraction d'aerosols impactes
90 REAL frac_nucl(klon, llm) ! fraction d'aerosols nuclees
91
92 real, intent(in):: pphis(klon)
93
94 ! Kerry Emanuel
95 real, intent(in):: da(klon, llm), phi(klon, llm, llm), mp(klon, llm)
96 REAL, intent(in):: upwd(klon, llm) ! saturated updraft mass flux
97 REAL, intent(in):: dnwd(klon, llm) ! saturated downdraft mass flux
98
99 real, intent(inout):: tr_seri(:, :, :) ! (klon, llm, nqmx - 2)
100 ! (mass fractions of tracers, excluding water, at mid-layers)
101
102 real, intent(in):: zmasse(:, :) ! (klon, llm)
103 ! (column-density of mass of air in a cell, in kg m-2)
104
105 ! Variables local to the procedure:
106
107 integer nsplit
108
109 ! TRACEURS
110
111 ! Sources et puits des traceurs:
112
113 ! Pour l'instant seuls les cas du rn et du pb ont ete envisages.
114
115 REAL source(klon) ! a voir lorsque le flux est prescrit
116 !
117 ! Pour la source de radon et son reservoir de sol
118
119 REAL, save:: trs(klon, nqmx - 2) ! Concentration de traceur dans le sol
120
121 REAL masktr(klon, nqmx - 2) ! Masque reservoir de sol traceur
122 ! Masque de l'echange avec la surface
123 ! (1 = reservoir) ou (possible => 1)
124 SAVE masktr
125 REAL fshtr(klon, nqmx - 2) ! Flux surfacique dans le reservoir de sol
126 SAVE fshtr
127 REAL hsoltr(nqmx - 2) ! Epaisseur equivalente du reservoir de sol
128 SAVE hsoltr
129 REAL tautr(nqmx - 2) ! Constante de decroissance radioactive
130 SAVE tautr
131 REAL vdeptr(nqmx - 2) ! Vitesse de depot sec dans la couche Brownienne
132 SAVE vdeptr
133 REAL scavtr(nqmx - 2) ! Coefficient de lessivage
134 SAVE scavtr
135
136 CHARACTER itn
137 INTEGER, save:: nid_tra
138
139 ! nature du traceur
140
141 logical aerosol(nqmx - 2) ! Nature du traceur
142 ! ! aerosol(it) = true => aerosol
143 ! ! aerosol(it) = false => gaz
144 logical clsol(nqmx - 2) ! couche limite sol calcul\'ee
145 logical radio(nqmx - 2) ! d\'ecroisssance radioactive
146 save aerosol, clsol, radio
147
148 ! convection tiedtke
149 INTEGER i, k, it
150 REAL delp(klon, llm)
151
152 ! Variables liees a l'ecriture de la bande histoire physique
153
154 ! Variables locales pour effectuer les appels en serie
155
156 REAL d_tr(klon, llm), d_trs(klon) ! tendances de traceurs
157 REAL d_tr_cl(klon, llm, nqmx - 2) ! tendance de traceurs couche limite
158
159 REAL d_tr_cv(klon, llm, nqmx - 2)
160 ! tendance de traceurs conv pour chq traceur
161
162 REAL d_tr_th(klon, llm, nqmx - 2) ! la tendance des thermiques
163 REAL d_tr_dec(klon, llm, 2) ! la tendance de la decroissance
164 ! ! radioactive du rn - > pb
165 REAL d_tr_lessi_impa(klon, llm, nqmx - 2) ! la tendance du lessivage
166 ! ! par impaction
167 REAL d_tr_lessi_nucl(klon, llm, nqmx - 2) ! la tendance du lessivage
168 ! ! par nucleation
169 REAL flestottr(klon, llm, nqmx - 2) ! flux de lessivage
170 ! ! dans chaque couche
171
172 real ztra_th(klon, llm)
173 integer isplit
174
175 ! Controls:
176 logical:: couchelimite = .true.
177 logical:: convection = .true.
178 logical:: lessivage = .true.
179 logical, save:: inirnpb
180
181 !--------------------------------------
182
183 call assert(shape(zmasse) == (/klon, llm/), "phytrac zmasse")
184 call assert(shape(tr_seri) == (/klon, llm, nqmx - 2/), "phytrac tr_seri")
185
186 if (firstcal) then
187 print *, 'phytrac: pdtphys = ', pdtphys
188 PRINT *, 'Frequency of tracer output: ecrit_tra = ', ecrit_tra
189 inirnpb = .true.
190
191 ! Initialisation des sorties :
192 call ini_histrac(nid_tra, pdtphys, nqmx - 2, lessivage)
193
194 ! Initialisation de certaines variables pour le radon et le plomb
195 ! Initialisation du traceur dans le sol (couche limite radonique)
196 trs(:, :) = 0.
197
198 open (unit=99, file='starttrac', status='old', err=999, &
199 form='formatted')
200 read(unit=99, fmt=*) (trs(i, 1), i=1, klon)
201 999 continue
202 close(unit=99)
203
204 ! Initialisation de la fraction d'aerosols lessivee
205
206 d_tr_lessi_impa = 0.
207 d_tr_lessi_nucl = 0.
208
209 ! Initialisation de la nature des traceurs
210
211 DO it = 1, nqmx - 2
212 aerosol(it) = .FALSE. ! Tous les traceurs sont des gaz par defaut
213 radio(it) = .FALSE. ! par d\'efaut pas de passage par "radiornpb"
214 clsol(it) = .FALSE. ! Par defaut couche limite avec flux prescrit
215 ENDDO
216
217 if (nqmx >= 5) then
218 call press_coefoz ! read input pressure levels for ozone coefficients
219 end if
220 ENDIF
221
222 if (inirnpb) THEN
223 ! Initialisation du traceur dans le sol (couche limite radonique)
224 radio(1)= .true.
225 radio(2)= .true.
226 clsol(1)= .true.
227 clsol(2)= .true.
228 aerosol(2) = .TRUE. ! le Pb est un aerosol
229 call initrrnpb(pctsrf, masktr, fshtr, hsoltr, tautr, vdeptr, scavtr)
230 inirnpb=.false.
231 endif
232
233 if (convection) then
234 ! Calcul de l'effet de la convection
235 DO it=1, nqmx - 2
236 if (iflag_con == 2) then
237 ! Tiedke
238 CALL nflxtr(pdtphys, pmfu, pmfd, pde_u, pen_d, paprs, &
239 tr_seri(:, :, it), d_tr_cv(:, :, it))
240 else if (iflag_con == 3) then
241 ! Emanuel
242 call cvltr(pdtphys, da, phi, mp, paprs, tr_seri(:, :, it), upwd, &
243 dnwd, d_tr_cv(:, :, it))
244 endif
245
246 DO k = 1, llm
247 DO i = 1, klon
248 tr_seri(i, k, it) = tr_seri(i, k, it) + d_tr_cv(i, k, it)
249 ENDDO
250 ENDDO
251 WRITE(unit=itn, fmt='(i1)') it
252 CALL minmaxqfi(tr_seri(:, :, it), 0., 1e33, &
253 'convection, tracer index = ' // itn)
254 ENDDO
255 endif
256
257 ! Calcul de l'effet des thermiques
258
259 do it=1, nqmx - 2
260 do k=1, llm
261 do i=1, klon
262 d_tr_th(i, k, it)=0.
263 tr_seri(i, k, it)=max(tr_seri(i, k, it), 0.)
264 tr_seri(i, k, it)=min(tr_seri(i, k, it), 1e10)
265 enddo
266 enddo
267 enddo
268
269 if (iflag_thermals > 0) then
270 nsplit=10
271 DO it=1, nqmx - 2
272 do isplit=1, nsplit
273 ! Thermiques
274 call dqthermcell(klon, llm, pdtphys/nsplit &
275 , fm_therm, entr_therm, zmasse &
276 , tr_seri(1:klon, 1:llm, it), d_tr, ztra_th)
277
278 do k=1, llm
279 do i=1, klon
280 d_tr(i, k)=pdtphys*d_tr(i, k)/nsplit
281 d_tr_th(i, k, it)=d_tr_th(i, k, it)+d_tr(i, k)
282 tr_seri(i, k, it)=max(tr_seri(i, k, it)+d_tr(i, k), 0.)
283 enddo
284 enddo
285 enddo
286 ENDDO
287 endif
288
289 ! Calcul de l'effet de la couche limite
290
291 if (couchelimite) then
292 DO k = 1, llm
293 DO i = 1, klon
294 delp(i, k) = paprs(i, k)-paprs(i, k+1)
295 ENDDO
296 ENDDO
297
298 ! MAF modif pour tenir compte du cas traceur
299 DO it=1, nqmx - 2
300 if (clsol(it)) then
301 ! couche limite avec quantite dans le sol calculee
302 CALL cltracrn(it, pdtphys, yu1, yv1, coefh, t_seri, ftsol, &
303 pctsrf, tr_seri(:, :, it), trs(:, it), paprs, pplay, delp, &
304 masktr(1, it), fshtr(1, it), hsoltr(it), tautr(it), &
305 vdeptr(it), rlat, d_tr_cl(1, 1, it), d_trs)
306 DO k = 1, llm
307 DO i = 1, klon
308 tr_seri(i, k, it) = tr_seri(i, k, it) + d_tr_cl(i, k, it)
309 ENDDO
310 ENDDO
311
312 trs(:, it) = trs(:, it) + d_trs
313 else
314 ! couche limite avec flux prescrit
315 !MAF provisoire source / traceur a creer
316 DO i=1, klon
317 source(i) = 0. ! pas de source, pour l'instant
318 ENDDO
319
320 CALL cltrac(pdtphys, coefh, t_seri, tr_seri(:, :, it), source, &
321 paprs, pplay, delp, d_tr_cl(1, 1, it))
322 DO k = 1, llm
323 DO i = 1, klon
324 tr_seri(i, k, it) = tr_seri(i, k, it) + d_tr_cl(i, k, it)
325 ENDDO
326 ENDDO
327 endif
328 ENDDO
329 endif
330
331 ! Calcul de l'effet du puits radioactif
332
333 ! MAF il faudrait faire une modification pour passer dans radiornpb
334 ! si radio=true
335 d_tr_dec = radiornpb(tr_seri, pdtphys, tautr)
336 DO it = 1, nqmx - 2
337 if (radio(it)) then
338 tr_seri(:, :, it) = tr_seri(:, :, it) + d_tr_dec(:, :, it)
339 WRITE(unit=itn, fmt='(i1)') it
340 CALL minmaxqfi(tr_seri(:, :, it), 0., 1e33, 'puits rn it='//itn)
341 endif
342 ENDDO
343
344 if (nqmx >= 5) then
345 ! Ozone as a tracer:
346 if (mod(itap - 1, lmt_pas) == 0) then
347 ! Once per day, update the coefficients for ozone chemistry:
348 call regr_pr_comb_coefoz(julien)
349 end if
350 call o3_chem(julien, gmtime, t_seri, zmasse, pdtphys, tr_seri(:, :, 3))
351 end if
352
353 ! Calcul de l'effet de la precipitation
354
355 IF (lessivage) THEN
356 d_tr_lessi_nucl = 0.
357 d_tr_lessi_impa = 0.
358 flestottr = 0.
359
360 ! tendance des aerosols nuclees et impactes
361
362 DO it = 1, nqmx - 2
363 IF (aerosol(it)) THEN
364 DO k = 1, llm
365 DO i = 1, klon
366 d_tr_lessi_nucl(i, k, it) = d_tr_lessi_nucl(i, k, it) + &
367 (1 - frac_nucl(i, k))*tr_seri(i, k, it)
368 d_tr_lessi_impa(i, k, it) = d_tr_lessi_impa(i, k, it) + &
369 (1 - frac_impa(i, k))*tr_seri(i, k, it)
370 ENDDO
371 ENDDO
372 ENDIF
373 ENDDO
374
375 ! Mises a jour des traceurs + calcul des flux de lessivage
376 ! Mise a jour due a l'impaction et a la nucleation
377
378 DO it = 1, nqmx - 2
379 IF (aerosol(it)) THEN
380 DO k = 1, llm
381 DO i = 1, klon
382 tr_seri(i, k, it) = tr_seri(i, k, it) * frac_impa(i, k) &
383 * frac_nucl(i, k)
384 ENDDO
385 ENDDO
386 ENDIF
387 ENDDO
388
389 ! Flux lessivage total
390
391 DO it = 1, nqmx - 2
392 DO k = 1, llm
393 DO i = 1, klon
394 flestottr(i, k, it) = flestottr(i, k, it) &
395 - (d_tr_lessi_nucl(i, k, it) + d_tr_lessi_impa(i, k, it)) &
396 * (paprs(i, k)-paprs(i, k+1)) / (RG * pdtphys)
397 ENDDO
398 ENDDO
399 ENDDO
400 ENDIF
401
402 ! Ecriture des sorties
403 call write_histrac(lessivage, itap, nid_tra)
404
405 if (lafin) then
406 print *, "C'est la fin de la physique."
407 open(unit=99, file='restarttrac', form='formatted')
408 do i=1, klon
409 write(unit=99, fmt=*) trs(i, 1)
410 enddo
411 PRINT *, 'Ecriture du fichier restarttrac'
412 close(unit=99)
413 endif
414
415 contains
416
417 subroutine write_histrac(lessivage, itap, nid_tra)
418
419 ! From phylmd/write_histrac.h, version 1.9 2006/02/21 08:08:30
420
421 use dimens_m, only: iim, jjm, llm
422 use histsync_m, only: histsync
423 use histwrite_m, only: histwrite
424 use temps, only: itau_phy
425 use iniadvtrac_m, only: tname
426 use comgeomphy, only: airephy
427 use dimphy, only: klon
428 use grid_change, only: gr_phy_write_2d
429 use gr_phy_write_3d_m, only: gr_phy_write_3d
430
431 logical, intent(in):: lessivage
432 integer, intent(in):: itap ! number of calls to "physiq"
433 integer, intent(in):: nid_tra
434
435 ! Variables local to the procedure:
436 integer it
437 integer itau_w ! pas de temps ecriture
438 logical, parameter:: ok_sync = .true.
439
440 !-----------------------------------------------------
441
442 itau_w = itau_phy + itap
443
444 CALL histwrite(nid_tra, "phis", itau_w, gr_phy_write_2d(pphis))
445 CALL histwrite(nid_tra, "aire", itau_w, gr_phy_write_2d(airephy))
446 CALL histwrite(nid_tra, "zmasse", itau_w, gr_phy_write_3d(zmasse))
447
448 DO it=1, nqmx - 2
449 CALL histwrite(nid_tra, tname(it+2), itau_w, &
450 gr_phy_write_3d(tr_seri(:, :, it)))
451 if (lessivage) THEN
452 CALL histwrite(nid_tra, "fl"//tname(it+2), itau_w, &
453 gr_phy_write_3d(flestottr(:, :, it)))
454 endif
455 CALL histwrite(nid_tra, "d_tr_th_"//tname(it+2), itau_w, &
456 gr_phy_write_3d(d_tr_th(:, :, it)))
457 CALL histwrite(nid_tra, "d_tr_cv_"//tname(it+2), itau_w, &
458 gr_phy_write_3d(d_tr_cv(:, :, it)))
459 CALL histwrite(nid_tra, "d_tr_cl_"//tname(it+2), itau_w, &
460 gr_phy_write_3d(d_tr_cl(:, :, it)))
461 ENDDO
462
463 CALL histwrite(nid_tra, "pplay", itau_w, gr_phy_write_3d(pplay))
464 CALL histwrite(nid_tra, "T", itau_w, gr_phy_write_3d(t_seri))
465
466 if (ok_sync) then
467 call histsync(nid_tra)
468 endif
469
470 end subroutine write_histrac
471
472 END SUBROUTINE phytrac
473
474 end module phytrac_m

  ViewVC Help
Powered by ViewVC 1.1.21