Index: branches/LMDZ_WRFmeas/WRFV3/lmdz/thermcell_main.F90
===================================================================
--- branches/LMDZ_WRFmeas/WRFV3/lmdz/thermcell_main.F90	(revision 89)
+++ branches/LMDZ_WRFmeas/WRFV3/lmdz/thermcell_main.F90	(revision 90)
@@ -105,101 +105,101 @@
 
       INTEGER ig,k,l,ll,ierr
-      real zsortie1d(klon)
-      INTEGER lmax(klon),lmin(klon),lalim(klon)
-      INTEGER lmix(klon)
-      INTEGER lmix_bis(klon)
-      real linter(klon)
-      real zmix(klon)
-      real zmax(klon),zw2(klon,klev+1),ztva(klon,klev),zw_est(klon,klev+1),ztva_est(klon,klev)
-!      real fraca(klon,klev)
-
-      real zmax_sec(klon)
+      real zsortie1d(ngrid)
+      INTEGER lmax(ngrid),lmin(ngrid),lalim(ngrid)
+      INTEGER lmix(ngrid)
+      INTEGER lmix_bis(ngrid)
+      real linter(ngrid)
+      real zmix(ngrid)
+      real zmax(ngrid),zw2(ngrid,nlay+1),ztva(ngrid,nlay),zw_est(ngrid,nlay+1),ztva_est(ngrid,nlay)
+!      real fraca(ngrid,nlay)
+
+      real zmax_sec(ngrid)
 !on garde le zmax du pas de temps precedent
-      real zmax0(klon)
+      real zmax0(ngrid)
 !FH/IM     save zmax0
 
       real lambda
 
-      real zlev(klon,klev+1),zlay(klon,klev)
-      real deltaz(klon,klev)
-      REAL zh(klon,klev)
-      real zthl(klon,klev),zdthladj(klon,klev)
-      REAL ztv(klon,klev)
-      real zu(klon,klev),zv(klon,klev),zo(klon,klev)
-      real zl(klon,klev)
-      real zsortie(klon,klev)
-      real zva(klon,klev)
-      real zua(klon,klev)
-      real zoa(klon,klev)
-
-      real zta(klon,klev)
-      real zha(klon,klev)
-      real fraca(klon,klev+1)
+      real zlev(ngrid,nlay+1),zlay(ngrid,nlay)
+      real deltaz(ngrid,nlay)
+      REAL zh(ngrid,nlay)
+      real zthl(ngrid,nlay),zdthladj(ngrid,nlay)
+      REAL ztv(ngrid,nlay)
+      real zu(ngrid,nlay),zv(ngrid,nlay),zo(ngrid,nlay)
+      real zl(ngrid,nlay)
+      real zsortie(ngrid,nlay)
+      real zva(ngrid,nlay)
+      real zua(ngrid,nlay)
+      real zoa(ngrid,nlay)
+
+      real zta(ngrid,nlay)
+      real zha(ngrid,nlay)
+      real fraca(ngrid,nlay+1)
       real zf,zf2
-      real thetath2(klon,klev),wth2(klon,klev),wth3(klon,klev)
-      real q2(klon,klev)
+      real thetath2(ngrid,nlay),wth2(ngrid,nlay),wth3(ngrid,nlay)
+      real q2(ngrid,nlay)
 ! FH probleme de dimensionnement avec l'allocation dynamique
 !     common/comtherm/thetath2,wth2
-      real wq(klon,klev)
-      real wthl(klon,klev)
-      real wthv(klon,klev)
+      real wq(ngrid,nlay)
+      real wthl(ngrid,nlay)
+      real wthv(ngrid,nlay)
     
-      real ratqscth(klon,klev)
+      real ratqscth(ngrid,nlay)
       real var
       real vardiff
-      real ratqsdiff(klon,klev)
+      real ratqsdiff(ngrid,nlay)
 
       logical sorties
-      real rho(klon,klev),rhobarz(klon,klev),masse(klon,klev)
-      real zpspsk(klon,klev)
-
-      real wmax(klon)
-      real wmax_tmp(klon)
-      real wmax_sec(klon)
-      real fm0(klon,klev+1),entr0(klon,klev),detr0(klon,klev)
-      real fm(klon,klev+1),entr(klon,klev),detr(klon,klev)
-
-      real ztla(klon,klev),zqla(klon,klev),zqta(klon,klev)
+      real rho(ngrid,nlay),rhobarz(ngrid,nlay),masse(ngrid,nlay)
+      real zpspsk(ngrid,nlay)
+
+      real wmax(ngrid)
+      real wmax_tmp(ngrid)
+      real wmax_sec(ngrid)
+      real fm0(ngrid,nlay+1),entr0(ngrid,nlay),detr0(ngrid,nlay)
+      real fm(ngrid,nlay+1),entr(ngrid,nlay),detr(ngrid,nlay)
+
+      real ztla(ngrid,nlay),zqla(ngrid,nlay),zqta(ngrid,nlay)
 !niveau de condensation
-      integer nivcon(klon)
-      real zcon(klon)
+      integer nivcon(ngrid)
+      real zcon(ngrid)
       REAL CHI
-      real zcon2(klon)
-      real pcon(klon)
-      real zqsat(klon,klev)
-      real zqsatth(klon,klev) 
-
-      real f_star(klon,klev+1),entr_star(klon,klev)
-      real detr_star(klon,klev)
-      real alim_star_tot(klon)
-      real alim_star(klon,klev)
-      real alim_star_clos(klon,klev)
-      real f(klon), f0(klon)
+      real zcon2(ngrid)
+      real pcon(ngrid)
+      real zqsat(ngrid,nlay)
+      real zqsatth(ngrid,nlay) 
+
+      real f_star(ngrid,nlay+1),entr_star(ngrid,nlay)
+      real detr_star(ngrid,nlay)
+      real alim_star_tot(ngrid)
+      real alim_star(ngrid,nlay)
+      real alim_star_clos(ngrid,nlay)
+      real f(ngrid), f0(ngrid)
 !FH/IM     save f0
-      real zlevinter(klon)
+      real zlevinter(ngrid)
       logical debut
        real seuil
-      real csc(klon,klev)
+      real csc(ngrid,nlay)
 
 !!! nrlmd le 10/04/2012
 
 !------Entrées
-      real pbl_tke(klon,klev+1,nbsrf)
-      real pctsrf(klon,nbsrf)
-      real omega(klon,klev)
-      real airephy(klon)
+      real pbl_tke(ngrid,nlay+1,nbsrf)
+      real pctsrf(ngrid,nbsrf)
+      real omega(ngrid,nlay)
+      real airephy(ngrid)
 !------Sorties
-      real zlcl(klon),fraca0(klon),w0(klon),w_conv(klon)
-      real therm_tke_max0(klon),env_tke_max0(klon)
-      real n2(klon),s2(klon)
-      real ale_bl_stat(klon)
-      real therm_tke_max(klon,klev),env_tke_max(klon,klev)
-      real alp_bl_det(klon),alp_bl_fluct_m(klon),alp_bl_fluct_tke(klon),alp_bl_conv(klon),alp_bl_stat(klon)
+      real zlcl(ngrid),fraca0(ngrid),w0(ngrid),w_conv(ngrid)
+      real therm_tke_max0(ngrid),env_tke_max0(ngrid)
+      real n2(ngrid),s2(ngrid)
+      real ale_bl_stat(ngrid)
+      real therm_tke_max(ngrid,nlay),env_tke_max(ngrid,nlay)
+      real alp_bl_det(ngrid),alp_bl_fluct_m(ngrid),alp_bl_fluct_tke(ngrid),alp_bl_conv(ngrid),alp_bl_stat(ngrid)
 !------Local
       integer nsrf
-      real rhobarz0(klon)                    ! Densité au LCL
-      logical ok_lcl(klon)                   ! Existence du LCL des thermiques
-      integer klcl(klon)                     ! Niveau du LCL
-      real interp(klon)                      ! Coef d'interpolation pour le LCL
+      real rhobarz0(ngrid)                    ! Densité au LCL
+      logical ok_lcl(ngrid)                   ! Existence du LCL des thermiques
+      integer klcl(ngrid)                     ! Niveau du LCL
+      real interp(ngrid)                      ! Coef d'interpolation pour le LCL
 !--Triggering
       real Su                                ! Surface unité: celle d'un updraft élémentaire
@@ -215,11 +215,11 @@
       real zmax_moy_coef
       parameter(zmax_moy_coef=0.33)
-      real depth(klon)                       ! Epaisseur moyenne du cumulus
-      real w_max(klon)                       ! Vitesse max statistique 
-      real s_max(klon)
+      real depth(ngrid)                       ! Epaisseur moyenne du cumulus
+      real w_max(ngrid)                       ! Vitesse max statistique 
+      real s_max(ngrid)
 !--Closure
-      real pbl_tke_max(klon,klev)            ! Profil de TKE moyenne 
-      real pbl_tke_max0(klon)                ! TKE moyenne au LCL
-      real w_ls(klon,klev)                   ! Vitesse verticale grande échelle (m/s)
+      real pbl_tke_max(ngrid,nlay)            ! Profil de TKE moyenne 
+      real pbl_tke_max0(ngrid)                ! TKE moyenne au LCL
+      real w_ls(ngrid,nlay)                   ! Vitesse verticale grande échelle (m/s)
       real coef_m                            ! On considère un rendement pour alp_bl_fluct_m
       parameter(coef_m=1.)
@@ -231,12 +231,12 @@
 !
       !nouvelles variables pour la convection
-      real Ale_bl(klon)
-      real Alp_bl(klon)
-      real alp_int(klon),dp_int(klon),zdp
-      real ale_int(klon)
-      integer n_int(klon)
-      real fm_tot(klon)
-      real wght_th(klon,klev)
-      integer lalim_conv(klon)
+      real Ale_bl(ngrid)
+      real Alp_bl(ngrid)
+      real alp_int(ngrid),dp_int(ngrid),zdp
+      real ale_int(ngrid)
+      integer n_int(ngrid)
+      real fm_tot(ngrid)
+      real wght_th(ngrid,nlay)
+      integer lalim_conv(ngrid)
 !v1d     logical therm
 !v1d     save therm
@@ -319,13 +319,13 @@
 
        sorties=.true.
-      IF(ngrid.NE.klon) THEN
+      IF(ngrid.NE.ngrid) THEN
          PRINT*
          PRINT*,'STOP dans convadj'
          PRINT*,'ngrid    =',ngrid
-         PRINT*,'klon  =',klon
+         PRINT*,'ngrid  =',ngrid
       ENDIF
 !
 !     write(lunout,*)'WARNING thermcell_main f0=max(f0,1.e-2)'
-     do ig=1,klon
+     do ig=1,ngrid
          f0(ig)=max(f0(ig),1.e-2)
          zmax0(ig)=max(zmax0(ig),40.)
@@ -344,7 +344,7 @@
       lfname='before thermcell_env'
       lvarname = 'pt'
-      CALL check_var3D(lfname, lvarname, pt, klon, klev, largest, .FALSE.)
+      CALL check_var3D(lfname, lvarname, pt, ngrid, nlay, largest, .FALSE.)
       lvarname = 'pdtadj'
-      CALL check_var3D(lfname, lvarname, pdtadj, klon, klev, largest, .FALSE.)
+      CALL check_var3D(lfname, lvarname, pdtadj, ngrid, nlay, largest, .FALSE.)
 
       CALL thermcell_env(ngrid,nlay,po,pt,pu,pv,pplay,  &
@@ -353,7 +353,7 @@
       lfname='after thermcell_env'
       lvarname = 'pt'
-      CALL check_var3D(lfname, lvarname, pt, klon, klev, largest, .FALSE.)
+      CALL check_var3D(lfname, lvarname, pt, ngrid, nlay, largest, .FALSE.)
       lvarname = 'pdtadj'
-      CALL check_var3D(lfname, lvarname, pdtadj, klon, klev, largest, .FALSE.)
+      CALL check_var3D(lfname, lvarname, pdtadj, ngrid, nlay, largest, .FALSE.)
        
       if (prt_level.ge.1) print*,'thermcell_main apres thermcell_env'
@@ -385,5 +385,5 @@
       enddo
          zlev(:,1)=0.
-         zlev(:,nlay+1)=(2.*pphi(:,klev)-pphi(:,klev-1))/RG
+         zlev(:,nlay+1)=(2.*pphi(:,nlay)-pphi(:,nlay-1))/RG
       do l=1,nlay
          zlay(:,l)=pphi(:,l)/RG
@@ -513,7 +513,7 @@
       lfname='after thermcell_plume'
       lvarname = 'pt'
-      CALL check_var3D(lfname, lvarname, pt, klon, klev, largest, .FALSE.)
+      CALL check_var3D(lfname, lvarname, pt, ngrid, nlay, largest, .FALSE.)
       lvarname = 'pdtadj'
-      CALL check_var3D(lfname, lvarname, pdtadj, klon, klev, largest, .FALSE.)
+      CALL check_var3D(lfname, lvarname, pdtadj, ngrid, nlay, largest, .FALSE.)
 
       if (prt_level.ge.1) print*,'apres thermcell_plume ',lev_out
@@ -633,5 +633,5 @@
       lfname='after flux'
       lvarname = 'fm'
-      CALL check_var3D(lfname, lvarname, fm, klon, klev, largest, .FALSE.)
+      CALL check_var3D(lfname, lvarname, fm, ngrid, nlay, largest, .FALSE.)
 
       if (prt_level.ge.1) print*,'thermcell_main apres thermcell_flux'
@@ -662,5 +662,5 @@
       lfname='before transport_vertical'
       lvarname = 'zdthladj'
-      CALL check_var3D(lfname, lvarname, zdthladj, klon, klev, largest, .FALSE.)
+      CALL check_var3D(lfname, lvarname, zdthladj, ngrid, nlay, largest, .FALSE.)
 
       call thermcell_dq(ngrid,nlay,dqimpl,ptimestep,fm0,entr0,masse,  &
@@ -670,15 +670,15 @@
       lfname='after transport_vertical'
       lvarname = 'zdthladj'
-      CALL check_var3D(lfname, lvarname, zdthladj, klon, klev, largest, .FALSE.)
+      CALL check_var3D(lfname, lvarname, zdthladj, ngrid, nlay, largest, .FALSE.)
 
 !------------------------------------------------------------------
 ! Calcul de la fraction de l'ascendance
 !------------------------------------------------------------------
-      do ig=1,klon
+      do ig=1,ngrid
          fraca(ig,1)=0.
          fraca(ig,nlay+1)=0.
       enddo
       do l=2,nlay
-         do ig=1,klon
+         do ig=1,ngrid
             if (zw2(ig,l).gt.1.e-10) then
             fraca(ig,l)=fm(ig,l)/(rhobarz(ig,l)*zw2(ig,l))
@@ -694,7 +694,7 @@
       lfname='before thermcell_dv2'
       lvarname = 'pt'
-      CALL check_var3D(lfname, lvarname, pt, klon, klev, largest, .FALSE.)
+      CALL check_var3D(lfname, lvarname, pt, ngrid, nlay, largest, .FALSE.)
       lvarname = 'pdtadj'
-      CALL check_var3D(lfname, lvarname, pdtadj, klon, klev, largest, .FALSE.)
+      CALL check_var3D(lfname, lvarname, pdtadj, ngrid, nlay, largest, .FALSE.)
 
 !IM 090508  
@@ -727,7 +727,7 @@
       lfname='after thermcell_dv2'
       lvarname = 'pt'
-      CALL check_var3D(lfname, lvarname, pt, klon, klev, largest, .FALSE.)
+      CALL check_var3D(lfname, lvarname, pt, ngrid, nlay, largest, .FALSE.)
       lvarname = 'pdtadj'
-      CALL check_var3D(lfname, lvarname, pdtadj, klon, klev, largest, .FALSE.)
+      CALL check_var3D(lfname, lvarname, pdtadj, ngrid, nlay, largest, .FALSE.)
       lvarname = 'zdthladj'
       CALL check_var3D(lfname, lvarname, zdthladj, ngrid, nlay, largest, .FALSE.)
@@ -833,5 +833,5 @@
     do ig=1,ngrid
       ok_lcl(ig)=.false.
-      if ( (pcon(ig) .gt. pplay(ig,klev-1)) .and. (pcon(ig) .lt. pplay(ig,1)) ) ok_lcl(ig)=.true.
+      if ( (pcon(ig) .gt. pplay(ig,nlay-1)) .and. (pcon(ig) .lt. pplay(ig,1)) ) ok_lcl(ig)=.true.
     enddo
 
@@ -1000,31 +1000,31 @@
       lfname='thermcell_main before closure'
       lvarname = 'pt'
-      CALL check_var3D(lfname, lvarname, pt, klon, klev, largest, .FALSE.)
+      CALL check_var3D(lfname, lvarname, pt, ngrid, nlay, largest, .FALSE.)
       lvarname = 'pdtadj'
-      CALL check_var3D(lfname, lvarname, pdtadj, klon, klev, largest, .FALSE.)
+      CALL check_var3D(lfname, lvarname, pdtadj, ngrid, nlay, largest, .FALSE.)
       lvarname = 'alp_bl_det'
-      CALL check_var(lfname, lvarname, alp_bl_det,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, alp_bl_det,ngrid, largest, .FALSE.)
       lvarname = 'rhobarz0'
-      CALL check_var(lfname, lvarname, rhobarz0,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, rhobarz0,ngrid, largest, .FALSE.)
       lvarname = 'fraca0'
-      CALL check_var(lfname, lvarname, fraca0,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, fraca0,ngrid, largest, .FALSE.)
       lvarname = 'w_conv'
-      CALL check_var(lfname, lvarname, w_conv,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, w_conv,ngrid, largest, .FALSE.)
       lvarname = 'w0'
-      CALL check_var(lfname, lvarname, w0,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, w0,ngrid, largest, .FALSE.)
       lvarname = 'alp_bl_fluct_m'
-      CALL check_var(lfname, lvarname, alp_bl_fluct_m,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, alp_bl_fluct_m,ngrid, largest, .FALSE.)
       lvarname = 'alp_bl_fluct_tke'
-      CALL check_var(lfname, lvarname, alp_bl_fluct_tke,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, alp_bl_fluct_tke,ngrid, largest, .FALSE.)
       lvarname = 'therm_tke_max0'
-      CALL check_var(lfname, lvarname, therm_tke_max0,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, therm_tke_max0,ngrid, largest, .FALSE.)
       lvarname = 'env_tke_max0'
-      CALL check_var(lfname, lvarname, env_tke_max0,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, env_tke_max0,ngrid, largest, .FALSE.)
       lvarname = 'pbl_tke_max0'
-      CALL check_var(lfname, lvarname, pbl_tke_max0,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, pbl_tke_max0,ngrid, largest, .FALSE.)
       lvarname = 'alp_bl_conv'
-      CALL check_var(lfname, lvarname, alp_bl_conv,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, alp_bl_conv,ngrid, largest, .FALSE.)
       lvarname = 'alp_bl_stat'
-      CALL check_var(lfname, lvarname, alp_bl_stat,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, alp_bl_stat,ngrid, largest, .FALSE.)
 !------------Closure------------------
 
@@ -1055,31 +1055,31 @@
       lfname='after closure'
       lvarname = 'pt'
-      CALL check_var3D(lfname, lvarname, pt, klon, klev, largest, .FALSE.)
+      CALL check_var3D(lfname, lvarname, pt, ngrid, nlay, largest, .FALSE.)
       lvarname = 'pdtadj'
-      CALL check_var3D(lfname, lvarname, pdtadj, klon, klev, largest, .FALSE.)
+      CALL check_var3D(lfname, lvarname, pdtadj, ngrid, nlay, largest, .FALSE.)
       lvarname = 'alp_bl_det'
-      CALL check_var(lfname, lvarname, alp_bl_det,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, alp_bl_det,ngrid, largest, .FALSE.)
       lvarname = 'rhobarz0'
-      CALL check_var(lfname, lvarname, rhobarz0,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, rhobarz0,ngrid, largest, .FALSE.)
       lvarname = 'fraca0'
-      CALL check_var(lfname, lvarname, fraca0,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, fraca0,ngrid, largest, .FALSE.)
       lvarname = 'w_conv'
-      CALL check_var(lfname, lvarname, w_conv,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, w_conv,ngrid, largest, .FALSE.)
       lvarname = 'w0'
-      CALL check_var(lfname, lvarname, w0,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, w0,ngrid, largest, .FALSE.)
       lvarname = 'alp_bl_fluct_m'
-      CALL check_var(lfname, lvarname, alp_bl_fluct_m,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, alp_bl_fluct_m,ngrid, largest, .FALSE.)
       lvarname = 'alp_bl_fluct_tke'
-      CALL check_var(lfname, lvarname, alp_bl_fluct_tke,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, alp_bl_fluct_tke,ngrid, largest, .FALSE.)
       lvarname = 'therm_tke_max0'
-      CALL check_var(lfname, lvarname, therm_tke_max0,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, therm_tke_max0,ngrid, largest, .FALSE.)
       lvarname = 'env_tke_max0'
-      CALL check_var(lfname, lvarname, env_tke_max0,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, env_tke_max0,ngrid, largest, .FALSE.)
       lvarname = 'pbl_tke_max0'
-      CALL check_var(lfname, lvarname, pbl_tke_max0,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, pbl_tke_max0,ngrid, largest, .FALSE.)
       lvarname = 'alp_bl_conv'
-      CALL check_var(lfname, lvarname, alp_bl_conv,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, alp_bl_conv,ngrid, largest, .FALSE.)
       lvarname = 'alp_bl_stat'
-      CALL check_var(lfname, lvarname, alp_bl_stat,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, alp_bl_stat,ngrid, largest, .FALSE.)
 
 !!! fin nrlmd le 10/04/2012
@@ -1113,5 +1113,5 @@
       lalim_conv(:)=lalim(:)
 
-      do k=1,klev
+      do k=1,nlay
          do ig=1,ngrid
             if (k<=lalim_conv(ig)) fm_tot(ig)=fm_tot(ig)+fm(ig,k)
@@ -1120,15 +1120,15 @@
       lfname='after calculation of Al[p/e]_bl'
       lvarname = 'fm'
-      CALL check_var3D(lfname, lvarname, fm, klon, klev, largest, .FALSE.)
+      CALL check_var3D(lfname, lvarname, fm, ngrid, nlay, largest, .FALSE.)
       lvarname = 'rhobarz'
-      CALL check_var3D(lfname, lvarname, rhobarz, klon, klev, largest, .FALSE.)
+      CALL check_var3D(lfname, lvarname, rhobarz, ngrid, nlay, largest, .FALSE.)
       lvarname = 'Alp_bl'
-      CALL check_var(lfname, lvarname, Alp_bl,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, Alp_bl, ngrid, largest, .FALSE.)
       lvarname = 'Ale_bl'
-      CALL check_var(lfname, lvarname, Ale_bl,klon, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, Ale_bl, ngrid, largest, .FALSE.)
 
 ! assez bizarre car, si on est dans la couche d'alim et que alim_star et
 ! plus petit que 1.e-10, on prend wght_th=1.
-      do k=1,klev
+      do k=1,nlay
          do ig=1,ngrid
             if (k<=lalim_conv(ig).and.alim_star(ig,k)>1.e-10) then
@@ -1183,9 +1183,9 @@
       lfname='thermcell_main last computations on Alp_bl'
       lvarname = 'alp_int'
-      CALL check_var(lfname, lvarname, alp_int, klon, largest*10.e4, .FALSE.)
+      CALL check_var(lfname, lvarname, alp_int, ngrid, largest*10.e4, .FALSE.)
       lvarname = 'dp_int'
-      CALL check_var3D(lfname, lvarname, dp_int, klon, largest, .FALSE.)
+      CALL check_var3D(lfname, lvarname, dp_int, ngrid, largest, .FALSE.)
       lvarname = 'Alp_bl'
-      CALL check_var(lfname, lvarname, Alp_bl, klon, klev, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, Alp_bl, ngrid, largest, .FALSE.)
 
 !------------------------------------------------------------------------
@@ -1198,5 +1198,5 @@
       ratqsdiff(:,:)=0.
 
-      do l=1,klev
+      do l=1,nlay
          do ig=1,ngrid
             if (l<=lalim(ig)) then
@@ -1208,5 +1208,5 @@
       if (prt_level.ge.1) print*,'14f OK convect8'
 
-      do l=1,klev
+      do l=1,nlay
          do ig=1,ngrid
             if (l<=lalim(ig)) then
@@ -1241,11 +1241,11 @@
       lfname='before leaving thermcell_main'
       lvarname = 'pt'
-      CALL check_var3D(lfname, lvarname, pt, klon, klev, largest, .FALSE.)
+      CALL check_var3D(lfname, lvarname, pt, ngrid, nlay, largest, .FALSE.)
       lvarname = 'pdtadj'
-      CALL check_var3D(lfname, lvarname, pdtadj, klon, klev, largest, .FALSE.)
+      CALL check_var3D(lfname, lvarname, pdtadj, ngrid, nlay, largest, .FALSE.)
       lvarname = 'Alp_bl'
-      CALL check_var(lfname, lvarname, Alp_bl, klon, klev, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, Alp_bl, ngrid, largest, .FALSE.)
       lvarname = 'Ale_bl'
-      CALL check_var(lfname, lvarname, Ale_bl, klon, klev, largest, .FALSE.)
+      CALL check_var(lfname, lvarname, Ale_bl, ngrid, largest, .FALSE.)
 
 
@@ -1255,17 +1255,17 @@
 !-----------------------------------------------------------------------------
 
-      subroutine test_ltherm(klon,klev,pplev,pplay,long,seuil,ztv,po,ztva,zqla,f_star,zw2,comment)
+      subroutine test_ltherm(ngrid,nlay,pplev,pplay,long,seuil,ztv,po,ztva,zqla,f_star,zw2,comment)
       IMPLICIT NONE
 #include "iniprint.h"
 
-      integer i, k, klon,klev
-      real pplev(klon,klev+1),pplay(klon,klev)
-      real ztv(klon,klev)
-      real po(klon,klev)
-      real ztva(klon,klev)
-      real zqla(klon,klev)
-      real f_star(klon,klev)
-      real zw2(klon,klev)
-      integer long(klon)
+      integer i, k, ngrid,nlay
+      real pplev(ngrid,nlay+1),pplay(ngrid,nlay)
+      real ztv(ngrid,nlay)
+      real po(ngrid,nlay)
+      real ztva(ngrid,nlay)
+      real zqla(ngrid,nlay)
+      real f_star(ngrid,nlay)
+      real zw2(ngrid,nlay)
+      integer long(ngrid)
       real seuil
       character*21 comment
@@ -1277,10 +1277,10 @@
 
 !  test sur la hauteur des thermiques ...
-         do i=1,klon
+         do i=1,ngrid
 !IMtemp           if (pplay(i,long(i)).lt.seuil*pplev(i,1)) then
            if (prt_level.ge.10) then
                print*,'WARNING ',comment,' au point ',i,' K= ',long(i)
                print*,'  K  P(MB)  THV(K)     Qenv(g/kg)THVA        QLA(g/kg)   F*        W2'
-               do k=1,klev
+               do k=1,nlay
                   write(6,'(i3,7f10.3)') k,pplay(i,k),ztv(i,k),1000*po(i,k),ztva(i,k),1000*zqla(i,k),f_star(i,k),zw2(i,k)
                enddo
