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