[1279] | 1 | ! $Id: advtrac.F90 4143 2022-05-09 10:35:40Z aborella $ |
---|
[1146] | 2 | |
---|
[4056] | 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 | ! |
---|
[4143] | 13 | USE infotrac, ONLY: nqtot, tracers, isoCheck |
---|
[4056] | 14 | USE control_mod, ONLY: iapp_tracvl, day_step |
---|
| 15 | USE comconst_mod, ONLY: dtvr |
---|
[524] | 16 | |
---|
[4056] | 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" |
---|
[524] | 25 | |
---|
[4056] | 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 | !--------------------------------------------------------------------------- |
---|
[4064] | 45 | INTEGER :: ij, l, iq, iadv |
---|
| 46 | ! REAL(KIND=KIND(1.d0)) :: t_initial, t_final, tps_cpu |
---|
[4056] | 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. |
---|
[524] | 64 | |
---|
[4056] | 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 |
---|
[524] | 69 | |
---|
[4056] | 70 | IF(iadvtr == 0) THEN |
---|
| 71 | pbaruc(:,:)=0 |
---|
| 72 | pbarvc(:,:)=0 |
---|
| 73 | END IF |
---|
[524] | 74 | |
---|
[4056] | 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 |
---|
[524] | 84 | |
---|
[4056] | 85 | !--- Selection de la masse instantannee des mailles avant le transport. |
---|
| 86 | IF(iadvtr == 0) THEN |
---|
[1549] | 87 | CALL SCOPY(ip1jmp1*llm,masse,1,massem,1) |
---|
[4056] | 88 | ! CALL filtreg ( massem ,jjp1, llm,-2, 2, .TRUE., 1 ) |
---|
| 89 | END IF |
---|
[524] | 90 | |
---|
[4056] | 91 | iadvtr = iadvtr+1 |
---|
| 92 | iapptrac = iadvtr |
---|
[524] | 93 | |
---|
[4056] | 94 | !--- Test pour savoir si on advecte a ce pas de temps |
---|
| 95 | IF(iadvtr /= iapp_tracvl) RETURN |
---|
[524] | 96 | |
---|
[4056] | 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. |
---|
[524] | 102 | |
---|
[4056] | 103 | CALL groupe(massem, pbaruc, pbarvc, pbarug, pbarvg, wg) |
---|
[524] | 104 | |
---|
[4056] | 105 | !--- Flux de masse diaganostiques traceurs |
---|
| 106 | flxw = wg / REAL(iapp_tracvl) |
---|
[524] | 107 | |
---|
[4056] | 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 |
---|
[524] | 120 | |
---|
[4056] | 121 | CALL minmax ( ip1jm-iip1, zdp(iip2), zdpmin,zdpmax ) |
---|
[524] | 122 | |
---|
[4056] | 123 | IF(MAX(ABS(zdpmin),ABS(zdpmax)) > 0.5) & |
---|
| 124 | WRITE(*,*)'WARNING DP/P l=',l,' MIN:',zdpmin,' MAX:', zdpmax |
---|
[524] | 125 | |
---|
[4056] | 126 | END DO |
---|
[524] | 127 | |
---|
[4056] | 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 |
---|
[524] | 136 | |
---|
[4056] | 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 |
---|
[1279] | 150 | |
---|
[4056] | 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 |
---|
[1279] | 156 | |
---|
[4056] | 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 |
---|
[1279] | 166 | |
---|
[4056] | 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 |
---|
[1279] | 176 | |
---|
[4056] | 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 |
---|
[1279] | 182 | |
---|
[4056] | 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 |
---|
[1279] | 194 | |
---|
[4056] | 195 | !--------------------------------------------------------------------------- |
---|
| 196 | ! Advection proprement dite (Modification Le Croller (07/2001) |
---|
| 197 | !--------------------------------------------------------------------------- |
---|
[1279] | 198 | |
---|
[4056] | 199 | !--------------------------------------------------------------------------- |
---|
| 200 | ! Calcul des moyennes basees sur la masse |
---|
| 201 | !--------------------------------------------------------------------------- |
---|
| 202 | CALL massbar(massem,massebx,masseby) |
---|
[1549] | 203 | |
---|
[4056] | 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 |
---|
[1549] | 216 | |
---|
[4143] | 217 | IF(isoCheck) WRITE(*,*) 'advtrac 227' |
---|
| 218 | CALL check_isotopes_seq(q,ip1jmp1,'advtrac 162') |
---|
[524] | 219 | |
---|
[4056] | 220 | !------------------------------------------------------------------------- |
---|
| 221 | ! Appel des sous programmes d'advection |
---|
| 222 | !------------------------------------------------------------------------- |
---|
| 223 | DO iq = 1, nqtot |
---|
| 224 | ! CALL clock(t_initial) |
---|
| 225 | IF(tracers(iq)%parent /= 'air') CYCLE |
---|
| 226 | iadv = tracers(iq)%iadv |
---|
| 227 | !----------------------------------------------------------------------- |
---|
| 228 | SELECT CASE(iadv) |
---|
| 229 | !----------------------------------------------------------------------- |
---|
[4050] | 230 | CASE(0); CYCLE |
---|
[4056] | 231 | !-------------------------------------------------------------------- |
---|
| 232 | CASE(10) !--- Schema de Van Leer I MUSCL |
---|
| 233 | !-------------------------------------------------------------------- |
---|
| 234 | ! WRITE(*,*) 'advtrac 239: iq,q(1721,19,:)=',iq,q(1721,19,:) |
---|
| 235 | CALL vlsplt(q,2.,massem,wg,pbarug,pbarvg,dtvr,iq) |
---|
[524] | 236 | |
---|
[4056] | 237 | !-------------------------------------------------------------------- |
---|
| 238 | CASE(14) !--- Schema "pseuDO amont" + test sur humidite specifique |
---|
| 239 | !--- pour la vapeur d'eau. F. Codron |
---|
| 240 | !-------------------------------------------------------------------- |
---|
| 241 | ! WRITE(*,*) 'advtrac 248: iq,q(1721,19,:)=',iq,q(1721,19,:) |
---|
| 242 | CALL vlspltqs(q,2.,massem,wg,pbarug,pbarvg,dtvr,p,pk,teta,iq) |
---|
[960] | 243 | |
---|
[4056] | 244 | !-------------------------------------------------------------------- |
---|
| 245 | CASE(12) !--- Schema de Frederic Hourdin |
---|
| 246 | !-------------------------------------------------------------------- |
---|
| 247 | CALL adaptdt(iadv,dtbon,n,pbarug,massem) ! pas de temps adaptatif |
---|
| 248 | IF(n > 1) WRITE(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=',dtvr,'n=',n |
---|
| 249 | DO indice=1,n |
---|
| 250 | CALL advn(q(1,1,iq),massem,wg,pbarug,pbarvg,dtbon,1) |
---|
| 251 | END DO |
---|
[524] | 252 | |
---|
[4056] | 253 | !-------------------------------------------------------------------- |
---|
| 254 | CASE(13) !--- Pas de temps adaptatif |
---|
| 255 | !-------------------------------------------------------------------- |
---|
| 256 | CALL adaptdt(iadv,dtbon,n,pbarug,massem) |
---|
| 257 | IF(n > 1) WRITE(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=',dtvr,'n=',n |
---|
| 258 | DO indice=1,n |
---|
| 259 | CALL advn(q(1,1,iq),massem,wg,pbarug,pbarvg,dtbon,2) |
---|
| 260 | END DO |
---|
[524] | 261 | |
---|
[4056] | 262 | !-------------------------------------------------------------------- |
---|
| 263 | CASE(20) !--- Schema de pente SLOPES |
---|
| 264 | !-------------------------------------------------------------------- |
---|
| 265 | CALL pentes_ini (q(1,1,iq),wg,massem,pbarug,pbarvg,0) |
---|
[524] | 266 | |
---|
[4056] | 267 | !-------------------------------------------------------------------- |
---|
| 268 | CASE(30) !--- Schema de Prather |
---|
| 269 | !-------------------------------------------------------------------- |
---|
| 270 | ! Pas de temps adaptatif |
---|
| 271 | CALL adaptdt(iadv,dtbon,n,pbarug,massem) |
---|
| 272 | IF(n > 1) WRITE(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=',dtvr,'n=',n |
---|
| 273 | CALL prather(q(1,1,iq),wg,massem,pbarug,pbarvg,n,dtbon) |
---|
[524] | 274 | |
---|
[4056] | 275 | !-------------------------------------------------------------------- |
---|
| 276 | CASE(11,16,17,18) !--- Schemas PPM Lin et Rood |
---|
| 277 | !-------------------------------------------------------------------- |
---|
| 278 | ! Test sur le flux horizontal |
---|
| 279 | CALL adaptdt(iadv,dtbon,n,pbarug,massem) ! pas de temps adaptatif |
---|
| 280 | IF(n > 1) WRITE(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=',dtvr,'n=',n |
---|
| 281 | ! Test sur le flux vertical |
---|
| 282 | CFLmaxz=0. |
---|
| 283 | DO l=2,llm |
---|
| 284 | DO ij=iip2,ip1jm |
---|
| 285 | aaa=wg(ij,l)*dtvr/massem(ij,l) |
---|
| 286 | CFLmaxz=max(CFLmaxz,aaa) |
---|
| 287 | bbb=-wg(ij,l)*dtvr/massem(ij,l-1) |
---|
| 288 | CFLmaxz=max(CFLmaxz,bbb) |
---|
| 289 | END DO |
---|
| 290 | END DO |
---|
| 291 | IF(CFLmaxz.GE.1) WRITE(*,*) 'WARNING vertical','CFLmaxz=', CFLmaxz |
---|
| 292 | !---------------------------------------------------------------- |
---|
| 293 | ! Ss-prg interface LMDZ.4->PPM3d (ss-prg de Lin) |
---|
| 294 | !---------------------------------------------------------------- |
---|
| 295 | CALL interpre(q(1,1,iq),qppm(1,1,iq),wg,fluxwppm,massem, & |
---|
| 296 | apppm,bpppm,massebx,masseby,pbarug,pbarvg, & |
---|
| 297 | unatppm,vnatppm,psppm) |
---|
[524] | 298 | |
---|
[4056] | 299 | !---------------------------------------------------------------- |
---|
| 300 | DO indice=1,n !--- VL (version PPM) horiz. et PPM vert. |
---|
| 301 | !---------------------------------------------------------------- |
---|
| 302 | SELECT CASE(iadv) |
---|
| 303 | !---------------------------------------------------------- |
---|
| 304 | CASE(11) |
---|
| 305 | !---------------------------------------------------------- |
---|
| 306 | CALL ppm3d(1,qppm(1,1,iq),psppm,psppm,unatppm,vnatppm,fluxwppm,dtbon, & |
---|
| 307 | 2,2,2,1,iim,jjp1,2,llm,apppm,bpppm,0.01,6400000,fill,dum,220.) |
---|
| 308 | !---------------------------------------------------------- |
---|
| 309 | CASE(16) !--- Monotonic PPM |
---|
| 310 | !---------------------------------------------------------- |
---|
| 311 | CALL ppm3d(1,qppm(1,1,iq),psppm,psppm,unatppm,vnatppm,fluxwppm,dtbon, & |
---|
| 312 | 3,3,3,1,iim,jjp1,2,llm,apppm,bpppm,0.01,6400000,fill,dum,220.) |
---|
| 313 | !---------------------------------------------------------- |
---|
| 314 | CASE(17) !--- Semi monotonic PPM |
---|
| 315 | !---------------------------------------------------------- |
---|
| 316 | CALL ppm3d(1,qppm(1,1,iq),psppm,psppm,unatppm,vnatppm,fluxwppm,dtbon, & |
---|
| 317 | 4,4,4,1,iim,jjp1,2,llm,apppm,bpppm,0.01,6400000, fill,dum,220.) |
---|
| 318 | !---------------------------------------------------------- |
---|
| 319 | CASE(18) !--- Positive Definite PPM |
---|
| 320 | !---------------------------------------------------------- |
---|
| 321 | CALL ppm3d(1,qppm(1,1,iq),psppm,psppm,unatppm,vnatppm,fluxwppm,dtbon, & |
---|
| 322 | 5,5,5,1,iim,jjp1,2,llm,apppm,bpppm,0.01,6400000,fill,dum,220.) |
---|
| 323 | END SELECT |
---|
| 324 | !---------------------------------------------------------------- |
---|
| 325 | END DO |
---|
| 326 | !---------------------------------------------------------------- |
---|
| 327 | ! Ss-prg interface PPM3d-LMDZ.4 |
---|
| 328 | !---------------------------------------------------------------- |
---|
| 329 | CALL interpost(q(1,1,iq),qppm(1,1,iq)) |
---|
| 330 | !---------------------------------------------------------------------- |
---|
| 331 | END SELECT |
---|
| 332 | !---------------------------------------------------------------------- |
---|
[524] | 333 | |
---|
[4056] | 334 | !---------------------------------------------------------------------- |
---|
| 335 | ! On impose une seule valeur du traceur au pole Sud j=jjm+1=jjp1 et Nord j=1 |
---|
| 336 | !---------------------------------------------------------------------- |
---|
| 337 | ! CALL traceurpole(q(1,1,iq),massem) |
---|
[524] | 338 | |
---|
[4056] | 339 | !--- Calcul du temps cpu pour un schema donne |
---|
| 340 | ! CALL clock(t_final) |
---|
| 341 | !ym tps_cpu=t_final-t_initial |
---|
| 342 | !ym cpuadv(iq)=cpuadv(iq)+tps_cpu |
---|
[524] | 343 | |
---|
[4056] | 344 | END DO |
---|
[524] | 345 | |
---|
[4143] | 346 | IF(isoCheck) WRITE(*,*) 'advtrac 402' |
---|
| 347 | CALL check_isotopes_seq(q,ip1jmp1,'advtrac 397') |
---|
[524] | 348 | |
---|
[4056] | 349 | !------------------------------------------------------------------------- |
---|
| 350 | ! on reinitialise a zero les flux de masse cumules |
---|
| 351 | !------------------------------------------------------------------------- |
---|
| 352 | iadvtr=0 |
---|
[524] | 353 | |
---|
[1549] | 354 | END SUBROUTINE advtrac |
---|