Index: trunk/LMDZ.TITAN/libf/phytitan/comm_wrf.F90
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/comm_wrf.F90	(revision 2291)
+++ trunk/LMDZ.TITAN/libf/phytitan/comm_wrf.F90	(revision 2291)
@@ -0,0 +1,62 @@
+module comm_wrf
+
+!!
+!! This module is useful to output fields in WRF style
+!!
+!USE only for the mescoscale (comm_HR_SW, comm_HR_LW). OUTPUT
+  REAL,SAVE,ALLOCATABLE :: comm_HR_SW(:,:)
+  REAL,SAVE,ALLOCATABLE :: comm_HR_LW(:,:)
+  REAL,SAVE,ALLOCATABLE :: comm_HR_DYN(:,:)
+  REAL,SAVE,ALLOCATABLE :: comm_SWDOWNZ(:)
+  REAL,SAVE,ALLOCATABLE :: comm_MTOT(:)
+  REAL,SAVE,ALLOCATABLE :: comm_GEOP(:,:)
+  REAL,SAVE,ALLOCATABLE :: comm_ALBEQ(:) 
+  REAL,SAVE,ALLOCATABLE :: comm_FLUXTOP_DN(:)
+  REAL,SAVE,ALLOCATABLE :: comm_FLUXABS_SW(:)
+  REAL,SAVE,ALLOCATABLE :: comm_FLUXTOP_LW(:)
+  REAL,SAVE,ALLOCATABLE :: comm_FLUXSURF_SW(:)
+  REAL,SAVE,ALLOCATABLE :: comm_FLUXSURF_LW(:)
+  REAL,SAVE,ALLOCATABLE :: comm_FLXGRD(:)
+
+contains
+
+  subroutine allocate_comm_wrf(ngrid,nlayer)
+  implicit none
+  integer,intent(in) :: ngrid ! number of atmospheric columns
+  integer,intent(in) :: nlayer ! number of atmospheric layers
+  allocate(comm_HR_SW(ngrid,nlayer))
+  allocate(comm_HR_LW(ngrid,nlayer))
+  allocate(comm_HR_DYN(ngrid,nlayer))
+  allocate(comm_SWDOWNZ(ngrid))
+  allocate(comm_MTOT(ngrid))
+  allocate(comm_GEOP(ngrid,nlayer))
+  allocate(comm_ALBEQ(ngrid))
+  allocate(comm_FLUXTOP_DN(ngrid))
+  allocate(comm_FLUXABS_SW(ngrid))
+  allocate(comm_FLUXTOP_LW(ngrid))
+  allocate(comm_FLUXSURF_SW(ngrid))
+  allocate(comm_FLUXSURF_LW(ngrid))
+  allocate(comm_FLXGRD(ngrid))
+
+  end subroutine allocate_comm_wrf
+
+  subroutine deallocate_comm_wrf
+  implicit none
+  deallocate(comm_HR_SW)
+  deallocate(comm_HR_LW)
+  deallocate(comm_HR_DYN)
+  deallocate(comm_SWDOWNZ)
+  deallocate(comm_MTOT)
+  deallocate(comm_GEOP)
+  deallocate(comm_ALBEQ)
+  deallocate(comm_FLUXTOP_DN)
+  deallocate(comm_FLUXABS_SW)
+  deallocate(comm_FLUXTOP_LW)
+  deallocate(comm_FLUXSURF_SW)
+  deallocate(comm_FLUXSURF_LW)
+  deallocate(comm_FLXGRD)
+
+  end subroutine deallocate_comm_wrf
+
+end module comm_wrf
+
Index: trunk/LMDZ.TITAN/libf/phytitan/phys_state_var_mod.F90
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/phys_state_var_mod.F90	(revision 2291)
+++ trunk/LMDZ.TITAN/libf/phytitan/phys_state_var_mod.F90	(revision 2291)
@@ -0,0 +1,176 @@
+!
+! $Id: phys_state_var_mod.F90 1670 2012-10-17 08:42:04Z idelkadi $
+!
+      MODULE phys_state_var_mod
+! Variables sauvegardees pour le startphy.nc
+!======================================================================
+!
+!
+!======================================================================
+! Declaration des variables
+      USE dimphy, only : klon,klev
+      USE comsoil_h, only : nsoilmx
+      use comsaison_h, only: mu0, fract
+      use radcommon_h, only: gzlat, gzlat_ig, Cmk 
+      USE radinc_h, only : L_NSPECTI, L_NSPECTV,naerkind
+      use turb_mod, only: q2,sensibFlux,wstar,ustar,tstar,hfmax_th,zmax_th
+
+      real,allocatable,dimension(:,:),save :: ztprevious ! Previous loop Atmospheric Temperature (K) ! Useful for Dynamical Heating calculation.
+      real,allocatable,dimension(:,:),save :: zuprevious ! Previous loop Zonal Wind (m.s-1)          ! Useful for Zonal Wind tendency calculation.
+
+      real, dimension(:),allocatable,save ::  tsurf                ! Surface temperature (K).
+      real, dimension(:,:),allocatable,save ::  tsoil              ! Sub-surface temperatures (K).
+      real, dimension(:,:),allocatable,save :: albedo              ! Surface Spectral albedo. By MT2015.
+      real, dimension(:),allocatable,save :: albedo_equivalent     ! Spectral Mean albedo.
+
+      real,dimension(:),allocatable,save :: albedo_bareground ! Bare Ground Albedo. By MT 2015.
+
+       real, dimension(:), allocatable, save       :: tankCH4    ! Depth of surface methane tank (m)
+
+      real,dimension(:),allocatable,save :: emis        ! Thermal IR surface emissivity.
+      real,dimension(:,:),allocatable,save :: dtrad     ! Net atmospheric radiative heating rate (K.s-1).
+      real,dimension(:),allocatable,save :: fluxrad_sky ! Radiative flux from sky absorbed by surface (W.m-2).
+      real,dimension(:),allocatable,save :: fluxrad     ! Net radiative surface flux (W.m-2).
+      real,dimension(:),allocatable,save :: capcal      ! Surface heat capacity (J m-2 K-1).
+      real,dimension(:),allocatable,save :: fluxgrd     ! Surface conduction flux (W.m-2).
+      real,dimension(:,:),allocatable,save :: qsurf     ! Tracer on surface (e.g. kg.m-2).
+
+      ! FOR DIAGNOSTIC :
+
+      real,dimension(:),allocatable,save :: fluxsurf_lw     ! Incident Long Wave (IR) surface flux (W.m-2).
+      real,dimension(:),allocatable,save :: fluxsurf_sw     ! Incident Short Wave (stellar) surface flux (W.m-2).
+      real,dimension(:),allocatable,save :: fluxsurfabs_sw  ! Absorbed Short Wave (stellar) flux by the surface (W.m-2).
+
+      real,dimension(:),allocatable,save :: fluxtop_lw      ! Outgoing LW (IR) flux to space (W.m-2).
+      real,dimension(:),allocatable,save :: fluxabs_sw      ! Absorbed SW (stellar) flux (W.m-2).
+      real,dimension(:),allocatable,save :: fluxtop_dn      ! Incoming SW (stellar) radiation at the top of the atmosphere (W.m-2).
+      real,dimension(:),allocatable,save :: fluxdyn         ! Horizontal heat transport by dynamics (W.m-2).
+
+      real,dimension(:,:),allocatable,save :: OLR_nu        ! Outgoing LW radiation in each band (Normalized to the band width (W/m2/cm-1)).
+      real,dimension(:,:),allocatable,save :: OSR_nu        ! Outgoing SW radiation in each band (Normalized to the band width (W/m2/cm-1)).
+      real,dimension(:,:),allocatable,save :: zdtlw         ! LW heating tendencies (K/s).
+      real,dimension(:,:),allocatable,save :: zdtsw         ! SW heating tendencies (K/s).
+      !real,dimension(:),allocatable,save :: sensibFlux      ! Turbulent flux given by the atmosphere to the surface (W.m-2).
+      real,dimension(:,:,:),allocatable,save :: int_dtauv   ! VI optical thickness of layers within narrowbands for diags ().
+      real,dimension(:,:,:),allocatable,save :: int_dtaui   ! IR optical thickness of layers within narrowbands for diags ().
+
+
+      real,allocatable,dimension(:,:),save :: qsurf_hist
+ 
+CONTAINS
+
+!======================================================================
+SUBROUTINE phys_state_var_init(nqtot)
+
+IMPLICIT NONE
+
+        integer,intent(in) :: nqtot
+
+!  Parametres de l'Orographie a l'Echelle Sous-Maille (OESM):
+!
+!zmea(:)   ! orographie moyenne
+!zstd(:)   ! deviation standard de l'OESM
+!zsig(:)   ! pente de l'OESM
+!zgam(:)   ! anisotropie de l'OESM
+!zthe(:)   ! orientation de l'OESM
+!zpic(:)   ! Maximum de l'OESM
+!zval(:)   ! Minimum de l'OESM
+!rugoro(:) ! longueur de rugosite de l'OESM 
+        print*,'klon',klon,'klev',klev
+        ALLOCATE(tsurf(klon))
+        ALLOCATE(tsoil(klon,nsoilmx))
+        ALLOCATE(albedo(klon,L_NSPECTV))
+        ALLOCATE(albedo_equivalent(klon))
+        ALLOCATE(albedo_bareground(klon))
+        ALLOCATE(emis(klon))
+        ALLOCATE(dtrad(klon,klev))
+        ALLOCATE(fluxrad_sky(klon))
+        ALLOCATE(fluxrad(klon))
+        ALLOCATE(capcal(klon))
+        ALLOCATE(fluxgrd(klon))
+        ALLOCATE(qsurf(klon,nqtot))
+        ALLOCATE(q2(klon,klev+1))
+        ALLOCATE(tankCH4(klon))
+        ALLOCATE(ztprevious(klon,klev))
+        ALLOCATE(zuprevious(klon,klev))
+        ALLOCATE(qsurf_hist(klon,nqtot))
+        ALLOCATE(fluxsurf_lw(klon))
+        ALLOCATE(fluxsurf_sw(klon))
+        ALLOCATE(fluxsurfabs_sw(klon))
+        ALLOCATE(fluxtop_lw(klon))
+        ALLOCATE(fluxabs_sw(klon))
+        ALLOCATE(fluxtop_dn(klon))
+        ALLOCATE(fluxdyn(klon))
+        ALLOCATE(OLR_nu(klon,L_NSPECTI))
+        ALLOCATE(OSR_nu(klon,L_NSPECTV))
+        ALLOCATE(sensibFlux(klon))
+        ALLOCATE(zdtlw(klon,klev))
+        ALLOCATE(zdtsw(klon,klev))
+        ALLOCATE(int_dtaui(klon,klev,L_NSPECTI))
+        ALLOCATE(int_dtauv(klon,klev,L_NSPECTV))
+        ! This is defined in comsaison_h
+        ALLOCATE(mu0(klon))
+        ALLOCATE(fract(klon))
+         ! This is defined in radcommon_h
+        ALLOCATE(gzlat(klon,klev))
+        ALLOCATE(gzlat_ig(klon))
+        ALLOCATE(Cmk(klon))
+        allocate(wstar(klon))
+        allocate(ustar(klon))
+        allocate(tstar(klon))
+        allocate(hfmax_th(klon))
+        allocate(zmax_th(klon))
+
+END SUBROUTINE phys_state_var_init
+
+!======================================================================
+SUBROUTINE phys_state_var_end
+
+IMPLICIT NONE
+
+        DEALLOCATE(tsurf)
+        DEALLOCATE(tsoil)
+        DEALLOCATE(albedo)
+        DEALLOCATE(albedo_equivalent)
+        DEALLOCATE(albedo_bareground)
+        DEALLOCATE(emis)
+        DEALLOCATE(dtrad)
+        DEALLOCATE(fluxrad_sky)
+        DEALLOCATE(fluxrad)
+        DEALLOCATE(capcal)
+        DEALLOCATE(fluxgrd)
+        DEALLOCATE(qsurf)
+        DEALLOCATE(q2)
+        DEALLOCATE(tankCH4)
+        DEALLOCATE(ztprevious)
+        DEALLOCATE(zuprevious)
+        DEALLOCATE(qsurf_hist)
+        DEALLOCATE(fluxsurf_lw)
+        DEALLOCATE(fluxsurf_sw)
+        DEALLOCATE(fluxsurfabs_sw)
+        DEALLOCATE(fluxtop_lw)
+        DEALLOCATE(fluxabs_sw)
+        DEALLOCATE(fluxtop_dn)
+        DEALLOCATE(fluxdyn)
+        DEALLOCATE(OLR_nu)
+        DEALLOCATE(OSR_nu)
+        DEALLOCATE(sensibFlux)
+        DEALLOCATE(zdtlw)
+        DEALLOCATE(zdtsw)
+        DEALLOCATE(int_dtaui)
+        DEALLOCATE(int_dtauv)
+        DEALLOCATE(mu0)
+        DEALLOCATE(fract)
+        DEALLOCATE(gzlat)
+        DEALLOCATE(gzlat_ig)
+        DEALLOCATE(Cmk)
+        deallocate(wstar)
+        deallocate(ustar)
+        deallocate(tstar)
+        deallocate(hfmax_th)
+        deallocate(zmax_th)
+
+
+END SUBROUTINE phys_state_var_end
+
+      END MODULE phys_state_var_mod
Index: trunk/LMDZ.TITAN/libf/phytitan/physiq_mod.F90
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/physiq_mod.F90	(revision 2245)
+++ trunk/LMDZ.TITAN/libf/phytitan/physiq_mod.F90	(revision 2291)
@@ -38,7 +38,16 @@
                              zzlevbar, zzlaybar, ztfibar, zqfibar
       use callkeys_mod
+      use phys_state_var_mod
+      use turb_mod, only : q2,sensibFlux,turb_resolved
+#ifndef MESOSCALE
       use vertical_layers_mod, only: presnivs, pseudoalt
       use ioipsl_getin_p_mod, only: getin_p
       use mod_phys_lmdz_omp_data, ONLY: is_omp_master
+#else
+use comm_wrf, only : comm_HR_SW, comm_HR_LW, &
+                     comm_FLUXTOP_DN,comm_FLUXABS_SW,&
+                     comm_FLUXTOP_LW,comm_FLUXSURF_SW,&
+                     comm_FLUXSURF_LW,comm_FLXGRD
+#endif
 #ifdef CPP_XIOS      
       use xios_output_mod, only: initialize_xios_output, &
@@ -207,24 +216,8 @@
 !$OMP THREADPRIVATE(day_ini,icount)
 
-      real, dimension(:),allocatable,save ::  tsurf                ! Surface temperature (K).
-      real, dimension(:,:),allocatable,save ::  tsoil              ! Sub-surface temperatures (K).
-      real, dimension(:,:),allocatable,save :: albedo              ! Surface Spectral albedo. By MT2015.
-      real, dimension(:),allocatable,save :: albedo_equivalent     ! Spectral Mean albedo.
-      
 !$OMP THREADPRIVATE(tsurf,tsoil,albedo,albedo_equivalent)
 
-      real,dimension(:),allocatable,save :: albedo_bareground ! Bare Ground Albedo. By MT 2015.
-      
 !$OMP THREADPRIVATE(albedo_bareground)
 
-      real,dimension(:),allocatable,save :: emis        ! Thermal IR surface emissivity.
-      real,dimension(:,:),allocatable,save :: dtrad     ! Net atmospheric radiative heating rate (K.s-1).
-      real,dimension(:),allocatable,save :: fluxrad_sky ! Radiative flux from sky absorbed by surface (W.m-2).
-      real,dimension(:),allocatable,save :: fluxrad     ! Net radiative surface flux (W.m-2).
-      real,dimension(:),allocatable,save :: capcal      ! Surface heat capacity (J m-2 K-1).
-      real,dimension(:),allocatable,save :: fluxgrd     ! Surface conduction flux (W.m-2).
-      real,dimension(:,:),allocatable,save :: qsurf     ! Tracer on surface (e.g. kg.m-2).
-      real,dimension(:,:),allocatable,save :: q2        ! Turbulent Kinetic Energy.
-      
 !$OMP THREADPRIVATE(emis,dtrad,fluxrad_sky,fluxrad,capcal,fluxgrd,qsurf,q2)
 
@@ -240,19 +233,4 @@
       ! FOR DIAGNOSTIC :
       
-      real,dimension(:),allocatable,save :: fluxsurf_lw     ! Incident Long Wave (IR) surface flux (W.m-2).
-      real,dimension(:),allocatable,save :: fluxsurf_sw     ! Incident Short Wave (stellar) surface flux (W.m-2).
-      real,dimension(:),allocatable,save :: fluxsurfabs_sw  ! Absorbed Short Wave (stellar) flux by the surface (W.m-2).
-      real,dimension(:),allocatable,save :: fluxtop_lw      ! Outgoing LW (IR) flux to space (W.m-2).
-      real,dimension(:),allocatable,save :: fluxabs_sw      ! Absorbed SW (stellar) flux (W.m-2).
-      real,dimension(:),allocatable,save :: fluxtop_dn      ! Incoming SW (stellar) radiation at the top of the atmosphere (W.m-2).
-      real,dimension(:),allocatable,save :: fluxdyn         ! Horizontal heat transport by dynamics (W.m-2).
-      real,dimension(:,:),allocatable,save :: OLR_nu        ! Outgoing LW radiation in each band (Normalized to the band width (W/m2/cm-1)).
-      real,dimension(:,:),allocatable,save :: OSR_nu        ! Outgoing SW radiation in each band (Normalized to the band width (W/m2/cm-1)).
-      real,dimension(:,:),allocatable,save :: zdtlw         ! LW heating tendencies (K/s).
-      real,dimension(:,:),allocatable,save :: zdtsw         ! SW heating tendencies (K/s).
-      real,dimension(:),allocatable,save :: sensibFlux      ! Turbulent flux given by the atmosphere to the surface (W.m-2).
-      real,dimension(:,:,:),allocatable,save :: int_dtauv   ! VI optical thickness of layers within narrowbands for diags ().
-      real,dimension(:,:,:),allocatable,save :: int_dtaui   ! IR optical thickness of layers within narrowbands for diags ().
-     
 !$OMP THREADPRIVATE(fluxsurf_lw,fluxsurf_sw,fluxsurfabs_sw,fluxtop_lw,fluxabs_sw,fluxtop_dn,fluxdyn,OLR_nu,OSR_nu,&        
         !$OMP zdtlw,zdtsw,sensibFlux,int_dtauv,int_dtaui))
@@ -331,6 +309,4 @@
       real zdtdyn(ngrid,nlayer)                          ! Dynamical Heating (K/s).
       real zdudyn(ngrid,nlayer)                          ! Dynamical Zonal Wind tendency (m.s-2).
-      real,allocatable,dimension(:,:),save :: ztprevious ! Previous loop Atmospheric Temperature (K)                                                         ! Useful for Dynamical Heating calculation.
-      real,allocatable,dimension(:,:),save :: zuprevious ! Previous loop Zonal Wind (m.s-1)                                                                  ! Useful for Zonal Wind tendency calculation.
 !$OMP THREADPRIVATE(ztprevious,zuprevious)
 
@@ -363,5 +339,4 @@
       real tf, ntf    
 
-      real,allocatable,dimension(:,:),save :: qsurf_hist
 !$OMP THREADPRIVATE(qsurf_hist)
    
@@ -393,5 +368,4 @@
 
       ! Surface methane
-      real, dimension(:), allocatable, save       :: tankCH4    ! Depth of surface methane tank (m)
 !$OMP THREADPRIVATE(tankCH4)
 
@@ -434,4 +408,5 @@
 ! --------------------------------
       if (firstcall) then
+#ifndef MESOSCALE
         allocate(tpq(ngrid,nlayer,nq))
         tpq(:,:,:) = pq(:,:,:)
@@ -442,44 +417,7 @@
         endif
 
-        ! Allocate saved arrays.
-        ALLOCATE(tsurf(ngrid))
-        ALLOCATE(tsoil(ngrid,nsoilmx))    
-        ALLOCATE(albedo(ngrid,L_NSPECTV))
-        ALLOCATE(albedo_equivalent(ngrid))        
-        ALLOCATE(albedo_bareground(ngrid))                
-        ALLOCATE(emis(ngrid))   
-        ALLOCATE(dtrad(ngrid,nlayer))
-        ALLOCATE(fluxrad_sky(ngrid))
-        ALLOCATE(fluxrad(ngrid))    
-        ALLOCATE(capcal(ngrid))    
-        ALLOCATE(fluxgrd(ngrid))  
-        ALLOCATE(qsurf(ngrid,nq))  
-        ALLOCATE(q2(ngrid,nlayer+1)) 
-        ALLOCATE(tankCH4(ngrid)) 
-        ALLOCATE(ztprevious(ngrid,nlayer))
-        ALLOCATE(zuprevious(ngrid,nlayer))
-        ALLOCATE(qsurf_hist(ngrid,nq))
-        ALLOCATE(fluxsurf_lw(ngrid))
-        ALLOCATE(fluxsurf_sw(ngrid))
-        ALLOCATE(fluxsurfabs_sw(ngrid))
-        ALLOCATE(fluxtop_lw(ngrid))
-        ALLOCATE(fluxabs_sw(ngrid))
-        ALLOCATE(fluxtop_dn(ngrid))
-        ALLOCATE(fluxdyn(ngrid))
-        ALLOCATE(OLR_nu(ngrid,L_NSPECTI))
-        ALLOCATE(OSR_nu(ngrid,L_NSPECTV))
-        ALLOCATE(sensibFlux(ngrid))
-        ALLOCATE(zdtlw(ngrid,nlayer))
-        ALLOCATE(zdtsw(ngrid,nlayer))
-        ALLOCATE(int_dtaui(ngrid,nlayer,L_NSPECTI))
-        ALLOCATE(int_dtauv(ngrid,nlayer,L_NSPECTV))
- 
-        ! This is defined in comsaison_h
-        ALLOCATE(mu0(ngrid))
-        ALLOCATE(fract(ngrid))            
-         ! This is defined in radcommon_h
-        ALLOCATE(gzlat(ngrid,nlayer))
-        ALLOCATE(gzlat_ig(nlayer))
-        ALLOCATE(Cmk(nlayer))          
+        call phys_state_var_init(nq)
+
+#endif
 
 !        Variables set to 0
@@ -565,6 +503,15 @@
 !        Read 'startfi.nc' file.
 !        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#ifndef MESOSCALE
          call phyetat0(startphy_file,ngrid,nlayer,"startfi.nc",0,0,nsoilmx,nq,      &
                        day_ini,time_phys,tsurf,tsoil,emis,q2,qsurf,tankCH4)                       
+#else
+         emis(:)=0.0
+         q2(:,:)=0.0
+         qsurf(:,:)=0.0
+         day_ini = pday
+#endif
+
+#ifndef MESOSCALE
          if (.not.startphy_file) then
            ! additionnal "academic" initialization of physics
@@ -578,4 +525,5 @@
            day_ini=pday
          endif
+#endif
 
          if (pday.ne.day_ini) then
@@ -639,4 +587,5 @@
          endif
 
+#ifndef MESOSCALE
          if (ngrid.ne.1) then
             ! Note : no need to create a restart file in 1d.
@@ -645,4 +594,5 @@
                           albedo_bareground,inertiedat,zmea,zstd,zsig,zgam,zthe)
          endif
+#endif
          
          ! XIOS outputs
@@ -991,9 +941,10 @@
          end if !end of 'UseTurbDiff'
 
-
-         pdv(:,:)=pdv(:,:)+zdvdif(:,:)
-         pdu(:,:)=pdu(:,:)+zdudif(:,:)
-         pdt(:,:)=pdt(:,:)+zdtdif(:,:)
-         zdtsurf(:)=zdtsurf(:)+zdtsdif(:)
+         if (.not. turb_resolved) then 
+           pdv(:,:)=pdv(:,:)+zdvdif(:,:)
+           pdu(:,:)=pdu(:,:)+zdudif(:,:)
+           pdt(:,:)=pdt(:,:)+zdtdif(:,:)
+         endif
+           zdtsurf(:)=zdtsurf(:)+zdtsdif(:)
 
          if (tracer) then 
@@ -1466,4 +1417,5 @@
          ztime_fin = ptime + ptimestep/(float(iphysiq)*daysec)
 
+#ifndef MESOSCALE
          if (ngrid.ne.1) then
             write(*,*)'PHYSIQ: for physdem ztime_fin =',ztime_fin
@@ -1473,7 +1425,9 @@
                           tsurf,tsoil,emis,q2,qsurf_hist,tankCH4)
          endif
+#endif
+
     endif ! end of 'lastcall'
 
-
+#ifndef MESOSCALE 
 !-----------------------------------------------------------------------------------------------------
 !           OUTPUT in netcdf file "DIAGFI.NC", containing any variable for diagnostic
@@ -1733,4 +1687,15 @@
       endif
 #endif
+#else 
+      !MESOSCALE outputs      
+      comm_HR_SW(1:ngrid,1:nlayer) = zdtsw(1:ngrid,1:nlayer)
+      comm_HR_LW(1:ngrid,1:nlayer) = zdtlw(1:ngrid,1:nlayer)
+      comm_FLUXTOP_DN(1:ngrid)=fluxtop_dn(1:ngrid)
+      comm_FLUXABS_SW(1:ngrid)=fluxabs_sw(1:ngrid)
+      comm_FLUXTOP_LW(1:ngrid)=fluxtop_lw(1:ngrid)
+      comm_FLUXSURF_SW(1:ngrid)=fluxsurf_sw(1:ngrid)
+      comm_FLUXSURF_LW(1:ngrid)=fluxsurf_lw(1:ngrid)
+      comm_FLXGRD(1:ngrid)=fluxgrd(1:ngrid)
+#endif      
 
       icount=icount+1
Index: trunk/LMDZ.TITAN/libf/phytitan/turb_mod.F90
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/turb_mod.F90	(revision 2291)
+++ trunk/LMDZ.TITAN/libf/phytitan/turb_mod.F90	(revision 2291)
@@ -0,0 +1,39 @@
+module turb_mod
+
+  !! variables
+  REAL,SAVE,ALLOCATABLE :: q2(:,:)    ! Turbulent Kinetic Energy
+  REAL,allocatable,SAVE :: l0(:)
+!$OMP THREADPRIVATE(q2,l0)
+  REAL,SAVE,ALLOCATABLE :: ustar(:)
+  REAL,SAVE,ALLOCATABLE :: wstar(:)
+  REAL,SAVE,ALLOCATABLE :: tstar(:)
+!$OMP THREADPRIVATE(ustar,wstar,tstar)
+  REAL,SAVE,ALLOCATABLE :: hfmax_th(:)
+  REAL,SAVE,ALLOCATABLE :: zmax_th(:)
+!$OMP THREADPRIVATE(hfmax_th,zmax_th)
+  REAL,SAVE,ALLOCATABLE :: sensibFlux(:)
+  LOGICAL,SAVE :: turb_resolved = .false.
+!$OMP THREADPRIVATE(sensibFlux,turb_resolved)
+      ! this is a flag to say 'turbulence is resolved'
+      ! mostly for LES use. default is FALSE (for GCM and mesoscale)
+
+!contains
+
+!  subroutine ini_turb_mod(ngrid,nlayer)
+
+!  implicit none
+!  integer,intent(in) :: ngrid ! number of atmospheric columns
+!  integer,intent(in) :: nlayer ! number of atmospheric layers
+
+!    allocate(q2(ngrid,nlayer+1))
+!    allocate(l0(ngrid))
+!    allocate(wstar(ngrid))
+!   allocate(ustar(ngrid))
+!   allocate(tstar(ngrid))
+!   allocate(hfmax_th(ngrid))
+!   allocate(zmax_th(ngrid))
+!   allocate(sensibFlux(ngrid))
+
+!  end subroutine ini_turb_mod
+
+end module turb_mod
Index: trunk/LMDZ.TITAN/libf/phytitan/turbdiff.F90
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/turbdiff.F90	(revision 2245)
+++ trunk/LMDZ.TITAN/libf/phytitan/turbdiff.F90	(revision 2291)
@@ -10,4 +10,5 @@
       use comcstfi_mod, only: rcp, g, r, cpp
       use callkeys_mod, only: tracer,nosurf
+      use turb_mod, only : ustar
 
       implicit none
@@ -327,4 +328,5 @@
          zcdh(ig) = zcdh_true(ig)*sqrt(zu2)
          zkh(ig,1)= zcdh(ig)
+         ustar(ig)= sqrt(zcdv_true(ig))*sqrt(zu2)
       ENDDO
 
