[1279] | 1 | ! $Id: advtrac.f90 5324 2024-11-12 15:31:36Z abarral $ |
---|
[1146] | 2 | |
---|
[4056] | 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 | ! |
---|
[5282] | 11 | USE iniprint_mod_h |
---|
[5281] | 12 | USE comgeom2_mod_h |
---|
[5280] | 13 | USE comdissip_mod_h |
---|
[4143] | 14 | USE infotrac, ONLY: nqtot, tracers, isoCheck |
---|
[4056] | 15 | USE control_mod, ONLY: iapp_tracvl, day_step |
---|
| 16 | USE comconst_mod, ONLY: dtvr |
---|
[5258] | 17 | USE strings_mod, ONLY: int2str |
---|
[5271] | 18 | USE dimensions_mod, ONLY: iim, jjm, llm, ndm |
---|
[5323] | 19 | USE paramet_mod_h |
---|
[5271] | 20 | IMPLICIT NONE |
---|
[4056] | 21 | ! |
---|
[5271] | 22 | |
---|
[5272] | 23 | |
---|
[4056] | 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 | !--------------------------------------------------------------------------- |
---|
[4064] | 43 | INTEGER :: ij, l, iq, iadv |
---|
| 44 | ! REAL(KIND=KIND(1.d0)) :: t_initial, t_final, tps_cpu |
---|
[4056] | 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. |
---|
[524] | 62 | |
---|
[4056] | 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 |
---|
[524] | 67 | |
---|
[4056] | 68 | IF(iadvtr == 0) THEN |
---|
| 69 | pbaruc(:,:)=0 |
---|
| 70 | pbarvc(:,:)=0 |
---|
| 71 | END IF |
---|
[524] | 72 | |
---|
[4056] | 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 |
---|
[524] | 82 | |
---|
[4056] | 83 | !--- Selection de la masse instantannee des mailles avant le transport. |
---|
| 84 | IF(iadvtr == 0) THEN |
---|
[1549] | 85 | CALL SCOPY(ip1jmp1*llm,masse,1,massem,1) |
---|
[4056] | 86 | ! CALL filtreg ( massem ,jjp1, llm,-2, 2, .TRUE., 1 ) |
---|
| 87 | END IF |
---|
[524] | 88 | |
---|
[4056] | 89 | iadvtr = iadvtr+1 |
---|
| 90 | iapptrac = iadvtr |
---|
[524] | 91 | |
---|
[4056] | 92 | !--- Test pour savoir si on advecte a ce pas de temps |
---|
| 93 | IF(iadvtr /= iapp_tracvl) RETURN |
---|
[524] | 94 | |
---|
[4056] | 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. |
---|
[524] | 100 | |
---|
[4056] | 101 | CALL groupe(massem, pbaruc, pbarvc, pbarug, pbarvg, wg) |
---|
[524] | 102 | |
---|
[4056] | 103 | !--- Flux de masse diaganostiques traceurs |
---|
| 104 | flxw = wg / REAL(iapp_tracvl) |
---|
[524] | 105 | |
---|
[4056] | 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 |
---|
[524] | 118 | |
---|
[4056] | 119 | CALL minmax ( ip1jm-iip1, zdp(iip2), zdpmin,zdpmax ) |
---|
[524] | 120 | |
---|
[4056] | 121 | IF(MAX(ABS(zdpmin),ABS(zdpmax)) > 0.5) & |
---|
| 122 | WRITE(*,*)'WARNING DP/P l=',l,' MIN:',zdpmin,' MAX:', zdpmax |
---|
[524] | 123 | |
---|
[4056] | 124 | END DO |
---|
[524] | 125 | |
---|
[4056] | 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 |
---|
[524] | 134 | |
---|
[4056] | 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 |
---|
[1279] | 148 | |
---|
[4056] | 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 |
---|
[1279] | 154 | |
---|
[4056] | 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 |
---|
[1279] | 164 | |
---|
[4056] | 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 |
---|
[1279] | 174 | |
---|
[4056] | 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 |
---|
[1279] | 180 | |
---|
[4056] | 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 |
---|
[1279] | 192 | |
---|
[4056] | 193 | !--------------------------------------------------------------------------- |
---|
| 194 | ! Advection proprement dite (Modification Le Croller (07/2001) |
---|
| 195 | !--------------------------------------------------------------------------- |
---|
[1279] | 196 | |
---|
[4056] | 197 | !--------------------------------------------------------------------------- |
---|
| 198 | ! Calcul des moyennes basees sur la masse |
---|
| 199 | !--------------------------------------------------------------------------- |
---|
| 200 | CALL massbar(massem,massebx,masseby) |
---|
[1549] | 201 | |
---|
[4143] | 202 | IF(isoCheck) WRITE(*,*) 'advtrac 227' |
---|
| 203 | CALL check_isotopes_seq(q,ip1jmp1,'advtrac 162') |
---|
[524] | 204 | |
---|
[4056] | 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 | !----------------------------------------------------------------------- |
---|
[4050] | 215 | CASE(0); CYCLE |
---|
[4056] | 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) |
---|
[524] | 221 | |
---|
[4056] | 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) |
---|
[960] | 228 | |
---|
[4056] | 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 |
---|
[524] | 237 | |
---|
[4056] | 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 |
---|
[524] | 246 | |
---|
[4056] | 247 | !-------------------------------------------------------------------- |
---|
| 248 | CASE(20) !--- Schema de pente SLOPES |
---|
| 249 | !-------------------------------------------------------------------- |
---|
| 250 | CALL pentes_ini (q(1,1,iq),wg,massem,pbarug,pbarvg,0) |
---|
[524] | 251 | |
---|
[4056] | 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) |
---|
[524] | 259 | |
---|
[4056] | 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) |
---|
[524] | 283 | |
---|
[4056] | 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 | !---------------------------------------------------------------------- |
---|
[524] | 318 | |
---|
[4056] | 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) |
---|
[524] | 323 | |
---|
[4056] | 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 |
---|
[524] | 328 | |
---|
[4056] | 329 | END DO |
---|
[524] | 330 | |
---|
[4143] | 331 | IF(isoCheck) WRITE(*,*) 'advtrac 402' |
---|
| 332 | CALL check_isotopes_seq(q,ip1jmp1,'advtrac 397') |
---|
[524] | 333 | |
---|
[4056] | 334 | !------------------------------------------------------------------------- |
---|
| 335 | ! on reinitialise a zero les flux de masse cumules |
---|
| 336 | !------------------------------------------------------------------------- |
---|
| 337 | iadvtr=0 |
---|
[524] | 338 | |
---|
[1549] | 339 | END SUBROUTINE advtrac |
---|