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