Index: /trunk/LMDZ.MARS/libf/phymars/meso_callkeys.h
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/meso_callkeys.h	(revision 161)
+++ /trunk/LMDZ.MARS/libf/phymars/meso_callkeys.h	(revision 162)
@@ -12,5 +12,5 @@
      &   ,callg2d,linear,rayleigh,tracer,active,doubleq,submicron       &
      &   ,lifting,callddevil,scavenging,sedimentation,activice,water    &
-     &   ,caps,photochem
+     &   ,caps,photochem,calltherm,outptherm
      
       COMMON/callkeys_i/iradia,iaervar,iddist,ilwd,ilwb,ilwn,ncouche    &
@@ -23,5 +23,6 @@
      &   ,callstats,calleofdump                                         &
      &   ,callnirco2,callnlte,callthermos,callconduct,                  &
-     &    calleuv,callmolvis,callmoldiff,thermochem,thermoswater
+     &    calleuv,callmolvis,callmoldiff,thermochem,thermoswater        &
+     &   ,calltherm,outptherm
 
 
Index: /trunk/LMDZ.MARS/libf/phymars/meso_inifis.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/meso_inifis.F	(revision 161)
+++ /trunk/LMDZ.MARS/libf/phymars/meso_inifis.F	(revision 162)
@@ -254,4 +254,5 @@
 
          write(*,*) "Directory where external input files are:"
+         !datafile="/u/forget/WWW/datagcm/datafile"
          ! NB: default 'datafile' is set in datafile.h
          call getin("datadir",datafile)
@@ -341,4 +342,14 @@
          write(*,*) " calldifv = ",calldifv
 
+         write(*,*) "call thermals ?"
+         calltherm=.false. ! default value
+         call getin("calltherm",calltherm)
+         write(*,*) " calltherm = ",calltherm
+
+         write(*,*) "output thermal diagnostics ?"
+         outptherm=.false. ! default value
+         call getin("outptherm",outptherm)
+         write(*,*) " outptherm = ",outptherm
+
          write(*,*) "call convective adjustment ?"
          calladj=.true. ! default value
@@ -346,4 +357,8 @@
          write(*,*) " calladj = ",calladj
          
+         if (calltherm .and. (.not. calladj)) then
+          print*,'Convadj has to be activated when using thermals'
+          stop
+         endif
 
          write(*,*) "call CO2 condensation ?"
Index: /trunk/LMDZ.MARS/libf/phymars/meso_physiq.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/meso_physiq.F	(revision 161)
+++ /trunk/LMDZ.MARS/libf/phymars/meso_physiq.F	(revision 162)
@@ -246,5 +246,5 @@
 c     Albedo of deposited surface ice
       !!REAL, PARAMETER :: alb_surfice = 0.4 ! 0.45
-      REAL, PARAMETER :: alb_surfice = 0.45 !!TESTS_JB
+      REAL, PARAMETER :: alb_surfice = 0.45 !!TESTS_JB 
 
       SAVE day_ini, icount
@@ -337,5 +337,5 @@
       REAL ccn(ngridmx,nlayermx)   ! Cloud condensation nuclei
                                    !   (particules kg-1)
-      SAVE ccn  !! in case iradia != 1 
+      SAVE ccn  !! in case iradia != 1
       real rdust(ngridmx,nlayermx) ! dust geometric mean radius (m)
       real qtot1,qtot2 ! total aerosol mass
@@ -359,4 +359,12 @@
       REAL time_phys
 
+c Variables from thermal
+
+      REAL lmax_th_out(ngrid)
+      REAL pdu_th(ngrid,nlayer),pdv_th(ngrid,nlayer)
+      REAL pdt_th(ngrid,nlayer),pdq_th(ngrid,nlayer,nq)
+      INTEGER lmax_th(ngrid)
+      REAL dtke_th(ngrid,nlayer+1)
+      REAL dummycol(ngrid)
 c=======================================================================
 #ifdef MESOSCALE
@@ -446,5 +454,4 @@
 c ****WRF
 ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
-
 
 
@@ -995,4 +1002,43 @@
       ENDIF ! of IF (calldifv)
 
+c-----------------------------------------------------------------------
+c   TEST. Thermals :
+c HIGHLY EXPERIMENTAL, BEWARE !!
+c   -----------------------------
+ 
+      if(calltherm) then
+ 
+        call calltherm_interface(ngrid,nlayer,firstcall,
+     $ long,lati,zzlev,zzlay,
+     $ ptimestep,pu,pv,pt,pq,pdu,pdv,pdt,pdq,q2,
+     $ pplay,pplev,pphi,nq,zpopsk,
+     $ pdu_th,pdv_th,pdt_th,pdq_th,lmax_th,dtke_th)
+ 
+         DO l=1,nlayer
+           DO ig=1,ngrid
+              pdu(ig,l)=pdu(ig,l)+pdu_th(ig,l)
+              pdv(ig,l)=pdv(ig,l)+pdv_th(ig,l)
+              pdt(ig,l)=pdt(ig,l)+pdt_th(ig,l)
+              q2(ig,l)=q2(ig,l)+dtke_th(ig,l)*ptimestep
+           ENDDO
+        ENDDO
+ 
+        DO ig=1,ngrid
+          q2(ig,nlayer+1)=q2(ig,nlayer+1)+dtke_th(ig,nlayer+1)*ptimestep
+        ENDDO      
+    
+        if (tracer) then
+        DO iq=1,nq
+         DO l=1,nlayer
+           DO ig=1,ngrid
+             pdq(ig,l,iq)=pdq(ig,l,iq)+pdq_th(ig,l,iq)
+           ENDDO
+         ENDDO
+        ENDDO
+        endif
+
+        else   !of if calltherm
+        lmax_th(:)=0
+        end if
 
 c-----------------------------------------------------------------------
@@ -1012,9 +1058,10 @@
 
          CALL convadj(ngrid,nlayer,nq,ptimestep,
-     $                pplay,pplev,zpopsk,
+     $                pplay,pplev,zpopsk,lmax_th,
      $                pu,pv,zh,pq,
      $                pdu,pdv,zdh,pdq,
      $                zduadj,zdvadj,zdhadj,
      $                zdqadj)
+
 
          DO l=1,nlayer
@@ -1502,5 +1549,4 @@
 c        which can later be used to make the statistic files of the run:
 c        "stats")          only possible in 3D runs !
-
          
          IF (callstats) THEN
