1 | ! $Id: advtrac.f90 5119 2024-07-24 16:46:45Z abarral $ |
---|
2 | |
---|
3 | SUBROUTINE advtrac(pbaru, pbarv, p, masse, q, iapptrac, teta, flxw, pk) |
---|
4 | ! Auteur : F. Hourdin |
---|
5 | |
---|
6 | ! Modif. P. Le Van (20/12/97) |
---|
7 | ! F. Codron (10/99) |
---|
8 | ! D. Le Croller (07/2001) |
---|
9 | ! M.A Filiberti (04/2002) |
---|
10 | |
---|
11 | USE infotrac, ONLY: nqtot, tracers, isoCheck |
---|
12 | USE control_mod, ONLY: iapp_tracvl, day_step |
---|
13 | USE comconst_mod, ONLY: dtvr |
---|
14 | USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_DEBUGIO |
---|
15 | USE lmdz_strings, ONLY: int2str |
---|
16 | USE lmdz_description, ONLY: descript |
---|
17 | USE lmdz_libmath, ONLY: minmax |
---|
18 | USE lmdz_iniprint, ONLY: lunout, prt_level |
---|
19 | USE lmdz_ssum_scopy, ONLY: scopy |
---|
20 | |
---|
21 | IMPLICIT NONE |
---|
22 | |
---|
23 | include "dimensions.h" |
---|
24 | include "paramet.h" |
---|
25 | include "comdissip.h" |
---|
26 | include "comgeom2.h" |
---|
27 | |
---|
28 | !--------------------------------------------------------------------------- |
---|
29 | ! Arguments |
---|
30 | !--------------------------------------------------------------------------- |
---|
31 | INTEGER, INTENT(OUT) :: iapptrac |
---|
32 | REAL, INTENT(IN) :: pbaru(ip1jmp1, llm) |
---|
33 | REAL, INTENT(IN) :: pbarv(ip1jm, llm) |
---|
34 | REAL, INTENT(INOUT) :: q(ip1jmp1, llm, nqtot) |
---|
35 | REAL, INTENT(IN) :: masse(ip1jmp1, llm) |
---|
36 | REAL, INTENT(IN) :: p(ip1jmp1, llmp1) |
---|
37 | REAL, INTENT(IN) :: teta(ip1jmp1, llm) |
---|
38 | REAL, INTENT(IN) :: pk(ip1jmp1, llm) |
---|
39 | REAL, INTENT(OUT) :: flxw(ip1jmp1, llm) |
---|
40 | !--------------------------------------------------------------------------- |
---|
41 | ! Ajout PPM |
---|
42 | !--------------------------------------------------------------------------- |
---|
43 | REAL :: massebx(ip1jmp1, llm), masseby(ip1jm, llm) |
---|
44 | !--------------------------------------------------------------------------- |
---|
45 | ! Variables locales |
---|
46 | !--------------------------------------------------------------------------- |
---|
47 | INTEGER :: ij, l, iq, iadv |
---|
48 | ! REAL(KIND=KIND(1.d0)) :: t_initial, t_final, tps_cpu |
---|
49 | REAL :: zdp(ip1jmp1), zdpmin, zdpmax |
---|
50 | INTEGER, SAVE :: iadvtr = 0 |
---|
51 | REAL, DIMENSION(ip1jmp1, llm) :: pbaruc, pbarug, massem, wg |
---|
52 | REAL, DIMENSION(ip1jm, llm) :: pbarvc, pbarvg |
---|
53 | SAVE massem, pbaruc, pbarvc |
---|
54 | !--------------------------------------------------------------------------- |
---|
55 | ! Rajouts pour PPM |
---|
56 | !--------------------------------------------------------------------------- |
---|
57 | INTEGER indice, n |
---|
58 | REAL :: dtbon ! Pas de temps adaptatif pour que CFL<1 |
---|
59 | REAL :: CFLmaxz, aaa, bbb ! CFL maximum |
---|
60 | REAL, DIMENSION(iim, jjp1, llm) :: unatppm, vnatppm, fluxwppm |
---|
61 | REAL :: qppm(iim * jjp1, llm, nqtot) |
---|
62 | REAL :: psppm(iim, jjp1) ! pression au sol |
---|
63 | REAL, DIMENSION(llmp1) :: apppm, bpppm |
---|
64 | LOGICAL, SAVE :: dum = .TRUE., fill = .TRUE. |
---|
65 | |
---|
66 | INTEGER, SAVE :: countcfl = 0 |
---|
67 | REAL, DIMENSION(ip1jmp1, llm) :: cflx, cflz |
---|
68 | REAL, DIMENSION(ip1jm, llm) :: cfly |
---|
69 | REAL, DIMENSION(llm), SAVE :: cflxmax, cflymax, cflzmax |
---|
70 | |
---|
71 | IF(iadvtr == 0) THEN |
---|
72 | pbaruc(:, :) = 0 |
---|
73 | pbarvc(:, :) = 0 |
---|
74 | END IF |
---|
75 | |
---|
76 | !--- Accumulation des flux de masse horizontaux |
---|
77 | DO l = 1, llm |
---|
78 | DO ij = 1, ip1jmp1 |
---|
79 | pbaruc(ij, l) = pbaruc(ij, l) + pbaru(ij, l) |
---|
80 | END DO |
---|
81 | DO ij = 1, ip1jm |
---|
82 | pbarvc(ij, l) = pbarvc(ij, l) + pbarv(ij, l) |
---|
83 | END DO |
---|
84 | END DO |
---|
85 | |
---|
86 | !--- Selection de la masse instantannee des mailles avant le transport. |
---|
87 | IF(iadvtr == 0) THEN |
---|
88 | CALL SCOPY(ip1jmp1 * llm, masse, 1, massem, 1) |
---|
89 | ! CALL filtreg ( massem ,jjp1, llm,-2, 2, .TRUE., 1 ) |
---|
90 | END IF |
---|
91 | |
---|
92 | iadvtr = iadvtr + 1 |
---|
93 | iapptrac = iadvtr |
---|
94 | |
---|
95 | !--- Test pour savoir si on advecte a ce pas de temps |
---|
96 | IF(iadvtr /= iapp_tracvl) RETURN |
---|
97 | |
---|
98 | ! .. Modif P.Le Van ( 20/12/97 ) .... |
---|
99 | |
---|
100 | ! traitement des flux de masse avant advection. |
---|
101 | ! 1. calcul de w |
---|
102 | ! 2. groupement des mailles pres du pole. |
---|
103 | |
---|
104 | CALL groupe(massem, pbaruc, pbarvc, pbarug, pbarvg, wg) |
---|
105 | |
---|
106 | !--- Flux de masse diaganostiques traceurs |
---|
107 | flxw = wg / REAL(iapp_tracvl) |
---|
108 | |
---|
109 | !--- Test sur l'eventuelle creation de valeurs negatives de la masse |
---|
110 | DO l = 1, llm - 1 |
---|
111 | DO ij = iip2 + 1, ip1jm |
---|
112 | zdp(ij) = pbarug(ij - 1, l) - pbarug(ij, l) & |
---|
113 | - pbarvg(ij - iip1, l) + pbarvg(ij, l) & |
---|
114 | + wg(ij, l + 1) - wg(ij, l) |
---|
115 | END DO |
---|
116 | ! ym ---> pourquoi jjm-1 et non jjm ? a cause du pole ? |
---|
117 | CALL SCOPY(jjm - 1, zdp(iip1 + iip1), iip1, zdp(iip2), iip1) |
---|
118 | DO ij = iip2, ip1jm |
---|
119 | zdp(ij) = zdp(ij) * dtvr / massem(ij, l) |
---|
120 | END DO |
---|
121 | |
---|
122 | CALL minmax (ip1jm - iip1, zdp(iip2), zdpmin, zdpmax) |
---|
123 | |
---|
124 | IF(MAX(ABS(zdpmin), ABS(zdpmax)) > 0.5) & |
---|
125 | WRITE(*, *)'WARNING DP/P l=', l, ' MIN:', zdpmin, ' MAX:', zdpmax |
---|
126 | |
---|
127 | END DO |
---|
128 | |
---|
129 | !------------------------------------------------------------------------- |
---|
130 | ! Calcul des criteres CFL en X, Y et Z |
---|
131 | !------------------------------------------------------------------------- |
---|
132 | IF(countcfl == 0.) THEN |
---|
133 | cflxmax(:) = 0. |
---|
134 | cflymax(:) = 0. |
---|
135 | cflzmax(:) = 0. |
---|
136 | END IF |
---|
137 | |
---|
138 | countcfl = countcfl + iapp_tracvl |
---|
139 | cflx(:, :) = 0. |
---|
140 | cfly(:, :) = 0. |
---|
141 | cflz(:, :) = 0. |
---|
142 | DO l = 1, llm |
---|
143 | DO ij = iip2, ip1jm - 1 |
---|
144 | IF(pbarug(ij, l)>=0.) THEN |
---|
145 | cflx(ij, l) = pbarug(ij, l) * dtvr / masse(ij, l) |
---|
146 | ELSE |
---|
147 | cflx(ij, l) = -pbarug(ij, l) * dtvr / masse(ij + 1, l) |
---|
148 | END IF |
---|
149 | END DO |
---|
150 | END DO |
---|
151 | |
---|
152 | DO l = 1, llm |
---|
153 | DO ij = iip2, ip1jm - 1, iip1 |
---|
154 | cflx(ij + iip1, l) = cflx(ij, l) |
---|
155 | END DO |
---|
156 | END DO |
---|
157 | |
---|
158 | DO l = 1, llm |
---|
159 | DO ij = 1, ip1jm |
---|
160 | IF(pbarvg(ij, l)>=0.) THEN |
---|
161 | cfly(ij, l) = pbarvg(ij, l) * dtvr / masse(ij, l) |
---|
162 | ELSE |
---|
163 | cfly(ij, l) = -pbarvg(ij, l) * dtvr / masse(ij + iip1, l) |
---|
164 | END IF |
---|
165 | END DO |
---|
166 | END DO |
---|
167 | |
---|
168 | DO l = 2, llm |
---|
169 | DO ij = 1, ip1jm |
---|
170 | IF(wg(ij, l) >= 0.) THEN |
---|
171 | cflz(ij, l) = wg(ij, l) * dtvr / masse(ij, l) |
---|
172 | ELSE |
---|
173 | cflz(ij, l) = -wg(ij, l) * dtvr / masse(ij, l - 1) |
---|
174 | END IF |
---|
175 | END DO |
---|
176 | END DO |
---|
177 | |
---|
178 | DO l = 1, llm |
---|
179 | cflxmax(l) = max(cflxmax(l), maxval(cflx(:, l))) |
---|
180 | cflymax(l) = max(cflymax(l), maxval(cfly(:, l))) |
---|
181 | cflzmax(l) = max(cflzmax(l), maxval(cflz(:, l))) |
---|
182 | END DO |
---|
183 | |
---|
184 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
185 | ! Par defaut, on sort le diagnostic des CFL tous les jours. |
---|
186 | ! Si on veut le sortir a chaque pas d'advection en cas de plantage |
---|
187 | ! IF(countcfl==iapp_tracvl) THEN |
---|
188 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
189 | IF(countcfl==day_step) THEN |
---|
190 | DO l = 1, llm |
---|
191 | WRITE(lunout, *) 'L, CFL[xyz]max:', l, cflxmax(l), cflymax(l), cflzmax(l) |
---|
192 | END DO |
---|
193 | countcfl = 0 |
---|
194 | END IF |
---|
195 | |
---|
196 | !--------------------------------------------------------------------------- |
---|
197 | ! Advection proprement dite (Modification Le Croller (07/2001) |
---|
198 | !--------------------------------------------------------------------------- |
---|
199 | |
---|
200 | !--------------------------------------------------------------------------- |
---|
201 | ! Calcul des moyennes basees sur la masse |
---|
202 | !--------------------------------------------------------------------------- |
---|
203 | CALL massbar(massem, massebx, masseby) |
---|
204 | |
---|
205 | IF (CPPKEY_DEBUGIO) THEN |
---|
206 | CALL WriteField_u('massem', massem) |
---|
207 | CALL WriteField_u('wg', wg) |
---|
208 | CALL WriteField_u('pbarug', pbarug) |
---|
209 | CALL WriteField_v('pbarvg', pbarvg) |
---|
210 | CALL WriteField_u('p_tmp', p) |
---|
211 | CALL WriteField_u('pk_tmp', pk) |
---|
212 | CALL WriteField_u('teta_tmp', teta) |
---|
213 | DO iq = 1, nqtot |
---|
214 | CALL WriteField_u('q_adv' // trim(int2str(iq)), q(:, :, iq)) |
---|
215 | END DO |
---|
216 | END IF |
---|
217 | |
---|
218 | IF(isoCheck) WRITE(*, *) 'advtrac 227' |
---|
219 | CALL check_isotopes_seq(q, ip1jmp1, 'advtrac 162') |
---|
220 | |
---|
221 | !------------------------------------------------------------------------- |
---|
222 | ! Appel des sous programmes d'advection |
---|
223 | !------------------------------------------------------------------------- |
---|
224 | DO iq = 1, nqtot |
---|
225 | ! CALL clock(t_initial) |
---|
226 | IF(tracers(iq)%parent /= 'air') CYCLE |
---|
227 | iadv = tracers(iq)%iadv |
---|
228 | !----------------------------------------------------------------------- |
---|
229 | SELECT CASE(iadv) |
---|
230 | !----------------------------------------------------------------------- |
---|
231 | CASE(0); CYCLE |
---|
232 | !-------------------------------------------------------------------- |
---|
233 | CASE(10) !--- Schema de Van Leer I MUSCL |
---|
234 | !-------------------------------------------------------------------- |
---|
235 | ! WRITE(*,*) 'advtrac 239: iq,q(1721,19,:)=',iq,q(1721,19,:) |
---|
236 | CALL vlsplt(q, 2., massem, wg, pbarug, pbarvg, dtvr, iq) |
---|
237 | |
---|
238 | !-------------------------------------------------------------------- |
---|
239 | CASE(14) !--- Schema "pseuDO amont" + test sur humidite specifique |
---|
240 | !--- pour la vapeur d'eau. F. Codron |
---|
241 | !-------------------------------------------------------------------- |
---|
242 | ! WRITE(*,*) 'advtrac 248: iq,q(1721,19,:)=',iq,q(1721,19,:) |
---|
243 | CALL vlspltqs(q, 2., massem, wg, pbarug, pbarvg, dtvr, p, pk, teta, iq) |
---|
244 | |
---|
245 | !-------------------------------------------------------------------- |
---|
246 | CASE(12) !--- Schema de Frederic Hourdin |
---|
247 | !-------------------------------------------------------------------- |
---|
248 | CALL adaptdt(iadv, dtbon, n, pbarug, massem) ! pas de temps adaptatif |
---|
249 | IF(n > 1) WRITE(*, *) 'WARNING horizontal dt=', dtbon, 'dtvr=', dtvr, 'n=', n |
---|
250 | DO indice = 1, n |
---|
251 | CALL advn(q(1, 1, iq), massem, wg, pbarug, pbarvg, dtbon, 1) |
---|
252 | END DO |
---|
253 | |
---|
254 | !-------------------------------------------------------------------- |
---|
255 | CASE(13) !--- Pas de temps adaptatif |
---|
256 | !-------------------------------------------------------------------- |
---|
257 | CALL adaptdt(iadv, dtbon, n, pbarug, massem) |
---|
258 | IF(n > 1) WRITE(*, *) 'WARNING horizontal dt=', dtbon, 'dtvr=', dtvr, 'n=', n |
---|
259 | DO indice = 1, n |
---|
260 | CALL advn(q(1, 1, iq), massem, wg, pbarug, pbarvg, dtbon, 2) |
---|
261 | END DO |
---|
262 | |
---|
263 | !-------------------------------------------------------------------- |
---|
264 | CASE(20) !--- Schema de pente SLOPES |
---|
265 | !-------------------------------------------------------------------- |
---|
266 | CALL pentes_ini (q(1, 1, iq), wg, massem, pbarug, pbarvg, 0) |
---|
267 | |
---|
268 | !-------------------------------------------------------------------- |
---|
269 | CASE(30) !--- Schema de Prather |
---|
270 | !-------------------------------------------------------------------- |
---|
271 | ! Pas de temps adaptatif |
---|
272 | CALL adaptdt(iadv, dtbon, n, pbarug, massem) |
---|
273 | IF(n > 1) WRITE(*, *) 'WARNING horizontal dt=', dtbon, 'dtvr=', dtvr, 'n=', n |
---|
274 | CALL prather(q(1, 1, iq), wg, massem, pbarug, pbarvg, n, dtbon) |
---|
275 | |
---|
276 | !-------------------------------------------------------------------- |
---|
277 | CASE(11, 16, 17, 18) !--- Schemas PPM Lin et Rood |
---|
278 | !-------------------------------------------------------------------- |
---|
279 | ! Test sur le flux horizontal |
---|
280 | CALL adaptdt(iadv, dtbon, n, pbarug, massem) ! pas de temps adaptatif |
---|
281 | IF(n > 1) WRITE(*, *) 'WARNING horizontal dt=', dtbon, 'dtvr=', dtvr, 'n=', n |
---|
282 | ! Test sur le flux vertical |
---|
283 | CFLmaxz = 0. |
---|
284 | DO l = 2, llm |
---|
285 | DO ij = iip2, ip1jm |
---|
286 | aaa = wg(ij, l) * dtvr / massem(ij, l) |
---|
287 | CFLmaxz = max(CFLmaxz, aaa) |
---|
288 | bbb = -wg(ij, l) * dtvr / massem(ij, l - 1) |
---|
289 | CFLmaxz = max(CFLmaxz, bbb) |
---|
290 | END DO |
---|
291 | END DO |
---|
292 | IF(CFLmaxz>=1) WRITE(*, *) 'WARNING vertical', 'CFLmaxz=', CFLmaxz |
---|
293 | !---------------------------------------------------------------- |
---|
294 | ! Ss-prg interface LMDZ.4->PPM3d (ss-prg de Lin) |
---|
295 | !---------------------------------------------------------------- |
---|
296 | CALL interpre(q(1, 1, iq), qppm(1, 1, iq), wg, fluxwppm, massem, & |
---|
297 | apppm, bpppm, massebx, masseby, pbarug, pbarvg, & |
---|
298 | unatppm, vnatppm, psppm) |
---|
299 | |
---|
300 | !---------------------------------------------------------------- |
---|
301 | DO indice = 1, n !--- VL (version PPM) horiz. et PPM vert. |
---|
302 | !---------------------------------------------------------------- |
---|
303 | SELECT CASE(iadv) |
---|
304 | !---------------------------------------------------------- |
---|
305 | CASE(11) |
---|
306 | !---------------------------------------------------------- |
---|
307 | CALL ppm3d(1, qppm(1, 1, iq), psppm, psppm, unatppm, vnatppm, fluxwppm, dtbon, & |
---|
308 | 2, 2, 2, 1, iim, jjp1, 2, llm, apppm, bpppm, 0.01, 6400000, fill, dum, 220.) |
---|
309 | !---------------------------------------------------------- |
---|
310 | CASE(16) !--- Monotonic PPM |
---|
311 | !---------------------------------------------------------- |
---|
312 | CALL ppm3d(1, qppm(1, 1, iq), psppm, psppm, unatppm, vnatppm, fluxwppm, dtbon, & |
---|
313 | 3, 3, 3, 1, iim, jjp1, 2, llm, apppm, bpppm, 0.01, 6400000, fill, dum, 220.) |
---|
314 | !---------------------------------------------------------- |
---|
315 | CASE(17) !--- Semi monotonic PPM |
---|
316 | !---------------------------------------------------------- |
---|
317 | CALL ppm3d(1, qppm(1, 1, iq), psppm, psppm, unatppm, vnatppm, fluxwppm, dtbon, & |
---|
318 | 4, 4, 4, 1, iim, jjp1, 2, llm, apppm, bpppm, 0.01, 6400000, fill, dum, 220.) |
---|
319 | !---------------------------------------------------------- |
---|
320 | CASE(18) !--- Positive Definite PPM |
---|
321 | !---------------------------------------------------------- |
---|
322 | CALL ppm3d(1, qppm(1, 1, iq), psppm, psppm, unatppm, vnatppm, fluxwppm, dtbon, & |
---|
323 | 5, 5, 5, 1, iim, jjp1, 2, llm, apppm, bpppm, 0.01, 6400000, fill, dum, 220.) |
---|
324 | END SELECT |
---|
325 | !---------------------------------------------------------------- |
---|
326 | END DO |
---|
327 | !---------------------------------------------------------------- |
---|
328 | ! Ss-prg interface PPM3d-LMDZ.4 |
---|
329 | !---------------------------------------------------------------- |
---|
330 | CALL interpost(q(1, 1, iq), qppm(1, 1, iq)) |
---|
331 | !---------------------------------------------------------------------- |
---|
332 | END SELECT |
---|
333 | !---------------------------------------------------------------------- |
---|
334 | |
---|
335 | !---------------------------------------------------------------------- |
---|
336 | ! On impose une seule valeur du traceur au pole Sud j=jjm+1=jjp1 et Nord j=1 |
---|
337 | !---------------------------------------------------------------------- |
---|
338 | ! CALL traceurpole(q(1,1,iq),massem) |
---|
339 | |
---|
340 | !--- Calcul du temps cpu pour un schema donne |
---|
341 | ! CALL clock(t_final) |
---|
342 | !ym tps_cpu=t_final-t_initial |
---|
343 | !ym cpuadv(iq)=cpuadv(iq)+tps_cpu |
---|
344 | |
---|
345 | END DO |
---|
346 | |
---|
347 | IF(isoCheck) WRITE(*, *) 'advtrac 402' |
---|
348 | CALL check_isotopes_seq(q, ip1jmp1, 'advtrac 397') |
---|
349 | |
---|
350 | !------------------------------------------------------------------------- |
---|
351 | ! on reinitialise a zero les flux de masse cumules |
---|
352 | !------------------------------------------------------------------------- |
---|
353 | iadvtr = 0 |
---|
354 | |
---|
355 | END SUBROUTINE advtrac |
---|