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