[1632] | 1 | ! |
---|
[1673] | 2 | ! $Id$ |
---|
[1632] | 3 | ! |
---|
| 4 | c |
---|
| 5 | c |
---|
| 6 | #define DEBUG_IO |
---|
| 7 | #undef DEBUG_IO |
---|
| 8 | SUBROUTINE advtrac_loc(pbarug,pbarvg ,wg, |
---|
| 9 | * p, massem,q,teta, |
---|
| 10 | * pk ) |
---|
| 11 | |
---|
| 12 | c Auteur : F. Hourdin |
---|
| 13 | c |
---|
| 14 | c Modif. P. Le Van (20/12/97) |
---|
| 15 | c F. Codron (10/99) |
---|
| 16 | c D. Le Croller (07/2001) |
---|
| 17 | c M.A Filiberti (04/2002) |
---|
| 18 | c |
---|
[1823] | 19 | USE parallel_lmdz |
---|
[1632] | 20 | USE Write_Field_loc |
---|
| 21 | USE Write_Field |
---|
| 22 | USE Bands |
---|
| 23 | USE mod_hallo |
---|
| 24 | USE Vampir |
---|
| 25 | USE times |
---|
[2270] | 26 | USE infotrac, ONLY: nqtot, iadv, ok_iso_verif |
---|
[1987] | 27 | USE control_mod, ONLY: iapp_tracvl, day_step, planet_type |
---|
| 28 | USE advtrac_mod, ONLY: finmasse |
---|
[2597] | 29 | USE comconst_mod, ONLY: dtvr |
---|
[1632] | 30 | IMPLICIT NONE |
---|
| 31 | c |
---|
[2597] | 32 | include "dimensions.h" |
---|
| 33 | include "paramet.h" |
---|
| 34 | include "comdissip.h" |
---|
| 35 | include "comgeom2.h" |
---|
| 36 | include "description.h" |
---|
[1632] | 37 | |
---|
| 38 | c------------------------------------------------------------------- |
---|
| 39 | c Arguments |
---|
| 40 | c------------------------------------------------------------------- |
---|
| 41 | c Ajout PPM |
---|
| 42 | c-------------------------------------------------------- |
---|
| 43 | REAL massebx(ijb_u:ije_u,llm),masseby(ijb_v:ije_v,llm) |
---|
| 44 | c-------------------------------------------------------- |
---|
| 45 | INTEGER iapptrac |
---|
| 46 | REAL pbarug(ijb_u:ije_u,llm),pbarvg(ijb_v:ije_v,llm) |
---|
| 47 | REAL wg(ijb_u:ije_u,llm) |
---|
| 48 | REAL q(ijb_u:ije_u,llm,nqtot),massem(ijb_u:ije_u,llm) |
---|
| 49 | REAL p( ijb_u:ije_u,llmp1 ),teta(ijb_u:ije_u,llm) |
---|
| 50 | REAL pk(ijb_u:ije_u,llm) |
---|
| 51 | |
---|
| 52 | c------------------------------------------------------------- |
---|
| 53 | c Variables locales |
---|
| 54 | c------------------------------------------------------------- |
---|
| 55 | |
---|
| 56 | REAL zdp(ijb_u:ije_u) |
---|
| 57 | REAL (kind=kind(1.d0)) :: t_initial, t_final, tps_cpu |
---|
| 58 | INTEGER,SAVE :: iadvtr=0 |
---|
| 59 | c$OMP THREADPRIVATE(iadvtr) |
---|
| 60 | INTEGER ij,l,iq,iiq |
---|
| 61 | REAL zdpmin, zdpmax |
---|
| 62 | c---------------------------------------------------------- |
---|
| 63 | c Rajouts pour PPM |
---|
| 64 | c---------------------------------------------------------- |
---|
| 65 | INTEGER indice,n |
---|
| 66 | REAL dtbon ! Pas de temps adaptatif pour que CFL<1 |
---|
| 67 | REAL CFLmaxz,aaa,bbb ! CFL maximum |
---|
| 68 | REAL psppm(iim,jjb_u:jje_u) ! pression au sol |
---|
| 69 | REAL unatppm(iim,jjb_u:jje_u,llm),vnatppm(iim,jjb_u:jje_u,llm) |
---|
| 70 | REAL qppm(iim*jjnb_u,llm,nqtot) |
---|
| 71 | REAL fluxwppm(iim,jjb_u:jje_u,llm) |
---|
| 72 | REAL apppm(llmp1), bpppm(llmp1) |
---|
| 73 | LOGICAL dum,fill |
---|
| 74 | DATA fill/.true./ |
---|
| 75 | DATA dum/.true./ |
---|
| 76 | integer ijb,ije,ijbu,ijbv,ijeu,ijev,j |
---|
[1848] | 77 | type(Request),SAVE :: testRequest |
---|
| 78 | !$OMP THREADPRIVATE(testRequest) |
---|
[1632] | 79 | |
---|
[2270] | 80 | c test sur l''eventuelle creation de valeurs negatives de la masse |
---|
[1632] | 81 | ijb=ij_begin |
---|
| 82 | ije=ij_end |
---|
| 83 | if (pole_nord) ijb=ij_begin+iip1 |
---|
| 84 | if (pole_sud) ije=ij_end-iip1 |
---|
| 85 | |
---|
| 86 | c$OMP DO SCHEDULE(STATIC,OMP_CHUNK) |
---|
| 87 | DO l=1,llm-1 |
---|
| 88 | DO ij = ijb+1,ije |
---|
| 89 | zdp(ij) = pbarug(ij-1,l) - pbarug(ij,l) |
---|
| 90 | s - pbarvg(ij-iip1,l) + pbarvg(ij,l) |
---|
| 91 | s + wg(ij,l+1) - wg(ij,l) |
---|
| 92 | ENDDO |
---|
| 93 | |
---|
| 94 | c CALL SCOPY( jjm -1 ,zdp(iip1+iip1),iip1,zdp(iip2),iip1 ) |
---|
| 95 | c ym ---> pourquoi jjm-1 et non jjm ? a cause du pole ? |
---|
| 96 | |
---|
| 97 | do ij=ijb,ije-iip1+1,iip1 |
---|
| 98 | zdp(ij)=zdp(ij+iip1-1) |
---|
| 99 | enddo |
---|
| 100 | |
---|
| 101 | DO ij = ijb,ije |
---|
| 102 | zdp(ij)= zdp(ij)*dtvr/ massem(ij,l) |
---|
| 103 | ENDDO |
---|
| 104 | |
---|
| 105 | |
---|
| 106 | c CALL minmax ( ip1jm-iip1, zdp(iip2), zdpmin,zdpmax ) |
---|
| 107 | c ym ---> eventuellement a revoir |
---|
| 108 | CALL minmax ( ije-ijb+1, zdp(ijb), zdpmin,zdpmax ) |
---|
| 109 | |
---|
| 110 | IF(MAX(ABS(zdpmin),ABS(zdpmax)).GT.0.5) THEN |
---|
| 111 | PRINT*,'WARNING DP/P l=',l,' MIN:',zdpmin, |
---|
| 112 | s ' MAX:', zdpmax |
---|
| 113 | ENDIF |
---|
| 114 | |
---|
| 115 | ENDDO |
---|
| 116 | c$OMP END DO NOWAIT |
---|
| 117 | |
---|
| 118 | c------------------------------------------------------------------- |
---|
| 119 | c Advection proprement dite (Modification Le Croller (07/2001) |
---|
| 120 | c------------------------------------------------------------------- |
---|
| 121 | |
---|
| 122 | c---------------------------------------------------- |
---|
| 123 | c Calcul des moyennes basées sur la masse |
---|
| 124 | c---------------------------------------------------- |
---|
| 125 | |
---|
| 126 | cym ----> Normalement, inutile pour les schémas classiques |
---|
| 127 | cym ----> Revérifier lors de la parallélisation des autres schemas |
---|
| 128 | |
---|
| 129 | cym call massbar_p(massem,massebx,masseby) |
---|
| 130 | |
---|
| 131 | #ifdef DEBUG_IO |
---|
| 132 | CALL WriteField_u('massem',massem) |
---|
| 133 | CALL WriteField_u('wg',wg) |
---|
| 134 | CALL WriteField_u('pbarug',pbarug) |
---|
| 135 | CALL WriteField_v('pbarvg',pbarvg) |
---|
| 136 | CALL WriteField_u('p_tmp',p) |
---|
| 137 | CALL WriteField_u('pk_tmp',pk) |
---|
| 138 | CALL WriteField_u('teta_tmp',teta) |
---|
| 139 | do j=1,nqtot |
---|
| 140 | call WriteField_u('q_adv'//trim(int2str(j)), |
---|
| 141 | . q(:,:,j)) |
---|
| 142 | enddo |
---|
| 143 | #endif |
---|
| 144 | |
---|
| 145 | ! |
---|
| 146 | ! call Register_Hallo_v(pbarvg,llm,1,1,1,1,TestRequest) |
---|
| 147 | ! |
---|
| 148 | ! call SendRequest(TestRequest) |
---|
| 149 | !c$OMP BARRIER |
---|
| 150 | ! call WaitRequest(TestRequest) |
---|
| 151 | c$OMP BARRIER |
---|
| 152 | |
---|
[2286] | 153 | !write(*,*) 'advtrac 157: appel de vlspltgen_loc' |
---|
[1632] | 154 | call vlspltgen_loc( q,iadv, 2., massem, wg , |
---|
| 155 | * pbarug,pbarvg,dtvr,p, |
---|
| 156 | * pk,teta ) |
---|
| 157 | |
---|
| 158 | #ifdef DEBUG_IO |
---|
| 159 | do j=1,nqtot |
---|
| 160 | call WriteField_u('q_adv'//trim(int2str(j)), |
---|
| 161 | . q(:,:,j)) |
---|
| 162 | enddo |
---|
| 163 | #endif |
---|
| 164 | |
---|
[2600] | 165 | GOTO 1234 |
---|
[1632] | 166 | c----------------------------------------------------------- |
---|
| 167 | c Appel des sous programmes d'advection |
---|
| 168 | c----------------------------------------------------------- |
---|
| 169 | do iq=1,nqtot |
---|
| 170 | c call clock(t_initial) |
---|
| 171 | if(iadv(iq) == 0) cycle |
---|
| 172 | c ---------------------------------------------------------------- |
---|
| 173 | c Schema de Van Leer I MUSCL |
---|
| 174 | c ---------------------------------------------------------------- |
---|
| 175 | if(iadv(iq).eq.10) THEN |
---|
| 176 | |
---|
[2600] | 177 | !LF call vlsplt_p(q(1,1,iq),2.,massem,wg,pbarug,pbarvg,dtvr) |
---|
[1632] | 178 | |
---|
| 179 | c ---------------------------------------------------------------- |
---|
| 180 | c Schema "pseudo amont" + test sur humidite specifique |
---|
| 181 | C pour la vapeur d'eau. F. Codron |
---|
| 182 | c ---------------------------------------------------------------- |
---|
| 183 | else if(iadv(iq).eq.14) then |
---|
| 184 | c |
---|
| 185 | cym stop 'advtrac : appel à vlspltqs :schema non parallelise' |
---|
| 186 | !LF CALL vlspltqs_p( q(1,1,1), 2., massem, wg , |
---|
| 187 | !LF * pbarug,pbarvg,dtvr,p,pk,teta ) |
---|
| 188 | c ---------------------------------------------------------------- |
---|
| 189 | c Schema de Frederic Hourdin |
---|
| 190 | c ---------------------------------------------------------------- |
---|
| 191 | else if(iadv(iq).eq.12) then |
---|
| 192 | stop 'advtrac : schema non parallelise' |
---|
| 193 | c Pas de temps adaptatif |
---|
| 194 | call adaptdt(iadv(iq),dtbon,n,pbarug,massem) |
---|
| 195 | if (n.GT.1) then |
---|
| 196 | write(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=', |
---|
| 197 | s dtvr,'n=',n |
---|
| 198 | endif |
---|
| 199 | do indice=1,n |
---|
| 200 | call advn(q(1,1,iq),massem,wg,pbarug,pbarvg,dtbon,1) |
---|
| 201 | end do |
---|
| 202 | else if(iadv(iq).eq.13) then |
---|
| 203 | stop 'advtrac : schema non parallelise' |
---|
| 204 | c Pas de temps adaptatif |
---|
| 205 | call adaptdt(iadv(iq),dtbon,n,pbarug,massem) |
---|
| 206 | if (n.GT.1) then |
---|
| 207 | write(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=', |
---|
| 208 | s dtvr,'n=',n |
---|
| 209 | endif |
---|
| 210 | do indice=1,n |
---|
| 211 | call advn(q(1,1,iq),massem,wg,pbarug,pbarvg,dtbon,2) |
---|
| 212 | end do |
---|
| 213 | c ---------------------------------------------------------------- |
---|
| 214 | c Schema de pente SLOPES |
---|
| 215 | c ---------------------------------------------------------------- |
---|
| 216 | else if (iadv(iq).eq.20) then |
---|
| 217 | stop 'advtrac : schema non parallelise' |
---|
| 218 | |
---|
| 219 | call pentes_ini (q(1,1,iq),wg,massem,pbarug,pbarvg,0) |
---|
| 220 | |
---|
| 221 | c ---------------------------------------------------------------- |
---|
| 222 | c Schema de Prather |
---|
| 223 | c ---------------------------------------------------------------- |
---|
| 224 | else if (iadv(iq).eq.30) then |
---|
| 225 | stop 'advtrac : schema non parallelise' |
---|
| 226 | c Pas de temps adaptatif |
---|
| 227 | call adaptdt(iadv(iq),dtbon,n,pbarug,massem) |
---|
| 228 | if (n.GT.1) then |
---|
| 229 | write(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=', |
---|
| 230 | s dtvr,'n=',n |
---|
| 231 | endif |
---|
| 232 | call prather(q(1,1,iq),wg,massem,pbarug,pbarvg, |
---|
| 233 | s n,dtbon) |
---|
| 234 | c ---------------------------------------------------------------- |
---|
| 235 | c Schemas PPM Lin et Rood |
---|
| 236 | c ---------------------------------------------------------------- |
---|
| 237 | else if (iadv(iq).eq.11.OR.(iadv(iq).GE.16.AND. |
---|
| 238 | s iadv(iq).LE.18)) then |
---|
| 239 | |
---|
| 240 | stop 'advtrac : schema non parallelise' |
---|
| 241 | |
---|
| 242 | c Test sur le flux horizontal |
---|
| 243 | c Pas de temps adaptatif |
---|
| 244 | call adaptdt(iadv(iq),dtbon,n,pbarug,massem) |
---|
| 245 | if (n.GT.1) then |
---|
| 246 | write(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=', |
---|
| 247 | s dtvr,'n=',n |
---|
| 248 | endif |
---|
| 249 | c Test sur le flux vertical |
---|
| 250 | CFLmaxz=0. |
---|
| 251 | do l=2,llm |
---|
| 252 | do ij=iip2,ip1jm |
---|
| 253 | aaa=wg(ij,l)*dtvr/massem(ij,l) |
---|
| 254 | CFLmaxz=max(CFLmaxz,aaa) |
---|
| 255 | bbb=-wg(ij,l)*dtvr/massem(ij,l-1) |
---|
| 256 | CFLmaxz=max(CFLmaxz,bbb) |
---|
| 257 | enddo |
---|
| 258 | enddo |
---|
| 259 | if (CFLmaxz.GE.1) then |
---|
| 260 | write(*,*) 'WARNING vertical','CFLmaxz=', CFLmaxz |
---|
| 261 | endif |
---|
| 262 | |
---|
| 263 | c----------------------------------------------------------- |
---|
| 264 | c Ss-prg interface LMDZ.4->PPM3d |
---|
| 265 | c----------------------------------------------------------- |
---|
| 266 | |
---|
| 267 | call interpre(q(1,1,iq),qppm(1,1,iq),wg,fluxwppm,massem, |
---|
| 268 | s apppm,bpppm,massebx,masseby,pbarug,pbarvg, |
---|
| 269 | s unatppm,vnatppm,psppm) |
---|
| 270 | |
---|
| 271 | do indice=1,n |
---|
| 272 | c--------------------------------------------------------------------- |
---|
| 273 | c VL (version PPM) horiz. et PPM vert. |
---|
| 274 | c--------------------------------------------------------------------- |
---|
| 275 | if (iadv(iq).eq.11) then |
---|
| 276 | c Ss-prg PPM3d de Lin |
---|
| 277 | call ppm3d(1,qppm(1,1,iq), |
---|
| 278 | s psppm,psppm, |
---|
| 279 | s unatppm,vnatppm,fluxwppm,dtbon,2,2,2,1, |
---|
| 280 | s iim,jjp1,2,llm,apppm,bpppm,0.01,6400000, |
---|
| 281 | s fill,dum,220.) |
---|
| 282 | |
---|
| 283 | c---------------------------------------------------------------------- |
---|
| 284 | c Monotonic PPM |
---|
| 285 | c---------------------------------------------------------------------- |
---|
| 286 | else if (iadv(iq).eq.16) then |
---|
| 287 | c Ss-prg PPM3d de Lin |
---|
| 288 | call ppm3d(1,qppm(1,1,iq), |
---|
| 289 | s psppm,psppm, |
---|
| 290 | s unatppm,vnatppm,fluxwppm,dtbon,3,3,3,1, |
---|
| 291 | s iim,jjp1,2,llm,apppm,bpppm,0.01,6400000, |
---|
| 292 | s fill,dum,220.) |
---|
| 293 | c--------------------------------------------------------------------- |
---|
| 294 | |
---|
| 295 | c--------------------------------------------------------------------- |
---|
| 296 | c Semi Monotonic PPM |
---|
| 297 | c--------------------------------------------------------------------- |
---|
| 298 | else if (iadv(iq).eq.17) then |
---|
| 299 | c Ss-prg PPM3d de Lin |
---|
| 300 | call ppm3d(1,qppm(1,1,iq), |
---|
| 301 | s psppm,psppm, |
---|
| 302 | s unatppm,vnatppm,fluxwppm,dtbon,4,4,4,1, |
---|
| 303 | s iim,jjp1,2,llm,apppm,bpppm,0.01,6400000, |
---|
| 304 | s fill,dum,220.) |
---|
| 305 | c--------------------------------------------------------------------- |
---|
| 306 | |
---|
| 307 | c--------------------------------------------------------------------- |
---|
| 308 | c Positive Definite PPM |
---|
| 309 | c--------------------------------------------------------------------- |
---|
| 310 | else if (iadv(iq).eq.18) then |
---|
| 311 | c Ss-prg PPM3d de Lin |
---|
| 312 | call ppm3d(1,qppm(1,1,iq), |
---|
| 313 | s psppm,psppm, |
---|
| 314 | s unatppm,vnatppm,fluxwppm,dtbon,5,5,5,1, |
---|
| 315 | s iim,jjp1,2,llm,apppm,bpppm,0.01,6400000, |
---|
| 316 | s fill,dum,220.) |
---|
| 317 | c--------------------------------------------------------------------- |
---|
| 318 | endif |
---|
| 319 | enddo |
---|
| 320 | c----------------------------------------------------------------- |
---|
| 321 | c Ss-prg interface PPM3d-LMDZ.4 |
---|
| 322 | c----------------------------------------------------------------- |
---|
| 323 | call interpost(q(1,1,iq),qppm(1,1,iq)) |
---|
| 324 | endif |
---|
| 325 | c---------------------------------------------------------------------- |
---|
| 326 | |
---|
| 327 | c----------------------------------------------------------------- |
---|
| 328 | c On impose une seule valeur du traceur au pôle Sud j=jjm+1=jjp1 |
---|
| 329 | c et Nord j=1 |
---|
| 330 | c----------------------------------------------------------------- |
---|
| 331 | |
---|
| 332 | c call traceurpole(q(1,1,iq),massem) |
---|
| 333 | |
---|
| 334 | c calcul du temps cpu pour un schema donne |
---|
| 335 | |
---|
| 336 | |
---|
| 337 | end DO |
---|
| 338 | |
---|
| 339 | 1234 CONTINUE |
---|
| 340 | c$OMP BARRIER |
---|
| 341 | |
---|
[1673] | 342 | if (planet_type=="earth") then |
---|
| 343 | |
---|
[1632] | 344 | ijb=ij_begin |
---|
| 345 | ije=ij_end |
---|
| 346 | |
---|
| 347 | c$OMP DO SCHEDULE(STATIC,OMP_CHUNK) |
---|
| 348 | DO l = 1, llm |
---|
| 349 | DO ij = ijb, ije |
---|
| 350 | finmasse(ij,l) = p(ij,l) - p(ij,l+1) |
---|
| 351 | ENDDO |
---|
| 352 | ENDDO |
---|
| 353 | c$OMP END DO |
---|
| 354 | |
---|
[2270] | 355 | ! CRisi: on passe nqtot et non nq |
---|
| 356 | CALL qminimum_loc( q, nqtot, finmasse ) |
---|
[1632] | 357 | |
---|
[1673] | 358 | endif ! of if (planet_type=="earth") |
---|
[1632] | 359 | |
---|
| 360 | RETURN |
---|
| 361 | END |
---|
| 362 | |
---|