Index: /LMDZ5/trunk/libf/phylmd/concvl.F90
===================================================================
--- /LMDZ5/trunk/libf/phylmd/concvl.F90	(revision 2852)
+++ /LMDZ5/trunk/libf/phylmd/concvl.F90	(revision 2853)
@@ -13,5 +13,5 @@
 !RomP >>>
 !!     .             da,phi,mp,dd_t,dd_q,lalim_conv,wght_th)
-                  da, phi, mp, phi2, d1a, dam, sij, clw, elij, &     ! RomP
+                  da, phi, mp, phii, d1a, dam, sij, clw, elij, &     ! RomP
                   dd_t, dd_q, lalim_conv, wght_th, &                 ! RomP
                   evap, ep, epmlmMm, eplaMm, &                       ! RomP
@@ -87,84 +87,92 @@
   include "clesphys.h"
 
-  INTEGER iflag_clos
-
-  REAL dtime, paprs(klon, klev+1), pplay(klon, klev)
-  INTEGER k_upper_cv
-  REAL t(klon, klev), q(klon, klev), u(klon, klev), v(klon, klev)
-  REAL t_wake(klon, klev), q_wake(klon, klev)
-  REAL s_wake(klon)
-  REAL tra(klon, klev, nbtr)
-  INTEGER ntra
-  REAL sig1(klon, klev), w01(klon, klev), ptop2(klon)
-  REAL pmflxr(klon, klev+1), pmflxs(klon, klev+1)
-  REAL Ale(klon), Alp(klon)
-
-  REAL d_t(klon, klev), d_q(klon, klev), d_u(klon, klev), d_v(klon, klev)
-  REAL dd_t(klon, klev), dd_q(klon, klev)
-  REAL d_tra(klon, klev, nbtr)
-  REAL rain(klon), snow(klon)
-
-  INTEGER kbas(klon), ktop(klon)
-  REAL em_ph(klon, klev+1), em_p(klon, klev)
-  REAL upwd(klon, klev), dnwd(klon, klev), dnwdbis(klon, klev)
-
-!!       REAL Ma(klon,klev), mip(klon,klev),Vprecip(klon,klev)     !jyg
-  REAL Ma(klon, klev), mip(klon, klev), Vprecip(klon, klev+1)      !jyg
-  REAL Vprecipi(klon, klev+1)                                      !jyg
-  REAL wght(klon, klev)                                            !RL
-
-  REAL da(klon, klev), phi(klon, klev, klev), mp(klon, klev)
+  INTEGER, INTENT(IN)                           :: iflag_clos
+  REAL, INTENT(IN)                              :: dtime
+  REAL, DIMENSION(klon,klev),   INTENT(IN)      :: pplay
+  REAL, DIMENSION(klon,klev+1), INTENT(IN)      :: paprs
+  INTEGER,                      INTENT(IN)      :: k_upper_cv
+  REAL, DIMENSION(klon,klev),   INTENT(IN)      :: t, q, u, v
+  REAL, DIMENSION(klon,klev),   INTENT(IN)      :: t_wake, q_wake
+  REAL, DIMENSION(klon),        INTENT(IN)      :: s_wake
+  REAL, DIMENSION(klon,klev, nbtr),INTENT(IN)   :: tra
+  INTEGER,                      INTENT(IN)      :: ntra
+  REAL, DIMENSION(klon),        INTENT(IN)      :: Ale, Alp
+!CR:test: on passe lentr et alim_star des thermiques
+  INTEGER, DIMENSION(klon),     INTENT(IN)      :: lalim_conv
+  REAL, DIMENSION(klon,klev),   INTENT(IN)      :: wght_th
+
+  REAL, DIMENSION(klon,klev),   INTENT(INOUT)   :: sig1, w01
+
+  REAL, DIMENSION(klon,klev),   INTENT(OUT)     :: d_t, d_q, d_u, d_v
+  REAL, DIMENSION(klon,klev, nbtr),INTENT(OUT)  :: d_tra
+  REAL, DIMENSION(klon),        INTENT(OUT)     :: rain, snow
+
+  INTEGER, DIMENSION(klon),     INTENT(OUT)     :: kbas, ktop
+  REAL, DIMENSION(klon),        INTENT(OUT)     :: sigd
+  REAL, DIMENSION(klon),        INTENT(OUT)     :: cbmf, plcl, plfc, wbeff
+  REAL, DIMENSION(klon),        INTENT(OUT)     :: convoccur
+  REAL, DIMENSION(klon,klev),   INTENT(OUT)     :: upwd, dnwd, dnwdbis
+
+!!       REAL Ma(klon,klev), mip(klon,klev),Vprecip(klon,klev)                    !jyg
+  REAL, DIMENSION(klon,klev),   INTENT(OUT)     :: Ma, mip 
+  REAL, DIMENSION(klon,klev+1), INTENT(OUT)     :: Vprecip                        !jyg
+  REAL, DIMENSION(klon),        INTENT(OUT)     :: cape, cin
+  REAL, DIMENSION(klon,klev),   INTENT(OUT)     :: tvp
+  REAL, DIMENSION(klon,klev),   INTENT(OUT)     :: Tconv
+  INTEGER, DIMENSION(klon),     INTENT(OUT)     :: iflag
+  REAL, DIMENSION(klon),        INTENT(OUT)     :: pbase, bbase
+  REAL, DIMENSION(klon,klev),   INTENT(OUT)     :: dtvpdt1, dtvpdq1
+  REAL, DIMENSION(klon),        INTENT(OUT)     :: dplcldt, dplcldr
+  REAL, DIMENSION(klon,klev),   INTENT(OUT)     :: qcondc
+  REAL, DIMENSION(klon),        INTENT(OUT)     :: wd
+  REAL, DIMENSION(klon,klev+1), INTENT(OUT)     :: pmflxr, pmflxs
+
+  REAL, DIMENSION(klon,klev),   INTENT(OUT)     :: da, mp
+  REAL, DIMENSION(klon,klev,klev),INTENT(OUT)   :: phi
 ! RomP >>>
-  REAL phi2(klon, klev, klev)
-  REAL d1a(klon, klev), dam(klon, klev)
-  REAL sij(klon, klev, klev), clw(klon, klev), elij(klon, klev, klev)
-  REAL wdtrainA(klon, klev), wdtrainM(klon, klev)
-  REAL evap(klon, klev), ep(klon, klev)
-  REAL epmlmMm(klon, klev, klev), eplaMm(klon, klev)
+  REAL, DIMENSION(klon,klev,klev),INTENT(OUT)   :: phii
+  REAL, DIMENSION(klon,klev),   INTENT(OUT)     :: d1a, dam
+  REAL, DIMENSION(klon,klev,klev),INTENT(OUT)   :: sij, elij
+  REAL, DIMENSION(klon,klev),   INTENT(OUT)     :: clw
+  REAL, DIMENSION(klon,klev),   INTENT(OUT)     :: dd_t, dd_q
+  REAL, DIMENSION(klon,klev),   INTENT(OUT)     :: evap, ep
+  REAL, DIMENSION(klon,klev),   INTENT(OUT)     :: eplaMm
+  REAL, DIMENSION(klon,klev,klev), INTENT(OUT)  :: epmlmMm
+  REAL, DIMENSION(klon,klev),   INTENT(OUT)     :: wdtrainA, wdtrainM
 ! RomP <<<
-  REAL cape(klon), cin(klon), tvp(klon, klev)
-  REAL Tconv(klon, klev)
-
-!CR:test: on passe lentr et alim_star des thermiques
-  INTEGER lalim_conv(klon)
-  REAL wght_th(klon, klev)
-  REAL em_sig1feed ! sigma at lower bound of feeding layer
-  REAL em_sig2feed ! sigma at upper bound of feeding layer
-  REAL em_wght(klev) ! weight density determining the feeding mixture
+  REAL, DIMENSION(klon,klev),   INTENT(OUT)     :: wght                       !RL
+  REAL, DIMENSION(klon,klev),   INTENT(OUT)     :: qtc
+  REAL, DIMENSION(klon,klev),   INTENT(OUT)     :: sigt
+  REAL,                         INTENT(OUT)     :: tau_cld_cv, coefw_cld_cv
+  REAL, DIMENSION(klon),        INTENT(OUT)     :: epmax_diag                ! epmax_cape
+
+!
+!  Local
+!  ----
+  REAL, DIMENSION(klon,klev)                    :: em_p
+  REAL, DIMENSION(klon,klev+1)                  :: em_ph
+  REAL                                          :: em_sig1feed ! sigma at lower bound of feeding layer
+  REAL                                          :: em_sig2feed ! sigma at upper bound of feeding layer
+  REAL, DIMENSION(klev)                         :: em_wght ! weight density determining the feeding mixture
+  REAL, DIMENSION(klon,klev+1)                  :: Vprecipi                       !jyg
 !on enleve le save
 ! SAVE em_sig1feed,em_sig2feed,em_wght
 
-  INTEGER iflag(klon)
-  REAL rflag(klon)
-  REAL pbase(klon), bbase(klon)
-  REAL dtvpdt1(klon, klev), dtvpdq1(klon, klev)
-  REAL dplcldt(klon), dplcldr(klon)
-  REAL qcondc(klon, klev)
-  REAL qtc(klon, klev)
-  REAL sigt(klon, klev)
-  REAL wd(klon)
-  REAL plim1(klon), plim2(klon), asupmax(klon, klev)
-  REAL supmax0(klon), asupmaxmin(klon)
-
-  REAL sigd(klon)
-  REAL zx_t, zdelta, zx_qs, zcor
-  REAL tau_cld_cv, coefw_cld_cv
-  REAL epmax_diag(klon) ! epmax_cape
-
+  REAL, DIMENSION(klon)                         :: rflag
+  REAL, DIMENSION(klon)                         :: plim1, plim2
+  REAL, DIMENSION(klon)                         :: ptop2
+  REAL, DIMENSION(klon,klev)                    :: asupmax
+  REAL, DIMENSION(klon)                         :: supmax0, asupmaxmin
+  REAL                                          :: zx_t, zdelta, zx_qs, zcor
+!
 !   INTEGER iflag_mix
 !   SAVE iflag_mix
-  INTEGER noff, minorig
-  INTEGER i, k, itra
-  REAL qs(klon, klev), qs_wake(klon, klev)
-  REAL cbmf(klon), plcl(klon), plfc(klon), wbeff(klon)
-  REAL convoccur(klon)
+  INTEGER                                       :: noff, minorig
+  INTEGER                                       :: i,j, k, itra
+  REAL, DIMENSION(klon,klev)                    :: qs, qs_wake
 !LF          SAVE cbmf
 !IM/JYG      REAL, SAVE, ALLOCATABLE :: cbmf(:)
 !!!$OMP THREADPRIVATE(cbmf)!
-  REAL cbmflast(klon)
-  INTEGER ifrst
-  SAVE ifrst
-  DATA ifrst/0/
-!$OMP THREADPRIVATE(ifrst)
+  REAL, DIMENSION(klon)                         :: cbmflast
 
 
@@ -259,6 +267,4 @@
   snow(:) = 0
 
-! IF (ifrst .EQ. 0) THEN
-! ifrst = 1
   IF (first) THEN
     first = .FALSE.
@@ -293,5 +299,5 @@
       sigd(i) = 0.
     END DO
-  END IF !(ifrst .EQ. 0)
+  END IF !(first)
 
 ! Initialisation a chaque pas de temps
@@ -393,5 +399,5 @@
                    kbas, ktop, &
                    dtime, Ma, upwd, dnwd, dnwdbis, qcondc, wd, cape, &
-                   da, phi, mp, phi2, d1a, dam, sij, clw, elij, &       !RomP
+                   da, phi, mp, phii, d1a, dam, sij, clw, elij, &       !RomP
                    evap, ep, epmlmMm, eplaMm, &                         !RomP
                    wdtrainA, wdtrainM, &                                !RomP
@@ -428,7 +434,7 @@
                     asupmaxmin, lalim_conv, &
 !AC!+!RomP+jyg
-!!                   da,phi,mp,phi2,d1a,dam,sij,clw,elij, &               ! RomP
+!!                   da,phi,mp,phii,d1a,dam,sij,clw,elij, &               ! RomP
 !!                   evap,ep,epmlmMm,eplaMm,                              ! RomP
-                    da, phi, mp, phi2, d1a, dam, sij, wght, &           ! RomP+RL
+                    da, phi, mp, phii, d1a, dam, sij, wght, &           ! RomP+RL
                     clw, elij, evap, ep, epmlmMm, eplaMm, &             ! RomP+RL
                     wdtrainA, wdtrainM, qtc, sigt, &
Index: /LMDZ5/trunk/libf/phylmd/cva_driver.F90
===================================================================
--- /LMDZ5/trunk/libf/phylmd/cva_driver.F90	(revision 2852)
+++ /LMDZ5/trunk/libf/phylmd/cva_driver.F90	(revision 2853)
@@ -39,5 +39,4 @@
 ! **************************************************************
 
-  USE dimphy
   USE print_control_mod, ONLY: prt_level, lunout
   IMPLICIT NONE
@@ -168,5 +167,5 @@
   INTEGER, INTENT (IN)                               :: ndp1
   INTEGER, INTENT (IN)                               :: ntra
-  INTEGER, INTENT(IN)                                :: nloc ! (nloc=klon)  pour l'instant
+  INTEGER, INTENT(IN)                                :: nloc ! (nloc=len)  pour l'instant
   INTEGER, INTENT (IN)                               :: k_upper
   INTEGER, INTENT (IN)                               :: iflag_con
@@ -219,17 +218,17 @@
   REAL, DIMENSION (len), INTENT (OUT)                :: ptop21
   REAL, DIMENSION (len), INTENT (OUT)                :: sigd1
-  REAL, DIMENSION (len, nd), INTENT (OUT)            :: ma1
-  REAL, DIMENSION (len, nd), INTENT (OUT)            :: mip1
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: ma1        ! adiab. asc. mass flux (staggered grid)
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: mip1       ! mass flux shed from adiab. ascent (extensive)
 ! real Vprecip1(len,nd)
-  REAL, DIMENSION (len, ndp1), INTENT (OUT)          :: vprecip1
-  REAL, DIMENSION (len, ndp1), INTENT (OUT)          :: vprecipi1
-  REAL, DIMENSION (len, nd), INTENT (OUT)            :: upwd1
-  REAL, DIMENSION (len, nd), INTENT (OUT)            :: dnwd1
-  REAL, DIMENSION (len, nd), INTENT (OUT)            :: dnwd01
-  REAL, DIMENSION (len, nd), INTENT (OUT)            :: qcondc1         ! cld
+  REAL, DIMENSION (len, ndp1), INTENT (OUT)          :: vprecip1   ! tot precipitation flux (staggered grid)
+  REAL, DIMENSION (len, ndp1), INTENT (OUT)          :: vprecipi1  ! ice precipitation flux (staggered grid)
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: upwd1      ! upwd sat. mass flux (staggered grid)
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: dnwd1      ! dnwd sat. mass flux (staggered grid)
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: dnwd01     ! unsat. mass flux (staggered grid)
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: qcondc1    ! max cloud condensate (intensive)  ! cld
   REAL, DIMENSION (len), INTENT (OUT)                :: wd1             ! gust
   REAL, DIMENSION (len), INTENT (OUT)                :: cape1
   REAL, DIMENSION (len), INTENT (OUT)                :: cin1
-  REAL, DIMENSION (len, nd), INTENT (OUT)            :: tvp1
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: tvp1       ! Virt. temp. in the adiab. ascent
 
 !AC!
@@ -237,28 +236,32 @@
 !!      real da(len,nd),phi(len,nd,nd)
 !AC!
-  REAL, DIMENSION (len, nd), INTENT (OUT)            :: ftd1
-  REAL, DIMENSION (len, nd), INTENT (OUT)            :: fqd1
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: ftd1       ! Temp. tendency due to the sole unsat. drafts
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: fqd1       ! Moist. tendency due to the sole unsat. drafts
   REAL, DIMENSION (len), INTENT (OUT)                :: Plim11
   REAL, DIMENSION (len), INTENT (OUT)                :: Plim21
-  REAL, DIMENSION (len, nd), INTENT (OUT)            :: asupmax1
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: asupmax1   ! Highest mixing fraction of mixed updraughts
   REAL, DIMENSION (len), INTENT (OUT)                :: supmax01
   REAL, DIMENSION (len), INTENT (OUT)                :: asupmaxmin1
-  REAL, DIMENSION (len, nd), INTENT (OUT)            :: qtc1            ! cld
-  REAL, DIMENSION (len, nd), INTENT (OUT)            :: sigt1           ! cld
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: qtc1    ! in cloud water content (intensive)   ! cld
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: sigt1   ! fract. cloud area (intensive)        ! cld
 
 ! RomP >>>
-  REAL, DIMENSION (len, nd), INTENT (OUT)            :: wdtrainA1, wdtrainM1
-  REAL, DIMENSION (len, nd), INTENT (OUT)            :: da1, mp1
-  REAL, DIMENSION (len, nd, nd), INTENT (OUT)        :: phi1
-  REAL, DIMENSION (len, nd, nd), INTENT (OUT)        :: epmlmMm1
-  REAL, DIMENSION (len, nd), INTENT (OUT)            :: eplaMm1
-  REAL, DIMENSION (len, nd), INTENT (OUT)            :: evap1, ep1
-  REAL, DIMENSION (len, nd, nd), INTENT (OUT)        :: sigij1, elij1
-  REAL, DIMENSION (len, nd), INTENT (OUT)            :: clw1
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: wdtrainA1, wdtrainM1 ! precipitation sources (extensive)
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: mp1  ! unsat. mass flux (staggered grid)
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: da1  ! detrained mass flux of adiab. asc. air (extensive)
+  REAL, DIMENSION (len, nd, nd), INTENT (OUT)        :: phi1 ! mass flux of envt. air in mixed draughts (extensive)
+  REAL, DIMENSION (len, nd, nd), INTENT (OUT)        :: epmlmMm1  ! (extensive)
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: eplaMm1   ! (extensive)
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: evap1 ! evaporation rate in precip. downdraft. (intensive)
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: ep1
+  REAL, DIMENSION (len, nd, nd), INTENT (OUT)        :: sigij1 ! mass fraction of env. air in mixed draughts (intensive) 
+  REAL, DIMENSION (len, nd, nd), INTENT (OUT)        :: elij1! cond. water per unit mass of mixed draughts (intensive) 
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: clw1 ! cond. water per unit mass of the adiab. asc. (intensive) 
 !JYG,RL
-  REAL, DIMENSION (len, nd), INTENT (OUT)            :: wghti1      ! final weight of the feeding layers
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: wghti1   ! final weight of the feeding layers (extensive)
 !JYG,RL
-  REAL, DIMENSION (len, nd, nd), INTENT (OUT)        :: phi21
-  REAL, DIMENSION (len, nd), INTENT (OUT)            :: d1a1, dam1
+  REAL, DIMENSION (len, nd, nd), INTENT (OUT)        :: phi21    ! (extensive)
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: d1a1     ! (extensive)
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: dam1     ! (extensive)
 ! RomP <<<
   REAL, DIMENSION (len ), INTENT (OUT)               :: epmax_diag1      
@@ -395,10 +398,10 @@
 
 
-  INTEGER i, k, n, il, j
+  INTEGER i, k, il
   INTEGER nword1, nword2, nword3, nword4
   INTEGER icbmax
-  INTEGER nk1(klon)
-  INTEGER icb1(klon)
-  INTEGER icbs1(klon)
+  INTEGER nk1(len)
+  INTEGER icb1(len)
+  INTEGER icbs1(len)
 
   LOGICAL ok_inhib ! True => possible inhibition of convection by dryness
@@ -407,33 +410,30 @@
 
   REAL coef_convective(len)   ! = 1 for convective points, = 0 otherwise
-  REAL tnk1(klon)
-  REAL thnk1(klon)
-  REAL qnk1(klon)
-  REAL gznk1(klon)
-  REAL pnk1(klon)
-  REAL qsnk1(klon)
-  REAL unk1(klon)
-  REAL vnk1(klon)
-  REAL cpnk1(klon)
-  REAL hnk1(klon)
-  REAL pbase1(klon)
-  REAL buoybase1(klon)
-
-  REAL lf1(klon, klev), lf1_wake(klon, klev)
-  REAL lv1(klon, klev), lv1_wake(klon, klev)
-  REAL cpn1(klon, klev), cpn1_wake(klon, klev)
-  REAL tv1(klon, klev), tv1_wake(klon, klev)
-  REAL gz1(klon, klev), gz1_wake(klon, klev)
-  REAL hm1(klon, klev), hm1_wake(klon, klev)
-  REAL h1(klon, klev), h1_wake(klon, klev)
-  REAL tp1(klon, klev)
-  REAL th1(klon, klev), th1_wake(klon, klev)
-
-  REAL bid(klon, klev) ! dummy array
+  REAL tnk1(len)
+  REAL thnk1(len)
+  REAL qnk1(len)
+  REAL gznk1(len)
+  REAL qsnk1(len)
+  REAL unk1(len)
+  REAL vnk1(len)
+  REAL cpnk1(len)
+  REAL hnk1(len)
+  REAL pbase1(len)
+  REAL buoybase1(len)
+
+  REAL lf1(len, nd), lf1_wake(len, nd)
+  REAL lv1(len, nd), lv1_wake(len, nd)
+  REAL cpn1(len, nd), cpn1_wake(len, nd)
+  REAL tv1(len, nd), tv1_wake(len, nd)
+  REAL gz1(len, nd), gz1_wake(len, nd)
+  REAL hm1(len, nd)
+  REAL h1(len, nd), h1_wake(len, nd)
+  REAL tp1(len, nd)
+  REAL th1(len, nd), th1_wake(len, nd)
+
+  REAL bid(len, nd) ! dummy array
 
   INTEGER ncum
 
-  INTEGER j1feed(klon)
-  INTEGER j2feed(klon)
   REAL p1feed1(len) ! pressure at lower bound of feeding layer
   REAL p2feed1(len) ! pressure at upper bound of feeding layer
@@ -450,66 +450,65 @@
 !>jyg
   INTEGER iflag(nloc), nk(nloc), icb(nloc)
-  INTEGER nent(nloc, klev)
+  INTEGER nent(nloc, nd)
   INTEGER icbs(nloc)
   INTEGER inb(nloc), inbis(nloc)
 
   REAL cbmf(nloc), plcl(nloc), plfc(nloc), wbeff(nloc)
-  REAL t(nloc, klev), q(nloc, klev), qs(nloc, klev)
-  REAL t_wake(nloc, klev), q_wake(nloc, klev), qs_wake(nloc, klev)
+  REAL t(nloc, nd), q(nloc, nd), qs(nloc, nd)
+  REAL t_wake(nloc, nd), q_wake(nloc, nd), qs_wake(nloc, nd)
   REAL s_wake(nloc)
-  REAL u(nloc, klev), v(nloc, klev)
-  REAL gz(nloc, klev), h(nloc, klev), hm(nloc, klev)
-  REAL h_wake(nloc, klev), hm_wake(nloc, klev)
-  REAL lv(nloc, klev), lf(nloc, klev), cpn(nloc, klev)
-  REAL lv_wake(nloc, klev), lf_wake(nloc, klev), cpn_wake(nloc, klev)
-  REAL p(nloc, klev), ph(nloc, klev+1), tv(nloc, klev), tp(nloc, klev)
-  REAL tv_wake(nloc, klev)
-  REAL clw(nloc, klev)
-  REAL dph(nloc, klev)
-  REAL pbase(nloc), buoybase(nloc), th(nloc, klev)
-  REAL th_wake(nloc, klev)
-  REAL tvp(nloc, klev)
-  REAL sig(nloc, klev), w0(nloc, klev), ptop2(nloc)
-  REAL hp(nloc, klev), ep(nloc, klev), sigp(nloc, klev)
-  REAL buoy(nloc, klev)
+  REAL u(nloc, nd), v(nloc, nd)
+  REAL gz(nloc, nd), h(nloc, nd)
+  REAL h_wake(nloc, nd)
+  REAL lv(nloc, nd), lf(nloc, nd), cpn(nloc, nd)
+  REAL lv_wake(nloc, nd), lf_wake(nloc, nd), cpn_wake(nloc, nd)
+  REAL p(nloc, nd), ph(nloc, nd+1), tv(nloc, nd), tp(nloc, nd)
+  REAL tv_wake(nloc, nd)
+  REAL clw(nloc, nd)
+  REAL dph(nloc, nd)
+  REAL pbase(nloc), buoybase(nloc), th(nloc, nd)
+  REAL th_wake(nloc, nd)
+  REAL tvp(nloc, nd)
+  REAL sig(nloc, nd), w0(nloc, nd), ptop2(nloc)
+  REAL hp(nloc, nd), ep(nloc, nd), sigp(nloc, nd)
+  REAL buoy(nloc, nd)
   REAL cape(nloc)
   REAL cin(nloc)
-  REAL m(nloc, klev)
-  REAL ment(nloc, klev, klev), sigij(nloc, klev, klev)
-  REAL qent(nloc, klev, klev)
-  REAL hent(nloc, klev, klev)
-  REAL uent(nloc, klev, klev), vent(nloc, klev, klev)
-  REAL ments(nloc, klev, klev), qents(nloc, klev, klev)
-  REAL elij(nloc, klev, klev)
-  REAL supmax(nloc, klev)
+  REAL m(nloc, nd)
+  REAL ment(nloc, nd, nd), sigij(nloc, nd, nd)
+  REAL qent(nloc, nd, nd)
+  REAL hent(nloc, nd, nd)
+  REAL uent(nloc, nd, nd), vent(nloc, nd, nd)
+  REAL ments(nloc, nd, nd), qents(nloc, nd, nd)
+  REAL elij(nloc, nd, nd)
+  REAL supmax(nloc, nd)
   REAL Ale(nloc), Alp(nloc), coef_clos(nloc)
-  REAL omega(nloc,klev)
+  REAL omega(nloc,nd)
   REAL sigd(nloc)
-! real mp(nloc,klev), qp(nloc,klev), up(nloc,klev), vp(nloc,klev)
-! real wt(nloc,klev), water(nloc,klev), evap(nloc,klev), ice(nloc,klev)
-! real b(nloc,klev), sigd(nloc)
+! real mp(nloc,nd), qp(nloc,nd), up(nloc,nd), vp(nloc,nd)
+! real wt(nloc,nd), water(nloc,nd), evap(nloc,nd), ice(nloc,nd)
+! real b(nloc,nd), sigd(nloc)
 ! save mp,qp,up,vp,wt,water,evap,b
-  REAL, SAVE, ALLOCATABLE :: mp(:, :), qp(:, :), up(:, :), vp(:, :)
-  REAL, SAVE, ALLOCATABLE :: wt(:, :), water(:, :), evap(:, :)
-  REAL, SAVE, ALLOCATABLE :: ice(:, :), fondue(:, :), b(:, :)
-  REAL, SAVE, ALLOCATABLE :: frac(:, :), faci(:, :)
-!$OMP THREADPRIVATE(mp,qp,up,vp,wt,water,evap,ice,fondue,b,frac,faci)
-  REAL ft(nloc, klev), fq(nloc, klev)
-  REAL ftd(nloc, klev), fqd(nloc, klev)
-  REAL fu(nloc, klev), fv(nloc, klev)
-  REAL upwd(nloc, klev), dnwd(nloc, klev), dnwd0(nloc, klev)
-  REAL ma(nloc, klev), mip(nloc, klev)
-!!  REAL tls(nloc, klev), tps(nloc, klev)                 ! unused . jyg
+  REAL, DIMENSION(len,nd)     :: mp, qp, up, vp
+  REAL, DIMENSION(len,nd)     :: wt, water, evap
+  REAL, DIMENSION(len,nd)     :: ice, fondue, b
+  REAL, DIMENSION(len,nd)     :: frac, faci
+  REAL ft(nloc, nd), fq(nloc, nd)
+  REAL ftd(nloc, nd), fqd(nloc, nd)
+  REAL fu(nloc, nd), fv(nloc, nd)
+  REAL upwd(nloc, nd), dnwd(nloc, nd), dnwd0(nloc, nd)
+  REAL ma(nloc, nd), mip(nloc, nd)
+!!  REAL tls(nloc, nd), tps(nloc, nd)                 ! unused . jyg
   REAL qprime(nloc), tprime(nloc)
   REAL precip(nloc)
-! real Vprecip(nloc,klev)
-  REAL vprecip(nloc, klev+1)
-  REAL vprecipi(nloc, klev+1)
-  REAL tra(nloc, klev, ntra), trap(nloc, klev, ntra)
-  REAL ftra(nloc, klev, ntra), traent(nloc, klev, klev, ntra)
-  REAL qcondc(nloc, klev)      ! cld
+! real Vprecip(nloc,nd)
+  REAL vprecip(nloc, nd+1)
+  REAL vprecipi(nloc, nd+1)
+  REAL tra(nloc, nd, ntra), trap(nloc, nd, ntra)
+  REAL ftra(nloc, nd, ntra), traent(nloc, nd, nd, ntra)
+  REAL qcondc(nloc, nd)      ! cld
   REAL wd(nloc)                ! gust
   REAL Plim1(nloc), plim2(nloc)
-  REAL asupmax(nloc, klev)
+  REAL asupmax(nloc, nd)
   REAL supmax0(nloc)
   REAL asupmaxmin(nloc)
@@ -519,11 +518,11 @@
   REAL hnk(nloc), unk(nloc), vnk(nloc)
 
-  REAL qtc(nloc, klev)         ! cld
-  REAL sigt(nloc, klev)        ! cld
+  REAL qtc(nloc, nd)         ! cld
+  REAL sigt(nloc, nd)        ! cld
  
 ! RomP >>>
-  REAL wdtrainA(nloc, klev), wdtrainM(nloc, klev)
+  REAL wdtrainA(nloc, nd), wdtrainM(nloc, nd)
   REAL da(len, nd), phi(len, nd, nd)
-  REAL epmlmMm(nloc, klev, klev), eplaMm(nloc, klev)
+  REAL epmlmMm(nloc, nd, nd), eplaMm(nloc, nd)
   REAL phi2(len, nd, nd)
   REAL d1a(len, nd), dam(len, nd)
@@ -531,6 +530,4 @@
   REAL epmax_diag(nloc) ! epmax_cape
 
-  LOGICAL, SAVE :: first = .TRUE.
-!$OMP THREADPRIVATE(first)
   CHARACTER (LEN=20) :: modname = 'cva_driver'
   CHARACTER (LEN=80) :: abort_message
@@ -540,6 +537,6 @@
 
 
-! print *, 't1, t1_wake ',(k,t1(1,k),t1_wake(1,k),k=1,klev)
-! print *, 'q1, q1_wake ',(k,q1(1,k),q1_wake(1,k),k=1,klev)
+! print *, 't1, t1_wake ',(k,t1(1,k),t1_wake(1,k),k=1,nd)
+! print *, 'q1, q1_wake ',(k,q1(1,k),q1_wake(1,k),k=1,nd)
 
 ! -------------------------------------------------------------------
@@ -547,12 +544,4 @@
 ! -------------------------------------------------------------------
 
-  IF (first) THEN
-    ALLOCATE (mp(nloc,klev), qp(nloc,klev), up(nloc,klev))
-    ALLOCATE (vp(nloc,klev), wt(nloc,klev), water(nloc,klev))
-    ALLOCATE (ice(nloc,klev), fondue(nloc,klev))
-    ALLOCATE (evap(nloc,klev), b(nloc,klev))
-    ALLOCATE (frac(nloc,klev), faci(nloc,klev))
-    first = .FALSE.
-  END IF
 ! -- set simulation flags:
 ! (common cvflag)
@@ -736,5 +725,5 @@
 ! print*, 'IFLAG1 avant cv3_feed'
 ! print*,'len,nd',len,nd
-! write(*,'(64i1)') iflag1(2:klon-1)
+! write(*,'(64i1)') iflag1(2:len-1)
 
         if (prt_level >= 9) &
@@ -749,5 +738,5 @@
 ! print*, 'IFLAG1 apres cv3_feed'
 ! print*,'len,nd',len,nd
-! write(*,'(64i1)') iflag1(2:klon-1)
+! write(*,'(64i1)') iflag1(2:len-1)
 
   IF (iflag_con==4) THEN
@@ -799,5 +788,5 @@
 ! print*, 'IFLAG1 apres cv3_triger'
 ! print*,'len,nd',len,nd
-! write(*,'(64i1)') iflag1(2:klon-1)
+! write(*,'(64i1)') iflag1(2:len-1)
 
 ! call dump2d(iim,jjm-1,sig1(2)
@@ -828,5 +817,5 @@
   END DO
 
-! print*,'klon, ncum = ',len,ncum
+! print*,'len, ncum = ',len,ncum
 
   IF (ncum>0) THEN
@@ -944,5 +933,5 @@
 !      END IF
       IF (iflag_mix>=1) THEN
-        CALL zilch(supmax, nloc*klev)
+        CALL zilch(supmax, nloc*nd)
         if (prt_level >= 9) &
              PRINT *, 'cva_driver -> cv3p_mixing'
@@ -955,5 +944,5 @@
 
       ELSE
-        CALL zilch(supmax, nloc*klev)
+        CALL zilch(supmax, nloc*nd)
       END IF
     END IF
@@ -1031,5 +1020,5 @@
                         unk, vnk, hp, tv, tvp, ep, clw, m, sig, &
                         ment, qent, uent, vent, nent, sigij, elij, ments, qents, traent)
-        CALL zilch(hent, nloc*klev*klev)
+        CALL zilch(hent, nloc*nd*nd)
       ELSE
         CALL cv3_mixscale(nloc, ncum, nd, ment, m)
