Ignore:
Timestamp:
Aug 27, 2013, 9:22:40 AM (11 years ago)
Author:
emillour
Message:

Mars GCM:
(Minor) optimizations: avoid seding non-contiguous arrays to routines (to avoid implicit copies of these arrays before and after being sent to the routine).
EM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.MARS/libf/aeronomars/moldiff_red.F90

    r1013 r1020  
    3636
    3737      integer,dimension(nqmx) :: indic_diff
    38       integer ig,nz,l,k,n,nn,p,ij0
     38      integer ig,iq,nz,l,k,n,nn,p,ij0
    3939      integer istep,il,gcn,ntime,nlraf
    4040      real*8 masse
     
    4747      real*8 tt(nlayermx),tnew(nlayermx),tint(nlayermx)
    4848      real*8 zz(nlayermx)
    49       real*8,dimension(:,:),allocatable :: qq,qnew,qint,FacMass
    50       real*8,dimension(:,:),allocatable :: rhoK,rhokinit
     49      real*8,dimension(:,:),allocatable,save :: qq,qnew,qint,FacMass
     50      real*8,dimension(:,:),allocatable,save :: rhoK,rhokinit
    5151      real*8 rhoT(nlayermx)
    5252      real*8 dmmeandz(nlayermx)
     
    6060      real*8,dimension(:),allocatable :: Atri,Btri,Ctri,Dtri,Xtri,Tad,Dad,Zad,rhoad
    6161      real*8,dimension(:),allocatable :: alpha,beta,gama,delta,eps
    62       real*8,dimension(:),allocatable ::  wi,Wad,Uthermal,Lambdaexo,Hspecie
    63       real*8,dimension(:),allocatable :: Mtot1,Mtot2,Mraf1,Mraf2
     62      real*8,dimension(:),allocatable,save ::  wi,Wad,Uthermal,Lambdaexo,Hspecie
     63      real*8,dimension(:),allocatable,save :: Mtot1,Mtot2,Mraf1,Mraf2
    6464      character(len=20),dimension(14) :: ListeDiff
    6565!ccccccccccccccccccccccccccccccccccccccccccccccccccccccc
     
    140140        enddo
    141141        if (indic_diff(nn) .eq. 1) then
    142         print*,'specie', noms(nn), 'diffused in moldiff_red'
     142        print*,'specie ', noms(nn), 'diffused in moldiff_red'
    143143        ncompdiff=ncompdiff+1
    144144        endif
     
    172172        call moldiffcoeff_red(dij,indic_diff,gcmind,ncompdiff)
    173173        print*,'MOLDIFF  EXO'
     174
     175! allocatation des tableaux dependants du nombre d especes diffusees
     176        allocate(qq(nlayermx,ncompdiff))
     177        allocate(qnew(nlayermx,ncompdiff))
     178        allocate(qint(nlayermx,ncompdiff))
     179        allocate(FacMass(nlayermx,ncompdiff))
     180        allocate(rhok(nlayermx,ncompdiff))
     181        allocate(rhokinit(nlayermx,ncompdiff))
     182
     183        allocate(wi(ncompdiff))
     184        allocate(wad(ncompdiff))
     185        allocate(uthermal(ncompdiff))
     186        allocate(lambdaexo(ncompdiff))
     187        allocate(Hspecie(ncompdiff))
     188        allocate(Mtot1(ncompdiff))
     189        allocate(Mtot2(ncompdiff))
     190        allocate(Mraf1(ncompdiff))
     191        allocate(Mraf2(ncompdiff))
    174192
    175193        firstcall= .false.
     
    191209        invsgmu=1d0/g/masseU
    192210       
    193 ! allocatation des tableaux dependants du nombre d especes diffusees
    194         allocate(qq(nlayermx,ncompdiff))
    195         allocate(qnew(nlayermx,ncompdiff))
    196         allocate(qint(nlayermx,ncompdiff))
    197         allocate(FacMass(nlayermx,ncompdiff))
    198         allocate(rhok(nlayermx,ncompdiff))
    199         allocate(rhokinit(nlayermx,ncompdiff))
    200 
    201         allocate(wi(ncompdiff))
    202         allocate(wad(ncompdiff))
    203         allocate(uthermal(ncompdiff))
    204         allocate(lambdaexo(ncompdiff))
    205         allocate(Hspecie(ncompdiff))
    206         allocate(Mtot1(ncompdiff))
    207         allocate(Mtot2(ncompdiff))
    208         allocate(Mraf1(ncompdiff))
    209         allocate(Mraf2(ncompdiff))
    210 
    211211!       print*,'moldiff',i_h2,i_h,ncompdiff
    212212      do ig=1,ngridmx
     
    215215! Update the temperature
    216216
    217         CALL TMNEW(pt(ig,:),pdt(ig,:),pdtconduc(ig,:),pdteuv(ig,:)      &
    218      &  ,tt,ptimestep,nlayermx,ig)
     217!       CALL TMNEW(pt(ig,:),pdt(ig,:),pdtconduc(ig,:),pdteuv(ig,:)      &
     218!     &  ,tt,ptimestep,nlayermx,ig)
     219        do l=1,nlayermx
     220          tt(l)=pt(ig,l)*1D0+(pdt(ig,l)*dble(ptimestep)+                &
     221                              pdtconduc(ig,l)*dble(ptimestep)+          &
     222                              pdteuv(ig,l)*dble(ptimestep))
     223          ! to cach Nans...
     224          if (tt(l).ne.tt(l)) then
     225            print*,'Err TMNEW',ig,l,tt(l),pt(ig,l),                     &
     226              pdt(ig,l),pdtconduc(ig,l),pdteuv(ig,l),dble(ptimestep)
     227          endif
     228        enddo ! of do l=1,nlayermx
    219229
    220230! Update the mass mixing ratios modified by other processes
    221231
    222         CALL QMNEW(pq(ig,:,:),pdq(ig,:,:),qq,ptimestep,nlayermx,        &
    223      &  ncompdiff,gcmind,ig)
     232!       CALL QMNEW(pq(ig,:,:),pdq(ig,:,:),qq,ptimestep,nlayermx,        &
     233!     &  ncompdiff,gcmind,ig)
     234        do iq=1,ncompdiff
     235         do l=1,nlayermx
     236          qq(l,iq)=pq(ig,l,gcmind(iq))*1D0+(                            &
     237                           pdq(ig,l,gcmind(iq))*dble(ptimestep))
     238          qq(l,iq)=max(qq(l,iq),1d-30)
     239         enddo ! of do l=1,nlayermx
     240        enddo ! of do iq=1,ncompdiff
    224241
    225242! Compute the Pressure scale height
     
    282299
    283300!       if (nlraf .ge. 200) print*,ig,nlraf,Zmin,Zmax
    284 
    285 ! allocation for arrays
    286 
    287         allocate(Praf(nlraf),Traf(nlraf),Rraf(nlraf),Mraf(nlraf))
    288         allocate(Nraf(nlraf),Draf(nlraf),Hraf(nlraf),Wraf(nlraf))
    289         allocate(Zraf(nlraf),Tdiffraf(nlraf))
    290         allocate(Prafold(nlraf),Mrafold(nlraf))
    291         allocate(Qraf(nlraf,ncompdiff),Rrafk(nlraf,ncompdiff),Nrafk(nlraf,ncompdiff))
    292         allocate(Rrafkold(nlraf,ncompdiff))
    293         allocate(Drafmol(nlraf,ncompdiff),Hrafmol(nlraf,ncompdiff))
    294         allocate(Wrafmol(nlraf,ncompdiff),Tdiffrafmol(nlraf,ncompdiff))
    295         allocate(Atri(nlraf),Btri(nlraf),Ctri(nlraf),Dtri(nlraf),Xtri(nlraf))
    296         allocate(Tad(nlraf),Dad(nlraf),Zad(nlraf),rhoad(nlraf))
    297         allocate(alpha(nlraf),beta(nlraf),gama(nlraf),delta(nlraf),eps(nlraf))
     301       
     302         ! allocate arrays:
     303         allocate(Praf(nlraf),Traf(nlraf),Rraf(nlraf),Mraf(nlraf))
     304         allocate(Nraf(nlraf),Draf(nlraf),Hraf(nlraf),Wraf(nlraf))
     305         allocate(Zraf(nlraf),Tdiffraf(nlraf))
     306         allocate(Prafold(nlraf),Mrafold(nlraf))
     307         allocate(Qraf(nlraf,ncompdiff),Rrafk(nlraf,ncompdiff),Nrafk(nlraf,ncompdiff))
     308         allocate(Rrafkold(nlraf,ncompdiff))
     309         allocate(Drafmol(nlraf,ncompdiff),Hrafmol(nlraf,ncompdiff))
     310         allocate(Wrafmol(nlraf,ncompdiff),Tdiffrafmol(nlraf,ncompdiff))
     311         allocate(Atri(nlraf),Btri(nlraf),Ctri(nlraf),Dtri(nlraf),Xtri(nlraf))
     312         allocate(Tad(nlraf),Dad(nlraf),Zad(nlraf),rhoad(nlraf))
     313         allocate(alpha(nlraf),beta(nlraf),gama(nlraf),delta(nlraf),eps(nlraf))
    298314
    299315! before beginning, I use a better vertical resolution above il0,
     
    610626       enddo  ! ig loop         
    611627
    612         deallocate(qq,qnew,qint)
    613         deallocate(FacMass)
    614         deallocate(rhok,rhokinit)
    615         deallocate(wi,wad,uthermal,lambdaexo)
    616         deallocate(Hspecie)
    617         deallocate(Mtot1,Mtot2,Mraf1,Mraf2)
    618628
    619629      return
     
    11621172        H(nl)=-1D0/H(nl)
    11631173
    1164         do l=1,nl
    1165         if (abs(H(l)) .lt. 100.) then
     1174!       do l=1,nl
     1175!       if (abs(H(l)) .lt. 100.) then
    11661176!       print*,'H',l,H(l),Nk(l,nn),nn
    1167         endif
    1168         enddo
     1177!       endif
     1178!       enddo
    11691179
    11701180        END
Note: See TracChangeset for help on using the changeset viewer.