Ignore:
Timestamp:
Sep 23, 2013, 9:56:47 AM (11 years ago)
Author:
emillour
Message:

Mars GCM:

  • IMPORTANT CHANGE: Removed all reference/use of ngridmx (dimphys.h) in routines (necessary prerequisite to using parallel dynamics); in most cases this just means adding 'ngrid' as routine argument, and making local saved variables allocatable (and allocated at first call). In the process, had to convert many *.h files to equivalent modules: yomaer.h => yomaer_h.F90 , surfdat.h => surfdat_h.F90 , comsaison.h => comsaison_h.F90 , yomlw.h => yomlw_h.F90 , comdiurn.h => comdiurn_h.F90 , dimradmars.h => dimradmars_mod.F90 , comgeomfi.h => comgeomfi_h.F90, comsoil.h => comsoil_h.F90 , slope.h => slope_mod.F90
  • Also updated EOF routines, everything is now in eofdump_mod.F90
  • Removed unused routine lectfux.F (in dyn3d)

EM

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
     1subroutine moldiff_red(ngrid,nlayer,nq,pplay,pplev,pt,pdt,pq,pdq,&
     2                       ptimestep,zzlay,pdteuv,pdtconduc,pdqdiff)
     3
     4use tracer_mod, only: noms, mmol
    45
    56implicit none
    67
    7 #include "dimensions.h"
    8 #include "dimphys.h"
     8!#include "dimensions.h"
     9!#include "dimphys.h"
    910#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"
    1314!#include "tracer.h"
    14 #include "conc.h"
     15!#include "conc.h"
    1516#include "diffusion.h"
    1617
     
    1920! Input/Output
    2021!
     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
    2125      real ptimestep
    22       real pplay(ngridmx,nlayermx)
    23       real zzlay(ngridmx,nlayermx)
    24       real pplev(ngridmx,nlayermx+1)
    25       real pq(ngridmx,nlayermx,nqmx)
    26       real pdq(ngridmx,nlayermx,nqmx)
    27       real pt(ngridmx,nlayermx)
    28       real pdt(ngridmx,nlayermx)
    29       real pdteuv(ngridmx,nlayermx)
    30       real pdtconduc(ngridmx,nlayermx)
    31       real pdqdiff(ngridmx,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)
    3236!
    3337! Local
     
    3741!      real hco2(ncompdiff),ho
    3842
    39       integer,dimension(nqmx) :: indic_diff
     43      integer,dimension(nq) :: indic_diff
    4044      integer ig,iq,nz,l,k,n,nn,p,ij0
    4145      integer istep,il,gcn,ntime,nlraf
     
    4448      real*8 rho0,D0,T0,H0,time0,dZ,time,dZraf,tdiff,Zmin,Zmax
    4549      real*8 FacEsc,invsgmu
    46       real*8 hp(nlayermx)
    47       real*8 pp(nlayermx)
    48       real*8 pint(nlayermx)
    49       real*8 tt(nlayermx),tnew(nlayermx),tint(nlayermx)
    50       real*8 zz(nlayermx)
     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)
    5155      real*8,dimension(:,:),allocatable,save :: qq,qnew,qint,FacMass
    5256      real*8,dimension(:,:),allocatable,save :: rhoK,rhokinit
    53       real*8 rhoT(nlayermx)
    54       real*8 dmmeandz(nlayermx)
    55       real*8 massemoy(nlayermx)
     57      real*8 rhoT(nlayer)
     58      real*8 dmmeandz(nlayer)
     59      real*8 massemoy(nlayer)
    5660      real*8,dimension(:),allocatable :: Praf,Traf,Rraf,Mraf,Nraf,Draf,Hraf,Wraf
    5761      real*8,dimension(:),allocatable :: Zraf,Tdiffraf
     
    130134
    131135        ncompdiff=0
    132         indic_diff(1:nqmx)=0
     136        indic_diff(1:nq)=0
    133137       
    134         do nn=1,nqmx
     138        do nn=1,nq
    135139        do n=1,14
    136140        if (ListeDiff(n) .eq. noms(nn)) then
     
    151155! Store gcm indexes in gcmind
    152156        n=0
    153         do nn=1,nqmx
     157        do nn=1,nq
    154158        if (indic_diff(nn) .eq. 1) then
    155159        n=n+1
     
    162166! find vertical index above which diffusion is computed
    163167
    164         do l=1,nlayermx
     168        do l=1,nlayer
    165169        if (pplay(1,l) .gt. Pdiff) then
    166170        il0=l
     
    176180
    177181! allocatation des tableaux dependants du nombre d especes diffusees
    178         allocate(qq(nlayermx,ncompdiff))
    179         allocate(qnew(nlayermx,ncompdiff))
    180         allocate(qint(nlayermx,ncompdiff))
    181         allocate(FacMass(nlayermx,ncompdiff))
    182         allocate(rhok(nlayermx,ncompdiff))
    183         allocate(rhokinit(nlayermx,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))
    184188
    185189        allocate(wi(ncompdiff))
     
    212216       
    213217!       print*,'moldiff',i_h2,i_h,ncompdiff
    214       do ig=1,ngridmx
     218      do ig=1,ngrid
    215219        pp=dble(pplay(ig,:))
    216220
     
    218222
    219223!       CALL TMNEW(pt(ig,:),pdt(ig,:),pdtconduc(ig,:),pdteuv(ig,:)      &
    220 !     &  ,tt,ptimestep,nlayermx,ig)
    221         do l=1,nlayermx
     224!     &  ,tt,ptimestep,nlayer,ig)
     225        do l=1,nlayer
    222226          tt(l)=pt(ig,l)*1D0+(pdt(ig,l)*dble(ptimestep)+                &
    223227                              pdtconduc(ig,l)*dble(ptimestep)+          &
     
    228232              pdt(ig,l),pdtconduc(ig,l),pdteuv(ig,l),dble(ptimestep)
    229233          endif
    230         enddo ! of do l=1,nlayermx
     234        enddo ! of do l=1,nlayer
    231235
    232236! Update the mass mixing ratios modified by other processes
    233237
    234 !       CALL QMNEW(pq(ig,:,:),pdq(ig,:,:),qq,ptimestep,nlayermx,        &
     238!       CALL QMNEW(pq(ig,:,:),pdq(ig,:,:),qq,ptimestep,nlayer,        &
    235239!     &  ncompdiff,gcmind,ig)
    236240        do iq=1,ncompdiff
    237          do l=1,nlayermx
     241         do l=1,nlayer
    238242          qq(l,iq)=pq(ig,l,gcmind(iq))*1D0+(                            &
    239243                           pdq(ig,l,gcmind(iq))*dble(ptimestep))
    240244          qq(l,iq)=max(qq(l,iq),1d-30)
    241          enddo ! of do l=1,nlayermx
     245         enddo ! of do l=1,nlayer
    242246        enddo ! of do iq=1,ncompdiff
    243247
    244248! Compute the Pressure scale height
    245249
    246         CALL HSCALE(pp,hp,nlayermx)
     250        CALL HSCALE(pp,hp,nlayer)
    247251
    248252! Compute the atmospheric mass (in Dalton)
    249253
    250         CALL MMOY(massemoy,mmol,qq,gcmind,nlayermx,ncompdiff)
     254        CALL MMOY(massemoy,mmol,qq,gcmind,nlayer,ncompdiff)
    251255
    252256! Compute the vertical gradient of atmospheric mass
    253257
    254         CALL DMMOY(massemoy,hp,dmmeandz,nlayermx)
     258        CALL DMMOY(massemoy,hp,dmmeandz,nlayer)
    255259
    256260! Compute the altitude of each layer
    257261
    258         CALL ZVERT(pp,tt,massemoy,zz,nlayermx,ig)
     262        CALL ZVERT(pp,tt,massemoy,zz,nlayer,ig)
    259263
    260264! Compute the total mass density (kg/m3)
    261265       
    262         CALL RHOTOT(pp,tt,massemoy,qq,RHOT,RHOK,nlayermx,ncompdiff)
     266        CALL RHOTOT(pp,tt,massemoy,qq,RHOT,RHOK,nlayer,ncompdiff)
    263267        RHOKINIT=RHOK
    264268
     
    271275        Mtot1(1:ncompdiff)=0d0
    272276
    273         do l=il0,nlayermx
     277        do l=il0,nlayer
    274278        do nn=1,ncompdiff
    275279        Mtot1(nn)=Mtot1(nn)+1d0/g*qq(l,nn)*                             &
     
    279283
    280284        Zmin=zz(il0)
    281         Zmax=zz(nlayermx)
     285        Zmax=zz(nlayer)
    282286
    283287
     
    286290        if (Zmax .gt. 4000000.) then
    287291        Print*,'Zmax too high',ig,zmax,zmin
    288         do l=1,nlayermx
     292        do l=1,nlayer
    289293        print*,'old',zz(l),pt(ig,l),pdteuv(ig,l),pdq(ig,l,:)
    290294        print*,'l',l,rhot(l),tt(l),pp(l),massemoy(l),qq(l,:)
     
    321325        CALL UPPER_RESOL(pp,tt,zz,massemoy,RHOT,RHOK,                   &
    322326     &  qq,mmol,gcmind,Praf,Traf,Qraf,Mraf,Zraf,                        &
    323      &  Nraf,Nrafk,Rraf,Rrafk,il0,nlraf,ncompdiff,nlayermx,ig)
     327     &  Nraf,Nrafk,Rraf,Rrafk,il0,nlraf,ncompdiff,nlayer,ig)
    324328
    325329        Prafold=Praf
     
    330334
    331335        CALL GCMGRID_P(Zraf,Praf,Qraf,Traf,Nrafk,Rrafk,qq,qint,tt,tint  &
    332      &    ,pp,mmol,gcmind,nlraf,ncompdiff,nlayermx,ig)
     336     &    ,pp,mmol,gcmind,nlraf,ncompdiff,nlayer,ig)
    333337
    334338! We compute the mass correction factor of each specie at each pressure level
    335339
    336         CALL CORRMASS(qq,qint,FacMass,nlayermx,ncompdiff)
     340        CALL CORRMASS(qq,qint,FacMass,nlayer,ncompdiff)
    337341
    338342! Altitude step
     
    367371!       enddo
    368372
    369 !       do l=1,nlayermx
     373!       do l=1,nlayer
    370374!       print*,'l',l,zz(l),pp(l),tt(l),sum(qq(l,:)),massemoy(l)
    371375!       enddo
     
    374378! No change below il0
    375379       
    376         do l=1,nlayermx
     380        do l=1,nlayer
    377381         qnew(l,:)=qq(l,:) ! No effet below il0
    378382       enddo
     
    527531        print*,'Mraf',Mraf
    528532        stop
    529 !       pdqdiff(1:ngridmx,1:nlayermx,1:nqmx)=0.
     533!       pdqdiff(1:ngrid,1:nlayer,1:nq)=0.
    530534!       return
    531535!       Rrafk(l,nn)=1D-30*Rraf(l)
     
    572576
    573577        CALL GCMGRID_P2(Zraf,Praf,Qraf,Traf,Nrafk,Rrafk,qq,qnew,tt,tnew,&
    574      &   pp,mmol,gcmind,nlraf,ncompdiff,nlayermx,FacMass,ig)
    575 
    576         CALL RHOTOT(pp,tt,massemoy,qnew,RHOT,RHOK,nlayermx,ncompdiff)
     578     &   pp,mmol,gcmind,nlraf,ncompdiff,nlayer,FacMass,ig)
     579
     580        CALL RHOTOT(pp,tt,massemoy,qnew,RHOT,RHOK,nlayer,ncompdiff)
    577581
    578582        if (ig .eq. ij0) then
    579         do l=il0,nlayermx
     583        do l=il0,nlayer
    580584        write(*,'(i2,1x,19(e12.4,1x))') l,zz(l),tt(l),RHOK(l,1)/sum(RHOK(l,:)),RHOKINIT(l,1)/sum(RHOKINIT(l,:)),&
    581585     &  RHOK(l,2)/sum(RHOK(l,:)),RHOKINIT(l,2)/sum(RHOKINIT(l,:)),&
     
    590594        Mtot2(1:ncompdiff)=0d0
    591595
    592         do l=il0,nlayermx
     596        do l=il0,nlayer
    593597        do nn=1,ncompdiff
    594598        Mtot2(nn)=Mtot2(nn)+1d0/g*qnew(l,nn)*                           &
     
    600604
    601605!       do nn=1,ncompdiff
    602 !       CALL CheckMass2(qq,qnew,pplev(ig,:),il0,nlayermx,nn,ncompdiff)
     606!       CALL CheckMass2(qq,qnew,pplev(ig,:),il0,nlayer,nn,ncompdiff)
    603607!       enddo
    604608
    605609! Compute the diffusion trends du to diffusion
    606610
    607         do l=1,nlayermx
     611        do l=1,nlayer
    608612        do nn=1,ncompdiff
    609613        pdqdiff(ig,l,gcmind(nn))=(qnew(l,nn)-qq(l,nn))/ptimestep
Note: See TracChangeset for help on using the changeset viewer.