Changeset 1308


Ignore:
Timestamp:
Jul 10, 2014, 3:19:01 PM (11 years ago)
Author:
emillour
Message:

Generic GCM:
Some cleanup to simplify dynamics/physics interactions by getting rid
of dimphys.h (i.e. the nlayermx parameter) and minimizing use of
dimension.h in the physics.
EM

Location:
trunk/LMDZ.GENERIC
Files:
1 deleted
51 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.GENERIC/README

    r1283 r1308  
    10321032And some cosmetic cleanup in rain.F90, vdif_kc.F and turbdiff.F90
    10331033
     1034== 10/07/2014 == EM
     1035Some cleanup to simplify dynamics/physics interactions by getting rid
     1036of dimphys.h (i.e. the nlayermx parameter) and minimizing use of
     1037dimension.h in the physics.
     1038
  • trunk/LMDZ.GENERIC/libf/phystd/aeropacity.F90

    r1132 r1308  
    3030!     pq                Aerosol mixing ratio
    3131!     reffrad(ngrid,nlayer,naerkind)         Aerosol effective radius
    32 !     QREFvis3d(ngrid,nlayermx,naerkind) \ 3d extinction coefficients
    33 !     QREFir3d(ngrid,nlayermx,naerkind)  / at reference wavelengths
     32!     QREFvis3d(ngrid,nlayer,naerkind) \ 3d extinction coefficients
     33!     QREFir3d(ngrid,nlayer,naerkind)  / at reference wavelengths
    3434!
    3535!     Output
     
    4040!=======================================================================
    4141
    42 #include "dimensions.h"
    43 #include "dimphys.h"
     42!#include "dimensions.h"
     43!#include "dimphys.h"
    4444#include "callkeys.h"
    4545#include "comcstfi.h"
    46 #include "comvert.h"
     46!#include "comvert.h"
    4747
    4848      INTEGER,INTENT(IN) :: ngrid  ! number of atmospheric columns
     
    5454      REAL,INTENT(OUT) :: aerosol(ngrid,nlayer,naerkind) ! aerosol optical depth
    5555      REAL,INTENT(IN) :: reffrad(ngrid,nlayer,naerkind) ! aerosol effective radius
    56       REAL,INTENT(IN) :: QREFvis3d(ngrid,nlayermx,naerkind) ! extinction coefficient in the visible
    57       REAL,INTENT(IN) :: QREFir3d(ngrid,nlayermx,naerkind)
     56      REAL,INTENT(IN) :: QREFvis3d(ngrid,nlayer,naerkind) ! extinction coefficient in the visible
     57      REAL,INTENT(IN) :: QREFir3d(ngrid,nlayer,naerkind)
    5858      REAL,INTENT(OUT):: tau_col(ngrid) !column integrated visible optical depth
    5959      ! BENJAMIN MODIFS
    60       real,intent(in) :: cloudfrac(ngrid,nlayermx) ! cloud fraction
     60      real,intent(in) :: cloudfrac(ngrid,nlayer) ! cloud fraction
    6161      real,intent(out) :: totcloudfrac(ngrid) ! total cloud fraction
    6262      logical,intent(in) :: clearsky
     
    135135           iaer=iaero_co2
    136136!       1. Initialization
    137             aerosol(1:ngrid,1:nlayermx,iaer)=0.0
     137            aerosol(1:ngrid,1:nlayer,iaer)=0.0
    138138!       2. Opacity calculation
    139139            if (noaero) then ! aerosol set to zero
    140              aerosol(1:ngrid,1:nlayermx,iaer)=0.0
     140             aerosol(1:ngrid,1:nlayer,iaer)=0.0
    141141            elseif (aerofixco2.or.(i_co2ice.eq.0)) then !  CO2 ice cloud prescribed
    142                aerosol(1:ngrid,1:nlayermx,iaer)=1.e-9
     142               aerosol(1:ngrid,1:nlayer,iaer)=1.e-9
    143143               !aerosol(1:ngrid,12,iaer)=4.0 ! single cloud layer option
    144144            else
     
    172172           iaer=iaero_h2o
    173173!       1. Initialization
    174             aerosol(1:ngrid,1:nlayermx,iaer)=0.0
     174            aerosol(1:ngrid,1:nlayer,iaer)=0.0
    175175!       2. Opacity calculation
    176176            if (aerofixh2o.or.(i_h2oice.eq.0).or.clearsky) then
    177                aerosol(1:ngrid,1:nlayermx,iaer) =1.e-9
     177               aerosol(1:ngrid,1:nlayer,iaer) =1.e-9
    178178
    179179               ! put cloud at cloudlvl
     
    226226
    227227               if(CLFvarying)then
    228                   call totalcloudfrac(ngrid,nq,cloudfrac,totcloudfrac,pplev,pq,aerosol(1:ngrid,1:nlayermx,iaer))
     228                  call totalcloudfrac(ngrid,nlayer,nq,cloudfrac,totcloudfrac,pplev,pq,aerosol(1,1,iaer))
    229229                  do ig=1, ngrid
    230230                     do l=1,nlayer-1 ! to stop the rad tran bug
     
    253253          iaer=iaero_dust
    254254!         1. Initialization
    255           aerosol(1:ngrid,1:nlayermx,iaer)=0.0
     255          aerosol(1:ngrid,1:nlayer,iaer)=0.0
    256256         
    257257          topdust=30.0 ! km  (used to be 10.0 km) LK
     
    264264!             Typical mixing ratio profile
    265265
    266                  zp=(preff/pplay(ig,l))**(70./topdust)
     266                 zp=(pplev(ig,1)/pplay(ig,l))**(70./topdust)
    267267                 expfactor=max(exp(0.007*(1.-max(zp,1.))),1.e-3)
    268268
     
    277277!          Rescaling each layer to reproduce the choosen (or assimilated)
    278278!          dust extinction opacity at visible reference wavelength, which
    279 !          is scaled to the "preff" reference surface pressure available in comvert.h
    280 !          and stored in startfi.nc
     279!          is scaled to the surface pressure pplev(ig,1)
    281280
    282281            taudusttmp(1:ngrid)=0.
     
    291290                  aerosol(ig,l,iaer) = max(1E-20, &
    292291                          dusttau &
    293                        *  pplev(ig,1) / preff &
     292                       *  pplev(ig,1) / pplev(ig,1) &
    294293                       *  aerosol(ig,l,iaer) &
    295294                       /  taudusttmp(ig))
     
    307306
    308307!       1. Initialization
    309          aerosol(1:ngrid,1:nlayermx,iaer)=0.0
     308         aerosol(1:ngrid,1:nlayer,iaer)=0.0
    310309
    311310
     
    317316!              Typical mixing ratio profile
    318317
    319                zp=(preff/pplay(ig,l))**(70./30) !emulating topdust
     318               zp=(pplev(ig,1)/pplay(ig,l))**(70./30) !emulating topdust
    320319               expfactor=max(exp(0.007*(1.-max(zp,1.))),1.e-3)
    321320
     
    335334               aerosol(ig,l,iaer) = max(1E-20, &
    336335                          1 &
    337                        *  pplev(ig,1) / preff &
     336                       *  pplev(ig,1) / pplev(ig,1) &
    338337                       *  aerosol(ig,l,iaer) &
    339338                       /  tauh2so4tmp(ig))
     
    367366           iaer=iaero_back2lay
    368367!       1. Initialization
    369             aerosol(1:ngrid,1:nlayermx,iaer)=0.0
     368            aerosol(1:ngrid,1:nlayer,iaer)=0.0
    370369!       2. Opacity calculation
    371370          DO ig=1,ngrid
  • trunk/LMDZ.GENERIC/libf/phystd/aeroptproperties.F90

    r787 r1308  
    3232!     ==============================================================
    3333
    34 #include "dimensions.h"
    35 #include "dimphys.h"
     34!#include "dimensions.h"
     35!#include "dimphys.h"
    3636#include "callkeys.h"
    3737
     
    6060      INTEGER :: grid_i,grid_j
    6161!     Intermediate variable
    62       REAL :: var_tmp,var3d_tmp(ngrid,nlayermx)
     62      REAL :: var_tmp,var3d_tmp(ngrid,nlayer)
    6363!     Bilinear interpolation factors
    6464      REAL :: kx,ky,k1,k2,k3,k4
     
    161161      INTEGER :: ngrid,nlayer
    162162!     Aerosol effective radius used for radiative transfer (meter)
    163       REAL :: reffrad(ngrid,nlayermx,naerkind)
     163      REAL,INTENT(IN) :: reffrad(ngrid,nlayer,naerkind)
    164164!     Aerosol effective variance used for radiative transfer (n.u.)
    165       REAL :: nueffrad(ngrid,nlayermx,naerkind)
     165      REAL,INTENT(IN) :: nueffrad(ngrid,nlayer,naerkind)
    166166
    167167!     Outputs
    168168!     -------
    169169
    170       REAL :: QVISsQREF3d(ngrid,nlayermx,L_NSPECTV,naerkind)
    171       REAL :: omegaVIS3d(ngrid,nlayermx,L_NSPECTV,naerkind)
    172       REAL :: gVIS3d(ngrid,nlayermx,L_NSPECTV,naerkind)
    173 
    174       REAL :: QIRsQREF3d(ngrid,nlayermx,L_NSPECTI,naerkind)
    175       REAL :: omegaIR3d(ngrid,nlayermx,L_NSPECTI,naerkind)
    176       REAL :: gIR3d(ngrid,nlayermx,L_NSPECTI,naerkind)
    177 
    178       REAL :: QREFvis3d(ngrid,nlayermx,naerkind)
    179       REAL :: QREFir3d(ngrid,nlayermx,naerkind)
    180 
    181       REAL :: omegaREFvis3d(ngrid,nlayermx,naerkind)
    182       REAL :: omegaREFir3d(ngrid,nlayermx,naerkind)
     170      REAL,INTENT(OUT) :: QVISsQREF3d(ngrid,nlayer,L_NSPECTV,naerkind)
     171      REAL,INTENT(OUT) :: omegaVIS3d(ngrid,nlayer,L_NSPECTV,naerkind)
     172      REAL,INTENT(OUT) :: gVIS3d(ngrid,nlayer,L_NSPECTV,naerkind)
     173
     174      REAL,INTENT(OUT) :: QIRsQREF3d(ngrid,nlayer,L_NSPECTI,naerkind)
     175      REAL,INTENT(OUT) :: omegaIR3d(ngrid,nlayer,L_NSPECTI,naerkind)
     176      REAL,INTENT(OUT) :: gIR3d(ngrid,nlayer,L_NSPECTI,naerkind)
     177
     178      REAL,INTENT(OUT) :: QREFvis3d(ngrid,nlayer,naerkind)
     179      REAL,INTENT(OUT) :: QREFir3d(ngrid,nlayer,naerkind)
     180
     181      REAL :: omegaREFvis3d(ngrid,nlayer,naerkind)
     182      REAL :: omegaREFir3d(ngrid,nlayer,naerkind)
    183183
    184184      DO iaer = 1, naerkind ! Loop on aerosol kind
     
    724724                        k2*omegrefIRgrid(grid_i+1,1,iaer)
    725725          ENDIF                  ! --------------------------------
    726         ENDDO !nlayermx
     726        ENDDO !nlayer
    727727      ENDDO !ngrid
    728728
  • trunk/LMDZ.GENERIC/libf/phystd/calc_cpp_mugaz.F90

    r869 r1308  
    2020      implicit none
    2121
    22 #include "dimensions.h"
    23 #include "dimphys.h"
     22!#include "dimensions.h"
     23!#include "dimphys.h"
    2424#include "comcstfi.h"
    2525#include "callkeys.h"
  • trunk/LMDZ.GENERIC/libf/phystd/calcenergy_kcm.F90

    r787 r1308  
    1 subroutine calcenergy_kcm(Tsurf,T,Play,Plev,Qsurf,Q,muvar,Eatmtot)
     1subroutine calcenergy_kcm(nlayer,Tsurf,T,Play,Plev,Qsurf,Q,muvar,Eatmtot)
    22
    33
     
    1111!     ----------------------------------------------------------------
    1212
    13 #include "dimensions.h"
    14 #include "dimphys.h"
     13!#include "dimensions.h"
     14!#include "dimphys.h"
    1515#include "comcstfi.h"
    1616!#include "callkeys.h"
     
    1919
    2020  ! inputs
    21   real Tsurf,T(1:nlayermx)
    22   real Play(1:nlayermx),Plev(1:nlayermx+1)
    23   real Qsurf,Q(1:nlayermx)
    24   real muvar(1,nlayermx+1)
     21  integer,intent(in) :: nlayer
     22  real Tsurf,T(1:nlayer)
     23  real Play(1:nlayer),Plev(1:nlayer+1)
     24  real Qsurf,Q(1:nlayer)
     25  real muvar(1,nlayer+1)
    2526
    2627  ! internal
     
    2930  real s_c,rho_v,L
    3031  double precision p_v, s_v, nul
    31   real VMR(1:nlayermx)
     32  real VMR(1:nlayer)
    3233
    3334  ! output
     
    4142
    4243
    43   do il=1,nlayermx
     44  do il=1,nlayer
    4445     VMR(il)=Q(il)*(muvar(1,il+1)/mH2O)
    4546  end do
     
    4748
    4849  Eatmtot = 0.0
    49   do il=1,nlayermx
     50  do il=1,nlayer
    5051
    5152
  • trunk/LMDZ.GENERIC/libf/phystd/callcorrk.F90

    r1194 r1308  
    3535!==================================================================
    3636
    37 #include "dimphys.h"
     37!#include "dimphys.h"
    3838#include "comcstfi.h"
    3939#include "callkeys.h"
     
    4242!     Declaration of the arguments (INPUT - OUTPUT) on the LMD GCM grid
    4343!     Layer #1 is the layer near the ground.
    44 !     Layer #nlayermx is the layer at the top.
     44!     Layer #nlayer is the layer at the top.
    4545
    4646      INTEGER,INTENT(IN) :: ngrid ! number of atmospheric columns
     
    5252      REAL,INTENT(IN) :: emis(ngrid)     ! LW emissivity
    5353      real,intent(in) :: mu0(ngrid) ! cosine of sun incident angle
    54       REAL,INTENT(IN) :: pplev(ngrid,nlayermx+1)  ! inter-layer pressure (Pa)
    55       REAL,INTENT(IN) :: pplay(ngrid,nlayermx)    ! mid-layer pressure (Pa)
    56       REAL,INTENT(IN) :: pt(ngrid,nlayermx)  ! air temperature (K)
     54      REAL,INTENT(IN) :: pplev(ngrid,nlayer+1)  ! inter-layer pressure (Pa)
     55      REAL,INTENT(IN) :: pplay(ngrid,nlayer)    ! mid-layer pressure (Pa)
     56      REAL,INTENT(IN) :: pt(ngrid,nlayer)  ! air temperature (K)
    5757      REAL,INTENT(IN) :: tsurf(ngrid)        ! surface temperature (K)
    5858      REAL,INTENT(IN) :: fract(ngrid)        ! fraction of day
    5959      REAL,INTENT(IN) :: dist_star           ! distance star-planet (AU)
    60       REAL,INTENT(OUT) :: aerosol(ngrid,nlayermx,naerkind) ! aerosol tau (kg/kg)
    61       real,intent(in) :: muvar(ngrid,nlayermx+1)
    62       REAL,INTENT(OUT) :: dtlw(ngrid,nlayermx) ! heating rate (K/s) due to LW
    63       REAL,INTENT(OUT) :: dtsw(ngrid,nlayermx) ! heating rate (K/s) due to SW
     60      REAL,INTENT(OUT) :: aerosol(ngrid,nlayer,naerkind) ! aerosol tau (kg/kg)
     61      real,intent(in) :: muvar(ngrid,nlayer+1)
     62      REAL,INTENT(OUT) :: dtlw(ngrid,nlayer) ! heating rate (K/s) due to LW
     63      REAL,INTENT(OUT) :: dtsw(ngrid,nlayer) ! heating rate (K/s) due to SW
    6464      REAL,INTENT(OUT) :: fluxsurf_lw(ngrid)   ! incident LW flux to surf (W/m2)
    6565      REAL,INTENT(OUT) :: fluxsurf_sw(ngrid)   ! incident SW flux to surf (W/m2)
     
    7171      REAL,INTENT(OUT) :: tau_col(ngrid) ! diagnostic from aeropacity
    7272!     for H2O cloud fraction in aeropacity
    73       real,intent(in) :: cloudfrac(ngrid,nlayermx)
     73      real,intent(in) :: cloudfrac(ngrid,nlayer)
    7474      real,intent(out) :: totcloudfrac(ngrid)
    7575      logical,intent(in) :: clearsky
     
    7979!     Globally varying aerosol optical properties on GCM grid
    8080!     Not needed everywhere so not in radcommon_h
    81       REAL :: QVISsQREF3d(ngrid,nlayermx,L_NSPECTV,naerkind)
    82       REAL :: omegaVIS3d(ngrid,nlayermx,L_NSPECTV,naerkind)
    83       REAL :: gVIS3d(ngrid,nlayermx,L_NSPECTV,naerkind)
    84 
    85       REAL :: QIRsQREF3d(ngrid,nlayermx,L_NSPECTI,naerkind)
    86       REAL :: omegaIR3d(ngrid,nlayermx,L_NSPECTI,naerkind)
    87       REAL :: gIR3d(ngrid,nlayermx,L_NSPECTI,naerkind)
    88 
    89 !      REAL :: omegaREFvis3d(ngrid,nlayermx,naerkind)
    90 !      REAL :: omegaREFir3d(ngrid,nlayermx,naerkind) ! not sure of the point of these...
     81      REAL :: QVISsQREF3d(ngrid,nlayer,L_NSPECTV,naerkind)
     82      REAL :: omegaVIS3d(ngrid,nlayer,L_NSPECTV,naerkind)
     83      REAL :: gVIS3d(ngrid,nlayer,L_NSPECTV,naerkind)
     84
     85      REAL :: QIRsQREF3d(ngrid,nlayer,L_NSPECTI,naerkind)
     86      REAL :: omegaIR3d(ngrid,nlayer,L_NSPECTI,naerkind)
     87      REAL :: gIR3d(ngrid,nlayer,L_NSPECTI,naerkind)
     88
     89!      REAL :: omegaREFvis3d(ngrid,nlayer,naerkind)
     90!      REAL :: omegaREFir3d(ngrid,nlayer,naerkind) ! not sure of the point of these...
    9191
    9292      REAL,ALLOCATABLE,SAVE :: reffrad(:,:,:) ! aerosol effective radius (m)
     
    141141      real*8,save ::  GIAER(L_LEVELS+1,L_NSPECTI,naerkind)
    142142
    143       !REAL :: QREFvis3d(ngrid,nlayermx,naerkind)
    144       !REAL :: QREFir3d(ngrid,nlayermx,naerkind)
     143      !REAL :: QREFvis3d(ngrid,nlayer,naerkind)
     144      !REAL :: QREFir3d(ngrid,nlayer,naerkind)
    145145      !save QREFvis3d, QREFir3d
    146146      real, dimension(:,:,:), save, allocatable :: QREFvis3d
     
    177177
    178178!     included by RW for runaway greenhouse 1D study
    179       real vtmp(nlayermx)
     179      real vtmp(nlayer)
    180180      REAL*8 muvarrad(L_LEVELS)
    181181
     
    195195         !!! ALLOCATED instances are necessary because of CLFvarying
    196196         !!! strategy to call callcorrk twice in physiq...
    197          IF(.not.ALLOCATED(QREFvis3d)) ALLOCATE(QREFvis3d(ngrid,nlayermx,naerkind))
    198          IF(.not.ALLOCATED(QREFir3d)) ALLOCATE(QREFir3d(ngrid,nlayermx,naerkind))
     197         IF(.not.ALLOCATED(QREFvis3d)) ALLOCATE(QREFvis3d(ngrid,nlayer,naerkind))
     198         IF(.not.ALLOCATED(QREFir3d)) ALLOCATE(QREFir3d(ngrid,nlayer,naerkind))
    199199         ! Effective radius and variance of the aerosols
    200200         IF(.not.ALLOCATED(reffrad)) allocate(reffrad(ngrid,nlayer,naerkind))
     
    207207            call abort
    208208         endif
    209          call su_aer_radii(ngrid,reffrad,nueffrad)
     209         call su_aer_radii(ngrid,nlayer,reffrad,nueffrad)
    210210         
    211211         
     
    266266
    267267         if ((iaer.eq.iaero_co2).and.tracer.and.(igcm_co2_ice.gt.0)) then ! treat condensed co2 particles.
    268             call co2_reffrad(ngrid,nq,pq,reffrad(1,1,iaero_co2))
    269             print*,'Max. CO2 ice particle size = ',maxval(reffrad(1:ngrid,1:nlayermx,iaer))/1.e-6,' um'
    270             print*,'Min. CO2 ice particle size = ',minval(reffrad(1:ngrid,1:nlayermx,iaer))/1.e-6,' um'
     268            call co2_reffrad(ngrid,nlayer,nq,pq,reffrad(1,1,iaero_co2))
     269            print*,'Max. CO2 ice particle size = ',maxval(reffrad(1:ngrid,1:nlayer,iaer))/1.e-6,' um'
     270            print*,'Min. CO2 ice particle size = ',minval(reffrad(1:ngrid,1:nlayer,iaer))/1.e-6,' um'
    271271         end if
    272272         if ((iaer.eq.iaero_h2o).and.water) then ! treat condensed water particles. to be generalized for other aerosols
    273             call h2o_reffrad(ngrid,pq(1,1,igcm_h2o_ice),pt, &
     273            call h2o_reffrad(ngrid,nlayer,pq(1,1,igcm_h2o_ice),pt, &
    274274                             reffrad(1,1,iaero_h2o),nueffrad(1,1,iaero_h2o))
    275             print*,'Max. H2O cloud particle size = ',maxval(reffrad(1:ngrid,1:nlayermx,iaer))/1.e-6,' um'
    276             print*,'Min. H2O cloud particle size = ',minval(reffrad(1:ngrid,1:nlayermx,iaer))/1.e-6,' um'
     275            print*,'Max. H2O cloud particle size = ',maxval(reffrad(1:ngrid,1:nlayer,iaer))/1.e-6,' um'
     276            print*,'Min. H2O cloud particle size = ',minval(reffrad(1:ngrid,1:nlayer,iaer))/1.e-6,' um'
    277277         endif
    278278         if(iaer.eq.iaero_dust)then
    279             call dust_reffrad(ngrid,reffrad(1,1,iaero_dust))
     279            call dust_reffrad(ngrid,nlayer,reffrad(1,1,iaero_dust))
    280280            print*,'Dust particle size = ',reffrad(1,1,iaer)/1.e-6,' um'
    281281         endif
    282282         if(iaer.eq.iaero_h2so4)then
    283             call h2so4_reffrad(ngrid,reffrad(1,1,iaero_h2so4))
     283            call h2so4_reffrad(ngrid,nlayer,reffrad(1,1,iaero_h2so4))
    284284            print*,'H2SO4 particle size =',reffrad(1,1,iaer)/1.e-6,' um'
    285285         endif
     
    318318            do iaer=1,naerkind
    319319               DO nw=1,L_NSPECTV
    320                   do l=1,nlayermx
    321 
    322                      temp1=QVISsQREF3d(ig,nlayermx+1-l,nw,iaer)         &
    323                          *QREFvis3d(ig,nlayermx+1-l,iaer)
    324 
    325                      temp2=QVISsQREF3d(ig,max(nlayermx-l,1),nw,iaer)    &
    326                          *QREFvis3d(ig,max(nlayermx-l,1),iaer)
     320                  do l=1,nlayer
     321
     322                     temp1=QVISsQREF3d(ig,nlayer+1-l,nw,iaer)         &
     323                         *QREFvis3d(ig,nlayer+1-l,iaer)
     324
     325                     temp2=QVISsQREF3d(ig,max(nlayer-l,1),nw,iaer)    &
     326                         *QREFvis3d(ig,max(nlayer-l,1),iaer)
    327327
    328328                     qxvaer(2*l,nw,iaer)  = temp1
    329329                     qxvaer(2*l+1,nw,iaer)=(temp1+temp2)/2
    330330
    331                      temp1=temp1*omegavis3d(ig,nlayermx+1-l,nw,iaer)
    332                      temp2=temp2*omegavis3d(ig,max(nlayermx-l,1),nw,iaer)
     331                     temp1=temp1*omegavis3d(ig,nlayer+1-l,nw,iaer)
     332                     temp2=temp2*omegavis3d(ig,max(nlayer-l,1),nw,iaer)
    333333
    334334                     qsvaer(2*l,nw,iaer)  = temp1
    335335                     qsvaer(2*l+1,nw,iaer)=(temp1+temp2)/2
    336336
    337                      temp1=gvis3d(ig,nlayermx+1-l,nw,iaer)
    338                      temp2=gvis3d(ig,max(nlayermx-l,1),nw,iaer)
     337                     temp1=gvis3d(ig,nlayer+1-l,nw,iaer)
     338                     temp2=gvis3d(ig,max(nlayer-l,1),nw,iaer)
    339339
    340340                     gvaer(2*l,nw,iaer)  = temp1
     
    344344
    345345                  qxvaer(1,nw,iaer)=qxvaer(2,nw,iaer)
    346                   qxvaer(2*nlayermx+1,nw,iaer)=0.
     346                  qxvaer(2*nlayer+1,nw,iaer)=0.
    347347
    348348                  qsvaer(1,nw,iaer)=qsvaer(2,nw,iaer)
    349                   qsvaer(2*nlayermx+1,nw,iaer)=0.
     349                  qsvaer(2*nlayer+1,nw,iaer)=0.
    350350
    351351                  gvaer(1,nw,iaer)=gvaer(2,nw,iaer)
    352                   gvaer(2*nlayermx+1,nw,iaer)=0.
     352                  gvaer(2*nlayer+1,nw,iaer)=0.
    353353
    354354               end do
     
    356356!     longwave
    357357               DO nw=1,L_NSPECTI
    358                   do l=1,nlayermx
    359 
    360                      temp1=QIRsQREF3d(ig,nlayermx+1-l,nw,iaer)         &
    361                           *QREFir3d(ig,nlayermx+1-l,iaer)
    362 
    363                      temp2=QIRsQREF3d(ig,max(nlayermx-l,1),nw,iaer)    &
    364                           *QREFir3d(ig,max(nlayermx-l,1),iaer)
     358                  do l=1,nlayer
     359
     360                     temp1=QIRsQREF3d(ig,nlayer+1-l,nw,iaer)         &
     361                          *QREFir3d(ig,nlayer+1-l,iaer)
     362
     363                     temp2=QIRsQREF3d(ig,max(nlayer-l,1),nw,iaer)    &
     364                          *QREFir3d(ig,max(nlayer-l,1),iaer)
    365365
    366366                     qxiaer(2*l,nw,iaer)  = temp1
    367367                     qxiaer(2*l+1,nw,iaer)=(temp1+temp2)/2
    368368
    369                      temp1=temp1*omegair3d(ig,nlayermx+1-l,nw,iaer)
    370                      temp2=temp2*omegair3d(ig,max(nlayermx-l,1),nw,iaer)
     369                     temp1=temp1*omegair3d(ig,nlayer+1-l,nw,iaer)
     370                     temp2=temp2*omegair3d(ig,max(nlayer-l,1),nw,iaer)
    371371
    372372                     qsiaer(2*l,nw,iaer)  = temp1
    373373                     qsiaer(2*l+1,nw,iaer)=(temp1+temp2)/2
    374374
    375                      temp1=gir3d(ig,nlayermx+1-l,nw,iaer)
    376                      temp2=gir3d(ig,max(nlayermx-l,1),nw,iaer)
     375                     temp1=gir3d(ig,nlayer+1-l,nw,iaer)
     376                     temp2=gir3d(ig,max(nlayer-l,1),nw,iaer)
    377377
    378378                     giaer(2*l,nw,iaer)  = temp1
     
    382382
    383383                  qxiaer(1,nw,iaer)=qxiaer(2,nw,iaer)
    384                   qxiaer(2*nlayermx+1,nw,iaer)=0.
     384                  qxiaer(2*nlayer+1,nw,iaer)=0.
    385385
    386386                  qsiaer(1,nw,iaer)=qsiaer(2,nw,iaer)
    387                   qsiaer(2*nlayermx+1,nw,iaer)=0.
     387                  qsiaer(2*nlayer+1,nw,iaer)=0.
    388388
    389389                  giaer(1,nw,iaer)=giaer(2,nw,iaer)
    390                   giaer(2*nlayermx+1,nw,iaer)=0.
     390                  giaer(2*nlayer+1,nw,iaer)=0.
    391391
    392392               end do
     
    481481      elseif(varfixed)then
    482482
    483          do l=1,nlayermx        ! here we will assign fixed water vapour profiles globally
     483         do l=1,nlayer        ! here we will assign fixed water vapour profiles globally
    484484            RH = satval * ((pplay(ig,l)/pplev(ig,1) - 0.02) / 0.98)
    485485            if(RH.lt.0.0) RH=0.0
     
    507507!         call watersat(Ttemp,ptemp,qsat)
    508508
    509          qvar(2*nlayermx+1)= RH * qsat ! ~realistic profile (e.g. 80% saturation at ground)
     509         qvar(2*nlayer+1)= RH * qsat ! ~realistic profile (e.g. 80% saturation at ground)
    510510 
    511511      else
     
    541541     
    542542            muvarrad(1) = muvarrad(2)
    543             muvarrad(2*nlayermx+1)=muvar(ig,1)
     543            muvarrad(2*nlayer+1)=muvar(ig,1)
    544544
    545545            print*,'Recalculating qvar with VARIABLE epsi for kastprof'
     
    579579     
    580580         muvarrad(1) = muvarrad(2)
    581          muvarrad(2*nlayermx+1)=muvar(ig,1)         
     581         muvarrad(2*nlayer+1)=muvar(ig,1)         
    582582      endif
    583583     
     
    607607
    608608      tlevrad(1) = tlevrad(2)
    609       tlevrad(2*nlayermx+1)=tsurf(ig)
     609      tlevrad(2*nlayer+1)=tsurf(ig)
    610610     
    611611      tmid(1) = tlevrad(2)
  • trunk/LMDZ.GENERIC/libf/phystd/callsedim.F

    r1006 r1308  
    2828c   -------------
    2929
    30 #include "dimensions.h"
    31 #include "dimphys.h"
     30!#include "dimensions.h"
     31!#include "dimphys.h"
    3232#include "comcstfi.h"
    3333#include "callkeys.h"
     
    6565      real epaisseur (ngrid,nlay) ! Layer thickness (m)
    6666      real wq(ngrid,nlay+1) ! displaced tracer mass (kg.m-2)
    67 c      real dens(ngrid,nlayermx) ! Mean density of the ice part. accounting for dust core
     67c      real dens(ngrid,nlay) ! Mean density of the ice part. accounting for dust core
    6868
    6969
     
    125125          if (water.and.(iq.eq.igcm_h2o_ice)) then
    126126            ! compute radii for h2o_ice
    127              call h2o_reffrad(ngrid,zqi(1,1,igcm_h2o_ice),zt,
     127             call h2o_reffrad(ngrid,nlay,zqi(1,1,igcm_h2o_ice),zt,
    128128     &                reffrad(1,1,iaero_h2o),nueffrad(1,1,iaero_h2o))
    129129            ! call sedimentation for h2o_ice
  • trunk/LMDZ.GENERIC/libf/phystd/condense_cloud.F90

    r1216 r1308  
    3232!     ptsrf(ngrid)          Surface temperature
    3333!     
    34 !     pdt(ngrid,nlayermx)   Time derivative before condensation/sublimation of pt
     34!     pdt(ngrid,nlayer)   Time derivative before condensation/sublimation of pt
    3535!     pdtsrf(ngrid)         Time derivative before condensation/sublimation of ptsrf
    3636!     pqsurf(ngrid,nq)      Sedimentation flux at the surface (kg.m-2.s-1)
     
    3838!     Outputs
    3939!     -------
    40 !     pdpsrf(ngrid)         \  Contribution of condensation/sublimation
    41 !     pdtc(ngrid,nlayermx)  /  to the time derivatives of Ps, pt, and ptsrf
    42 !     pdtsrfc(ngrid)       /
     40!     pdpsrf(ngrid)       \  Contribution of condensation/sublimation
     41!     pdtc(ngrid,nlayer)  /  to the time derivatives of Ps, pt, and ptsrf
     42!     pdtsrfc(ngrid)     /
    4343!     
    4444!     Both
     
    5656!==================================================================
    5757
    58 #include "dimensions.h"
    59 #include "dimphys.h"
     58!#include "dimensions.h"
     59!#include "dimphys.h"
    6060#include "comcstfi.h"
    61 #include "comvert.h"
     61!#include "comvert.h"
    6262#include "callkeys.h"
    6363
     
    9999
    100100      REAL reffrad(ngrid,nlayer) ! radius (m) of the co2 ice particles
    101       REAL*8 zt(ngrid,nlayermx)
    102       REAL zq(ngrid,nlayermx,nq)
     101      REAL*8 zt(ngrid,nlayer)
     102      REAL zq(ngrid,nlayer,nq)
    103103      REAL zcpi
    104       REAL ztcond (ngrid,nlayermx)
    105       REAL ztnuc (ngrid,nlayermx)
     104      REAL ztcond (ngrid,nlayer)
     105      REAL ztnuc (ngrid,nlayer)
    106106      REAL ztcondsol(ngrid)
    107107      REAL zdiceco2(ngrid)
    108       REAL zcondicea(ngrid,nlayermx), zcondices(ngrid)
     108      REAL zcondicea(ngrid,nlayer), zcondices(ngrid)
    109109      REAL zfallice(ngrid), Mfallice(ngrid)
    110       REAL zmflux(nlayermx+1)
    111       REAL zu(nlayermx),zv(nlayermx)
     110      REAL zmflux(nlayer+1)
     111      REAL zu(nlayer),zv(nlayer)
    112112      REAL ztsrf(ngrid)
    113       REAL ztc(nlayermx), ztm(nlayermx+1)
    114       REAL zum(nlayermx+1) , zvm(nlayermx+1)
     113      REAL ztc(nlayer), ztm(nlayer+1)
     114      REAL zum(nlayer+1) , zvm(nlayer+1)
    115115      LOGICAL condsub(ngrid)
    116116      REAL subptimestep
    117117      Integer Ntime
    118       real masse (ngrid,nlayermx), w(ngrid,nlayermx,nq)
    119       real wq(ngrid,nlayermx+1)
     118      real masse (ngrid,nlayer), w(ngrid,nlayer,nq)
     119      real wq(ngrid,nlayer+1)
    120120      real vstokes,reff
    121121
    122122!     Special diagnostic variables
    123       real tconda1(ngrid,nlayermx)
    124       real tconda2(ngrid,nlayermx)
    125       real zdtsig (ngrid,nlayermx)
    126       real zdt (ngrid,nlayermx)
     123      real tconda1(ngrid,nlayer)
     124      real tconda2(ngrid,nlayer)
     125      real zdtsig (ngrid,nlayer)
     126      real zdt (ngrid,nlayer)
    127127
    128128!-----------------------------------------------------------------------
     
    205205!     zcondices(ngrid)     condensation rate on the ground  (kg/m2/s)
    206206!     zfallice(ngrid)      flux of ice falling on surface   (kg/m2/s)
    207 !     pdtc(ngrid,nlayermx) dT/dt due to phase changes       (K/s)
     207!     pdtc(ngrid,nlayer) dT/dt due to phase changes       (K/s)
    208208     
    209209
     
    301301           
    302302!     sedimentation computed from radius computed from q in module radii_mod
    303          call co2_reffrad(ngrid,nq,zq,reffrad)
     303         call co2_reffrad(ngrid,nlayer,nq,zq,reffrad)
    304304         
    305305         do  ilay=1,nlayer
     
    321321!     Computing q after sedimentation
    322322
    323          call vlz_fi(ngrid,zq(1,1,i_co2ice),2.,masse,w(1,1,i_co2ice),wq)
     323         call vlz_fi(ngrid,nlayer,zq(1,1,i_co2ice),2.,masse,w(1,1,i_co2ice),wq)
    324324
    325325
  • trunk/LMDZ.GENERIC/libf/phystd/convadj.F

    r787 r1308  
    2929!     ------------
    3030
    31 #include "dimensions.h"
    32 #include "dimphys.h"
     31!#include "dimensions.h"
     32!#include "dimphys.h"
    3333#include "comcstfi.h"
    3434#include "callkeys.h"
     
    5757      INTEGER jcnt, jadrs(ngrid)
    5858
    59       REAL sig(nlayermx+1),sdsig(nlayermx),dsig(nlayermx)
    60       REAL zu(ngrid,nlayermx),zv(ngrid,nlayermx)
    61       REAL zh(ngrid,nlayermx)
    62       REAL zu2(ngrid,nlayermx),zv2(ngrid,nlayermx)
    63       REAL zh2(ngrid,nlayermx), zhc(ngrid,nlayermx)
     59      REAL sig(nlay+1),sdsig(nlay),dsig(nlay)
     60      REAL zu(ngrid,nlay),zv(ngrid,nlay)
     61      REAL zh(ngrid,nlay)
     62      REAL zu2(ngrid,nlay),zv2(ngrid,nlay)
     63      REAL zh2(ngrid,nlay), zhc(ngrid,nlay)
    6464      REAL zhm,zsm,zdsm,zum,zvm,zalpha,zhmc
    6565
     
    6767      INTEGER iq,ico2
    6868      save ico2
    69       REAL zq(ngrid,nlayermx,nq), zq2(ngrid,nlayermx,nq)
     69      REAL zq(ngrid,nlay,nq), zq2(ngrid,nlay,nq)
    7070      REAL zqm(nq),zqco2m
    7171      real m_co2, m_noco2, A , B
  • trunk/LMDZ.GENERIC/libf/phystd/evap.F

    r787 r1308  
    1       subroutine evap(ngrid,nq,dtime,pt, pq, pdq, pdt, 
     1      subroutine evap(ngrid,nlayer,nq,dtime,pt, pq, pdq, pdt, 
    22     $     dqevap,dtevap, qevap, tevap)
    33       
     
    77      implicit none
    88
    9 #include "dimensions.h"
    10 #include "dimphys.h"
     9!#include "dimensions.h"
     10!#include "dimphys.h"
    1111#include "comcstfi.h"
    1212
     
    2424!==================================================================
    2525
    26       INTEGER ngrid,nq
     26      INTEGER ngrid,nlayer,nq
    2727
    2828! Arguments:
    29       REAL pt(ngrid,nlayermx)
    30       REAL pq(ngrid,nlayermx,nq)
    31       REAL pdt(ngrid,nlayermx)
    32       REAL pdq(ngrid,nlayermx,nq)
    33       REAL dqevap(ngrid,nlayermx)
    34       REAL dtevap(ngrid,nlayermx)
    35       REAL qevap(ngrid,nlayermx,nq)
     29      REAL pt(ngrid,nlayer)
     30      REAL pq(ngrid,nlayer,nq)
     31      REAL pdt(ngrid,nlayer)
     32      REAL pdq(ngrid,nlayer,nq)
     33      REAL dqevap(ngrid,nlayer)
     34      REAL dtevap(ngrid,nlayer)
     35      REAL qevap(ngrid,nlayer,nq)
    3636      REAL dtime
    3737 
    3838! Local:
    39       REAL tevap(ngrid,nlayermx)
     39      REAL tevap(ngrid,nlayer)
    4040      REAL zlvdcp
    4141      REAL zlsdcp
     
    4747!
    4848
    49       DO l=1,nlayermx
     49      DO l=1,nlayer
    5050        DO ig=1,ngrid
    5151         qevap(ig,l,igcm_h2o_vap)=pq(ig,l,igcm_h2o_vap)
     
    5757      ENDDO
    5858
    59       DO l = 1, nlayermx 
     59      DO l = 1, nlayer
    6060        DO ig = 1, ngrid
    6161         zlvdcp=RLVTT/RCPD!/(1.0+RVTMP2*qevap(ig,l,igcm_h2o_vap))
     
    7777      ENDDO
    7878
    79       RETURN
    8079      END
  • trunk/LMDZ.GENERIC/libf/phystd/forceWCfn.F

    r787 r1308  
    1       subroutine forceWCfn(ngrid,nq,pplev,pt,dq,dqs)
     1      subroutine forceWCfn(ngrid,nlayer,nq,pplev,pt,dq,dqs)
    22
    33      USE tracer_h
     
    1818!==================================================================
    1919
    20 #include "dimensions.h"
    21 #include "dimphys.h"
     20!#include "dimensions.h"
     21!#include "dimphys.h"
    2222#include "comcstfi.h"
    2323
    24       INTEGER ngrid,nq
     24      INTEGER ngrid,nlayer,nq
    2525
    2626      real masse, Wtot, Wdiff
    2727
    28       real pplev(ngrid,nlayermx+1)
     28      real pplev(ngrid,nlayer+1)
    2929      real pt(ngrid)
    3030
    3131      real dqs(ngrid,nq)
    32       real dq(ngrid,nlayermx,nq)
     32      real dq(ngrid,nlayer,nq)
    3333
    3434      integer iq, ig, ilay
     
    3737        do ig=1,ngrid
    3838           Wtot = 0.0
    39            do ilay=1,nlayermx
     39           do ilay=1,nlayer
    4040              masse = (pplev(ig,ilay) - pplev(ig,ilay+1))/g
    4141              Wtot  = Wtot + masse*dq(ig,ilay,iq)
  • trunk/LMDZ.GENERIC/libf/phystd/hydrol.F90

    r1297 r1308  
    3939!==================================================================
    4040
    41 #include "dimensions.h"
    42 #include "dimphys.h"
     41!#include "dimensions.h"
     42!#include "dimphys.h"
    4343#include "comcstfi.h"
    4444#include "callkeys.h"
  • trunk/LMDZ.GENERIC/libf/phystd/ini_archive.F

    r1216 r1308  
    4040
    4141#include "dimensions.h"
    42 #include "dimphys.h"
     42!#include "dimphys.h"
    4343#include "paramet.h"
    4444#include "comconst.h"
  • trunk/LMDZ.GENERIC/libf/phystd/inifis.F

    r1297 r1308  
    1010      use comsoil_h, only: ini_comsoil_h
    1111      use control_mod, only: ecritphy
     12      use planete_mod, only: nres
    1213      use planetwide_mod, only: planetwide_sumval
    1314
     
    5152      USE ioipsl_getincom
    5253      IMPLICIT NONE
    53 #include "dimensions.h"
    54 #include "dimphys.h"
    55 #include "planete.h"
     54!#include "dimensions.h"
     55!#include "dimphys.h"
     56!#include "planete.h"
    5657#include "comcstfi.h"
    5758#include "callkeys.h"
     
    8889      avocado = 6.02214179e23   ! added by RW
    8990
    90 ! --------------------------------------------------------
    91 !     The usual Tests
    92 !     --------------
    93       IF (nlayer.NE.nlayermx) THEN
    94          PRINT*,'STOP in inifis'
    95          PRINT*,'Probleme de dimensions :'
    96          PRINT*,'nlayer     = ',nlayer
    97          PRINT*,'nlayermx   = ',nlayermx
    98          STOP
    99       ENDIF
    10091
    10192      ! read in 'ecritphy' (frequency of calls to physics, in dynamical steps)
  • trunk/LMDZ.GENERIC/libf/phystd/iniorbit.F

    r590 r1308  
    11      SUBROUTINE iniorbit
    22     $     (papoastr,pperiastr,pyear_day,pperi_day,pobliq)
     3     
     4      USE planete_mod, only: apoastr, periastr, year_day, obliquit,
     5     &                       peri_day, e_elips, p_elips, timeperi
    36      IMPLICIT NONE
    47
     
    1922c   ----------
    2023c   - Doit etre appele avant d'utiliser orbite.
    21 c   - initialise une partie du common planete.h
     24c   - initialise une partie du common planete_mod
    2225c
    2326c   Arguments:
     
    3538c   -------------
    3639
    37 #include "planete.h"
     40!#include "planete.h"
    3841#include "comcstfi.h"
    3942
  • trunk/LMDZ.GENERIC/libf/phystd/iniphysiq.F90

    r1216 r1308  
    1616                       rlatd ! latitudes
    1717use infotrac, only : nqtot ! number of advected tracers
     18use planete_mod, only: ini_planete_mod
    1819
    1920implicit none
     21include "dimensions.h"
     22include "comvert.h"
    2023
    2124real,intent(in) :: prad ! radius of the planet (m)
     
    6770rlatd(1:klon_omp)=plat(offset+klon_omp_begin:offset+klon_omp_end)
    6871
     72! copy over preff , ap() and bp()
     73call ini_planete_mod(nlayer,preff,ap,bp)
     74
    6975! copy some fundamental parameters to physics
    7076! and do some initializations
  • trunk/LMDZ.GENERIC/libf/phystd/initracer.F

    r1297 r1308  
    2424
    2525#include "dimensions.h"
    26 #include "dimphys.h"
     26!#include "dimphys.h"
    2727#include "comcstfi.h"
    2828#include "callkeys.h"
  • trunk/LMDZ.GENERIC/libf/phystd/iniwrite_specIR.F

    r993 r1308  
    3434#include "netcdf.inc"
    3535#include "serre.h"
    36 #include"dimphys.h"
     36!#include"dimphys.h"
    3737
    3838c   Arguments:
  • trunk/LMDZ.GENERIC/libf/phystd/iniwrite_specVI.F

    r993 r1308  
    3434#include "netcdf.inc"
    3535#include "serre.h"
    36 #include"dimphys.h"
     36!#include"dimphys.h"
    3737
    3838c   Arguments:
  • trunk/LMDZ.GENERIC/libf/phystd/kcm1d.F90

    r1216 r1308  
    77  use ioipsl_getincom, only: getin
    88  use comsaison_h, only: mu0, fract, dist_star
     9  use planete_mod
    910!  use control_mod
    1011
     
    3031
    3132#include "dimensions.h"
    32 #include "dimphys.h"
     33!#include "dimphys.h"
    3334#include "callkeys.h"
    3435#include "comcstfi.h"
    35 #include "planete.h"
     36!#include "planete.h"
    3637!#include "control.h"
    3738
     
    4243  integer nlayer,nlevel,nq
    4344  integer ilay,ilev,iq,iw,iter
    44   real play(nlayermx)     ! Pressure at the middle of the layers [Pa]
    45   real zlay(nlayermx)     ! Altitude at middle of the layers [km]
    46   real plev(nlayermx+1)   ! Intermediate pressure levels [Pa]
    47   real temp(nlayermx)     ! temperature at the middle of the layers [K]
     45  real play(llm)     ! Pressure at the middle of the layers [Pa]
     46  real zlay(llm)     ! Altitude at middle of the layers [km]
     47  real plev(llm+1)   ! Intermediate pressure levels [Pa]
     48  real temp(llm)     ! temperature at the middle of the layers [K]
    4849  real,allocatable :: q(:,:)   ! tracer mixing ratio [kg/kg]
    4950  real,allocatable :: vmr(:,:) ! tracer mixing ratio [mol/mol]
     
    5354  real emis, albedo
    5455
    55   real muvar(nlayermx+1)
    56 
    57   real dtsw(nlayermx) ! heating rate (K/s) due to SW
    58   real dtlw(nlayermx) ! heating rate (K/s) due to LW
     56  real muvar(llm+1)
     57
     58  real dtsw(llm) ! heating rate (K/s) due to SW
     59  real dtlw(llm) ! heating rate (K/s) due to LW
    5960  real fluxsurf_lw   ! incident LW flux to surf (W/m2)
    6061  real fluxtop_lw    ! outgoing LW flux to space (W/m2)
     
    6465
    6566  ! not used
    66   real reffrad(nlayermx,naerkind)
    67   real nueffrad(nlayermx,naerkind)
    68   real cloudfrac(nlayermx)
     67  real reffrad(llm,naerkind)
     68  real nueffrad(llm,naerkind)
     69  real cloudfrac(llm)
    6970  real totcloudfrac
    7071  real tau_col
    7172
    7273  real dTstrat
    73   real aerosol(nlayermx,naerkind) ! aerosol tau (kg/kg)
     74  real aerosol(llm,naerkind) ! aerosol tau (kg/kg)
    7475  real OLR_nu(1,L_NSPECTI)
    7576  real OSR_nu(1,L_NSPECTV)
     
    9394
    9495
    95   nlayer=nlayermx
     96  nlayer=llm
    9697  nlevel=nlayer+1
    9798
     
    225226        ! allocate arrays which depend on number of tracers
    226227        allocate(nametrac(nq))
    227         allocate(q(nlayermx,nq))
    228         allocate(vmr(nlayermx,nq))
     228        allocate(q(nlayer,nq))
     229        allocate(vmr(nlayer,nq))
    229230        allocate(qsurf(nq))
    230231
     
    268269
    269270     !    Create vertical profiles
    270      call kcmprof_fn(psurf,qsurf(1),tsurf,    &
     271     call kcmprof_fn(nlayer,psurf,qsurf(1),tsurf,    &
    271272          tstrat,play,plev,zlay,temp,q(:,1),muvar(1))
    272273
     
    316317  ! Calculate total atmospheric energy
    317318  Eatmtot=0.0
    318   !  call calcenergy_kcm(tsurf,temp,play,plev,qsurf,&
     319  !  call calcenergy_kcm(nlayer,tsurf,temp,play,plev,qsurf,&
    319320  !     q(:,1),muvar,Eatmtot)
    320321
  • trunk/LMDZ.GENERIC/libf/phystd/kcmprof_fn.F90

    r869 r1308  
    1 subroutine kcmprof_fn(psurf_rcm,qsurf_rcm,Tsurf_rcm,Tstra_rcm,P_rcm,Pl_rcm,z_rcm,T_rcm,q_rcm,m_rcm)
     1subroutine kcmprof_fn(nlayer,psurf_rcm,qsurf_rcm,Tsurf_rcm,Tstra_rcm,P_rcm,Pl_rcm,z_rcm,T_rcm,q_rcm,m_rcm)
    22
    33use params_h
     
    1212!     ----------------------------------------------------------------
    1313
    14 #include "dimensions.h"
    15 #include "dimphys.h"
     14!#include "dimensions.h"
     15!#include "dimphys.h"
    1616#include "comcstfi.h"
    1717#include "callkeys.h"
     
    2121
    2222  ! rcm inputs
     23  integer nlayer
    2324  real Tsurf_rcm,Tstra_rcm
    2425
    2526  ! rcm outputs
    2627  real psurf_rcm,qsurf_rcm
    27   real P_rcm(1:nlayermx)
    28   real Pl_rcm(1:nlayermx+1)
    29   real z_rcm(1:nlayermx)
    30   real T_rcm(1:nlayermx),q_rcm(1:nlayermx)
    31   real m_rcm(1:nlayermx+1)
     28  real P_rcm(1:nlayer)
     29  real Pl_rcm(1:nlayer+1)
     30  real z_rcm(1:nlayer)
     31  real T_rcm(1:nlayer),q_rcm(1:nlayer)
     32  real m_rcm(1:nlayer+1)
    3233
    3334  ! rcm for interpolation (should really use log coords?)
     
    161162
    162163  ! define fine pressure grid
    163   dlogp_rcm = -(log(psurf_rcm)-log(ptop))/nlayermx
     164  dlogp_rcm = -(log(psurf_rcm)-log(ptop))/nlayer
    164165
    165166  P_rcm(1)  = psurf_rcm*exp(dlogp_rcm)
    166   do ilay_rcm=1,nlayermx-1
     167  do ilay_rcm=1,nlayer-1
    167168     P_rcm(ilay_rcm+1) = P_rcm(ilay_rcm)*exp(dlogp_rcm)
    168169  enddo
    169170
    170171  Pl_rcm(1) = psurf_rcm
    171   do ilev_rcm=2,nlayermx
     172  do ilev_rcm=2,nlayer
    172173     ! log-linear interpolation
    173174     Pl_rcm(ilev_rcm) = exp( log( P_rcm(ilev_rcm)*P_rcm(ilev_rcm-1) )/2 )
     
    318319  do ilay=2,nlay
    319320
    320      if(ilay_rcm.le.nlayermx)then
     321     if(ilay_rcm.le.nlayer)then
    321322     ! interpolate rcm variables
    322323
     
    349350
    350351  ifinal_rcm=ilay_rcm-1
    351   if(ifinal_rcm.lt.nlayermx)then
     352  if(ifinal_rcm.lt.nlayer)then
    352353     if(verbose)then
    353354        print*,'Interpolation in kcmprof stopped at layer',ilay_rcm,'!'
    354355     endif
    355356
    356      do ilay_rcm=ifinal_rcm+1,nlayermx
     357     do ilay_rcm=ifinal_rcm+1,nlayer
    357358
    358359        z_rcm(ilay_rcm) = z_rcm(ilay_rcm-1)
     
    364365  endif
    365366
    366   do ilay=2,nlayermx
     367  do ilay=2,nlayer
    367368     if(T_rcm(ilay).lt.Ttop)then
    368369        T_rcm(ilay)=Ttop
     
    373374  if(co2cond)then
    374375     print*,'CO2 condensation haircut - assumes CO2-dominated atmosphere!'
    375      do ilay=2,nlayermx
     376     do ilay=2,nlayer
    376377        if(P_rcm(ilay).lt.518000.)then
    377378           TCO2cond = (-3167.8)/(log(.01*P_rcm(ilay))-23.23) ! Fanale's formula
  • trunk/LMDZ.GENERIC/libf/phystd/largescale.F90

    r1016 r1308  
    1       subroutine largescale(ngrid,nq,ptimestep, pplev, pplay, pt, pq,   &
    2                         pdt, pdq, pdtlsc, pdqvaplsc, pdqliqlsc, rneb)
     1      subroutine largescale(ngrid,nlayer,nq,ptimestep, pplev, pplay,    &
     2                    pt, pq, pdt, pdq, pdtlsc, pdqvaplsc, pdqliqlsc, rneb)
    33
    44
     
    2323!==================================================================
    2424
    25 #include "dimensions.h"
    26 #include "dimphys.h"
     25!#include "dimensions.h"
     26!#include "dimphys.h"
    2727#include "comcstfi.h"
    2828
    2929#include "callkeys.h"
    3030
    31       INTEGER ngrid,nq
     31      INTEGER ngrid,nlayer,nq
    3232
    3333!     Arguments
    3434      REAL ptimestep                 ! intervalle du temps (s)
    35       REAL pplev(ngrid,nlayermx+1) ! pression a inter-couche
    36       REAL pplay(ngrid,nlayermx)   ! pression au milieu de couche
    37       REAL pt(ngrid,nlayermx)      ! temperature (K)
    38       REAL pq(ngrid,nlayermx,nq) ! tracer mixing ratio (kg/kg)
    39       REAL pdt(ngrid,nlayermx)     ! physical temperature tenedency (K/s)
    40       REAL pdq(ngrid,nlayermx,nq)! physical tracer tenedency (K/s)
    41       REAL pdtlsc(ngrid,nlayermx)  ! incrementation de la temperature (K)
    42       REAL pdqvaplsc(ngrid,nlayermx) ! incrementation de la vapeur d'eau
    43       REAL pdqliqlsc(ngrid,nlayermx) ! incrementation de l'eau liquide
    44       REAL rneb(ngrid,nlayermx)    ! fraction nuageuse
     35      REAL pplev(ngrid,nlayer+1) ! pression a inter-couche
     36      REAL pplay(ngrid,nlayer)   ! pression au milieu de couche
     37      REAL pt(ngrid,nlayer)      ! temperature (K)
     38      REAL pq(ngrid,nlayer,nq) ! tracer mixing ratio (kg/kg)
     39      REAL pdt(ngrid,nlayer)     ! physical temperature tenedency (K/s)
     40      REAL pdq(ngrid,nlayer,nq)! physical tracer tenedency (K/s)
     41      REAL pdtlsc(ngrid,nlayer)  ! incrementation de la temperature (K)
     42      REAL pdqvaplsc(ngrid,nlayer) ! incrementation de la vapeur d'eau
     43      REAL pdqliqlsc(ngrid,nlayer) ! incrementation de l'eau liquide
     44      REAL rneb(ngrid,nlayer)    ! fraction nuageuse
    4545
    4646
     
    6363     
    6464! evaporation calculations
    65       REAL dqevap(ngrid,nlayermx),dtevap(ngrid,nlayermx)     
    66       REAL qevap(ngrid,nlayermx,nq)
    67       REAL tevap(ngrid,nlayermx)
     65      REAL dqevap(ngrid,nlayer),dtevap(ngrid,nlayer)     
     66      REAL qevap(ngrid,nlayer,nq)
     67      REAL tevap(ngrid,nlayer)
    6868
    6969      DOUBLE PRECISION zx_q(ngrid)
     
    8383!     GCM -----> subroutine variables, initialisation of outputs
    8484
    85       pdtlsc(1:ngrid,1:nlayermx)  = 0.0
    86       pdqvaplsc(1:ngrid,1:nlayermx)  = 0.0
    87       pdqliqlsc(1:ngrid,1:nlayermx) = 0.0
    88       rneb(1:ngrid,1:nlayermx) = 0.0
     85      pdtlsc(1:ngrid,1:nlayer)  = 0.0
     86      pdqvaplsc(1:ngrid,1:nlayer)  = 0.0
     87      pdqliqlsc(1:ngrid,1:nlayer) = 0.0
     88      rneb(1:ngrid,1:nlayer) = 0.0
    8989      Lcp=RLVTT/RCPD
    9090
    9191
    9292      ! Evaporate cloud water/ice
    93       call evap(ngrid,nq,ptimestep,pt,pq,pdq,pdt,dqevap,dtevap,qevap,tevap)
     93      call evap(ngrid,nlayer,nq,ptimestep,pt,pq,pdq,pdt,dqevap,dtevap,qevap,tevap)
    9494      ! note: we use qevap but not tevap in largescale/moistadj
    9595            ! otherwise is a big mess
     
    9797
    9898!  Boucle verticale (du haut vers le bas)
    99    DO k = nlayermx, 1, -1
     99   DO k = nlayer, 1, -1
    100100
    101101      zt(1:ngrid)=pt(1:ngrid,k)+(pdt(1:ngrid,k)+dtevap(1:ngrid,k))*ptimestep
     
    171171         pdtlsc(1:ngrid,k)  = pdqliqlsc(1:ngrid,k)*real(Lcp)
    172172
    173    Enddo ! k= nlayermx, 1, -1
     173   Enddo ! k= nlayer, 1, -1
    174174 
    175175
    176       return
    177176      end
  • trunk/LMDZ.GENERIC/libf/phystd/lect_start_archive.F

    r1297 r1308  
    1       SUBROUTINE lect_start_archive(date,tsurf,tsoil,emis,q2,
     1      SUBROUTINE lect_start_archive(ngrid,nlayer,
     2     &     date,tsurf,tsoil,emis,q2,
    23     &     t,ucov,vcov,ps,h,phisold_newgrid,
    34     &     q,qsurf,surfith,nid,
     
    3031
    3132#include "dimensions.h"
    32 #include "dimphys.h"
     33!#include "dimphys.h"
    3334!#include "planete.h"
    3435#include "paramet.h"
     
    4748c=======================================================================
    4849
     50      INTEGER,INTENT(IN) :: ngrid, nlayer
     51
    4952c Old variables dimensions (from file)
    5053c------------------------------------
     
    99102c variable physique
    100103c------------------
    101       REAL tsurf(ngridmx) ! surface temperature
    102       REAL tsoil(ngridmx,nsoilmx) ! soil temperature
    103       REAL co2ice(ngridmx) ! CO2 ice layer
    104       REAL emis(ngridmx)
    105       REAL q2(ngridmx,nlayermx+1),qsurf(ngridmx,nqtot)
    106       REAL tslab(ngridmx,noceanmx)
    107       REAL rnat(ngridmx),pctsrf_sic(ngridmx)
    108       REAL tsea_ice(ngridmx),sea_ice(ngridmx)
    109 c     REAL phisfi(ngridmx)
     104      REAL tsurf(ngrid) ! surface temperature
     105      REAL tsoil(ngrid,nsoilmx) ! soil temperature
     106      REAL co2ice(ngrid) ! CO2 ice layer
     107      REAL emis(ngrid)
     108      REAL q2(ngrid,llm+1),qsurf(ngrid,nqtot)
     109      REAL tslab(ngrid,noceanmx)
     110      REAL rnat(ngrid),pctsrf_sic(ngrid)
     111      REAL tsea_ice(ngrid),sea_ice(ngrid)
     112c     REAL phisfi(ngrid)
    110113
    111114      INTEGER i,j,l
     
    322325      allocate(varp1 (imold+1,jmold+1,llm+1))
    323326
    324       write(*,*) 'q2',ngridmx,nlayermx+1
     327      write(*,*) 'q2',ngrid,llm+1
    325328      write(*,*) 'q2S',iip1,jjp1,llm+1
    326329      write(*,*) 'q2old',imold+1,jmold+1,lmold+1
     
    10521055      call interp_horiz (tsurfold,tsurfs,imold,jmold,iim,jjm,1,
    10531056     &                   rlonuold,rlatvold,rlonu,rlatv)
    1054       call gr_dyn_fi (1,iim+1,jjm+1,ngridmx,tsurfs,tsurf)
     1057      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,tsurfs,tsurf)
    10551058c     write(44,*) 'tsurf', tsurf
    10561059
     
    10591062!     &                  imold,jmold,iim,jjm,nsoilmx,
    10601063!     &                   rlonuold,rlatvold,rlonu,rlatv)
    1061 !      call gr_dyn_fi (nsoilmx,iim+1,jjm+1,ngridmx,tsoils,tsoil)
     1064!      call gr_dyn_fi (nsoilmx,iim+1,jjm+1,ngrid,tsoils,tsoil)
    10621065c     write(45,*) 'tsoil',tsoil
    10631066
     
    10651068      call interp_horiz (emisold,emiss,imold,jmold,iim,jjm,1,
    10661069     &                   rlonuold,rlatvold,rlonu,rlatv)
    1067       call gr_dyn_fi (1,iim+1,jjm+1,ngridmx,emiss,emis)
     1070      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,emiss,emis)
    10681071c     write(46,*) 'emis',emis
    10691072
     
    12011204
    12021205      ! Reshape inertiedatS to scalar grid as inertiedat
    1203       call gr_dyn_fi (nsoilmx,iim+1,jjm+1,ngridmx,
     1206      call gr_dyn_fi (nsoilmx,iim+1,jjm+1,ngrid,
    12041207     &                  inertiedatS,inertiedat)
    12051208     
     
    12871290
    12881291      ! Reshape tsoilS to scalar grid as tsoil
    1289        call gr_dyn_fi (nsoilmx,iim+1,jjm+1,ngridmx,tsoilS,tsoil)
     1292       call gr_dyn_fi (nsoilmx,iim+1,jjm+1,ngrid,tsoilS,tsoil)
    12901293
    12911294c-----------------------------------------------------------------------
     
    12941297      call interp_horiz (tslabold,tslabs,imold,jmold,iim,jjm,noceanmx,
    12951298     &                   rlonuold,rlatvold,rlonu,rlatv)
    1296       call gr_dyn_fi (1,iim+1,jjm+1,ngridmx,tslabs,tslab)
     1299      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,tslabs,tslab)
    12971300
    12981301      call interp_horiz (rnatold,rnats,imold,jmold,iim,jjm,1,
    12991302     &                   rlonuold,rlatvold,rlonu,rlatv)
    1300       call gr_dyn_fi (1,iim+1,jjm+1,ngridmx,rnats,rnat)
     1303      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,rnats,rnat)
    13011304
    13021305      call interp_horiz (pctsrf_sicold,pctsrf_sics,imold,jmold,iim,
    13031306     &                   jjm,1,rlonuold,rlatvold,rlonu,rlatv)
    1304       call gr_dyn_fi (1,iim+1,jjm+1,ngridmx,pctsrf_sics,pctsrf_sic)
     1307      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,pctsrf_sics,pctsrf_sic)
    13051308
    13061309      call interp_horiz (tsea_iceold,tsea_ices,imold,jmold,iim,jjm,1,
    13071310     &                   rlonuold,rlatvold,rlonu,rlatv)
    1308       call gr_dyn_fi (1,iim+1,jjm+1,ngridmx,tsea_ices,tsea_ice)
     1311      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,tsea_ices,tsea_ice)
    13091312
    13101313      call interp_horiz (sea_iceold,sea_ices,imold,jmold,iim,jjm,1,
    13111314     &                   rlonuold,rlatvold,rlonu,rlatv)
    1312       call gr_dyn_fi (1,iim+1,jjm+1,ngridmx,sea_ices,sea_ice)
     1315      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,sea_ices,sea_ice)
    13131316
    13141317c-----------------------------------------------------------------------
     
    13341337     &                   rlonuold,rlatvold,rlonu,rlatv)
    13351338      write (*,*) 'lect_start_archive: q2s ', q2s (1,2,1)  ! INFO
    1336       call gr_dyn_fi (llm+1,iim+1,jjm+1,ngridmx,q2s,q2)
     1339      call gr_dyn_fi (llm+1,iim+1,jjm+1,ngrid,q2s,q2)
    13371340      write (*,*) 'lect_start_archive: q2 ', q2 (1,2)  ! INFO
    13381341c     write(47,*) 'q2',q2
     
    13841387      enddo
    13851388
    1386       call gr_dyn_fi (nqtot,iim+1,jjm+1,ngridmx,qsurfs,qsurf)
     1389      call gr_dyn_fi (nqtot,iim+1,jjm+1,ngrid,qsurfs,qsurf)
    13871390
    13881391c traceurs 3D
     
    14351438      enddo
    14361439     
    1437 !      call gr_dyn_fi (1,iim+1,jjm+1,ngridmx,co2ices,co2ice)
     1440!      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,co2ices,co2ice)
    14381441! no need to transfer "co2ice" any more; it is in qsurf(igcm_co2_ice)
    14391442
  • trunk/LMDZ.GENERIC/libf/phystd/mass_redistribution.F90

    r1194 r1308  
    99       USE comgeomfi_h
    1010       USE tracer_h
     11       USE planete_mod, only: bp
    1112
    1213       IMPLICIT NONE
     
    5051!    ------------------
    5152!
    52 #include "dimensions.h"
    53 #include "dimphys.h"
     53!#include "dimensions.h"
     54!#include "dimphys.h"
    5455#include "comcstfi.h"
    55 #include "comvert.h"
    56 #include "paramet.h"
     56!#include "comvert.h"
     57!#include "paramet.h"
    5758#include "callkeys.h"
    5859
     
    8485
    8586!    vertical reorganization of sigma levels
    86       REAL zzu(nlayermx),zzv(nlayermx)
    87       REAL zzq(nlayermx,nq),zzt(nlayermx)
     87      REAL zzu(nlayer),zzv(nlayer)
     88      REAL zzq(nlayer,nq),zzt(nlayer)
    8889!    Dummy variables     
    8990      INTEGER n,l,ig,iq
    90       REAL zdtsig(ngrid,nlayermx)
    91       REAL zmass(ngrid,nlayermx),zzmass(nlayermx),w(nlayermx+1)
    92       REAL zdmass_sum(ngrid,nlayermx+1)
    93       REAL zmflux(nlayermx+1)
    94       REAL zq1(nlayermx)
     91      REAL zdtsig(ngrid,nlayer)
     92      REAL zmass(ngrid,nlayer),zzmass(nlayer),w(nlayer+1)
     93      REAL zdmass_sum(ngrid,nlayer+1)
     94      REAL zmflux(nlayer+1)
     95      REAL zq1(nlayer)
    9596      REAL ztsrf(ngrid)
    96       REAL ztm(nlayermx+1)
    97       REAL zum(nlayermx+1) , zvm(nlayermx+1)
    98       REAL zqm(nlayermx+1,nq),zqm1(nlayermx+1)
     97      REAL ztm(nlayer+1)
     98      REAL zum(nlayer+1) , zvm(nlayer+1)
     99      REAL zqm(nlayer+1,nq),zqm1(nlayer+1)
     100      REAL sigma(nlayer+1)
    99101
    100102!   local saved variables
     
    127129
    128130      DO ig=1,ngrid
    129          zdmass_sum(ig,nlayermx+1)=0.
    130          DO l = nlayermx, 1, -1
     131         zdmass_sum(ig,nlayer+1)=0.
     132         DO l = nlayer, 1, -1
    131133           zmass(ig,l) = (pplev(ig,l)-pplev(ig,l+1))/glat(ig)
    132134           zdmass_sum(ig,l)= zdmass_sum(ig,l+1)+pdmassmr(ig,l)
     
    181183!  Correction to account for redistribution between sigma or hybrid
    182184!  layers when changing surface pressure
    183 !  zzx quantities have dimension (nlayermx) to speed up calculation
     185!  zzx quantities have dimension (nlayer) to speed up calculation
    184186! *************************************************************
    185187
    186188      DO ig=1,ngrid
    187          zzt(1:nlayermx)  = pt(ig,1:nlayermx) + pdt(ig,1:nlayermx) * ptimestep
    188          zzu(1:nlayermx)  = pu(ig,1:nlayermx) + pdu(ig,1:nlayermx) * ptimestep
    189          zzv(1:nlayermx)  = pv(ig,1:nlayermx) + pdv(ig,1:nlayermx) * ptimestep
    190          zzq(1:nlayermx,1:nq)=pq(ig,1:nlayermx,1:nq)+pdq(ig,1:nlayermx,1:nq)*ptimestep ! must add the water that has fallen???
     189         zzt(1:nlayer)  = pt(ig,1:nlayer) + pdt(ig,1:nlayer) * ptimestep
     190         zzu(1:nlayer)  = pu(ig,1:nlayer) + pdu(ig,1:nlayer) * ptimestep
     191         zzv(1:nlayer)  = pv(ig,1:nlayer) + pdv(ig,1:nlayer) * ptimestep
     192         zzq(1:nlayer,1:nq)=pq(ig,1:nlayer,1:nq)+pdq(ig,1:nlayer,1:nq)*ptimestep ! must add the water that has fallen???
    191193
    192194!  Mass fluxes of air through the sigma levels (kg.m-2.s-1)  (>0 when up)
    193195!  """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    194 
    195196         zmflux(1) = zmassboil(ig)
     197         sigma(1)=1
    196198         DO l=1,nlayer
     199           ! Ehouarn: shouldn't we rather compute sigma levels than use bp()?
     200!           sigma(l+1)=pplev(ig,l+1)/pplev(ig,1)
     201!           zmflux(l+1) = zmflux(l) + pdmassmr(ig,l) - &
     202!                        (sigma(l)-sigma(l+1))*(zdmass_sum(ig,1)+zmflux(1))
     203!            if (abs(zmflux(l+1)).lt.1E-13.OR.sigma(l+1).eq.0.) zmflux(l+1)=0.
     204           ! Ehouarn: but for now leave things as before
    197205            zmflux(l+1) = zmflux(l) + pdmassmr(ig,l) - (bp(l)-bp(l+1))*(zdmass_sum(ig,1)+zmflux(1))
    198206! zmflux set to 0 if very low to avoid: top layer is disappearing in v1ld 
    199             if (abs(zmflux(l+1)).lt.1E-13.OR.bp(l+1).eq.0.) zmflux(l+1)=0.
     207            if (abs(zmflux(l+1)).lt.1E-13.OR.sigma(l+1).eq.0.) zmflux(l+1)=0.
    200208         END DO
    201209
    202210! Mass of each layer
    203211! ------------------
    204          zzmass(1:nlayermx)=zmass(ig,1:nlayermx)*(1.+pdpsrfmr(ig)*ptimestep/pplev(ig,1))
     212         zzmass(1:nlayer)=zmass(ig,1:nlayer)*(1.+pdpsrfmr(ig)*ptimestep/pplev(ig,1))
    205213
    206214
     
    219227         
    220228!        Van Leer scheme:
    221          w(1:nlayermx+1)=-zmflux(1:nlayermx+1)*ptimestep
     229         w(1:nlayer+1)=-zmflux(1:nlayer+1)*ptimestep
    222230         call vl1d(zzt,2.,zzmass,w,ztm)
    223231         call vl1d(zzu ,2.,zzmass,w,zum)
    224232         call vl1d(zzv ,2.,zzmass,w,zvm)
    225233         do iq=1,nq
    226            zq1(1:nlayermx)=zzq(1:nlayermx,iq)
     234           zq1(1:nlayer)=zzq(1:nlayer,iq)
    227235           zqm1(1)=zqm(1,iq)
    228236!               print*,iq
  • trunk/LMDZ.GENERIC/libf/phystd/moistadj.F90

    r1016 r1308  
    1 subroutine moistadj(ngrid, nq, pt, pq, pdq, pplev, pplay, pdtmana, pdqmana, ptimestep, rneb)
     1subroutine moistadj(ngrid, nlayer, nq, pt, pq, pdq, pplev, pplay, pdtmana, pdqmana, ptimestep, rneb)
    22
    33  use watercommon_h, only: T_h2O_ice_liq, RLVTT, RCPD, RCPV, Psat_water, Lcpdqsat_water
    4   USE tracer_h
     4  USE tracer_h, only: igcm_h2o_vap, igcm_h2o_ice
    55
    66  implicit none
     
    2020!=====================================================================
    2121
    22 #include "dimensions.h"
    23 #include "dimphys.h"
     22!#include "dimensions.h"
     23!#include "dimphys.h"
    2424#include "comcstfi.h"
    2525
    26       INTEGER ngrid, nq
    27 
    28       REAL pt(ngrid,nlayermx)            ! temperature (K)
    29       REAL pq(ngrid,nlayermx,nq)       ! tracer (kg/kg)
    30       REAL pdq(ngrid,nlayermx,nq)
    31 
    32       REAL pdqmana(ngrid,nlayermx,nq)  ! tendency of tracers (kg/kg.s-1)
    33       REAL pdtmana(ngrid,nlayermx)       ! temperature increment
     26      INTEGER,INTENT(IN) :: ngrid, nlayer, nq
     27
     28      REAL,INTENT(IN) :: pt(ngrid,nlayer) ! temperature (K)
     29      REAL,INTENT(IN) :: pq(ngrid,nlayer,nq) ! tracer (kg/kg)
     30      REAL,INTENT(IN) :: pdq(ngrid,nlayer,nq)
     31      REAL,INTENT(IN) :: pplev(ngrid,nlayer+1) ! inter-layer pressure (Pa)
     32      REAL,INTENT(IN) :: pplay(ngrid,nlayer)   ! mid-layer pressure (Pa)
     33      REAL,INTENT(IN) :: ptimestep ! physics timestep (s)
     34      REAL,INTENT(OUT) :: pdqmana(ngrid,nlayer,nq)  ! tracer tendencies (kg/kg.s-1)
     35      REAL,INTENT(OUT) :: pdtmana(ngrid,nlayer) ! temperature increment(K/s)
     36      REAL,INTENT(OUT) :: rneb(ngrid,nlayer) ! cloud fraction
    3437
    3538!     local variables
    36       REAL zt(ngrid,nlayermx)      ! temperature (K)
    37       REAL zq(ngrid,nlayermx)      ! humidite specifique (kg/kg)
    38       REAL pplev(ngrid,nlayermx+1) ! pression a inter-couche (Pa)
    39       REAL pplay(ngrid,nlayermx)   ! pression au milieu de couche (Pa)
    40 
    41       REAL d_t(ngrid,nlayermx)     ! temperature increment
    42       REAL d_q(ngrid,nlayermx)     ! incrementation pour vapeur d'eau
    43       REAL d_ql(ngrid,nlayermx)    ! incrementation pour l'eau liquide
    44       REAL rneb(ngrid,nlayermx) ! cloud fraction
    45       REAL ptimestep
     39      REAL zt(ngrid,nlayer)      ! temperature (K)
     40      REAL zq(ngrid,nlayer)      ! humidite specifique (kg/kg)
     41
     42      REAL d_t(ngrid,nlayer)     ! temperature increment
     43      REAL d_q(ngrid,nlayer)     ! incrementation pour vapeur d'eau
     44      REAL d_ql(ngrid,nlayer)    ! incrementation pour l'eau liquide
    4645
    4746!      REAL t_coup
     
    5554      INTEGER k1, k1p, k2, k2p
    5655      LOGICAL itest(ngrid)
    57       REAL delta_q(ngrid, nlayermx)
    58       DOUBLE PRECISION :: cp_new_t(nlayermx), v_cptt(ngrid,nlayermx)
    59       REAL cp_delta_t(nlayermx)
    60       DOUBLE PRECISION :: v_cptj(nlayermx), v_cptjk1, v_ssig
     56      REAL delta_q(ngrid, nlayer)
     57      DOUBLE PRECISION :: cp_new_t(nlayer), v_cptt(ngrid,nlayer)
     58      REAL cp_delta_t(nlayer)
     59      DOUBLE PRECISION :: v_cptj(nlayer), v_cptjk1, v_ssig
    6160      REAL v_p, v_t, v_zqs,v_cptt2,v_pratio,v_dlnpsat
    62       REAL zqs(ngrid,nlayermx), zdqs(ngrid,nlayermx),zpsat(ngrid,nlayermx),zdlnpsat(ngrid,nlayermx)
     61      REAL zqs(ngrid,nlayer), zdqs(ngrid,nlayer),zpsat(ngrid,nlayer),zdlnpsat(ngrid,nlayer)
    6362      REAL zq1(ngrid), zq2(ngrid)
    64       DOUBLE PRECISION :: gamcpdz(ngrid,2:nlayermx)
     63      DOUBLE PRECISION :: gamcpdz(ngrid,2:nlayer)
    6564      DOUBLE PRECISION :: zdp, zdpm
    6665
     
    6867      REAL zflo ! flotabilite
    6968
    70       DOUBLE PRECISION :: local_q(ngrid,nlayermx),local_t(ngrid,nlayermx)
     69      DOUBLE PRECISION :: local_q(ngrid,nlayer),local_t(ngrid,nlayer)
    7170
    7271      REAL zdelta, zcor, zcvm5
     
    7978      INTEGER,SAVE :: i_ice=0  ! water ice
    8079
    81       LOGICAL firstcall
    82       SAVE firstcall
    83 
    84       DATA firstcall /.TRUE./
     80      LOGICAL,SAVE :: firstcall=.TRUE.
    8581
    8682      IF (firstcall) THEN
     
    9692
    9793!     GCM -----> subroutine variables
    98       zq(1:ngrid,1:nlayermx)    = pq(1:ngrid,1:nlayermx,i_h2o)+ pdq(1:ngrid,1:nlayermx,i_h2o)*ptimestep
    99       zt(1:ngrid,1:nlayermx)    = pt(1:ngrid,1:nlayermx)
    100       pdqmana(1:ngrid,1:nlayermx,1:nq)=0.0
    101 
    102       DO k = 1, nlayermx
     94      zq(1:ngrid,1:nlayer)    = pq(1:ngrid,1:nlayer,i_h2o)+ pdq(1:ngrid,1:nlayer,i_h2o)*ptimestep
     95      zt(1:ngrid,1:nlayer)    = pt(1:ngrid,1:nlayer)
     96      pdqmana(1:ngrid,1:nlayer,1:nq)=0.0
     97
     98      DO k = 1, nlayer
    10399       DO i = 1, ngrid
    104100         if(zq(i,k).lt.0.)then
     
    108104      ENDDO
    109105     
    110       local_q(1:ngrid,1:nlayermx) = zq(1:ngrid,1:nlayermx)
    111       local_t(1:ngrid,1:nlayermx) = zt(1:ngrid,1:nlayermx)
    112       rneb(1:ngrid,1:nlayermx) = 0.0
    113       d_ql(1:ngrid,1:nlayermx) = 0.0
    114       d_t(1:ngrid,1:nlayermx)  = 0.0
    115       d_q(1:ngrid,1:nlayermx)  = 0.0
     106      local_q(1:ngrid,1:nlayer) = zq(1:ngrid,1:nlayer)
     107      local_t(1:ngrid,1:nlayer) = zt(1:ngrid,1:nlayer)
     108      rneb(1:ngrid,1:nlayer) = 0.0
     109      d_ql(1:ngrid,1:nlayer) = 0.0
     110      d_t(1:ngrid,1:nlayer)  = 0.0
     111      d_q(1:ngrid,1:nlayer)  = 0.0
    116112
    117113!     Calculate v_cptt
    118       DO k = 1, nlayermx
     114      DO k = 1, nlayer
    119115         DO i = 1, ngrid
    120116            v_cptt(i,k) = RCPD * local_t(i,k)
     
    128124
    129125!     Calculate Gamma * Cp * dz: (gamma is the critical gradient)
    130       DO k = 2, nlayermx
     126      DO k = 2, nlayer
    131127         DO i = 1, ngrid
    132128            zdp = pplev(i,k)-pplev(i,k+1)
     
    159155  810 CONTINUE ! look for k1, the base of the column
    160156      k2 = k2 + 1
    161       IF (k2 .GT. nlayermx) GOTO 9999
     157      IF (k2 .GT. nlayer) GOTO 9999
    162158      zflo = v_cptt(i,k2-1) - v_cptt(i,k2) - gamcpdz(i,k2)
    163159      zsat=(local_q(i,k2-1)-zqs(i,k2-1))*(pplev(i,k2-1)-pplev(i,k2))   &
     
    169165
    170166  820 CONTINUE !! look for k2, the top of the column
    171       IF (k2 .EQ. nlayermx) GOTO 821
     167      IF (k2 .EQ. nlayer) GOTO 821
    172168      k2p = k2 + 1
    173169      zsat=zsat+(pplev(i,k2p)-pplev(i,k2p+1))*(local_q(i,k2p)-zqs(i,k2p))
     
    227223!      ENDDO
    228224
    229       DO k = 2, nlayermx
     225      DO k = 2, nlayer
    230226         zdpm = pplev(i,k-1) - pplev(i,k)
    231227         zdp = pplev(i,k) - pplev(i,k+1)
     
    272268! a l'endroit ou la vapeur d'eau est diminuee par l'ajustement):
    273269
    274       DO k = 1, nlayermx
     270      DO k = 1, nlayer
    275271      DO i = 1, ngrid
    276272         IF (itest(i)) THEN
     
    291287         ENDIF
    292288      ENDDO
    293       DO k = 1, nlayermx
     289      DO k = 1, nlayer
    294290      DO i = 1, ngrid
    295291         IF (itest(i)) THEN
     
    300296      ENDDO
    301297      ENDDO
    302       DO k = 1, nlayermx
     298      DO k = 1, nlayer
    303299      DO i = 1, ngrid
    304300         IF (itest(i)) THEN
     
    308304      ENDDO
    309305
    310       DO k = 1, nlayermx
     306      DO k = 1, nlayer
    311307      DO i = 1, ngrid
    312308          local_q(i, k) = MAX(local_q(i, k), seuil_vap)
     
    314310      ENDDO
    315311
    316       DO k = 1, nlayermx
     312      DO k = 1, nlayer
    317313      DO i = 1, ngrid
    318314         d_t(i,k) = local_t(i,k) - zt(i,k)
     
    322318
    323319!     now subroutine -----> GCM variables
    324       DO k = 1, nlayermx
     320      DO k = 1, nlayer
    325321         DO i = 1, ngrid
    326322           
     
    333329
    334330
    335       RETURN
    336331   END
  • trunk/LMDZ.GENERIC/libf/phystd/newsedim.F

    r858 r1308  
    1616!   ------------
    1717
    18 #include "dimensions.h"
    19 #include "dimphys.h"
     18!#include "dimensions.h"
     19!#include "dimphys.h"
    2020#include "comcstfi.h"
    2121
     
    4747c    Traceurs :
    4848c    ~~~~~~~~
    49       real traversee (ngrid,nlayermx)
    50       real vstokes(ngrid,nlayermx)
    51       real w(ngrid,nlayermx)
     49      real traversee (ngrid,nlay)
     50      real vstokes(ngrid,nlay)
     51      real w(ngrid,nlay)
    5252      real ptop, dztop, Ep, Stra
    5353
     
    191191      end do
    192192
    193       call vlz_fi(ngrid,pqi,2.,masse,w,wq)
     193      call vlz_fi(ngrid,nlay,pqi,2.,masse,w,wq)
    194194c         write(*,*) ' newsed: wq(6), wq(7), q(6)',
    195195c    &                wq(1,6),wq(1,7),pqi(1,6)
    196196
    197       RETURN
    198197      END
  • trunk/LMDZ.GENERIC/libf/phystd/newstart.F

    r1297 r1308  
    3232
    3333#include "dimensions.h"
    34 #include "dimphys.h"
    35 #include "planete.h"
     34!#include "dimphys.h"
     35      integer, parameter :: ngridmx = (2+(jjm-1)*iim - 1/jjm)
     36!#include "planete.h"
    3637#include "paramet.h"
    3738#include "comconst.h"
     
    9899      real emisread             ! added by RW
    99100      REAL,ALLOCATABLE :: qsurf(:,:)
    100       REAL q2(ngridmx,nlayermx+1)
     101      REAL q2(ngridmx,llm+1)
    101102!      REAL rnaturfi(ngridmx)
    102103      real alb(iip1,jjp1),albfi(ngridmx) ! albedos
     
    171172
    172173!     added by BC for cloud fraction setup
    173       REAL hice(ngridmx),cloudfrac(ngridmx,nlayermx)
     174      REAL hice(ngridmx),cloudfrac(ngridmx,llm)
    174175      REAL totalfrac(ngridmx)
    175176
     
    341342        write(*,*) 'Reading file STARTFI'
    342343        fichnom = 'startfi.nc'
    343         CALL phyetat0 (ngridmx,fichnom,tab0,Lmodif,nsoilmx,nqtot,
    344      .        day_ini,time,
     344        CALL phyetat0 (ngridmx,llm,fichnom,tab0,Lmodif,nsoilmx,
     345     .        nqtot,day_ini,time,
    345346     .        tsurf,tsoil,emis,q2,qsurf,   !) ! temporary modif by RDW
    346347     .        cloudfrac,totalfrac,hice,rnat,pctsrf_sic,tslab,tsea_ice,
     
    534535
    535536        write(*,*) 'Reading file START_ARCHIVE'
    536         CALL lect_start_archive(date,tsurf,tsoil,emis,q2,
     537        CALL lect_start_archive(ngridmx,llm,
     538     &   date,tsurf,tsoil,emis,q2,
    537539     &   t,ucov,vcov,ps,teta,phisold_newgrid,q,qsurf,
    538540     &   surfith,nid,
     
    956958                 ucov(1:iip1,1:jjp1,1:llm)=0.
    957959                 vcov(1:iip1,1:jjm,1:llm)=0.
    958                  q2(1:ngridmx,1:nlayermx+1)=0.
     960                 q2(1:ngridmx,1:llm+1)=0.
    959961               else
    960962                 write(*,*)'problem reading file ',trim(txt),' !'
     
    12961298          ucov(1:iip1,1:jjp1,1:llm)=0
    12971299          vcov(1:iip1,1:jjm,1:llm)=0
    1298           q2(1:ngridmx,1:nlayermx+1)=0
     1300          q2(1:ngridmx,1:llm+1)=0
    12991301
    13001302c       radequi : Radiative equilibrium profile of temperatures and no winds
     
    13261328          ucov(1:iip1,1:jjp1,1:llm)=0
    13271329          vcov(1:iip1,1:jjm,1:llm)=0
    1328           q2(1:ngridmx,1:nlayermx+1)=0
     1330          q2(1:ngridmx,1:llm+1)=0
    13291331
    13301332c       coldstart : T set 1K above CO2 frost point and no winds
     
    13621364          ucov(1:iip1,1:jjp1,1:llm)=0
    13631365          vcov(1:iip1,1:jjm,1:llm)=0
    1364           q2(1:ngridmx,1:nlayermx+1)=0
     1366          q2(1:ngridmx,1:llm+1)=0
    13651367
    13661368
  • trunk/LMDZ.GENERIC/libf/phystd/newtrelax.F90

    r787 r1308  
    1 subroutine newtrelax(ngrid,mu0,sinlat,popsk,temp,pplay,pplev,dtrad,firstcall)
     1subroutine newtrelax(ngrid,nlayer,mu0,sinlat,popsk,temp,pplay,pplev,dtrad,firstcall)
    22       
    33  implicit none
    44
    5 #include "dimensions.h"
    6 #include "dimphys.h"
     5!#include "dimensions.h"
     6!#include "dimphys.h"
    77#include "comcstfi.h"
    88#include "callkeys.h"
     
    2121!==================================================================
    2222 
    23   integer ngrid
    2423 
    2524  ! Input
    26   real mu0(ngrid)                    ! cosine of sun incident angle
    27   real sinlat(ngrid)                 ! sine of latitude
    28   real temp(ngrid,nlayermx)          ! temperature at each layer (K)
    29   real pplay(ngrid,nlayermx)         ! pressure at each layer (Pa)
    30   real pplev(ngrid,nlayermx+1)       ! pressure at each level (Pa)
    31   real popsk(ngrid,nlayermx)         ! pot. T to T converter
     25  integer,intent(in) :: ngrid, nlayer
     26  logical,intent(in) :: firstcall
     27  real,intent(in) :: mu0(ngrid)            ! cosine of sun incident angle
     28  real,intent(in) :: sinlat(ngrid)         ! sine of latitude
     29  real,intent(in) :: temp(ngrid,nlayer)    ! temperature at each layer (K)
     30  real,intent(in) :: pplay(ngrid,nlayer)   ! pressure at each layer (Pa)
     31  real,intent(in) :: pplev(ngrid,nlayer+1) ! pressure at each level (Pa)
     32  real,intent(in) :: popsk(ngrid,nlayer)   ! pot. T to T converter
    3233
    3334  ! Output
    34   real dtrad(ngrid,nlayermx)
     35  real,intent(out) :: dtrad(ngrid,nlayer)
    3536
    3637  ! Internal
     
    4445  real sig, f_sig, sig_trop
    4546  integer l,ig
    46   logical firstcall
    4747
    4848
     
    5353  if(firstcall) then
    5454
    55      ALLOCATE(Trelax(ngrid,nlayermx))
     55     ALLOCATE(Trelax(ngrid,nlayer))
    5656
    5757     print*,'-----------------------------------------------------'
     
    6666           T_surf = 126. + 239.*mu0(ig)
    6767           T_trop = 140. + 52.*mu0(ig)
    68            do l=1,nlayermx
     68           do l=1,nlayer
    6969
    7070              if(mu0(ig).le.0.0)then ! night side
     
    8686        sig_trop=(T_trop/T_surf)**(1./rcp)
    8787
    88         do l=1,nlayermx
     88        do l=1,nlayer
    8989           do ig=1,ngrid
    9090
     
    109109     endif
    110110
    111      firstcall=.false.
    112  
    113111  endif
    114112
    115113  ! Calculate radiative forcing
    116   do l=1,nlayermx
     114  do l=1,nlayer
    117115     do ig=1,ngrid
    118116        dtrad(ig,l) = -(temp(ig,l) - Trelax(ig,l)) / tau_relax
     
    129127  !call writediagfi(ngrid,'ThetaZ','stellar zenith angle','deg',2,mu0)
    130128
    131   return
    132129end subroutine newtrelax
  • trunk/LMDZ.GENERIC/libf/phystd/ocean_slab_mod.F90

    r1298 r1308  
    1515
    1616
    17 #include "dimensions.h"
    18 #include "dimphys.h"
     17!#include "dimensions.h"
     18!#include "dimphys.h"
    1919#include "comcstfi.h"
    2020#include "callkeys.h"
     
    6767
    6868
    69 #include "dimensions.h"
    70 #include "dimphys.h"
     69!#include "dimensions.h"
     70!#include "dimphys.h"
    7171#include "comcstfi.h"
    7272#include "callkeys.h"
     
    210210      use slab_ice_h
    211211
    212 #include "dimensions.h"
    213 #include "dimphys.h"
     212!#include "dimensions.h"
     213!#include "dimphys.h"
    214214#include "comcstfi.h"
    215215#include "callkeys.h"
     
    451451    use slab_ice_h
    452452
    453 #include "dimensions.h"
    454 #include "comcstfi.h"
     453!#include "dimensions.h"
     454!#include "comcstfi.h"
    455455!    INCLUDE "iniprint.h"
    456456#include "callkeys.h"
     
    534534!  Transport diffusif
    535535!         IF (ok_soil_hdiff) THEN
    536              CALL divgrad_phy(noceanmx,tmp_tslab_loc,dtdiff_loc)
     536             CALL divgrad_phy(ngrid,noceanmx,tmp_tslab_loc,dtdiff_loc)
    537537             dtdiff_loc=dtdiff_loc*soil_hdiff*50./SUM(slabh)!*100.
    538538 !           dtdiff_loc(:,1)=dtdiff_loc(:,1)*soil_hdiff*50./SUM(slabh)*0.8
     
    544544! Calcul  de transport par Ekman
    545545
    546           CALL slab_ekman2(taux_slab,tauy_slab,tslab,dtekman_loc)
     546          CALL slab_ekman2(ngrid,taux_slab,tauy_slab,tslab,dtekman_loc)
    547547
    548548
  • trunk/LMDZ.GENERIC/libf/phystd/orbite.F

    r253 r1308  
    11      subroutine orbite(pls,pdist_star,pdecli)
     2     
     3      use planete_mod, only: p_elips, e_elips, timeperi, obliquit
    24      implicit none
    35
     
    2325c   -------------
    2426
    25 #include "planete.h"
     27!#include "planete.h"
    2628#include "comcstfi.h"
    2729
  • trunk/LMDZ.GENERIC/libf/phystd/phyetat0.F90

    r1297 r1308  
    1 subroutine phyetat0 (ngrid,fichnom,tab0,Lmodif,nsoil,nq, &
     1subroutine phyetat0 (ngrid,nlayer,fichnom,tab0,Lmodif,nsoil,nq, &
    22                     day_ini,time,tsurf,tsoil, &
    33                     emis,q2,qsurf,cloudfrac,totcloudfrac,hice, &
     
    2020!======================================================================
    2121#include "netcdf.inc"
    22 #include "dimensions.h"
    23 #include "dimphys.h"
    24 #include "planete.h"
     22!#include "dimensions.h"
     23!#include "dimphys.h"
     24!#include "planete.h"
    2525#include "comcstfi.h"
    2626
     
    3333!  inputs:
    3434  integer,intent(in) :: ngrid
     35  integer,intent(in) :: nlayer
    3536  character*(*),intent(in) :: fichnom ! "startfi.nc" file
    3637  integer,intent(in) :: tab0
     
    4546  real,intent(out) :: tsoil(ngrid,nsoil) ! soil temperature
    4647  real,intent(out) :: emis(ngrid) ! surface emissivity
    47   real,intent(out) :: q2(ngrid, llm+1) !
     48  real,intent(out) :: q2(ngrid,nlayer+1) !
    4849  real,intent(out) :: qsurf(ngrid,nq) ! tracers on surface
    4950! real co2ice(ngrid) ! co2 ice cover
    50   real,intent(out) :: cloudfrac(ngrid,nlayermx)
     51  real,intent(out) :: cloudfrac(ngrid,nlayer)
    5152  real,intent(out) :: hice(ngrid), totcloudfrac(ngrid)
    5253  real,intent(out) :: pctsrf_sic(ngrid),tslab(ngrid,noceanmx) 
  • trunk/LMDZ.GENERIC/libf/phystd/phyredem.F90

    r1297 r1308  
    1717                      put_var, put_field, length
    1818  use mod_grid_phy_lmdz, only : klon_glo
     19  use planete_mod, only: year_day, periastr, apoastr, peri_day, &
     20                         obliquit, z0, lmixmin, emin_turb
    1921
    2022  implicit none
    21 #include "planete.h"
     23!#include "planete.h"
    2224#include "comcstfi.h"
    2325  character(len=*), intent(in) :: filename
     
    147149!#include "temps.h"
    148150#include "comcstfi.h"
    149 #include "planete.h"
     151!#include "planete.h"
    150152#include "callkeys.h"
    151153!======================================================================
  • trunk/LMDZ.GENERIC/libf/phystd/physiq.F90

    r1297 r1308  
    1212      use gases_h, only: gnom, gfrac
    1313      use radcommon_h, only: sigma, eclipse, glat, grav
    14       use radii_mod, only: h2o_reffrad, co2_reffrad, h2o_cloudrad
     14      use radii_mod, only: h2o_reffrad, co2_reffrad
    1515      use aerosol_mod, only: iaero_co2, iaero_h2o
    1616      use surfdat_h, only: phisfi, albedodat, zmea, zstd, zsig, zgam, zthe, &
     
    3232      use planetwide_mod, only: planetwide_minval,planetwide_maxval,planetwide_sumval
    3333      use mod_phys_lmdz_para, only : is_master
    34 
     34      use planete_mod, only: apoastr, periastr, year_day, peri_day, &
     35                            obliquit, nres, z0
    3536
    3637      implicit none
     
    102103!   ------
    103104!
    104 !    pdu(ngrid,nlayermx)        \
    105 !    pdv(ngrid,nlayermx)         \  Temporal derivative of the corresponding
    106 !    pdt(ngrid,nlayermx)         /  variables due to physical processes.
    107 !    pdq(ngrid,nlayermx)        /
     105!    pdu(ngrid,nlayer)        \
     106!    pdv(ngrid,nlayer)         \  Temporal derivative of the corresponding
     107!    pdt(ngrid,nlayer)         /  variables due to physical processes.
     108!    pdq(ngrid,nlayer)        /
    108109!    pdpsrf(ngrid)             /
    109110!    tracerdyn                 call tracer in dynamical part of GCM ?
     
    131132!    ------------------
    132133
    133 #include "dimensions.h"
    134 #include "dimphys.h"
     134!#include "dimensions.h"
     135!#include "dimphys.h"
    135136#include "callkeys.h"
    136137#include "comcstfi.h"
    137 #include "planete.h"
     138!#include "planete.h"
    138139!#include "control.h"
    139140#include "netcdf.inc"
     
    179180!     "longrefvis" set in dimradmars.h , for one of the "naerkind"  kind of
    180181!      aerosol optical properties:
    181 !      real aerosol(ngrid,nlayermx,naerkind)
     182!      real aerosol(ngrid,nlayer,naerkind)
    182183!     this is now internal to callcorrk and hence no longer needed here
    183184
     
    207208!     aerosol (dust or ice) extinction optical depth  at reference wavelength
    208209!     for the "naerkind" optically active aerosols:
    209       real aerosol(ngrid,nlayermx,naerkind)
    210       real zh(ngrid,nlayermx)      ! potential temperature (K)
     210      real aerosol(ngrid,nlayer,naerkind)
     211      real zh(ngrid,nlayer)      ! potential temperature (K)
    211212
    212213      character*80 fichier
     
    228229      real zls                       ! solar longitude (rad)
    229230      real zday                      ! date (time since Ls=0, in martian days)
    230       real zzlay(ngrid,nlayermx)   ! altitude at the middle of the layers
    231       real zzlev(ngrid,nlayermx+1) ! altitude at layer boundaries
     231      real zzlay(ngrid,nlayer)   ! altitude at the middle of the layers
     232      real zzlev(ngrid,nlayer+1) ! altitude at layer boundaries
    232233      real latvl1,lonvl1             ! Viking Lander 1 point (for diagnostic)
    233234
    234235!     Tendencies due to various processes:
    235236      real dqsurf(ngrid,nq)
    236       real cldtlw(ngrid,nlayermx)                           ! (K/s) LW heating rate for clear areas
    237       real cldtsw(ngrid,nlayermx)                           ! (K/s) SW heating rate for clear areas
     237      real cldtlw(ngrid,nlayer)                           ! (K/s) LW heating rate for clear areas
     238      real cldtsw(ngrid,nlayer)                           ! (K/s) SW heating rate for clear areas
    238239      real zdtsurf(ngrid)                                   ! (K/s)
    239       real dtlscale(ngrid,nlayermx)
    240       real zdvdif(ngrid,nlayermx),zdudif(ngrid,nlayermx)  ! (m.s-2)
    241       real zdhdif(ngrid,nlayermx), zdtsdif(ngrid)         ! (K/s)
    242       real zdtdif(ngrid,nlayermx)                             ! (K/s)
    243       real zdvadj(ngrid,nlayermx),zduadj(ngrid,nlayermx)  ! (m.s-2)
    244       real zdhadj(ngrid,nlayermx)                           ! (K/s)
    245       real zdtgw(ngrid,nlayermx)                            ! (K/s)
    246       real zdtmr(ngrid,nlayermx)
    247       real zdugw(ngrid,nlayermx),zdvgw(ngrid,nlayermx)    ! (m.s-2)
    248       real zdtc(ngrid,nlayermx),zdtsurfc(ngrid)
    249       real zdvc(ngrid,nlayermx),zduc(ngrid,nlayermx)
    250       real zdumr(ngrid,nlayermx),zdvmr(ngrid,nlayermx)
     240      real dtlscale(ngrid,nlayer)
     241      real zdvdif(ngrid,nlayer),zdudif(ngrid,nlayer)  ! (m.s-2)
     242      real zdhdif(ngrid,nlayer), zdtsdif(ngrid)         ! (K/s)
     243      real zdtdif(ngrid,nlayer)                       ! (K/s)
     244      real zdvadj(ngrid,nlayer),zduadj(ngrid,nlayer)  ! (m.s-2)
     245      real zdhadj(ngrid,nlayer)                           ! (K/s)
     246      real zdtgw(ngrid,nlayer)                            ! (K/s)
     247      real zdtmr(ngrid,nlayer)
     248      real zdugw(ngrid,nlayer),zdvgw(ngrid,nlayer)    ! (m.s-2)
     249      real zdtc(ngrid,nlayer),zdtsurfc(ngrid)
     250      real zdvc(ngrid,nlayer),zduc(ngrid,nlayer)
     251      real zdumr(ngrid,nlayer),zdvmr(ngrid,nlayer)
    251252      real zdtsurfmr(ngrid)
    252253     
    253       real zdmassmr(ngrid,nlayermx),zdpsrfmr(ngrid)
     254      real zdmassmr(ngrid,nlayer),zdpsrfmr(ngrid)
    254255      real zdmassmr_col(ngrid)
    255256
    256       real zdqdif(ngrid,nlayermx,nq), zdqsdif(ngrid,nq)
    257       real zdqevap(ngrid,nlayermx)
    258       real zdqsed(ngrid,nlayermx,nq), zdqssed(ngrid,nq)
    259       real zdqdev(ngrid,nlayermx,nq), zdqsdev(ngrid,nq)
    260       real zdqadj(ngrid,nlayermx,nq)
    261       real zdqc(ngrid,nlayermx,nq)
    262       real zdqmr(ngrid,nlayermx,nq),zdqsurfmr(ngrid,nq)
    263       real zdqlscale(ngrid,nlayermx,nq)
     257      real zdqdif(ngrid,nlayer,nq), zdqsdif(ngrid,nq)
     258      real zdqevap(ngrid,nlayer)
     259      real zdqsed(ngrid,nlayer,nq), zdqssed(ngrid,nq)
     260      real zdqdev(ngrid,nlayer,nq), zdqsdev(ngrid,nq)
     261      real zdqadj(ngrid,nlayer,nq)
     262      real zdqc(ngrid,nlayer,nq)
     263      real zdqmr(ngrid,nlayer,nq),zdqsurfmr(ngrid,nq)
     264      real zdqlscale(ngrid,nlayer,nq)
    264265      real zdqslscale(ngrid,nq)
    265       real zdqchim(ngrid,nlayermx,nq)
     266      real zdqchim(ngrid,nlayer,nq)
    266267      real zdqschim(ngrid,nq)
    267268
    268       real zdteuv(ngrid,nlayermx)    ! (K/s)
    269       real zdtconduc(ngrid,nlayermx) ! (K/s)
    270       real zdumolvis(ngrid,nlayermx)
    271       real zdvmolvis(ngrid,nlayermx)
    272       real zdqmoldiff(ngrid,nlayermx,nq)
     269      real zdteuv(ngrid,nlayer)    ! (K/s)
     270      real zdtconduc(ngrid,nlayer) ! (K/s)
     271      real zdumolvis(ngrid,nlayer)
     272      real zdvmolvis(ngrid,nlayer)
     273      real zdqmoldiff(ngrid,nlayer,nq)
    273274
    274275!     Local variables for local calculations:
    275276      real zflubid(ngrid)
    276       real zplanck(ngrid),zpopsk(ngrid,nlayermx)
    277       real zdum1(ngrid,nlayermx)
    278       real zdum2(ngrid,nlayermx)
     277      real zplanck(ngrid),zpopsk(ngrid,nlayer)
     278      real zdum1(ngrid,nlayer)
     279      real zdum2(ngrid,nlayer)
    279280      real ztim1,ztim2,ztim3, z1,z2
    280281      real ztime_fin
    281       real zdh(ngrid,nlayermx)
     282      real zdh(ngrid,nlayer)
    282283      real gmplanet
    283284      real taux(ngrid),tauy(ngrid)
     
    288289! local variables only used for diagnostics (output in file "diagfi" or "stats")
    289290! ------------------------------------------------------------------------------
    290       real ps(ngrid), zt(ngrid,nlayermx)
    291       real zu(ngrid,nlayermx),zv(ngrid,nlayermx)
    292       real zq(ngrid,nlayermx,nq)
     291      real ps(ngrid), zt(ngrid,nlayer)
     292      real zu(ngrid,nlayer),zv(ngrid,nlayer)
     293      real zq(ngrid,nlayer,nq)
    293294      character*2 str2
    294295      character*5 str5
    295       real zdtadj(ngrid,nlayermx)
    296       real zdtdyn(ngrid,nlayermx)
     296      real zdtadj(ngrid,nlayer)
     297      real zdtdyn(ngrid,nlayer)
    297298      real,allocatable,dimension(:,:),save :: ztprevious
    298       real reff(ngrid,nlayermx) ! effective dust radius (used if doubleq=T)
     299      real reff(ngrid,nlayer) ! effective dust radius (used if doubleq=T)
    299300      real qtot1,qtot2            ! total aerosol mass
    300301      integer igmin, lmin
    301302      logical tdiag
    302303
    303       real zplev(ngrid,nlayermx+1),zplay(ngrid,nlayermx)
     304      real zplev(ngrid,nlayer+1),zplay(ngrid,nlayer)
    304305      real zstress(ngrid), cd
    305       real hco2(nq), tmean, zlocal(nlayermx)
    306       real vmr(ngrid,nlayermx) ! volume mixing ratio
     306      real hco2(nq), tmean, zlocal(nlayer)
     307      real vmr(ngrid,nlayer) ! volume mixing ratio
    307308
    308309      real time_phys
     
    318319
    319320!     included by RW for H2O precipitation
    320       real zdtrain(ngrid,nlayermx)
    321       real zdqrain(ngrid,nlayermx,nq)
     321      real zdtrain(ngrid,nlayer)
     322      real zdqrain(ngrid,nlayer,nq)
    322323      real zdqsrain(ngrid)
    323324      real zdqssnow(ngrid)
     
    325326
    326327!     included by RW for H2O Manabe scheme
    327       real dtmoist(ngrid,nlayermx)
    328       real dqmoist(ngrid,nlayermx,nq)
    329 
    330       real qvap(ngrid,nlayermx)
    331       real dqvaplscale(ngrid,nlayermx)
    332       real dqcldlscale(ngrid,nlayermx)
    333       real rneb_man(ngrid,nlayermx)
    334       real rneb_lsc(ngrid,nlayermx)
     328      real dtmoist(ngrid,nlayer)
     329      real dqmoist(ngrid,nlayer,nq)
     330
     331      real qvap(ngrid,nlayer)
     332      real dqvaplscale(ngrid,nlayer)
     333      real dqcldlscale(ngrid,nlayer)
     334      real rneb_man(ngrid,nlayer)
     335      real rneb_lsc(ngrid,nlayer)
    335336
    336337!     included by RW to account for surface cooling by evaporation
     
    339340
    340341!     to test energy conservation (RW+JL)
    341       real mass(ngrid,nlayermx),massarea(ngrid,nlayermx)
     342      real mass(ngrid,nlayer),massarea(ngrid,nlayer)
    342343      real dEtot, dEtots, AtmToSurf_TurbFlux
    343344      real,save :: dEtotSW, dEtotsSW, dEtotLW, dEtotsLW
    344       real dEzRadsw(ngrid,nlayermx),dEzRadlw(ngrid,nlayermx),dEzdiff(ngrid,nlayermx)
     345      real dEzRadsw(ngrid,nlayer),dEzRadlw(ngrid,nlayer),dEzdiff(ngrid,nlayer)
    345346      real dEdiffs(ngrid),dEdiff(ngrid)
    346       real madjdE(ngrid), lscaledE(ngrid),madjdEz(ngrid,nlayermx), lscaledEz(ngrid,nlayermx)
     347      real madjdE(ngrid), lscaledE(ngrid),madjdEz(ngrid,nlayer), lscaledEz(ngrid,nlayer)
    347348!JL12 conservation test for mean flow kinetic energy has been disabled temporarily
    348349      real dtmoist_max,dtmoist_min
     
    351352
    352353!     included by BC for evaporation     
    353       real qevap(ngrid,nlayermx,nq)
    354       real tevap(ngrid,nlayermx)
    355       real dqevap1(ngrid,nlayermx)
    356       real dtevap1(ngrid,nlayermx)
     354      real qevap(ngrid,nlayer,nq)
     355      real tevap(ngrid,nlayer)
     356      real dqevap1(ngrid,nlayer)
     357      real dtevap1(ngrid,nlayer)
    357358
    358359!     included by BC for hydrology
     
    367368
    368369!     included by RW for RH diagnostic
    369       real qsat(ngrid,nlayermx), RH(ngrid,nlayermx), H2Omaxcol(ngrid),psat_tmp
     370      real qsat(ngrid,nlayer), RH(ngrid,nlayer), H2Omaxcol(ngrid),psat_tmp
    370371
    371372!     included by RW for hydrology
     
    378379!     included by BC for double radiative transfer call
    379380      logical clearsky
    380       real zdtsw1(ngrid,nlayermx)
    381       real zdtlw1(ngrid,nlayermx)
     381      real zdtsw1(ngrid,nlayer)
     382      real zdtlw1(ngrid,nlayer)
    382383      real fluxsurf_lw1(ngrid)     
    383384      real fluxsurf_sw1(ngrid) 
     
    402403
    403404!     included by RW for temp convadj conservation test
    404       real playtest(nlayermx)
    405       real plevtest(nlayermx)
    406       real ttest(nlayermx)
    407       real qtest(nlayermx)
     405      real playtest(nlayer)
     406      real plevtest(nlayer)
     407      real ttest(nlayer)
     408      real qtest(nlayer)
    408409      integer igtest
    409410
    410411!     included by RW for runway greenhouse 1D study
    411       real muvar(ngrid,nlayermx+1)
     412      real muvar(ngrid,nlayer+1)
    412413
    413414!     included by RW for variable H2O particle sizes
    414415      real,allocatable,dimension(:,:,:),save :: reffrad ! aerosol effective radius (m)
    415416      real,allocatable,dimension(:,:,:),save :: nueffrad ! aerosol effective radius variance
    416 !      real :: nueffrad_dummy(ngrid,nlayermx,naerkind) !! AS. This is temporary. Check below why.
    417       real :: reffh2oliq(ngrid,nlayermx) ! liquid water particles effective radius (m)
    418       real :: reffh2oice(ngrid,nlayermx) ! water ice particles effective radius (m)
    419    !   real reffH2O(ngrid,nlayermx)
     417!      real :: nueffrad_dummy(ngrid,nlayer,naerkind) !! AS. This is temporary. Check below why.
     418      real :: reffh2oliq(ngrid,nlayer) ! liquid water particles effective radius (m)
     419      real :: reffh2oice(ngrid,nlayer) ! water ice particles effective radius (m)
     420   !   real reffH2O(ngrid,nlayer)
    420421      real reffcol(ngrid,naerkind)
    421422
     
    469470        ALLOCATE(rnat(ngrid))         
    470471        ALLOCATE(emis(ngrid))   
    471         ALLOCATE(dtrad(ngrid,nlayermx))
     472        ALLOCATE(dtrad(ngrid,nlayer))
    472473        ALLOCATE(fluxrad_sky(ngrid))
    473474        ALLOCATE(fluxrad(ngrid))   
     
    475476        ALLOCATE(fluxgrd(ngrid)) 
    476477        ALLOCATE(qsurf(ngrid,nq)) 
    477         ALLOCATE(q2(ngrid,nlayermx+1))
    478         ALLOCATE(ztprevious(ngrid,nlayermx))
    479         ALLOCATE(cloudfrac(ngrid,nlayermx))
     478        ALLOCATE(q2(ngrid,nlayer+1))
     479        ALLOCATE(ztprevious(ngrid,nlayer))
     480        ALLOCATE(cloudfrac(ngrid,nlayer))
    480481        ALLOCATE(totcloudfrac(ngrid))
    481482        ALLOCATE(hice(ngrid))
    482483        ALLOCATE(qsurf_hist(ngrid,nq))
    483         ALLOCATE(reffrad(ngrid,nlayermx,naerkind))
    484         ALLOCATE(nueffrad(ngrid,nlayermx,naerkind))
     484        ALLOCATE(reffrad(ngrid,nlayer,naerkind))
     485        ALLOCATE(nueffrad(ngrid,nlayer,naerkind))
    485486        ALLOCATE(ice_initial(ngrid))
    486487        ALLOCATE(ice_min(ngrid))
     
    494495        ALLOCATE(OSR_nu(ngrid,L_NSPECTV))
    495496        ALLOCATE(sensibFlux(ngrid))
    496         ALLOCATE(zdtlw(ngrid,nlayermx))
    497         ALLOCATE(zdtsw(ngrid,nlayermx))
     497        ALLOCATE(zdtlw(ngrid,nlayer))
     498        ALLOCATE(zdtsw(ngrid,nlayer))
    498499        ALLOCATE(tau_col(ngrid))
    499500        ALLOCATE(pctsrf_sic(ngrid))
     
    541542!        read startfi (initial parameters)
    542543!        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    543          call phyetat0(ngrid,"startfi.nc",0,0,nsoilmx,nq,   &
     544         call phyetat0(ngrid,nlayer,"startfi.nc",0,0,nsoilmx,nq,   &
    544545               day_ini,time_phys,tsurf,tsoil,emis,q2,qsurf,   &
    545546               cloudfrac,totcloudfrac,hice,  &
     
    587588
    588589
    589            CALL init_masquv(zmasq)
     590           CALL init_masquv(ngrid,zmasq)
    590591
    591592
     
    721722!     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    722723     
    723       pdu(1:ngrid,1:nlayermx) = 0.0
    724       pdv(1:ngrid,1:nlayermx) = 0.0
     724      pdu(1:ngrid,1:nlayer) = 0.0
     725      pdv(1:ngrid,1:nlayer) = 0.0
    725726      if ( .not.nearco2cond ) then
    726          pdt(1:ngrid,1:nlayermx) = 0.0
     727         pdt(1:ngrid,1:nlayer) = 0.0
    727728      endif
    728       pdq(1:ngrid,1:nlayermx,1:nq) = 0.0
     729      pdq(1:ngrid,1:nlayer,1:nq) = 0.0
    729730      pdpsrf(1:ngrid)       = 0.0
    730731      zflubid(1:ngrid)      = 0.0
     
    773774!     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    774775
    775       zzlay(1:ngrid,1:nlayermx)=pphi(1:ngrid,1:nlayermx)
    776       do l=1,nlayermx         
     776      zzlay(1:ngrid,1:nlayer)=pphi(1:ngrid,1:nlayer)
     777      do l=1,nlayer         
    777778      zzlay(1:ngrid,l)= zzlay(1:ngrid,l)/glat(1:ngrid)
    778779      enddo
     
    892893              endif
    893894              if(water) then
    894                   muvar(1:ngrid,1:nlayermx)=mugaz/(1.e0+(1.e0/epsi-1.e0)*pq(1:ngrid,1:nlayermx,igcm_h2o_vap))
    895                   muvar(1:ngrid,nlayermx+1)=mugaz/(1.e0+(1.e0/epsi-1.e0)*pq(1:ngrid,nlayermx,igcm_h2o_vap))
     895                  muvar(1:ngrid,1:nlayer)=mugaz/(1.e0+(1.e0/epsi-1.e0)*pq(1:ngrid,1:nlayer,igcm_h2o_vap))
     896                  muvar(1:ngrid,nlayer+1)=mugaz/(1.e0+(1.e0/epsi-1.e0)*pq(1:ngrid,nlayer,igcm_h2o_vap))
    896897                  ! take into account water effect on mean molecular weight
    897898              else
    898                   muvar(1:ngrid,1:nlayermx+1)=mugaz
     899                  muvar(1:ngrid,1:nlayer+1)=mugaz
    899900              endif
    900901     
     
    950951                    tau_col(ig)     = ntf*tau_col1(ig)     + tf*tau_col(ig)
    951952                   
    952                     zdtlw(ig,1:nlayermx) = ntf*zdtlw1(ig,1:nlayermx) + tf*zdtlw(ig,1:nlayermx)
    953                     zdtsw(ig,1:nlayermx) = ntf*zdtsw1(ig,1:nlayermx) + tf*zdtsw(ig,1:nlayermx)
     953                    zdtlw(ig,1:nlayer) = ntf*zdtlw1(ig,1:nlayer) + tf*zdtlw(ig,1:nlayer)
     954                    zdtsw(ig,1:nlayer) = ntf*zdtsw1(ig,1:nlayer) + tf*zdtsw(ig,1:nlayer)
    954955
    955956                    OSR_nu(ig,1:L_NSPECTV) = ntf*OSR_nu1(ig,1:L_NSPECTV) + tf*OSR_nu(ig,1:L_NSPECTV)                   
     
    976977
    977978!             Net atmospheric radiative heating rate (K.s-1)
    978               dtrad(1:ngrid,1:nlayermx)=zdtsw(1:ngrid,1:nlayermx)+zdtlw(1:ngrid,1:nlayermx)
     979              dtrad(1:ngrid,1:nlayer)=zdtsw(1:ngrid,1:nlayer)+zdtlw(1:ngrid,1:nlayer)
    979980
    980981           elseif(newtonian)then
     
    982983!          b) Call Newtonian cooling scheme
    983984!          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    984               call newtrelax(ngrid,mu0,sinlat,zpopsk,pt,pplay,pplev,dtrad,firstcall)
     985              call newtrelax(ngrid,nlayer,mu0,sinlat,zpopsk,pt,pplay,pplev,dtrad,firstcall)
    985986
    986987              zdtsurf(1:ngrid) = +(pt(1:ngrid,1)-tsurf(1:ngrid))/ptimestep
     
    10011002
    10021003
    1003               dtrad(1:ngrid,1:nlayermx)=0.0
     1004              dtrad(1:ngrid,1:nlayer)=0.0
    10041005              ! hence no atmospheric radiative heating
    10051006
     
    10151016        zplanck(1:ngrid)=emis(1:ngrid)*sigma*zplanck(1:ngrid)*zplanck(1:ngrid)
    10161017        fluxrad(1:ngrid)=fluxrad_sky(1:ngrid)-zplanck(1:ngrid)
    1017         pdt(1:ngrid,1:nlayermx)=pdt(1:ngrid,1:nlayermx)+dtrad(1:ngrid,1:nlayermx)
     1018        pdt(1:ngrid,1:nlayer)=pdt(1:ngrid,1:nlayer)+dtrad(1:ngrid,1:nlayer)
    10181019
    10191020!-------------------------
     
    10481049         zflubid(1:ngrid)=fluxrad(1:ngrid)+fluxgrd(1:ngrid)
    10491050
    1050          zdum1(1:ngrid,1:nlayermx)=0.0
    1051          zdum2(1:ngrid,1:nlayermx)=0.0
     1051         zdum1(1:ngrid,1:nlayer)=0.0
     1052         zdum2(1:ngrid,1:nlayer)=0.0
    10521053
    10531054
     
    10661067         else
    10671068         
    1068            zdh(1:ngrid,1:nlayermx)=pdt(1:ngrid,1:nlayermx)/zpopsk(1:ngrid,1:nlayermx)
     1069           zdh(1:ngrid,1:nlayer)=pdt(1:ngrid,1:nlayer)/zpopsk(1:ngrid,1:nlayer)
    10691070 
    10701071           call vdifc(ngrid,nlayer,nq,rnat,zpopsk,   &
     
    10771078              taux,tauy,lastcall)
    10781079
    1079            zdtdif(1:ngrid,1:nlayermx)=zdhdif(1:ngrid,1:nlayermx)*zpopsk(1:ngrid,1:nlayermx) ! for diagnostic only
    1080            zdqevap(1:ngrid,1:nlayermx)=0.
     1080           zdtdif(1:ngrid,1:nlayer)=zdhdif(1:ngrid,1:nlayer)*zpopsk(1:ngrid,1:nlayer) ! for diagnostic only
     1081           zdqevap(1:ngrid,1:nlayer)=0.
    10811082
    10821083         end if !turbdiff
    10831084
    1084          pdv(1:ngrid,1:nlayermx)=pdv(1:ngrid,1:nlayermx)+zdvdif(1:ngrid,1:nlayermx)
    1085          pdu(1:ngrid,1:nlayermx)=pdu(1:ngrid,1:nlayermx)+zdudif(1:ngrid,1:nlayermx)
    1086          pdt(1:ngrid,1:nlayermx)=pdt(1:ngrid,1:nlayermx)+zdtdif(1:ngrid,1:nlayermx)
     1085         pdv(1:ngrid,1:nlayer)=pdv(1:ngrid,1:nlayer)+zdvdif(1:ngrid,1:nlayer)
     1086         pdu(1:ngrid,1:nlayer)=pdu(1:ngrid,1:nlayer)+zdudif(1:ngrid,1:nlayer)
     1087         pdt(1:ngrid,1:nlayer)=pdt(1:ngrid,1:nlayer)+zdtdif(1:ngrid,1:nlayer)
    10871088         zdtsurf(1:ngrid)=zdtsurf(1:ngrid)+zdtsdif(1:ngrid)
    10881089
     
    10941095
    10951096         if (tracer) then
    1096            pdq(1:ngrid,1:nlayermx,1:nq)=pdq(1:ngrid,1:nlayermx,1:nq)+ zdqdif(1:ngrid,1:nlayermx,1:nq)
     1097           pdq(1:ngrid,1:nlayer,1:nq)=pdq(1:ngrid,1:nlayer,1:nq)+ zdqdif(1:ngrid,1:nlayer,1:nq)
    10971098           dqsurf(1:ngrid,1:nq)=dqsurf(1:ngrid,1:nq) + zdqsdif(1:ngrid,1:nq)
    10981099         end if ! of if (tracer)
     
    11711172      if(calladj) then
    11721173
    1173          zdh(1:ngrid,1:nlayermx) = pdt(1:ngrid,1:nlayermx)/zpopsk(1:ngrid,1:nlayermx)
    1174          zduadj(1:ngrid,1:nlayermx)=0.0
    1175          zdvadj(1:ngrid,1:nlayermx)=0.0
    1176          zdhadj(1:ngrid,1:nlayermx)=0.0
     1174         zdh(1:ngrid,1:nlayer) = pdt(1:ngrid,1:nlayer)/zpopsk(1:ngrid,1:nlayer)
     1175         zduadj(1:ngrid,1:nlayer)=0.0
     1176         zdvadj(1:ngrid,1:nlayer)=0.0
     1177         zdhadj(1:ngrid,1:nlayer)=0.0
    11771178
    11781179
     
    11841185              zdqadj)
    11851186
    1186          pdu(1:ngrid,1:nlayermx) = pdu(1:ngrid,1:nlayermx) + zduadj(1:ngrid,1:nlayermx)
    1187          pdv(1:ngrid,1:nlayermx) = pdv(1:ngrid,1:nlayermx) + zdvadj(1:ngrid,1:nlayermx)
    1188          pdt(1:ngrid,1:nlayermx)    = pdt(1:ngrid,1:nlayermx) + zdhadj(1:ngrid,1:nlayermx)*zpopsk(1:ngrid,1:nlayermx)
    1189          zdtadj(1:ngrid,1:nlayermx) = zdhadj(1:ngrid,1:nlayermx)*zpopsk(1:ngrid,1:nlayermx) ! for diagnostic only
     1187         pdu(1:ngrid,1:nlayer) = pdu(1:ngrid,1:nlayer) + zduadj(1:ngrid,1:nlayer)
     1188         pdv(1:ngrid,1:nlayer) = pdv(1:ngrid,1:nlayer) + zdvadj(1:ngrid,1:nlayer)
     1189         pdt(1:ngrid,1:nlayer)    = pdt(1:ngrid,1:nlayer) + zdhadj(1:ngrid,1:nlayer)*zpopsk(1:ngrid,1:nlayer)
     1190         zdtadj(1:ngrid,1:nlayer) = zdhadj(1:ngrid,1:nlayer)*zpopsk(1:ngrid,1:nlayer) ! for diagnostic only
    11901191
    11911192         if(tracer) then
    1192             pdq(1:ngrid,1:nlayermx,1:nq) = pdq(1:ngrid,1:nlayermx,1:nq) + zdqadj(1:ngrid,1:nlayermx,1:nq)
     1193            pdq(1:ngrid,1:nlayer,1:nq) = pdq(1:ngrid,1:nlayer,1:nq) + zdqadj(1:ngrid,1:nlayer,1:nq)
    11931194         end if
    11941195
     
    12401241              zdqc)
    12411242
    1242          pdt(1:ngrid,1:nlayermx)=pdt(1:ngrid,1:nlayermx)+zdtc(1:ngrid,1:nlayermx)
    1243          pdv(1:ngrid,1:nlayermx)=pdv(1:ngrid,1:nlayermx)+zdvc(1:ngrid,1:nlayermx)
    1244          pdu(1:ngrid,1:nlayermx)=pdu(1:ngrid,1:nlayermx)+zduc(1:ngrid,1:nlayermx)
     1243         pdt(1:ngrid,1:nlayer)=pdt(1:ngrid,1:nlayer)+zdtc(1:ngrid,1:nlayer)
     1244         pdv(1:ngrid,1:nlayer)=pdv(1:ngrid,1:nlayer)+zdvc(1:ngrid,1:nlayer)
     1245         pdu(1:ngrid,1:nlayer)=pdu(1:ngrid,1:nlayer)+zduc(1:ngrid,1:nlayer)
    12451246         zdtsurf(1:ngrid) = zdtsurf(1:ngrid) + zdtsurfc(1:ngrid)
    12461247
    1247          pdq(1:ngrid,1:nlayermx,1:nq)=pdq(1:ngrid,1:nlayermx,1:nq)+ zdqc(1:ngrid,1:nlayermx,1:nq)
     1248         pdq(1:ngrid,1:nlayer,1:nq)=pdq(1:ngrid,1:nlayer,1:nq)+ zdqc(1:ngrid,1:nlayer,1:nq)
    12481249         ! Note: we do not add surface co2ice tendency
    12491250         ! because qsurf(:,igcm_co2_ice) is updated in condens_co2cloud
     
    12831284!             ----------------
    12841285
    1285                dqmoist(1:ngrid,1:nlayermx,1:nq)=0.
    1286                dtmoist(1:ngrid,1:nlayermx)=0.
    1287 
    1288                call moistadj(ngrid,nq,pt,pq,pdq,pplev,pplay,dtmoist,dqmoist,ptimestep,rneb_man)
    1289 
    1290                pdq(1:ngrid,1:nlayermx,igcm_h2o_vap) = pdq(1:ngrid,1:nlayermx,igcm_h2o_vap)   &
    1291                           +dqmoist(1:ngrid,1:nlayermx,igcm_h2o_vap)
    1292                pdq(1:ngrid,1:nlayermx,igcm_h2o_ice) =pdq(1:ngrid,1:nlayermx,igcm_h2o_ice)     &
    1293                           +dqmoist(1:ngrid,1:nlayermx,igcm_h2o_ice)
    1294                pdt(1:ngrid,1:nlayermx) = pdt(1:ngrid,1:nlayermx)+dtmoist(1:ngrid,1:nlayermx)
     1286               dqmoist(1:ngrid,1:nlayer,1:nq)=0.
     1287               dtmoist(1:ngrid,1:nlayer)=0.
     1288
     1289               call moistadj(ngrid,nlayer,nq,pt,pq,pdq,pplev,pplay,dtmoist,dqmoist,ptimestep,rneb_man)
     1290
     1291               pdq(1:ngrid,1:nlayer,igcm_h2o_vap) = pdq(1:ngrid,1:nlayer,igcm_h2o_vap)   &
     1292                          +dqmoist(1:ngrid,1:nlayer,igcm_h2o_vap)
     1293               pdq(1:ngrid,1:nlayer,igcm_h2o_ice) =pdq(1:ngrid,1:nlayer,igcm_h2o_ice)     &
     1294                          +dqmoist(1:ngrid,1:nlayer,igcm_h2o_ice)
     1295               pdt(1:ngrid,1:nlayer) = pdt(1:ngrid,1:nlayer)+dtmoist(1:ngrid,1:nlayer)
    12951296
    12961297               !-------------------------
     
    13211322!        Large scale condensation/evaporation
    13221323!        --------------------------------
    1323                call largescale(ngrid,nq,ptimestep,pplev,pplay,pt,pq,pdt,pdq,dtlscale,dqvaplscale,dqcldlscale,rneb_lsc)
    1324 
    1325                pdt(1:ngrid,1:nlayermx) = pdt(1:ngrid,1:nlayermx)+dtlscale(1:ngrid,1:nlayermx)
    1326                pdq(1:ngrid,1:nlayermx,igcm_h2o_vap) = pdq(1:ngrid,1:nlayermx,igcm_h2o_vap)+dqvaplscale(1:ngrid,1:nlayermx)
    1327                pdq(1:ngrid,1:nlayermx,igcm_h2o_ice) = pdq(1:ngrid,1:nlayermx,igcm_h2o_ice)+dqcldlscale(1:ngrid,1:nlayermx)
     1324               call largescale(ngrid,nlayer,nq,ptimestep,pplev,pplay,pt,pq,pdt,pdq,dtlscale,dqvaplscale,dqcldlscale,rneb_lsc)
     1325
     1326               pdt(1:ngrid,1:nlayer) = pdt(1:ngrid,1:nlayer)+dtlscale(1:ngrid,1:nlayer)
     1327               pdq(1:ngrid,1:nlayer,igcm_h2o_vap) = pdq(1:ngrid,1:nlayer,igcm_h2o_vap)+dqvaplscale(1:ngrid,1:nlayer)
     1328               pdq(1:ngrid,1:nlayer,igcm_h2o_ice) = pdq(1:ngrid,1:nlayer,igcm_h2o_ice)+dqcldlscale(1:ngrid,1:nlayer)
    13281329
    13291330               !-------------------------
     
    13631364            if(waterrain)then
    13641365
    1365                zdqrain(1:ngrid,1:nlayermx,1:nq) = 0.0
     1366               zdqrain(1:ngrid,1:nlayer,1:nq) = 0.0
    13661367               zdqsrain(1:ngrid)    = 0.0
    13671368               zdqssnow(1:ngrid)    = 0.0
     
    13701371                   zdtrain,zdqrain,zdqsrain,zdqssnow,cloudfrac)
    13711372
    1372                pdq(1:ngrid,1:nlayermx,igcm_h2o_vap) = pdq(1:ngrid,1:nlayermx,igcm_h2o_vap) &
    1373                      +zdqrain(1:ngrid,1:nlayermx,igcm_h2o_vap)
    1374                pdq(1:ngrid,1:nlayermx,igcm_h2o_ice) = pdq(1:ngrid,1:nlayermx,igcm_h2o_ice) &
    1375                      +zdqrain(1:ngrid,1:nlayermx,igcm_h2o_ice)
    1376                pdt(1:ngrid,1:nlayermx) = pdt(1:ngrid,1:nlayermx)+zdtrain(1:ngrid,1:nlayermx)
     1373               pdq(1:ngrid,1:nlayer,igcm_h2o_vap) = pdq(1:ngrid,1:nlayer,igcm_h2o_vap) &
     1374                     +zdqrain(1:ngrid,1:nlayer,igcm_h2o_vap)
     1375               pdq(1:ngrid,1:nlayer,igcm_h2o_ice) = pdq(1:ngrid,1:nlayer,igcm_h2o_ice) &
     1376                     +zdqrain(1:ngrid,1:nlayer,igcm_h2o_ice)
     1377               pdt(1:ngrid,1:nlayer) = pdt(1:ngrid,1:nlayer)+zdtrain(1:ngrid,1:nlayer)
    13771378               dqsurf(1:ngrid,igcm_h2o_vap) = dqsurf(1:ngrid,igcm_h2o_vap)+zdqsrain(1:ngrid) ! a bug was here
    13781379               dqsurf(1:ngrid,igcm_h2o_ice) = dqsurf(1:ngrid,igcm_h2o_ice)+zdqssnow(1:ngrid)
     
    14191420!        -------------
    14201421        if (sedimentation) then
    1421            zdqsed(1:ngrid,1:nlayermx,1:nq) = 0.0
     1422           zdqsed(1:ngrid,1:nlayer,1:nq) = 0.0
    14221423           zdqssed(1:ngrid,1:nq)  = 0.0
    14231424
     
    14551456              ! and as in rain.F90, whether it falls as rain or snow depends
    14561457              ! only on the surface temperature
    1457            pdq(1:ngrid,1:nlayermx,1:nq) = pdq(1:ngrid,1:nlayermx,1:nq) + zdqsed(1:ngrid,1:nlayermx,1:nq)
     1458           pdq(1:ngrid,1:nlayer,1:nq) = pdq(1:ngrid,1:nlayer,1:nq) + zdqsed(1:ngrid,1:nlayer,1:nq)
    14581459           dqsurf(1:ngrid,1:nq) = dqsurf(1:ngrid,1:nq) + zdqssed(1:ngrid,1:nq)
    14591460
     
    14831484         if(mass_redistrib) then
    14841485
    1485             zdmassmr(1:ngrid,1:nlayermx) = mass(1:ngrid,1:nlayermx) * &
    1486                (   zdqevap(1:ngrid,1:nlayermx)                          &
    1487                  + zdqrain(1:ngrid,1:nlayermx,igcm_h2o_vap)             &
    1488                  + dqmoist(1:ngrid,1:nlayermx,igcm_h2o_vap)             &
    1489                  + dqvaplscale(1:ngrid,1:nlayermx) )
     1486            zdmassmr(1:ngrid,1:nlayer) = mass(1:ngrid,1:nlayer) * &
     1487               (   zdqevap(1:ngrid,1:nlayer)                          &
     1488                 + zdqrain(1:ngrid,1:nlayer,igcm_h2o_vap)             &
     1489                 + dqmoist(1:ngrid,1:nlayer,igcm_h2o_vap)             &
     1490                 + dqvaplscale(1:ngrid,1:nlayer) )
    14901491
    14911492            do ig = 1, ngrid
    1492                zdmassmr_col(ig)=SUM(zdmassmr(ig,1:nlayermx))
     1493               zdmassmr_col(ig)=SUM(zdmassmr(ig,1:nlayer))
    14931494            enddo
    14941495           
     
    15031504         
    15041505
    1505             pdq(1:ngrid,1:nlayermx,1:nq) = pdq(1:ngrid,1:nlayermx,1:nq) + zdqmr(1:ngrid,1:nlayermx,1:nq)
     1506            pdq(1:ngrid,1:nlayer,1:nq) = pdq(1:ngrid,1:nlayer,1:nq) + zdqmr(1:ngrid,1:nlayer,1:nq)
    15061507            dqsurf(1:ngrid,1:nq)         = dqsurf(1:ngrid,1:nq) + zdqsurfmr(1:ngrid,1:nq)
    1507             pdt(1:ngrid,1:nlayermx)        = pdt(1:ngrid,1:nlayermx) + zdtmr(1:ngrid,1:nlayermx)
    1508             pdu(1:ngrid,1:nlayermx)        = pdu(1:ngrid,1:nlayermx) + zdumr(1:ngrid,1:nlayermx)
    1509             pdv(1:ngrid,1:nlayermx)        = pdv(1:ngrid,1:nlayermx) + zdvmr(1:ngrid,1:nlayermx)
     1508            pdt(1:ngrid,1:nlayer)        = pdt(1:ngrid,1:nlayer) + zdtmr(1:ngrid,1:nlayer)
     1509            pdu(1:ngrid,1:nlayer)        = pdu(1:ngrid,1:nlayer) + zdumr(1:ngrid,1:nlayer)
     1510            pdv(1:ngrid,1:nlayer)        = pdv(1:ngrid,1:nlayer) + zdvmr(1:ngrid,1:nlayer)
    15101511            pdpsrf(1:ngrid)                = pdpsrf(1:ngrid) + zdpsrfmr(1:ngrid)
    15111512            zdtsurf(1:ngrid)               = zdtsurf(1:ngrid) + zdtsurfmr(1:ngrid)
    15121513           
    1513 !           print*,'after mass redistrib, q=',pq(211,1:nlayermx,igcm_h2o_vap)+ptimestep*pdq(211,1:nlayermx,igcm_h2o_vap)
     1514!           print*,'after mass redistrib, q=',pq(211,1:nlayer,igcm_h2o_vap)+ptimestep*pdq(211,1:nlayer,igcm_h2o_vap)
    15141515         endif
    15151516
     
    16721673 
    16731674      ! temperature, zonal and meridional wind
    1674       zt(1:ngrid,1:nlayermx) = pt(1:ngrid,1:nlayermx) + pdt(1:ngrid,1:nlayermx)*ptimestep
    1675       zu(1:ngrid,1:nlayermx) = pu(1:ngrid,1:nlayermx) + pdu(1:ngrid,1:nlayermx)*ptimestep
    1676       zv(1:ngrid,1:nlayermx) = pv(1:ngrid,1:nlayermx) + pdv(1:ngrid,1:nlayermx)*ptimestep
     1675      zt(1:ngrid,1:nlayer) = pt(1:ngrid,1:nlayer) + pdt(1:ngrid,1:nlayer)*ptimestep
     1676      zu(1:ngrid,1:nlayer) = pu(1:ngrid,1:nlayer) + pdu(1:ngrid,1:nlayer)*ptimestep
     1677      zv(1:ngrid,1:nlayer) = pv(1:ngrid,1:nlayer) + pdv(1:ngrid,1:nlayer)*ptimestep
    16771678
    16781679      ! diagnostic
    1679       zdtdyn(1:ngrid,1:nlayermx)     = pt(1:ngrid,1:nlayermx)-ztprevious(1:ngrid,1:nlayermx)
    1680       ztprevious(1:ngrid,1:nlayermx) = zt(1:ngrid,1:nlayermx)
     1680      zdtdyn(1:ngrid,1:nlayer)     = pt(1:ngrid,1:nlayer)-ztprevious(1:ngrid,1:nlayer)
     1681      ztprevious(1:ngrid,1:nlayer) = zt(1:ngrid,1:nlayer)
    16811682
    16821683      if(firstcall)then
    1683          zdtdyn(1:ngrid,1:nlayermx)=0.0
     1684         zdtdyn(1:ngrid,1:nlayer)=0.0
    16841685      endif
    16851686
     
    16901691
    16911692      ! tracers
    1692       zq(1:ngrid,1:nlayermx,1:nq) = pq(1:ngrid,1:nlayermx,1:nq) + pdq(1:ngrid,1:nlayermx,1:nq)*ptimestep
     1693      zq(1:ngrid,1:nlayer,1:nq) = pq(1:ngrid,1:nlayer,1:nq) + pdq(1:ngrid,1:nlayer,1:nq)*ptimestep
    16931694
    16941695      ! surface pressure
     
    17981799         do iq=1,nq
    17991800           do ig=1,ngrid
    1800               qcol(ig,iq) = SUM( zq(ig,1:nlayermx,iq) * mass(ig,1:nlayermx))
     1801              qcol(ig,iq) = SUM( zq(ig,1:nlayer,iq) * mass(ig,1:nlayer))
    18011802           enddo
    18021803         enddo
     
    18051806         reffcol(1:ngrid,1:naerkind)=0.0
    18061807         if(co2cond.and.(iaero_co2.ne.0))then
    1807             call co2_reffrad(ngrid,nq,zq,reffrad(1,1,iaero_co2))
     1808            call co2_reffrad(ngrid,nlayer,nq,zq,reffrad(1,1,iaero_co2))
    18081809            do ig=1,ngrid
    1809                reffcol(ig,iaero_co2) = SUM(zq(ig,1:nlayermx,igcm_co2_ice)*reffrad(ig,1:nlayermx,iaero_co2)*mass(ig,1:nlayermx))
     1810               reffcol(ig,iaero_co2) = SUM(zq(ig,1:nlayer,igcm_co2_ice)*reffrad(ig,1:nlayer,iaero_co2)*mass(ig,1:nlayer))
    18101811            enddo
    18111812         endif
    18121813         if(water.and.(iaero_h2o.ne.0))then
    1813             call h2o_reffrad(ngrid,zq(1,1,igcm_h2o_ice),zt, &
     1814            call h2o_reffrad(ngrid,nlayer,zq(1,1,igcm_h2o_ice),zt, &
    18141815                             reffrad(1,1,iaero_h2o),nueffrad(1,1,iaero_h2o))
    18151816            do ig=1,ngrid
    1816                reffcol(ig,iaero_h2o) = SUM(zq(ig,1:nlayermx,igcm_h2o_ice)*reffrad(ig,1:nlayermx,iaero_h2o)*mass(ig,1:nlayermx))
     1817               reffcol(ig,iaero_h2o) = SUM(zq(ig,1:nlayer,igcm_h2o_ice)*reffrad(ig,1:nlayer,iaero_h2o)*mass(ig,1:nlayer))
    18171818            enddo
    18181819         endif
     
    19891990              end do
    19901991            if (water) then
    1991                vmr=zq(1:ngrid,1:nlayermx,igcm_h2o_vap)*mugaz/mmol(igcm_h2o_vap)
     1992               vmr=zq(1:ngrid,1:nlayer,igcm_h2o_vap)*mugaz/mmol(igcm_h2o_vap)
    19921993               call wstats(ngrid,"vmr_h2ovapor",                           &
    19931994                          "H2O vapour volume mixing ratio","mol/mol",       &
  • trunk/LMDZ.GENERIC/libf/phystd/planete_mod.F90

    r1304 r1308  
    1 !-----------------------------------------------------------------------
    2 ! INCLUDE planet.h
    3 
    4       COMMON/planet/apoastr,periastr,year_day,peri_day,                 &
    5      &       obliquit,nres,                                             &
    6      &       z0,lmixmin,emin_turb,coefvis,coefir,                       &
    7      &       timeperi,e_elips,p_elips
    8 
    9       real apoastr,periastr,year_day,peri_day,                          &
    10      &     obliquit,nres,                                               &
    11      &     z0,lmixmin,emin_turb,coefvis,coefir,                         &
    12      &       timeperi,e_elips,p_elips
    13      
    14 
    15 !-----------------------------------------------------------------------
     1MODULE planete_mod
     2  IMPLICIT NONE
     3 
     4  REAL :: apoastr ! maximum star-planet distance (AU)
     5  REAL :: periastr ! minimum star-planet distance (AU)
     6  REAL :: year_day ! length of year (sols)
     7  REAL :: peri_day ! date of periastron (sols since N. spring)
     8  REAL :: obliquit ! Obliquity of the planet (deg)
     9  REAL :: nres ! tidal resonance ratio
     10  REAL :: z0 ! surface roughness (m)
     11  REAL :: lmixmin ! mixing length
     12  REAL :: emin_turb ! minimal energy
     13  REAL :: coefvis
     14  REAL :: coefir
     15  REAL :: timeperi
     16  REAL :: e_elips
     17  REAL :: p_elips
     18 
     19  REAL :: preff ! reference surface pressure (Pa)
     20  REAL,ALLOCATABLE :: ap(:) ! hybrid coordinate at layer interface
     21  REAL,ALLOCATABLE :: bp(:) ! hybrid coordinate at layer interface
     22 
     23  CONTAINS
     24 
     25  subroutine ini_planete_mod(nlayer,preff_dyn,ap_dyn,bp_dyn)
     26 
     27  implicit none
     28  integer,intent(in) :: nlayer ! number of atmospheric layers
     29  real,intent(in) :: preff_dyn ! reference surface pressure (Pa)
     30  real,intent(in) :: ap_dyn(nlayer+1) ! hybrid coordinate at interfaces
     31  real,intent(in) :: bp_dyn(nlayer+1) ! hybrid coordinate at interfaces
     32 
     33  allocate(ap(nlayer+1))
     34  allocate(bp(nlayer+1))
     35 
     36  preff=preff_dyn
     37  ap(:)=ap_dyn(:)
     38  bp(:)=bp_dyn(:)
     39 
     40  end subroutine ini_planete_mod
     41 
     42END MODULE planete_mod
  • trunk/LMDZ.GENERIC/libf/phystd/radii_mod.F90

    r1283 r1308  
    2020
    2121!==================================================================
    22    subroutine su_aer_radii(ngrid,reffrad,nueffrad)
     22   subroutine su_aer_radii(ngrid,nlayer,reffrad,nueffrad)
    2323!==================================================================
    2424!     Purpose
     
    3939
    4040      include "callkeys.h"
    41       include "dimensions.h"
    42       include "dimphys.h"
    43 
    44       integer,intent(in) :: ngrid
    45 
    46       real, intent(out) :: reffrad(ngrid,nlayermx,naerkind)      !aerosols radii (K)
    47       real, intent(out) :: nueffrad(ngrid,nlayermx,naerkind)     !variance     
     41!      include "dimensions.h"
     42!      include "dimphys.h"
     43
     44      integer,intent(in) :: ngrid
     45      integer,intent(in) :: nlayer
     46
     47      real, intent(out) :: reffrad(ngrid,nlayer,naerkind)      !aerosols radii (K)
     48      real, intent(out) :: nueffrad(ngrid,nlayer,naerkind)     !variance     
    4849
    4950      logical, save :: firstcall=.true.
     
    5859
    5960            if(iaer.eq.iaero_co2)then ! CO2 ice
    60                reffrad(1:ngrid,1:nlayermx,iaer) = 1.e-4
    61                nueffrad(1:ngrid,1:nlayermx,iaer) = 0.1
     61               reffrad(1:ngrid,1:nlayer,iaer) = 1.e-4
     62               nueffrad(1:ngrid,1:nlayer,iaer) = 0.1
    6263            endif
    6364
    6465            if(iaer.eq.iaero_h2o)then ! H2O ice
    65                reffrad(1:ngrid,1:nlayermx,iaer) = 1.e-5
    66                nueffrad(1:ngrid,1:nlayermx,iaer) = 0.1
     66               reffrad(1:ngrid,1:nlayer,iaer) = 1.e-5
     67               nueffrad(1:ngrid,1:nlayer,iaer) = 0.1
    6768            endif
    6869
    6970            if(iaer.eq.iaero_dust)then ! dust
    70                reffrad(1:ngrid,1:nlayermx,iaer) = 1.e-5
    71                nueffrad(1:ngrid,1:nlayermx,iaer) = 0.1
     71               reffrad(1:ngrid,1:nlayer,iaer) = 1.e-5
     72               nueffrad(1:ngrid,1:nlayer,iaer) = 0.1
    7273            endif
    7374 
    7475            if(iaer.eq.iaero_h2so4)then ! H2O ice
    75                reffrad(1:ngrid,1:nlayermx,iaer) = 1.e-6
    76                nueffrad(1:ngrid,1:nlayermx,iaer) = 0.1
     76               reffrad(1:ngrid,1:nlayer,iaer) = 1.e-6
     77               nueffrad(1:ngrid,1:nlayer,iaer) = 0.1
    7778            endif
    7879           
    7980            if(iaer.eq.iaero_back2lay)then ! Two-layer aerosols
    80                reffrad(1:ngrid,1:nlayermx,iaer) = 2.e-6
    81                nueffrad(1:ngrid,1:nlayermx,iaer) = 0.1
     81               reffrad(1:ngrid,1:nlayer,iaer) = 2.e-6
     82               nueffrad(1:ngrid,1:nlayer,iaer) = 0.1
    8283            endif
    8384
     
    126127
    127128!==================================================================
    128    subroutine h2o_reffrad(ngrid,pq,pt,reffrad,nueffrad)
     129   subroutine h2o_reffrad(ngrid,nlayer,pq,pt,reffrad,nueffrad)
    129130!==================================================================
    130131!     Purpose
     
    141142
    142143      include "callkeys.h"
    143       include "dimensions.h"
    144       include "dimphys.h"
     144!      include "dimensions.h"
     145!      include "dimphys.h"
    145146      include "comcstfi.h"
    146147
    147148      integer,intent(in) :: ngrid
    148 
    149       real, intent(in) :: pq(ngrid,nlayermx) !water ice mixing ratios (kg/kg)
    150       real, intent(in) :: pt(ngrid,nlayermx) !temperature (K)
    151       real, intent(out) :: reffrad(ngrid,nlayermx)      !aerosol radii
    152       real, intent(out) :: nueffrad(ngrid,nlayermx) ! dispersion     
     149      integer,intent(in) :: nlayer
     150
     151      real, intent(in) :: pq(ngrid,nlayer) !water ice mixing ratios (kg/kg)
     152      real, intent(in) :: pt(ngrid,nlayer) !temperature (K)
     153      real, intent(out) :: reffrad(ngrid,nlayer)      !aerosol radii
     154      real, intent(out) :: nueffrad(ngrid,nlayer) ! dispersion     
    153155
    154156      integer :: ig,l
     
    158160
    159161      if (radfixed) then
    160          do l=1,nlayermx
     162         do l=1,nlayer
    161163            do ig=1,ngrid
    162164               zfice = 1.0 - (pt(ig,l)-T_h2O_ice_clouds) / (T_h2O_ice_liq-T_h2O_ice_clouds)
     
    167169         enddo
    168170      else
    169          do l=1,nlayermx
     171         do l=1,nlayer
    170172            do ig=1,ngrid
    171173               zfice = 1.0 - (pt(ig,l)-T_h2O_ice_clouds) / (T_h2O_ice_liq-T_h2O_ice_clouds)
     
    186188
    187189!==================================================================
    188    subroutine h2o_cloudrad(ngrid,pql,reffliq,reffice)
     190   subroutine h2o_cloudrad(ngrid,nlayer,pql,reffliq,reffice)
    189191!==================================================================
    190192!     Purpose
     
    201203
    202204      include "callkeys.h"
    203       include "dimensions.h"
    204       include "dimphys.h"
     205!      include "dimensions.h"
     206!      include "dimphys.h"
    205207      include "comcstfi.h"
    206208
    207209      integer,intent(in) :: ngrid
    208 
    209       real, intent(in) :: pql(ngrid,nlayermx) !condensed water mixing ratios (kg/kg)
    210       real, intent(out) :: reffliq(ngrid,nlayermx),reffice(ngrid,nlayermx)     !liquid and ice water particle radii (m)
     210      integer,intent(in) :: nlayer
     211
     212      real, intent(in) :: pql(ngrid,nlayer) !condensed water mixing ratios (kg/kg)
     213      real, intent(out) :: reffliq(ngrid,nlayer),reffice(ngrid,nlayer)     !liquid and ice water particle radii (m)
    211214
    212215      real,external :: CBRT           
     
    214217
    215218      if (radfixed) then
    216          reffliq(1:ngrid,1:nlayermx)= rad_h2o
    217          reffice(1:ngrid,1:nlayermx)= rad_h2o_ice
     219         reffliq(1:ngrid,1:nlayer)= rad_h2o
     220         reffice(1:ngrid,1:nlayer)= rad_h2o_ice
    218221      else
    219          do k=1,nlayermx
     222         do k=1,nlayer
    220223           do i=1,ngrid
    221224             reffliq(i,k) = CBRT(3*pql(i,k)/(4*Nmix_h2o*pi*rhowater))
     
    234237
    235238!==================================================================
    236    subroutine co2_reffrad(ngrid,nq,pq,reffrad)
     239   subroutine co2_reffrad(ngrid,nlayer,nq,pq,reffrad)
    237240!==================================================================
    238241!     Purpose
     
    249252
    250253      include "callkeys.h"
    251       include "dimensions.h"
    252       include "dimphys.h"
     254!      include "dimensions.h"
     255!      include "dimphys.h"
    253256      include "comcstfi.h"
    254257
    255       integer,intent(in) :: ngrid,nq
    256 
    257       real, intent(in) :: pq(ngrid,nlayermx,nq) !tracer mixing ratios (kg/kg)
    258       real, intent(out) :: reffrad(ngrid,nlayermx)      !co2 ice particles radii (K)
     258      integer,intent(in) :: ngrid,nlayer,nq
     259
     260      real, intent(in) :: pq(ngrid,nlayer,nq) !tracer mixing ratios (kg/kg)
     261      real, intent(out) :: reffrad(ngrid,nlayer)      !co2 ice particles radii (m)
    259262
    260263      integer :: ig,l
     
    265268
    266269      if (radfixed) then
    267          reffrad(1:ngrid,1:nlayermx) = 5.e-5 ! CO2 ice
     270         reffrad(1:ngrid,1:nlayer) = 5.e-5 ! CO2 ice
    268271      else
    269          do l=1,nlayermx
     272         do l=1,nlayer
    270273            do ig=1,ngrid
    271274               zrad = CBRT( 3*pq(ig,l,igcm_co2_ice)/(4*Nmix_co2*pi*rho_co2) )
     
    281284
    282285!==================================================================
    283    subroutine dust_reffrad(ngrid,reffrad)
     286   subroutine dust_reffrad(ngrid,nlayer,reffrad)
    284287!==================================================================
    285288!     Purpose
     
    294297      Implicit none
    295298
    296       include "callkeys.h"
    297       include "dimensions.h"
    298       include "dimphys.h"
    299 
    300       integer,intent(in) :: ngrid
    301 
    302       real, intent(out) :: reffrad(ngrid,nlayermx)      !dust particles radii (K)
     299!      include "callkeys.h"
     300!      include "dimensions.h"
     301!      include "dimphys.h"
     302
     303      integer,intent(in) :: ngrid
     304      integer,intent(in) :: nlayer
     305
     306      real, intent(out) :: reffrad(ngrid,nlayer)      !dust particles radii (m)
    303307           
    304       reffrad(1:ngrid,1:nlayermx) = 2.e-6 ! dust
     308      reffrad(1:ngrid,1:nlayer) = 2.e-6 ! dust
    305309
    306310   end subroutine dust_reffrad
     
    309313
    310314!==================================================================
    311    subroutine h2so4_reffrad(ngrid,reffrad)
     315   subroutine h2so4_reffrad(ngrid,nlayer,reffrad)
    312316!==================================================================
    313317!     Purpose
     
    322326      Implicit none
    323327
    324       include "callkeys.h"
    325       include "dimensions.h"
    326       include "dimphys.h"
    327 
    328       integer,intent(in) :: ngrid
    329 
    330       real, intent(out) :: reffrad(ngrid,nlayermx)      !h2so4 particle radii (K)
     328!      include "callkeys.h"
     329!      include "dimensions.h"
     330!      include "dimphys.h"
     331
     332      integer,intent(in) :: ngrid
     333      integer,intent(in) :: nlayer
     334
     335      real, intent(out) :: reffrad(ngrid,nlayer)      !h2so4 particle radii (m)
    331336               
    332       reffrad(1:ngrid,1:nlayermx) = 1.e-6 ! h2so4
     337      reffrad(1:ngrid,1:nlayer) = 1.e-6 ! h2so4
    333338
    334339   end subroutine h2so4_reffrad
     
    352357
    353358     include "callkeys.h"
    354      include "dimensions.h"
    355      include "dimphys.h"
    356 
    357       integer,intent(in) :: ngrid
    358 
    359       real, intent(out) :: reffrad(ngrid,nlayermx)      ! particle radii
     359!     include "dimensions.h"
     360!     include "dimphys.h"
     361
     362      integer,intent(in) :: ngrid
     363
     364      real, intent(out) :: reffrad(ngrid,nlayer)      ! particle radii (m)
    360365      REAL,INTENT(IN) :: pplev(ngrid,nlayer+1) ! inter-layer pressure (Pa)
    361366      INTEGER,INTENT(IN) :: nlayer ! number of atmospheric layers
  • trunk/LMDZ.GENERIC/libf/phystd/rain.F90

    r1304 r1308  
    1 subroutine rain(ngrid,nq,ptimestep,pplev,pplay,t,pdt,pq,pdq,d_t,dqrain,dqsrain,dqssnow,rneb)
     1subroutine rain(ngrid,nlayer,nq,ptimestep,pplev,pplay,t,pdt,pq,pdq,d_t,dqrain,dqsrain,dqssnow,rneb)
    22
    33
     
    2222!==================================================================
    2323
    24   include "dimensions.h"
    25   include "dimphys.h"
     24!  include "dimensions.h"
     25!  include "dimphys.h"
    2626  include "comcstfi.h"
    2727  include "callkeys.h"
    2828
    2929!     Arguments
    30       integer,intent(in) :: ngrid ! number of atmospherci columns
     30      integer,intent(in) :: ngrid ! number of atmospheric columns
     31      integer,intent(in) :: nlayer ! number of atmospheric layers
    3132      integer,intent(in) :: nq ! number of tracers
    3233      real,intent(in) :: ptimestep    ! time interval
    33       real,intent(in) :: pplev(ngrid,nlayermx+1) ! inter-layer pressure (Pa)
    34       real,intent(in) :: pplay(ngrid,nlayermx)   ! mid-layer pressure (Pa)
    35       real,intent(in) :: t(ngrid,nlayermx) ! input temperature (K)
    36       real,intent(in) :: pdt(ngrid,nlayermx) ! input tendency on temperature (K/s)     
    37       real,intent(in) :: pq(ngrid,nlayermx,nq)  ! tracers (kg/kg)
    38       real,intent(in) :: pdq(ngrid,nlayermx,nq) ! input tendency on tracers
    39       real,intent(out) :: d_t(ngrid,nlayermx) ! temperature tendency (K/s)
    40       real,intent(out) :: dqrain(ngrid,nlayermx,nq) ! tendency of H2O precipitation (kg/kg.s-1)
     34      real,intent(in) :: pplev(ngrid,nlayer+1) ! inter-layer pressure (Pa)
     35      real,intent(in) :: pplay(ngrid,nlayer)   ! mid-layer pressure (Pa)
     36      real,intent(in) :: t(ngrid,nlayer) ! input temperature (K)
     37      real,intent(in) :: pdt(ngrid,nlayer) ! input tendency on temperature (K/s)     
     38      real,intent(in) :: pq(ngrid,nlayer,nq)  ! tracers (kg/kg)
     39      real,intent(in) :: pdq(ngrid,nlayer,nq) ! input tendency on tracers
     40      real,intent(out) :: d_t(ngrid,nlayer) ! temperature tendency (K/s)
     41      real,intent(out) :: dqrain(ngrid,nlayer,nq) ! tendency of H2O precipitation (kg/kg.s-1)
    4142      real,intent(out) :: dqsrain(ngrid)  ! rain flux at the surface (kg.m-2.s-1)
    4243      real,intent(out) :: dqssnow(ngrid)  ! snow flux at the surface (kg.m-2.s-1)
    43       real,intent(in) :: rneb(ngrid,nlayermx) ! cloud fraction
    44 
    45       REAL zt(ngrid,nlayermx)         ! working temperature (K)
    46       REAL ql(ngrid,nlayermx)         ! liquid water (Kg/Kg)
    47       REAL q(ngrid,nlayermx)          ! specific humidity (Kg/Kg)
    48       REAL d_q(ngrid,nlayermx)        ! water vapor increment
    49       REAL d_ql(ngrid,nlayermx)       ! liquid water / ice increment
     44      real,intent(in) :: rneb(ngrid,nlayer) ! cloud fraction
     45
     46      REAL zt(ngrid,nlayer)         ! working temperature (K)
     47      REAL ql(ngrid,nlayer)         ! liquid water (Kg/Kg)
     48      REAL q(ngrid,nlayer)          ! specific humidity (Kg/Kg)
     49      REAL d_q(ngrid,nlayer)        ! water vapor increment
     50      REAL d_ql(ngrid,nlayer)       ! liquid water / ice increment
    5051
    5152!     Subroutine options
     
    7374!     Local variables
    7475      INTEGER i, k, n
    75       REAL zqs(ngrid,nlayermx),Tsat(ngrid,nlayermx), zdelta, zcor
     76      REAL zqs(ngrid,nlayer),Tsat(ngrid,nlayer), zdelta, zcor
    7677      REAL zrfl(ngrid), zrfln(ngrid), zqev, zqevt
    7778
     
    8081      REAL zchau(ngrid),zfroi(ngrid),zfrac(ngrid),zneb(ngrid)
    8182
    82       real reffh2oliq(ngrid,nlayermx),reffh2oice(ngrid,nlayermx)
     83      real reffh2oliq(ngrid,nlayer),reffh2oice(ngrid,nlayer)
    8384 
    8485      real ttemp, ptemp, psat_tmp
    85       real tnext(ngrid,nlayermx)
    86 
    87       real l2c(ngrid,nlayermx)
     86      real tnext(ngrid,nlayer)
     87
     88      real l2c(ngrid,nlayer)
    8889      real dWtot
    8990
     
    151152
    152153!     GCM -----> subroutine variables
    153       DO k = 1, nlayermx
     154      DO k = 1, nlayer
    154155      DO i = 1, ngrid
    155156
     
    172173
    173174!     Initialise the outputs
    174       d_t(1:ngrid,1:nlayermx) = 0.0
    175       d_q(1:ngrid,1:nlayermx) = 0.0
    176       d_ql(1:ngrid,1:nlayermx) = 0.0
     175      d_t(1:ngrid,1:nlayer) = 0.0
     176      d_q(1:ngrid,1:nlayer) = 0.0
     177      d_ql(1:ngrid,1:nlayer) = 0.0
    177178      zrfl(1:ngrid) = 0.0
    178179      zrfln(1:ngrid) = 0.0
    179180
    180181      ! calculate saturation mixing ratio
    181       DO k = 1, nlayermx
     182      DO k = 1, nlayer
    182183         DO i = 1, ngrid
    183184            ttemp = zt(i,k)
     
    190191
    191192      ! get column / layer conversion factor
    192       DO k = 1, nlayermx
     193      DO k = 1, nlayer
    193194         DO i = 1, ngrid
    194195            l2c(i,k)=(pplev(i,k)-pplev(i,k+1))/g
     
    199200      ! We carry the rain with us and calculate that added by warm/cold precipitation
    200201      ! processes and that subtracted by evaporation at each level.
    201       DO k = nlayermx, 1, -1
     202      DO k = nlayer, 1, -1
    202203
    203204         IF (evap_prec) THEN ! note no rneb dependence!
     
    273274
    274275 !recalculate liquid water particle radii
    275            call h2o_cloudrad(ngrid,ql,reffh2oliq,reffh2oice)
     276           call h2o_cloudrad(ngrid,nlayer,ql,reffh2oliq,reffh2oice)
    276277
    277278           SELECT CASE(precip_scheme)
     
    357358         endif ! if precip_scheme=1
    358359
    359       ENDDO ! of DO k = nlayermx, 1, -1
     360      ENDDO ! of DO k = nlayer, 1, -1
    360361
    361362!     Rain or snow on the ground
     
    376377!     now subroutine -----> GCM variables
    377378      if (evap_prec) then
    378         dqrain(1:ngrid,1:nlayermx,i_vap)=d_q(1:ngrid,1:nlayermx)/ptimestep
    379         d_t(1:ngrid,1:nlayermx)=d_t(1:ngrid,1:nlayermx)/ptimestep
     379        dqrain(1:ngrid,1:nlayer,i_vap)=d_q(1:ngrid,1:nlayer)/ptimestep
     380        d_t(1:ngrid,1:nlayer)=d_t(1:ngrid,1:nlayer)/ptimestep
    380381      else
    381         dqrain(1:ngrid,1:nlayermx,i_vap)=0.0
    382         d_t(1:ngrid,1:nlayermx)=0.0
     382        dqrain(1:ngrid,1:nlayer,i_vap)=0.0
     383        d_t(1:ngrid,1:nlayer)=0.0
    383384      endif
    384       dqrain(1:ngrid,1:nlayermx,i_ice) = d_ql(1:ngrid,1:nlayermx)/ptimestep
     385      dqrain(1:ngrid,1:nlayer,i_ice) = d_ql(1:ngrid,1:nlayer)/ptimestep
    385386
    386387    end subroutine rain
  • trunk/LMDZ.GENERIC/libf/phystd/rcm1d.F

    r1303 r1308  
    1616      use comgeomphy, only: initcomgeomphy
    1717      use slab_ice_h, only: noceanmx
     18      use planete_mod
    1819
    1920      implicit none
     
    4546#include "dimensions.h"
    4647#include "paramet.h"
    47 #include "dimphys.h"
     48!include "dimphys.h"
    4849#include "callkeys.h"
    4950#include "comcstfi.h"
    50 #include "planete.h"
     51!#include "planete.h"
    5152!#include "control.h"
    5253#include "comvert.h"
     
    6768      REAL day           ! date durant le run
    6869      REAL time             ! time (0<time<1 ; time=0.5 a midi)
    69       REAL play(nlayermx)   ! Pressure at the middle of the layers (Pa)
    70       REAL plev(nlayermx+1) ! intermediate pressure levels (pa)
     70      REAL play(llm)   ! Pressure at the middle of the layers (Pa)
     71      REAL plev(llm+1) ! intermediate pressure levels (pa)
    7172      REAL psurf,tsurf(1)     
    72       REAL u(nlayermx),v(nlayermx)  ! zonal, meridional wind
     73      REAL u(llm),v(llm)  ! zonal, meridional wind
    7374      REAL gru,grv   ! prescribed "geostrophic" background wind
    74       REAL temp(nlayermx)   ! temperature at the middle of the layers
     75      REAL temp(llm)   ! temperature at the middle of the layers
    7576      REAL,ALLOCATABLE :: q(:,:) ! tracer mixing ratio (e.g. kg/kg)
    7677      REAL,ALLOCATABLE :: qsurf(:)      ! tracer surface budget (e.g. kg.m-2)
     
    8182      integer :: i_h2o_vap=0  ! tracer index of h2o vapor
    8283      REAL emis(1)             ! surface layer
    83       REAL q2(nlayermx+1)   ! Turbulent Kinetic Energy
    84       REAL zlay(nlayermx)   ! altitude estimee dans les couches (km)
     84      REAL q2(llm+1)   ! Turbulent Kinetic Energy
     85      REAL zlay(llm)   ! altitude estimee dans les couches (km)
    8586
    8687c    Physical and dynamical tandencies (e.g.  m.s-2, K/s, Pa/s)
    87       REAL du(nlayermx),dv(nlayermx),dtemp(nlayermx)
    88       REAL dudyn(nlayermx),dvdyn(nlayermx),dtempdyn(nlayermx)
     88      REAL du(llm),dv(llm),dtemp(llm)
     89      REAL dudyn(llm),dvdyn(llm),dtempdyn(llm)
    8990      REAL dpsurf   
    9091      REAL,ALLOCATABLE :: dq(:,:)
     
    9495!      INTEGER thermo
    9596      REAL zls
    96       REAL phi(nlayermx),h(nlayermx),s(nlayermx)
    97       REAL pks, ptif, w(nlayermx)
     97      REAL phi(llm),h(llm),s(llm)
     98      REAL pks, ptif, w(llm)
    9899      INTEGER ierr, aslun
    99       REAL tmp1(0:nlayermx),tmp2(0:nlayermx)
     100      REAL tmp1(0:llm),tmp2(0:llm)
    100101      Logical  tracerdyn
    101102      integer :: nq !=1 ! number of tracers
     
    111112!     added by RW for autozlevs computation
    112113      real nu, xx, pMIN, zlev, Htop
    113       real logplevs(nlayermx)
     114      real logplevs(llm)
    114115
    115116!     added by BC
    116       REAL cloudfrac(1,nlayermx)
     117      REAL cloudfrac(1,llm)
    117118      REAL hice(1),totcloudfrac(1)
    118119      REAL qzero1D   !initial water amount on the ground
     
    253254          if (nq>0) then
    254255            allocate(tname(nq))
    255             allocate(q(nlayermx,nq))
     256            allocate(q(llm,nq))
    256257            allocate(qsurf(nq))
    257             allocate(dq(nlayermx,nq))
    258             allocate(dqdyn(nlayermx,nq))
     258            allocate(dq(llm,nq))
     259            allocate(dqdyn(llm,nq))
    259260          else
    260261            write(*,*) "rcm1d: Error. You set tracer=.true."
     
    298299        allocate(tname(1))
    299300        allocate(qsurf(1))
    300         allocate(q(nlayermx,1))
    301         allocate(dq(nlayermx,1))
     301        allocate(q(llm,1))
     302        allocate(dq(llm,1))
    302303     
    303304       ! Check that tracer boolean is compliant with number of tracers
     
    484485c  --------------
    485486c
    486       nlayer=nlayermx
     487      nlayer=llm
    487488      nlevel=nlayer+1
    488489      nsoil=nsoilmx
     
    890891         OPEN(12,file='profile.out',form='formatted')
    891892         write(12,*) tsurf
    892          DO ilayer=1,nlayermx
     893         DO ilayer=1,llm
    893894            write(12,*) temp(ilayer) !, play(ilayer) !AS12 only temp so that iprofile=8 can be used
    894895         ENDDO
  • trunk/LMDZ.GENERIC/libf/phystd/soil.F

    r1216 r1308  
    1717!-----------------------------------------------------------------------
    1818
    19       include "dimensions.h"
    20       include "dimphys.h"
     19!      include "dimensions.h"
     20!      include "dimphys.h"
    2121
    2222
  • trunk/LMDZ.GENERIC/libf/phystd/start2archive.F

    r1297 r1308  
    2727! to use  'getin'
    2828      USE ioipsl_getincom
     29      USE planete_mod
    2930
    3031      implicit none
    3132
    3233#include "dimensions.h"
     34      integer, parameter :: ngridmx = (2+(jjm-1)*iim - 1/jjm)
    3335#include "paramet.h"
    3436#include "comconst.h"
     
    4143#include "ener.h"
    4244
    43 #include "dimphys.h"
    44 #include "planete.h"
     45!#include "dimphys.h"
     46!#include "planete.h"
    4547!#include"advtrac.h"
    4648#include "netcdf.inc"
     
    6971      REAL tsoil(ngridmx,nsoilmx) ! Soil temperature
    7072      REAL co2ice(ngridmx)      ! CO2 ice layer
    71       REAL q2(ngridmx,nlayermx+1)
     73      REAL q2(ngridmx,llm+1)
    7274      REAL,ALLOCATABLE :: qsurf(:,:)
    7375      REAL emis(ngridmx)
     
    8082!     added by FF for cloud fraction setup
    8183      REAL hice(ngridmx)
    82       REAL cloudfrac(ngridmx,nlayermx),totalcloudfrac(ngridmx)
     84      REAL cloudfrac(ngridmx,llm),totalcloudfrac(ngridmx)
    8385
    8486!     added by BC for slab ocean
     
    199201
    200202
    201       CALL phyetat0 (ngridmx,fichnom,0,Lmodif,nsoilmx,nqtot,day_ini_fi,
    202      .      timefi,
     203      CALL phyetat0 (ngridmx,llm,fichnom,0,Lmodif,nsoilmx,nqtot,
     204     .      day_ini_fi,timefi,
    203205     .      tsurf,tsoil,emis,q2,qsurf,
    204206!       change FF 05/2011
  • trunk/LMDZ.GENERIC/libf/phystd/stellarlong.F

    r590 r1308  
    11      SUBROUTINE stellarlong(pday,pstellong)
     2     
     3      USE planete_mod, ONLY: year_day, peri_day, e_elips, timeperi
    24      IMPLICIT NONE
    35
     
    4042c   -------------
    4143
    42 #include "planete.h"
     44!#include "planete.h"
    4345#include "comcstfi.h"
    4446
  • trunk/LMDZ.GENERIC/libf/phystd/surf_heat_transp_mod.F90

    r1298 r1308  
    77CONTAINS
    88
    9       SUBROUTINE divgrad_phy(nlevs,temp,delta)
     9      SUBROUTINE divgrad_phy(ngrid,nlevs,temp,delta)
    1010
    1111
     
    1414
    1515#include "dimensions.h"
    16 #include "dimphys.h"
     16!#include "dimphys.h"
    1717#include "paramet.h"
    1818#include "comcstfi.h"
     
    2020#include "comhdiff.h"
    2121     
    22       INTEGER nlevs, ll
    23       REAL temp(ngridmx,nlevs)
     22      INTEGER,INTENT(IN) :: ngrid, nlevs
     23      REAL,INTENT(IN) :: temp(ngrid,nlevs)
     24      REAL,INTENT(OUT) :: delta(ngrid,nlevs)
    2425      REAL delta_2d(ip1jmp1,nlevs)
    25       REAL delta(ngridmx,nlevs)
     26      INTEGER :: ll
    2627      REAL ghx(ip1jmp1,nlevs), ghy(ip1jm,nlevs)
    2728
    2829
    29       CALL gr_fi_dyn(nlevs,ngridmx,iip1,jjp1,temp,delta_2d)
     30      CALL gr_fi_dyn(nlevs,ngrid,iip1,jjp1,temp,delta_2d)
    3031      CALL grad(nlevs,delta_2d,ghx,ghy)
    3132      DO ll=1,nlevs
     
    3637      END DO
    3738      CALL diverg(nlevs,ghx,ghy,delta_2d)
    38       CALL gr_dyn_fi(nlevs,iip1,jjp1,ngridmx,delta_2d,delta)
     39      CALL gr_dyn_fi(nlevs,iip1,jjp1,ngrid,delta_2d,delta)
    3940
    4041
     
    4344
    4445
    45       SUBROUTINE init_masquv(zmasq)
     46      SUBROUTINE init_masquv(ngrid,zmasq)
    4647     
    4748      IMPLICIT NONE
    4849
    4950#include "dimensions.h"
    50 #include "dimphys.h"
     51!#include "dimphys.h"
    5152#include "paramet.h"
    5253#include "comcstfi.h"   
     
    5556
    5657
    57       REAL zmasq(ngridmx)
     58      INTEGER,INTENT(IN) :: ngrid
     59      REAL zmasq(ngrid)
    5860      REAL zmasq_2d(ip1jmp1)
    5961      REAL ff(ip1jm)
     
    6668      zmasqv=1.
    6769
    68       CALL gr_fi_dyn(1,ngridmx,iip1,jjp1,zmasq,zmasq_2d)
     70      CALL gr_fi_dyn(1,ngrid,iip1,jjp1,zmasq,zmasq_2d)
    6971
    7072      DO i=1,ip1jmp1-1
     
    104106
    105107
    106       SUBROUTINE slab_ekman2(tx_phy,ty_phy,ts_phy,dt_phy)
     108      SUBROUTINE slab_ekman2(ngrid,tx_phy,ty_phy,ts_phy,dt_phy)
    107109 
    108110          use slab_ice_h
     
    111113     
    112114#include "dimensions.h"
    113 #include "dimphys.h"
     115!#include "dimphys.h"
    114116#include "paramet.h"
    115117#include "comcstfi.h"
     
    118120#include "comhdiff.h"
    119121
     122      INTEGER,INTENT(IN) :: ngrid
    120123      INTEGER ij
    121124      REAL txv(ip1jm),fluxm(ip1jm),tyv(ip1jm)
     
    123126      REAL tyu(ip1jmp1),txu(ip1jmp1),fluxz(ip1jmp1),fluxv(ip1jmp1)
    124127      REAL dt(ip1jmp1,noceanmx),ts(ip1jmp1,noceanmx)
    125       REAL tx_phy(ngridmx),ty_phy(ngridmx)
    126       REAL dt_phy(ngridmx,noceanmx),ts_phy(ngridmx,noceanmx)
     128      REAL tx_phy(ngrid),ty_phy(ngrid)
     129      REAL dt_phy(ngrid,noceanmx),ts_phy(ngrid,noceanmx)
    127130
    128131
     
    130133
    131134! Passage taux,y sur grilles 2d
    132       CALL gr_fi_dyn(1,ngridmx,iip1,jjp1,tx_phy,txu)
    133       CALL gr_fi_dyn(1,ngridmx,iip1,jjp1,ty_phy,tyu)
     135      CALL gr_fi_dyn(1,ngrid,iip1,jjp1,tx_phy,txu)
     136      CALL gr_fi_dyn(1,ngrid,iip1,jjp1,ty_phy,tyu)
    134137! Passage grille u,v
    135138! Multiplication par f ou eps.
     
    144147           
    145148! Calcul de T, Tdeep
    146       CALL gr_fi_dyn(2,ngridmx,iip1,jjp1,ts_phy,ts)
     149      CALL gr_fi_dyn(2,ngrid,iip1,jjp1,ts_phy,ts)
    147150       
    148151! Flux de masse
     
    222225
    223226! Retour grille physique
    224       CALL gr_dyn_fi(2,iip1,jjp1,ngridmx,dt,dt_phy)
     227      CALL gr_dyn_fi(2,iip1,jjp1,ngrid,dt,dt_phy)
    225228
    226229
  • trunk/LMDZ.GENERIC/libf/phystd/surface_nature.F

    r787 r1308  
    3333!==================================================================
    3434
    35 #include "dimensions.h"
    36 #include "dimphys.h"
     35!#include "dimensions.h"
     36!#include "dimphys.h"
    3737#include "comcstfi.h"
    3838#include "callkeys.h"
  • trunk/LMDZ.GENERIC/libf/phystd/surfini.F

    r1216 r1308  
    1515c   Declarations:
    1616c   -------------
    17 #include "dimensions.h"
    18 #include "dimphys.h"
     17!#include "dimensions.h"
     18!#include "dimphys.h"
    1919#include "callkeys.h"
    2020c
  • trunk/LMDZ.GENERIC/libf/phystd/tabfi.F

    r1216 r1308  
    3434c                              comparer avec le day_ini dynamique)
    3535c
    36 c      - lmax:    tab_cntrl(tab0+2) (pour test avec nlayermx)
     36c      - lmax:    tab_cntrl(tab0+2) (pour test avec nlayer)
    3737c
    3838c      - p_rad
     
    5151      use iostart, only: get_var
    5252      use mod_phys_lmdz_para, only: is_parallel
     53      use planete_mod, only: year_day, periastr, apoastr, peri_day,
     54     &                       obliquit, z0, lmixmin, emin_turb
    5355
    5456      implicit none
    5557 
    5658#include "comcstfi.h"
    57 #include "planete.h"
     59!#include "planete.h"
    5860#include "netcdf.inc"
    5961#include "callkeys.h"
  • trunk/LMDZ.GENERIC/libf/phystd/totalcloudfrac.F90

    r858 r1308  
    1       subroutine totalcloudfrac(ngrid,nq,rneb,totalrneb,pplev,pq,tau)
     1      subroutine totalcloudfrac(ngrid,nlayer,nq,rneb,totalrneb,pplev,pq,tau)
    22
    33      use watercommon_h
     
    1919!==================================================================
    2020
    21 #include "dimensions.h"
    22 #include "dimphys.h"
     21!#include "dimensions.h"
     22!#include "dimphys.h"
    2323#include "comcstfi.h"
    2424#include "callkeys.h"
    2525
    2626      integer,intent(in) :: ngrid        ! number of atmospheric columns
     27      integer,intent(in) :: nlayer       ! number of atmospheric layers
    2728      integer,intent(in) :: nq           ! number of tracers
    28       real,intent(in) :: rneb(ngrid,nlayermx)    ! cloud fraction     
     29      real,intent(in) :: rneb(ngrid,nlayer)    ! cloud fraction     
    2930      real,intent(out) :: totalrneb(ngrid)       ! total cloud fraction
    30       real,intent(in) :: pplev(ngrid,nlayermx+1) ! inter-layer pressure (Pa)
    31       real,intent(in) :: pq(ngrid,nlayermx,nq)   ! tracers (.../kg_of_air)
    32       real,intent(in) :: tau(ngrid,nlayermx)
     31      real,intent(in) :: pplev(ngrid,nlayer+1) ! inter-layer pressure (Pa)
     32      real,intent(in) :: pq(ngrid,nlayer,nq)   ! tracers (.../kg_of_air)
     33      real,intent(in) :: tau(ngrid,nlayer)
    3334
    34       real, dimension(nlayermx+1) :: masse
     35      real, dimension(nlayer+1) :: masse
    3536      integer, parameter          :: recovery=7
    3637      integer ltau_max
     
    4748      real clear,tau_min
    4849      real, parameter ::  tau_c=0.1 !threshold of optical depth for the calculation of total cloud fraction
    49       real rneb2(nlayermx)
     50      real rneb2(nlayer)
    5051
    5152
     
    5556         if (recovery.eq.1) then
    5657            clear = (1.-rneb(ig,1))
    57             do l=2,nlayermx      
     58            do l=2,nlayer     
    5859               clear = clear*(1.-rneb(ig,l))
    5960            enddo
     
    6263         elseif (recovery.eq.2) then
    6364            totalrneb(ig) = rneb(ig,1)
    64             do l=2,14 !nlayermx      
     65            do l=2,14 !nlayer   
    6566               totalrneb(ig) = max(rneb(ig,l),totalrneb(ig))
    6667            enddo
     
    6869         elseif (recovery.eq.3) then
    6970            totalrneb(ig) = rneb(ig,1)
    70             do l=2,nlayermx      
     71            do l=2,nlayer   
    7172               totalrneb(ig) = min(rneb(ig,l),totalrneb(ig))
    7273            enddo
     
    7778         elseif (recovery.eq.5) then
    7879            totalrneb(ig) = rneb(ig,1)           
    79             do l=1,nlayermx
     80            do l=1,nlayer
    8081               masse(l)=pq(ig,l,igcm_h2o_ice)*(pplev(ig,l)-pplev(ig,l+1))
    8182            enddo
     
    8586         elseif (recovery.eq.6) then
    8687            totalrneb(ig) = 0.           
    87             do l=1,nlayermx
     88            do l=1,nlayer
    8889               masse(l)=pq(ig,l,igcm_h2o_ice)*(pplev(ig,l)-pplev(ig,l+1))
    8990               masse(l)=max(masse(l),0.)
    9091            enddo
    9192            massetot=sum(masse,dim=1)
    92             do l=1,nlayermx
     93            do l=1,nlayer
    9394               totalrneb(ig) = totalrneb(ig)+rneb(ig,l)*masse(l)/massetot
    9495            enddo
     
    9697         elseif (recovery.eq.7) then
    9798
    98             rneb2(:)=rneb(ig,1:nlayermx)
    99             tau_min=MIN(tau_c,MAXVAL(tau(ig,1:nlayermx))/2.)
    100             do l=1,nlayermx
     99            rneb2(:)=rneb(ig,1:nlayer)
     100            tau_min=MIN(tau_c,MAXVAL(tau(ig,1:nlayer))/2.)
     101            do l=1,nlayer
    101102               if(tau(ig,l)<tau_min) rneb2(l)=0.       
    102103            enddo
    103             totalrneb(ig)=maxval(rneb2(1:nlayermx))
     104            totalrneb(ig)=maxval(rneb2(1:nlayer))
    104105
    105106         endif                  ! (recovery=)   
  • trunk/LMDZ.GENERIC/libf/phystd/turbdiff.F90

    r1297 r1308  
    4141!     ------------
    4242
    43       include "dimensions.h"
    44       include "dimphys.h"
     43!      include "dimensions.h"
     44!      include "dimphys.h"
    4545      include "comcstfi.h"
    4646      include "callkeys.h"
     
    4848!     arguments
    4949!     ---------
    50       INTEGER,INTENT(IN) :: ngrid,nlay
     50      INTEGER,INTENT(IN) :: ngrid
     51      INTEGER,INTENT(IN) :: nlay
    5152      REAL,INTENT(IN) :: ptimestep
    5253      REAL,INTENT(IN) :: pplay(ngrid,nlay),pplev(ngrid,nlay+1)
     
    8687
    8788      REAL z4st,zdplanck(ngrid)
    88       REAL zkv(ngrid,nlayermx+1),zkh(ngrid,nlayermx+1)
     89      REAL zkv(ngrid,nlay+1),zkh(ngrid,nlay+1)
    8990      REAL zcdv(ngrid),zcdh(ngrid)
    9091      REAL zcdv_true(ngrid),zcdh_true(ngrid)
    91       REAL zu(ngrid,nlayermx),zv(ngrid,nlayermx)
    92       REAL zh(ngrid,nlayermx),zt(ngrid,nlayermx)
     92      REAL zu(ngrid,nlay),zv(ngrid,nlay)
     93      REAL zh(ngrid,nlay),zt(ngrid,nlay)
    9394      REAL ztsrf(ngrid)
    9495      REAL z1(ngrid),z2(ngrid)
    95       REAL zmass(ngrid,nlayermx)
    96       REAL zfluxv(ngrid,nlayermx),zfluxt(ngrid,nlayermx),zfluxq(ngrid,nlayermx)
    97       REAL zb0(ngrid,nlayermx)
    98       REAL zExner(ngrid,nlayermx),zovExner(ngrid,nlayermx)
    99       REAL zcv(ngrid,nlayermx),zdv(ngrid,nlayermx)  !inversion coefficient for winds
    100       REAL zct(ngrid,nlayermx),zdt(ngrid,nlayermx)  !inversion coefficient for temperature
    101       REAL zcq(ngrid,nlayermx),zdq(ngrid,nlayermx)  !inversion coefficient for tracers
     96      REAL zmass(ngrid,nlay)
     97      REAL zfluxv(ngrid,nlay),zfluxt(ngrid,nlay),zfluxq(ngrid,nlay)
     98      REAL zb0(ngrid,nlay)
     99      REAL zExner(ngrid,nlay),zovExner(ngrid,nlay)
     100      REAL zcv(ngrid,nlay),zdv(ngrid,nlay)  !inversion coefficient for winds
     101      REAL zct(ngrid,nlay),zdt(ngrid,nlay)  !inversion coefficient for temperature
     102      REAL zcq(ngrid,nlay),zdq(ngrid,nlay)  !inversion coefficient for tracers
    102103      REAL zcst1
    103104      REAL zu2!, a
     
    110111!     -------
    111112      INTEGER iq
    112       REAL zq(ngrid,nlayermx,nq)
    113       REAL zqnoevap(ngrid,nlayermx) !special for water case to compute where evaporated water goes.
    114       REAL pdqevap(ngrid,nlayermx) !special for water case to compute where evaporated water goes.
     113      REAL zq(ngrid,nlay,nq)
     114      REAL zqnoevap(ngrid,nlay) !special for water case to compute where evaporated water goes.
     115      REAL pdqevap(ngrid,nlay) !special for water case to compute where evaporated water goes.
    115116      REAL zdmassevap(ngrid)
    116117      REAL rho(ngrid)         ! near-surface air density
     
    241242!     ------------------------------------------------------
    242243
    243       call vdif_kc(ngrid,ptimestep,g,pzlev,pzlay,pu,pv,zh,zcdv_true,pq2,zkv,zkh) !JL12 why not call vdif_kc with updated winds and temperature
     244      call vdif_kc(ngrid,nlay,ptimestep,g,pzlev,pzlay,pu,pv,zh,zcdv_true,pq2,zkv,zkh) !JL12 why not call vdif_kc with updated winds and temperature
    244245     
    245246!     Adding eddy mixing to mimic 3D general circulation in 1D
     
    262263 
    263264!JL12 calculate the flux coefficients (tables multiplied elements by elements)
    264       zfluxv(1:ngrid,1:nlayermx)=zkv(1:ngrid,1:nlayermx)*zb0(1:ngrid,1:nlayermx)
     265      zfluxv(1:ngrid,1:nlay)=zkv(1:ngrid,1:nlay)*zb0(1:ngrid,1:nlay)
    265266     
    266267!-----------------------------------------------------------------------
     
    364365!     JL12 calculate the flux coefficients (tables multiplied elements by elements)
    365366!     ---------------------------------------------------------------
    366       zfluxq(1:ngrid,1:nlayermx)=zkh(1:ngrid,1:nlayermx)*zb0(1:ngrid,1:nlayermx) !JL12 we save zfluxq which doesn't need the Exner factor
    367       zfluxt(1:ngrid,1:nlayermx)=zfluxq(1:ngrid,1:nlayermx)*zExner(1:ngrid,1:nlayermx)
     367      zfluxq(1:ngrid,1:nlay)=zkh(1:ngrid,1:nlay)*zb0(1:ngrid,1:nlay) !JL12 we save zfluxq which doesn't need the Exner factor
     368      zfluxt(1:ngrid,1:nlay)=zfluxq(1:ngrid,1:nlay)*zExner(1:ngrid,1:nlay)
    368369
    369370      DO ig=1,ngrid
  • trunk/LMDZ.GENERIC/libf/phystd/vdif_kc.F

    r1283 r1308  
    1       SUBROUTINE vdif_kc(ngrid,dt,g,zlev,zlay,u,v,teta,cd,q2,km,kn)
     1      SUBROUTINE vdif_kc(ngrid,nlay,dt,g,zlev,zlay,u,v,teta,cd,q2,km,kn)
    22      IMPLICIT NONE
    33c.......................................................................
    4 #include "dimensions.h"
    5 #include "dimphys.h"
     4!#include "dimensions.h"
     5!#include "dimphys.h"
    66c.......................................................................
    77c
     
    2828c.......................................................................
    2929      INTEGER,INTENT(IN) :: ngrid
     30      INTEGER,INTENT(IN) :: nlay
    3031      REAL,INTENT(IN) :: dt,g
    31       REAL,INTENT(IN) :: zlev(ngrid,nlayermx+1)
    32       REAL,INTENT(IN) :: zlay(ngrid,nlayermx)
    33       REAL,INTENT(IN) :: u(ngrid,nlayermx)
    34       REAL,INTENT(IN) :: v(ngrid,nlayermx)
    35       REAL,INTENT(IN) :: teta(ngrid,nlayermx)
     32      REAL,INTENT(IN) :: zlev(ngrid,nlay+1)
     33      REAL,INTENT(IN) :: zlay(ngrid,nlay)
     34      REAL,INTENT(IN) :: u(ngrid,nlay)
     35      REAL,INTENT(IN) :: v(ngrid,nlay)
     36      REAL,INTENT(IN) :: teta(ngrid,nlay)
    3637      REAL,INTENT(IN) :: cd(ngrid)
    37       REAL,INTENT(INOUT) :: q2(ngrid,nlayermx+1)
    38       REAL,INTENT(OUT) :: km(ngrid,nlayermx+1)
    39       REAL,INTENT(OUT) :: kn(ngrid,nlayermx+1)
     38      REAL,INTENT(INOUT) :: q2(ngrid,nlay+1)
     39      REAL,INTENT(OUT) :: km(ngrid,nlay+1)
     40      REAL,INTENT(OUT) :: kn(ngrid,nlay+1)
    4041c.......................................................................
    4142c
     
    5051c
    5152c.......................................................................
    52       INTEGER,PARAMETER :: nlay=nlayermx
    53       INTEGER,PARAMETER :: nlev=nlayermx+1
    54       REAL unsdz(ngrid,nlayermx)
    55       REAL unsdzdec(ngrid,nlayermx+1)
    56       REAL q(ngrid,nlayermx+1)
     53      INTEGER :: nlev
     54      REAL unsdz(ngrid,nlay)
     55      REAL unsdzdec(ngrid,nlay+1)
     56      REAL q(ngrid,nlay+1)
    5757c.......................................................................
    5858c
     
    6464c
    6565c.......................................................................
    66       REAL kmpre(ngrid,nlayermx+1)
     66      REAL kmpre(ngrid,nlay+1)
    6767      REAL qcstat
    6868      REAL q2cstat
     
    7272c
    7373c.......................................................................
    74       REAL long(ngrid,nlayermx+1)
     74      REAL long(ngrid,nlay+1)
    7575c.......................................................................
    7676c
     
    9595      REAL mcstat
    9696      REAL m2cstat
    97       REAL m(ngrid,nlayermx+1)
    98       REAL mpre(ngrid,nlayermx+1)
    99       REAL m2(ngrid,nlayermx+1)
    100       REAL n2(ngrid,nlayermx+1)
     97      REAL m(ngrid,nlay+1)
     98      REAL mpre(ngrid,nlay+1)
     99      REAL m2(ngrid,nlay+1)
     100      REAL n2(ngrid,nlay+1)
    101101c.......................................................................
    102102c
     
    120120      LOGICAL gnsup
    121121      REAL gm
    122 c      REAL ri(ngrid,nlayermx+1)
    123       REAL sn(ngrid,nlayermx+1)
    124       REAL snq2(ngrid,nlayermx+1)
    125       REAL sm(ngrid,nlayermx+1)
    126       REAL smq2(ngrid,nlayermx+1)
     122c      REAL ri(ngrid,nlaye+1)
     123      REAL sn(ngrid,nlay+1)
     124      REAL snq2(ngrid,nlay+1)
     125      REAL sm(ngrid,nlay+1)
     126      REAL smq2(ngrid,nlay+1)
    127127c.......................................................................
    128128c
     
    179179
    180180! initialization of local variables:
     181      nlev=nlay+1
    181182      long(:,:)=0.
    182183      n2(:,:)=0.
  • trunk/LMDZ.GENERIC/libf/phystd/vdifc.F

    r1297 r1308  
    3838!     ------------
    3939
    40 #include "dimensions.h"
    41 #include "dimphys.h"
     40!#include "dimensions.h"
     41!#include "dimphys.h"
    4242#include "comcstfi.h"
    4343#include "callkeys.h"
     
    7777
    7878      REAL z4st,zdplanck(ngrid)
    79       REAL zkv(ngrid,nlayermx+1),zkh(ngrid,nlayermx+1)
     79      REAL zkv(ngrid,nlay+1),zkh(ngrid,nlay+1)
    8080      REAL zcdv(ngrid),zcdh(ngrid)
    8181      REAL zcdv_true(ngrid),zcdh_true(ngrid)
    82       REAL zu(ngrid,nlayermx),zv(ngrid,nlayermx)
    83       REAL zh(ngrid,nlayermx)
     82      REAL zu(ngrid,nlay),zv(ngrid,nlay)
     83      REAL zh(ngrid,nlay)
    8484      REAL ztsrf2(ngrid)
    8585      REAL z1(ngrid),z2(ngrid)
    86       REAL za(ngrid,nlayermx),zb(ngrid,nlayermx)
    87       REAL zb0(ngrid,nlayermx)
    88       REAL zc(ngrid,nlayermx),zd(ngrid,nlayermx)
     86      REAL za(ngrid,nlay),zb(ngrid,nlay)
     87      REAL zb0(ngrid,nlay)
     88      REAL zc(ngrid,nlay),zd(ngrid,nlay)
    8989      REAL zcst1
    9090      REAL zu2!, a
    91       REAL zcq(ngrid,nlayermx),zdq(ngrid,nlayermx)
     91      REAL zcq(ngrid,nlay),zdq(ngrid,nlay)
    9292      REAL evap(ngrid)
    9393      REAL zcq0(ngrid),zdq0(ngrid)
     
    101101!     variables added for CO2 condensation
    102102!     ------------------------------------
    103       REAL hh                   !, zhcond(ngrid,nlayermx)
     103      REAL hh                   !, zhcond(ngrid,nlay)
    104104!     REAL latcond,tcond1mb
    105105!     REAL acond,bcond
     
    110110!     -------
    111111      INTEGER iq
    112       REAL zq(ngrid,nlayermx,nq)
     112      REAL zq(ngrid,nlay,nq)
    113113      REAL zq1temp(ngrid)
    114114      REAL rho(ngrid)         ! near-surface air density
     
    123123      real z1_T(ngrid), z2_T(ngrid)
    124124      real zb_T(ngrid)
    125       real zc_T(ngrid,nlayermx)
    126       real zd_T(ngrid,nlayermx)
     125      real zc_T(ngrid,nlay)
     126      real zd_T(ngrid,nlay)
    127127      real lat1(ngrid), lat2(ngrid)
    128128      real surfh2otot
     
    249249!     ------------------------------------------------------
    250250
    251       call vdif_kc(ngrid,ptimestep,g,pzlev,pzlay
     251      call vdif_kc(ngrid,nlay,ptimestep,g,pzlev,pzlay
    252252     &     ,pu,pv,ph,zcdv_true
    253253     &     ,pq2,zkv,zkh)
  • trunk/LMDZ.GENERIC/libf/phystd/vlz_fi.F

    r787 r1308  
    1       SUBROUTINE vlz_fi(ngrid,q,pente_max,masse,w,wq)
     1      SUBROUTINE vlz_fi(ngrid,nlayer,q,pente_max,masse,w,wq)
    22c
    33c     Auteurs:   P.Le Van, F.Hourdin, F.Forget
     
    1616      IMPLICIT NONE
    1717c
    18 #include "dimensions.h"
    19 #include "dimphys.h"
     18!#include "dimensions.h"
     19!#include "dimphys.h"
    2020
    2121c
     
    2323c   Arguments:
    2424c   ----------
    25       integer ngrid
    26       real masse(ngrid,llm),pente_max
    27       REAL q(ngrid,llm)
    28       REAL w(ngrid,llm)
    29       REAL wq(ngrid,llm+1)
     25      integer,intent(in) :: ngrid, nlayer
     26      real,intent(in) :: masse(ngrid,nlayer),pente_max
     27      REAL,INTENT(INOUT) :: q(ngrid,nlayer)
     28      REAL,INTENT(INOUT) :: w(ngrid,nlayer)
     29      REAL,INTENT(OUT) :: wq(ngrid,nlayer+1)
    3030c
    3131c      Local
     
    3535c
    3636
    37       real dzq(ngrid,llm),dzqw(ngrid,llm),adzqw(ngrid,llm),dzqmax
     37      real dzq(ngrid,nlayer),dzqw(ngrid,nlayer),adzqw(ngrid,nlayer)
     38      real dzqmax
    3839      real newmasse
    3940      real sigw, Mtot, MQtot
     
    4748c    sens de W
    4849
    49       do l=2,llm
     50      do l=2,nlayer
    5051         do ij=1,ngrid
    5152            dzqw(ij,l)=q(ij,l-1)-q(ij,l)
     
    5455      enddo
    5556
    56       do l=2,llm-1
     57      do l=2,nlayer-1
    5758         do ij=1,ngrid
    5859#ifdef CRAY
     
    7374      do ij=1,ngrid
    7475         dzq(ij,1)=0.
    75          dzq(ij,llm)=0.
     76         dzq(ij,nlayer)=0.
    7677      enddo
    7778c ---------------------------------------------------------------
     
    8384c      No flux at the model top:
    8485       do ij=1,ngrid
    85           wq(ij,llm+1)=0.
     86          wq(ij,nlayer+1)=0.
    8687       enddo
    8788
     
    8990c      ===============================
    9091
    91        do l = 1,llm          ! loop different than when w<0
     92       do l = 1,nlayer          ! loop different than when w<0
    9293        do ij=1,ngrid
    9394
     
    107108            Mtot = masse(ij,m)
    108109            MQtot = masse(ij,m)*q(ij,m)
    109             if(m.ge.llm)goto 88
     110            if(m.ge.nlayer)goto 88
    110111            do while(w(ij,l).gt.(Mtot+masse(ij,m+1)))
    111112                m=m+1
    112113                Mtot = Mtot + masse(ij,m)
    113114                MQtot = MQtot + masse(ij,m)*q(ij,m)
    114                 if(m.ge.llm)goto 88
     115                if(m.ge.nlayer)goto 88
    115116            end do
    116117 88         continue
    117             if (m.lt.llm) then
     118            if (m.lt.nlayer) then
    118119                sigw=(w(ij,l)-Mtot)/masse(ij,m+1)
    119120                wq(ij,l)=(MQtot + (w(ij,l)-Mtot)*
     
    137138       end do
    138139
    139        do l = 1,llm-1  ! loop different than when w>0
     140       do l = 1,nlayer-1  ! loop different than when w>0
    140141        do ij=1,ngrid
    141142         if(w(ij,l+1).le.0)then
     
    176177 99    continue
    177178
    178       do l=1,llm
     179      do l=1,nlayer
    179180         do ij=1,ngrid
    180181
     
    191192
    192193
    193 
    194       return
    195194      end
  • trunk/LMDZ.GENERIC/libf/phystd/writediagspecIR.F

    r1216 r1308  
    5454! Commons
    5555#include "dimensions.h"
    56 #include "dimphys.h"
     56!#include "dimphys.h"
    5757#include "paramet.h"
    5858!#include "control.h"
  • trunk/LMDZ.GENERIC/libf/phystd/writediagspecVI.F

    r1216 r1308  
    5454! Commons
    5555#include "dimensions.h"
    56 #include "dimphys.h"
     56!#include "dimphys.h"
    5757#include "paramet.h"
    5858!#include "control.h"
  • trunk/LMDZ.GENERIC/libf/phystd/wstats.F90

    r1216 r1308  
    77
    88#include "dimensions.h"
    9 #include "dimphys.h"
     9!#include "dimphys.h"
    1010#include "comconst.h"
    1111#include "statto.h"
     
    293293
    294294include "dimensions.h"
    295 include "dimphys.h"
     295!include "dimphys.h"
    296296include "netcdf.inc"
    297297
Note: See TracChangeset for help on using the changeset viewer.