Changeset 1047 for trunk/LMDZ.MARS/libf/aeronomars/moldiff_red.F90
- Timestamp:
- Sep 23, 2013, 9:56:47 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.MARS/libf/aeronomars/moldiff_red.F90
r1036 r1047 1 subroutine moldiff_red(pplay,pplev,pt,pdt,pq,pdq,ptimestep,zzlay,pdteuv,pdtconduc,pdqdiff) 2 3 use tracer_mod, only: nqmx, noms, mmol 1 subroutine moldiff_red(ngrid,nlayer,nq,pplay,pplev,pt,pdt,pq,pdq,& 2 ptimestep,zzlay,pdteuv,pdtconduc,pdqdiff) 3 4 use tracer_mod, only: noms, mmol 4 5 5 6 implicit none 6 7 7 #include "dimensions.h"8 #include "dimphys.h"8 !#include "dimensions.h" 9 !#include "dimphys.h" 9 10 #include "comcstfi.h" 10 #include "callkeys.h"11 #include "comdiurn.h"12 #include "chimiedata.h"11 !#include "callkeys.h" 12 !#include "comdiurn.h" 13 !#include "chimiedata.h" 13 14 !#include "tracer.h" 14 #include "conc.h"15 !#include "conc.h" 15 16 #include "diffusion.h" 16 17 … … 19 20 ! Input/Output 20 21 ! 22 integer,intent(in) :: ngrid ! number of atmospheric columns 23 integer,intent(in) :: nlayer ! number of atmospheric layers 24 integer,intent(in) :: nq ! number of advected tracers 21 25 real ptimestep 22 real pplay(ngrid mx,nlayermx)23 real zzlay(ngrid mx,nlayermx)24 real pplev(ngrid mx,nlayermx+1)25 real pq(ngrid mx,nlayermx,nqmx)26 real pdq(ngrid mx,nlayermx,nqmx)27 real pt(ngrid mx,nlayermx)28 real pdt(ngrid mx,nlayermx)29 real pdteuv(ngrid mx,nlayermx)30 real pdtconduc(ngrid mx,nlayermx)31 real pdqdiff(ngrid mx,nlayermx,nqmx)26 real pplay(ngrid,nlayer) 27 real zzlay(ngrid,nlayer) 28 real pplev(ngrid,nlayer+1) 29 real pq(ngrid,nlayer,nq) 30 real pdq(ngrid,nlayer,nq) 31 real pt(ngrid,nlayer) 32 real pdt(ngrid,nlayer) 33 real pdteuv(ngrid,nlayer) 34 real pdtconduc(ngrid,nlayer) 35 real pdqdiff(ngrid,nlayer,nq) 32 36 ! 33 37 ! Local … … 37 41 ! real hco2(ncompdiff),ho 38 42 39 integer,dimension(nq mx) :: indic_diff43 integer,dimension(nq) :: indic_diff 40 44 integer ig,iq,nz,l,k,n,nn,p,ij0 41 45 integer istep,il,gcn,ntime,nlraf … … 44 48 real*8 rho0,D0,T0,H0,time0,dZ,time,dZraf,tdiff,Zmin,Zmax 45 49 real*8 FacEsc,invsgmu 46 real*8 hp(nlayer mx)47 real*8 pp(nlayer mx)48 real*8 pint(nlayer mx)49 real*8 tt(nlayer mx),tnew(nlayermx),tint(nlayermx)50 real*8 zz(nlayer mx)50 real*8 hp(nlayer) 51 real*8 pp(nlayer) 52 real*8 pint(nlayer) 53 real*8 tt(nlayer),tnew(nlayer),tint(nlayer) 54 real*8 zz(nlayer) 51 55 real*8,dimension(:,:),allocatable,save :: qq,qnew,qint,FacMass 52 56 real*8,dimension(:,:),allocatable,save :: rhoK,rhokinit 53 real*8 rhoT(nlayer mx)54 real*8 dmmeandz(nlayer mx)55 real*8 massemoy(nlayer mx)57 real*8 rhoT(nlayer) 58 real*8 dmmeandz(nlayer) 59 real*8 massemoy(nlayer) 56 60 real*8,dimension(:),allocatable :: Praf,Traf,Rraf,Mraf,Nraf,Draf,Hraf,Wraf 57 61 real*8,dimension(:),allocatable :: Zraf,Tdiffraf … … 130 134 131 135 ncompdiff=0 132 indic_diff(1:nq mx)=0136 indic_diff(1:nq)=0 133 137 134 do nn=1,nq mx138 do nn=1,nq 135 139 do n=1,14 136 140 if (ListeDiff(n) .eq. noms(nn)) then … … 151 155 ! Store gcm indexes in gcmind 152 156 n=0 153 do nn=1,nq mx157 do nn=1,nq 154 158 if (indic_diff(nn) .eq. 1) then 155 159 n=n+1 … … 162 166 ! find vertical index above which diffusion is computed 163 167 164 do l=1,nlayer mx168 do l=1,nlayer 165 169 if (pplay(1,l) .gt. Pdiff) then 166 170 il0=l … … 176 180 177 181 ! allocatation des tableaux dependants du nombre d especes diffusees 178 allocate(qq(nlayer mx,ncompdiff))179 allocate(qnew(nlayer mx,ncompdiff))180 allocate(qint(nlayer mx,ncompdiff))181 allocate(FacMass(nlayer mx,ncompdiff))182 allocate(rhok(nlayer mx,ncompdiff))183 allocate(rhokinit(nlayer mx,ncompdiff))182 allocate(qq(nlayer,ncompdiff)) 183 allocate(qnew(nlayer,ncompdiff)) 184 allocate(qint(nlayer,ncompdiff)) 185 allocate(FacMass(nlayer,ncompdiff)) 186 allocate(rhok(nlayer,ncompdiff)) 187 allocate(rhokinit(nlayer,ncompdiff)) 184 188 185 189 allocate(wi(ncompdiff)) … … 212 216 213 217 ! print*,'moldiff',i_h2,i_h,ncompdiff 214 do ig=1,ngrid mx218 do ig=1,ngrid 215 219 pp=dble(pplay(ig,:)) 216 220 … … 218 222 219 223 ! CALL TMNEW(pt(ig,:),pdt(ig,:),pdtconduc(ig,:),pdteuv(ig,:) & 220 ! & ,tt,ptimestep,nlayer mx,ig)221 do l=1,nlayer mx224 ! & ,tt,ptimestep,nlayer,ig) 225 do l=1,nlayer 222 226 tt(l)=pt(ig,l)*1D0+(pdt(ig,l)*dble(ptimestep)+ & 223 227 pdtconduc(ig,l)*dble(ptimestep)+ & … … 228 232 pdt(ig,l),pdtconduc(ig,l),pdteuv(ig,l),dble(ptimestep) 229 233 endif 230 enddo ! of do l=1,nlayer mx234 enddo ! of do l=1,nlayer 231 235 232 236 ! Update the mass mixing ratios modified by other processes 233 237 234 ! CALL QMNEW(pq(ig,:,:),pdq(ig,:,:),qq,ptimestep,nlayer mx, &238 ! CALL QMNEW(pq(ig,:,:),pdq(ig,:,:),qq,ptimestep,nlayer, & 235 239 ! & ncompdiff,gcmind,ig) 236 240 do iq=1,ncompdiff 237 do l=1,nlayer mx241 do l=1,nlayer 238 242 qq(l,iq)=pq(ig,l,gcmind(iq))*1D0+( & 239 243 pdq(ig,l,gcmind(iq))*dble(ptimestep)) 240 244 qq(l,iq)=max(qq(l,iq),1d-30) 241 enddo ! of do l=1,nlayer mx245 enddo ! of do l=1,nlayer 242 246 enddo ! of do iq=1,ncompdiff 243 247 244 248 ! Compute the Pressure scale height 245 249 246 CALL HSCALE(pp,hp,nlayer mx)250 CALL HSCALE(pp,hp,nlayer) 247 251 248 252 ! Compute the atmospheric mass (in Dalton) 249 253 250 CALL MMOY(massemoy,mmol,qq,gcmind,nlayer mx,ncompdiff)254 CALL MMOY(massemoy,mmol,qq,gcmind,nlayer,ncompdiff) 251 255 252 256 ! Compute the vertical gradient of atmospheric mass 253 257 254 CALL DMMOY(massemoy,hp,dmmeandz,nlayer mx)258 CALL DMMOY(massemoy,hp,dmmeandz,nlayer) 255 259 256 260 ! Compute the altitude of each layer 257 261 258 CALL ZVERT(pp,tt,massemoy,zz,nlayer mx,ig)262 CALL ZVERT(pp,tt,massemoy,zz,nlayer,ig) 259 263 260 264 ! Compute the total mass density (kg/m3) 261 265 262 CALL RHOTOT(pp,tt,massemoy,qq,RHOT,RHOK,nlayer mx,ncompdiff)266 CALL RHOTOT(pp,tt,massemoy,qq,RHOT,RHOK,nlayer,ncompdiff) 263 267 RHOKINIT=RHOK 264 268 … … 271 275 Mtot1(1:ncompdiff)=0d0 272 276 273 do l=il0,nlayer mx277 do l=il0,nlayer 274 278 do nn=1,ncompdiff 275 279 Mtot1(nn)=Mtot1(nn)+1d0/g*qq(l,nn)* & … … 279 283 280 284 Zmin=zz(il0) 281 Zmax=zz(nlayer mx)285 Zmax=zz(nlayer) 282 286 283 287 … … 286 290 if (Zmax .gt. 4000000.) then 287 291 Print*,'Zmax too high',ig,zmax,zmin 288 do l=1,nlayer mx292 do l=1,nlayer 289 293 print*,'old',zz(l),pt(ig,l),pdteuv(ig,l),pdq(ig,l,:) 290 294 print*,'l',l,rhot(l),tt(l),pp(l),massemoy(l),qq(l,:) … … 321 325 CALL UPPER_RESOL(pp,tt,zz,massemoy,RHOT,RHOK, & 322 326 & qq,mmol,gcmind,Praf,Traf,Qraf,Mraf,Zraf, & 323 & Nraf,Nrafk,Rraf,Rrafk,il0,nlraf,ncompdiff,nlayer mx,ig)327 & Nraf,Nrafk,Rraf,Rrafk,il0,nlraf,ncompdiff,nlayer,ig) 324 328 325 329 Prafold=Praf … … 330 334 331 335 CALL GCMGRID_P(Zraf,Praf,Qraf,Traf,Nrafk,Rrafk,qq,qint,tt,tint & 332 & ,pp,mmol,gcmind,nlraf,ncompdiff,nlayer mx,ig)336 & ,pp,mmol,gcmind,nlraf,ncompdiff,nlayer,ig) 333 337 334 338 ! We compute the mass correction factor of each specie at each pressure level 335 339 336 CALL CORRMASS(qq,qint,FacMass,nlayer mx,ncompdiff)340 CALL CORRMASS(qq,qint,FacMass,nlayer,ncompdiff) 337 341 338 342 ! Altitude step … … 367 371 ! enddo 368 372 369 ! do l=1,nlayer mx373 ! do l=1,nlayer 370 374 ! print*,'l',l,zz(l),pp(l),tt(l),sum(qq(l,:)),massemoy(l) 371 375 ! enddo … … 374 378 ! No change below il0 375 379 376 do l=1,nlayer mx380 do l=1,nlayer 377 381 qnew(l,:)=qq(l,:) ! No effet below il0 378 382 enddo … … 527 531 print*,'Mraf',Mraf 528 532 stop 529 ! pdqdiff(1:ngrid mx,1:nlayermx,1:nqmx)=0.533 ! pdqdiff(1:ngrid,1:nlayer,1:nq)=0. 530 534 ! return 531 535 ! Rrafk(l,nn)=1D-30*Rraf(l) … … 572 576 573 577 CALL GCMGRID_P2(Zraf,Praf,Qraf,Traf,Nrafk,Rrafk,qq,qnew,tt,tnew,& 574 & pp,mmol,gcmind,nlraf,ncompdiff,nlayer mx,FacMass,ig)575 576 CALL RHOTOT(pp,tt,massemoy,qnew,RHOT,RHOK,nlayer mx,ncompdiff)578 & pp,mmol,gcmind,nlraf,ncompdiff,nlayer,FacMass,ig) 579 580 CALL RHOTOT(pp,tt,massemoy,qnew,RHOT,RHOK,nlayer,ncompdiff) 577 581 578 582 if (ig .eq. ij0) then 579 do l=il0,nlayer mx583 do l=il0,nlayer 580 584 write(*,'(i2,1x,19(e12.4,1x))') l,zz(l),tt(l),RHOK(l,1)/sum(RHOK(l,:)),RHOKINIT(l,1)/sum(RHOKINIT(l,:)),& 581 585 & RHOK(l,2)/sum(RHOK(l,:)),RHOKINIT(l,2)/sum(RHOKINIT(l,:)),& … … 590 594 Mtot2(1:ncompdiff)=0d0 591 595 592 do l=il0,nlayer mx596 do l=il0,nlayer 593 597 do nn=1,ncompdiff 594 598 Mtot2(nn)=Mtot2(nn)+1d0/g*qnew(l,nn)* & … … 600 604 601 605 ! do nn=1,ncompdiff 602 ! CALL CheckMass2(qq,qnew,pplev(ig,:),il0,nlayer mx,nn,ncompdiff)606 ! CALL CheckMass2(qq,qnew,pplev(ig,:),il0,nlayer,nn,ncompdiff) 603 607 ! enddo 604 608 605 609 ! Compute the diffusion trends du to diffusion 606 610 607 do l=1,nlayer mx611 do l=1,nlayer 608 612 do nn=1,ncompdiff 609 613 pdqdiff(ig,l,gcmind(nn))=(qnew(l,nn)-qq(l,nn))/ptimestep
Note: See TracChangeset
for help on using the changeset viewer.