Index: trunk/LMDZ.TITAN/libf/phytitan/callcorrk.F90
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/callcorrk.F90	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/callcorrk.F90	(revision 2366)
@@ -17,5 +17,6 @@
       use comcstfi_mod, only: pi, mugaz, cpp
       use callkeys_mod, only: diurnal,tracer,seashaze,corrk_recombin,   &
-                              strictboundcorrk,specOLR,diagdtau
+                              strictboundcorrk,specOLR,diagdtau,        &
+                              tplanckmin,tplanckmax
       use geometry_mod, only: latitude
 
@@ -115,4 +116,8 @@
       real*8 taugsurf(L_NSPECTV,L_NGAUSS-1)
       real*8 taugsurfi(L_NSPECTI,L_NGAUSS-1)
+
+      ! Miscellaneous :
+      character(len=100) :: message
+      character(len=10),parameter :: subname="callcorrk"
 
       logical OLRz
@@ -377,5 +382,23 @@
             endif
          endif
+
+         if (tlevrad(k).lt.tplanckmin) then
+            print*,'Minimum temperature is outside the boundaries for'
+            print*,'Planck function integration set in callphys.def, aborting.'
+            print*,"k=",k," tlevrad(k)=",tlevrad(k)
+            print*,"tplanckmin=",tplanckmin
+            message="Minimum temperature outside Planck function bounds - Change tplanckmin in callphys.def"
+            call abort_physic(subname,message,1)
+          else if (tlevrad(k).gt.tplanckmax) then
+            print*,'Maximum temperature is outside the boundaries for'
+            print*,'Planck function integration set in callphys.def, aborting.'
+            print*,"k=",k," tlevrad(k)=",tlevrad(k)
+            print*,"tplanckmax=",tplanckmax
+            message="Maximum temperature outside Planck function bounds - Change tplanckmax in callphys.def"
+            call abort_physic(subname,message,1)
+          endif
+
       enddo
+
       do k=1,L_NLAYRAD+1
          if(tmid(k).lt.tgasmin)then
Index: trunk/LMDZ.TITAN/libf/phytitan/callkeys_mod.F90
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/callkeys_mod.F90	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/callkeys_mod.F90	(revision 2366)
@@ -60,4 +60,9 @@
       real,save :: szangle
 !$OMP THREADPRIVATE(szangle)
+
+      real,save :: tplanckmin
+      real,save :: tplanckmax
+      real,save :: dtplanck
+!$OMP THREADPRIVATE(tplanckmin,tplanckmax,dtplanck)
       real,save :: Fat1AU
       real,save :: stelTbb
@@ -76,5 +81,6 @@
       real,save :: surfemis
 !$OMP THREADPRIVATE(surfalbedo,surfemis)
-
+      real,save :: noseason_day
+!$OMP THREADPRIVATE(noseason_day)
       logical,save :: iscallphys=.false.!existence of callphys.def
 !$OMP THREADPRIVATE(iscallphys)
Index: trunk/LMDZ.TITAN/libf/phytitan/comsaison_h.F90
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/comsaison_h.F90	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/comsaison_h.F90	(revision 2366)
@@ -4,10 +4,13 @@
        implicit none 
 
-       integer isaison
-       logical callsais
-       real dist_star,declin,right_ascen
+!       integer,save :: isaison
+!       logical,save :: callsais
+!!$OMP THREADPRIVATE(isaison,callsais)
+
+       real,save :: dist_star,declin,right_ascen
+!$OMP THREADPRIVATE(dist_star,declin,right_ascen)
 
        real, allocatable, dimension(:) :: mu0,fract
-!$OMP THREADPRIVATE(isaison,callsais,dist_star,declin,mu0,fract)
+!$OMP THREADPRIVATE(mu0,fract)
 
        end module comsaison_h
Index: trunk/LMDZ.TITAN/libf/phytitan/dyn1d/abort_gcm.F
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/dyn1d/abort_gcm.F	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/dyn1d/abort_gcm.F	(revision 2366)
@@ -1,1 +1,1 @@
-link ../../dyn3d/abort_gcm.F
+link ../../../../LMDZ.COMMON/libf/dyn3d/abort_gcm.F
Index: trunk/LMDZ.TITAN/libf/phytitan/dyn1d/comconst_mod.F90
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/dyn1d/comconst_mod.F90	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/dyn1d/comconst_mod.F90	(revision 2366)
@@ -1,1 +1,1 @@
-link ../../dyn3d/comconst_mod.F90
+link ../../../../LMDZ.COMMON/libf/dyn3d_common/comconst_mod.F90
Index: trunk/LMDZ.TITAN/libf/phytitan/dyn1d/comgeom.h
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/dyn1d/comgeom.h	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/dyn1d/comgeom.h	(revision 2366)
@@ -1,1 +1,1 @@
-link ../../dyn3d/comgeom.h
+link ../../../../LMDZ.COMMON/libf/dyn3d_common/comgeom.h
Index: trunk/LMDZ.TITAN/libf/phytitan/dyn1d/comvert_mod.F90
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/dyn1d/comvert_mod.F90	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/dyn1d/comvert_mod.F90	(revision 2366)
@@ -1,1 +1,1 @@
-link ../../dyn3d/comvert_mod.F90
+link ../../../../LMDZ.COMMON/libf/dyn3d_common/comvert_mod.F90
Index: trunk/LMDZ.TITAN/libf/phytitan/dyn1d/control_mod.F90
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/dyn1d/control_mod.F90	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/dyn1d/control_mod.F90	(revision 2366)
@@ -1,1 +1,1 @@
-link ../../dyn3d/control_mod.F90
+link ../../../../LMDZ.COMMON/libf/dyn3d_common/control_mod.F90
Index: trunk/LMDZ.TITAN/libf/phytitan/dyn1d/disvert.F
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/dyn1d/disvert.F	(revision 2365)
+++ 	(revision )
@@ -1,1 +1,0 @@
-link ../../dyn3d/disvert.F
Index: trunk/LMDZ.TITAN/libf/phytitan/dyn1d/disvert_noterre.F
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/dyn1d/disvert_noterre.F	(revision 2366)
+++ trunk/LMDZ.TITAN/libf/phytitan/dyn1d/disvert_noterre.F	(revision 2366)
@@ -0,0 +1,1 @@
+link ../../../../LMDZ.COMMON/libf/dyn3d_common/disvert_noterre.F
Index: trunk/LMDZ.TITAN/libf/phytitan/dyn1d/ener_mod.F90
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/dyn1d/ener_mod.F90	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/dyn1d/ener_mod.F90	(revision 2366)
@@ -1,1 +1,1 @@
-link ../../dyn3d/ener_mod.F90
+link ../../../../LMDZ.COMMON/libf/dyn3d_common/ener_mod.F90
Index: trunk/LMDZ.TITAN/libf/phytitan/dyn1d/infotrac.F90
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/dyn1d/infotrac.F90	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/dyn1d/infotrac.F90	(revision 2366)
@@ -1,1 +1,1 @@
-link ../../dyn3d/infotrac.F90
+link ../../../../LMDZ.COMMON/libf/dyn3d_common/infotrac.F90
Index: trunk/LMDZ.TITAN/libf/phytitan/dyn1d/logic_mod.F90
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/dyn1d/logic_mod.F90	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/dyn1d/logic_mod.F90	(revision 2366)
@@ -1,1 +1,1 @@
-link ../../dyn3d/logic_mod.F90
+link ../../../../LMDZ.COMMON/libf/dyn3d/logic_mod.F90
Index: trunk/LMDZ.TITAN/libf/phytitan/dyn1d/mod_const_mpi.F90
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/dyn1d/mod_const_mpi.F90	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/dyn1d/mod_const_mpi.F90	(revision 2366)
@@ -1,1 +1,1 @@
-link ../../dyn3d/mod_const_mpi.F90
+link ../../../../LMDZ.COMMON/libf/dyn3d/mod_const_mpi.F90
Index: trunk/LMDZ.TITAN/libf/phytitan/dyn1d/paramet.h
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/dyn1d/paramet.h	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/dyn1d/paramet.h	(revision 2366)
@@ -1,1 +1,1 @@
-link ../../dyn3d/paramet.h
+link ../../../../LMDZ.COMMON/libf/dyn3d_common/paramet.h
Index: trunk/LMDZ.TITAN/libf/phytitan/dyn1d/rcm1d.F
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/dyn1d/rcm1d.F	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/dyn1d/rcm1d.F	(revision 2366)
@@ -28,5 +28,5 @@
      &                       presnivs,pseudoalt,scaleheight
       USE vertical_layers_mod, ONLY: init_vertical_layers
-      USE logic_mod, ONLY: hybrid,autozlevs
+      USE logic_mod, ONLY: hybrid
       use regular_lonlat_mod, only: init_regular_lonlat
       use planete_mod, only: ini_planete_mod
@@ -35,4 +35,5 @@
       use mod_interface_dyn_phys, only: init_interface_dyn_phys
       use inifis_mod, only: inifis
+      use phys_state_var_mod, only: phys_state_var_init
       use physiq_mod, only: physiq
       implicit none
@@ -118,4 +119,5 @@
 
 !     added by RW for autozlevs computation
+      logical autozlevs
       real nu, xx, pMIN, zlev, Htop
       real logplevs(llm)
@@ -132,23 +134,20 @@
 c INITIALISATION
 c=======================================================================
-! initialize "serial/parallel" related stuff
-!      CALL init_phys_lmdz(iim,jjm+1,llm,1,(/(jjm-1)*iim+2/))
-!      CALL init_phys_lmdz(1,1,llm,1,(/1/))
-!      call initcomgeomphy
-
-      !! those are defined in surfdat_h.F90
-      IF (.not. ALLOCATED(albedodat)) ALLOCATE(albedodat(1))
-      IF (.not. ALLOCATED(phisfi)) ALLOCATE(phisfi(1))
-      IF (.not. ALLOCATED(zmea)) ALLOCATE(zmea(1))
-      IF (.not. ALLOCATED(zstd)) ALLOCATE(zstd(1))
-      IF (.not. ALLOCATED(zsig)) ALLOCATE(zsig(1))
-      IF (.not. ALLOCATED(zgam)) ALLOCATE(zgam(1))
-      IF (.not. ALLOCATED(zthe)) ALLOCATE(zthe(1))
-      !! those are defined in comdiurn_h.F90
-      IF (.not.ALLOCATED(sinlat)) ALLOCATE(sinlat(1))
-      IF (.not.ALLOCATED(coslat)) ALLOCATE(coslat(1))
-      IF (.not.ALLOCATED(sinlon)) ALLOCATE(sinlon(1))
-      IF (.not.ALLOCATED(coslon)) ALLOCATE(coslon(1))
-
+
+      ! read nq from traceur.def
+      open(90,file='traceur.def',status='old',form='formatted',
+     &       iostat=ierr)
+      if (ierr.eq.0) then
+        read(90,*,iostat=ierr) nq
+      else
+        nq=0
+      endif
+      close(90)
+      
+      ! Initialize dimphy module
+      call init_dimphy(1,llm) 
+      ! now initialize arrays using phys_state_var_init
+      call phys_state_var_init(nq)
+      
       saveprofile=.false.
       saveprofile=.true.
@@ -480,5 +479,5 @@
 !      call init_vertical_layers(nlayer,preff,scaleheight,
 !     &                      ap,bp,aps,bps,presnivs,pseudoalt)
-      call init_dimphy(1,nlayer) ! Initialize dimphy module
+!      call init_dimphy(1,nlayer) ! Initialize dimphy module
       call ini_planete_mod(nlayer,preff,ap,bp)
 
@@ -643,5 +642,5 @@
       endif
 
-      call disvert
+      call disvert_noterre
       ! now that disvert has been called, initialize module vertical_layers_mod
       call init_vertical_layers(nlayer,preff,scaleheight,
@@ -669,4 +668,6 @@
          ENDDO
          
+
+
          DO ilayer=1,nlayer
 !     zlay(ilayer)=-300.E+0 *r*log(play(ilayer)/plev(1))
Index: trunk/LMDZ.TITAN/libf/phytitan/dyn1d/serre_mod.F90
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/dyn1d/serre_mod.F90	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/dyn1d/serre_mod.F90	(revision 2366)
@@ -1,1 +1,1 @@
-link ../../dyn3d/serre_mod.F90
+link ../../../../LMDZ.COMMON/libf/dyn3d_common/serre_mod.F90
Index: trunk/LMDZ.TITAN/libf/phytitan/gfluxi.F
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/gfluxi.F	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/gfluxi.F	(revision 2366)
@@ -85,6 +85,6 @@
          LAMDA(L) = ALPHA(L)*(1.0D0-W0(L)*COSBAR(L))/UBARI
          
-         NT    = int(TLEV(2*L)*NTfac)   - NTstar+1
-         NT2   = int(TLEV(2*L+2)*NTfac) - NTstar+1
+         NT    = int(TLEV(2*L)*NTfac)   - NTstart+1
+         NT2   = int(TLEV(2*L+2)*NTfac) - NTstart+1
          
 ! AB : PLANCKIR(NW,NT) is replaced by P1, the linear interpolation result for a temperature NT
@@ -112,13 +112,13 @@
       ! -- same results for most thin atmospheres
       ! -- and stabilizes integrations
-      NT    = int(TLEV(2*L+1)*NTfac) - NTstar+1
+      NT    = int(TLEV(2*L+1)*NTfac) - NTstart+1
       !! For deep, opaque, thick first layers (e.g. Saturn)
       !! what is below works much better, not unstable, ...
       !! ... and actually fully accurate because 1st layer temp (JL) 
-      !NT    = int(TLEV(2*L)*NTfac) - NTstar+1
+      !NT    = int(TLEV(2*L)*NTfac) - NTstart+1
       !! (or this one yields same results
-      !NT    = int( (TLEV(2*L)+TLEV(2*L+1))*0.5*NTfac ) - NTstar+1
-      
-      NT2   = int(TLEV(2*L)*NTfac)   - NTstar+1
+      !NT    = int( (TLEV(2*L)+TLEV(2*L+1))*0.5*NTfac ) - NTstart+1
+      
+      NT2   = int(TLEV(2*L)*NTfac)   - NTstart+1
       
 ! AB : PLANCKIR(NW,NT) is replaced by P1, the linear interpolation result for a temperature NT
Index: trunk/LMDZ.TITAN/libf/phytitan/inifis_mod.F90
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/inifis_mod.F90	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/inifis_mod.F90	(revision 2366)
@@ -11,5 +11,4 @@
   use init_print_control_mod, only: init_print_control
   use radinc_h, only: ini_radinc_h
-  use datafile_mod
   use comdiurn_h, only: sinlat, coslat, sinlon, coslon
   use comgeomfi_h, only: totarea, totarea_planet
@@ -59,4 +58,5 @@
 !   declarations:
 !   -------------
+  use datafile_mod
   use ioipsl_getin_p_mod, only: getin_p
   IMPLICIT NONE
@@ -90,5 +90,7 @@
 
   ! Initialize some "temporal and calendar" related variables
+#ifndef MESOSCALE
   CALL init_time(day_ini,pdaysec,nday,ptimestep)
+#endif
 
   ! read in some parameters from "run.def" for physics,
@@ -147,4 +149,9 @@
      call getin_p("season",season)
      write(*,*) " season = ",season
+     
+     write(*,*) "No seasonal cycle: initial day to lock the run during restart"
+     noseason_day=0.0 ! default value
+     call getin_p("noseason_day",noseason_day)
+     write(*,*) "noseason_day=", noseason_day
 
      write(*,*) "Tidally resonant rotation ?"
@@ -276,4 +283,19 @@
      write(*,*) "strictboundcorrk = ",strictboundcorrk
 
+     write(*,*) "Minimum atmospheric temperature for Planck function integration ?"
+     tplanckmin=30.0 ! default value
+     call getin_p("tplanckmin",tplanckmin)
+     write(*,*) " tplanckmin = ",tplanckmin
+ 
+     write(*,*) "Maximum atmospheric temperature for Planck function integration ?"
+     tplanckmax=1500.0 ! default value
+     call getin_p("tplanckmax",tplanckmax)
+     write(*,*) " tplanckmax = ",tplanckmax
+ 
+     write(*,*) "Temperature step for Planck function integration ?"
+     dtplanck=0.1 ! default value
+     call getin_p("dtplanck",dtplanck)
+     write(*,*) " dtplanck = ",dtplanck
+ 
      write(*,*) "call gaseous absorption in the visible bands?", &
                     "(matters only if callrad=T)"
@@ -548,9 +570,7 @@
      endif ! of if (force_cpp)
      
-     
      call su_gases(nlayer,tracer)     
-     call calc_cpp_mugaz
-     
-     
+     call calc_cpp_mugaz 
+
      PRINT*,'--------------------------------------------'
      PRINT*
@@ -579,4 +599,5 @@
 
   ! Initializations for comgeomfi_h
+#ifndef MESOSCALE
   totarea=SSUM(ngrid,parea,1)
   call planetwide_sumval(parea,totarea_planet)
@@ -594,11 +615,11 @@
      coslon(ig)=cos(plon(ig))
   ENDDO
-
+#endif
   ! initialize variables in radinc_h
-  call ini_radinc_h(nlayer)
+  call ini_radinc_h(nlayer,tplanckmin,tplanckmax,dtplanck)
  
   ! allocate "comsoil_h" arrays
   call ini_comsoil_h(ngrid)
-      
+    
   END SUBROUTINE inifis
 
Index: trunk/LMDZ.TITAN/libf/phytitan/optcv.F90
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/optcv.F90	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/optcv.F90	(revision 2366)
@@ -11,5 +11,4 @@
                           callclouds,callmufi,seashaze,uncoupl_optic_haze
   use tracer_h, only: nmicro,nice
-  use MMP_OPTICS
 
   implicit none
Index: trunk/LMDZ.TITAN/libf/phytitan/phys_state_var_mod.F90
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/phys_state_var_mod.F90	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/phys_state_var_mod.F90	(revision 2366)
@@ -10,12 +10,18 @@
 ! Declaration des variables
       USE dimphy, only : klon,klev
+      use comchem_h, only: nkim
+      USE callkeys_mod, only: callchim
       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 surfdat_h, only: phisfi, albedodat,  &
+                        zmea, zstd, zsig, zgam, zthe
       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,allocatable,dimension(:,:),save :: ztprevious ! Previous loop Atmospheric Temperature (K)
+! Useful for Dynamical Heating calculation.
+      real,allocatable,dimension(:,:),save :: zuprevious
+!$OMP THREADPRIVATE(ztprevious,zuprevious)
 
       real, dimension(:),allocatable,save ::  tsurf                ! Surface temperature (K).
@@ -40,5 +46,4 @@
       real,dimension(:),allocatable,save :: fluxgrd     ! Surface conduction flux (W.m-2).
       real,dimension(:,:),allocatable,save :: qsurf     ! Tracer on surface (e.g. kg.m-2).
-
 !$OMP THREADPRIVATE(emis,dtrad,fluxrad_sky,fluxrad,capcal,fluxgrd,qsurf,q2)
 
@@ -48,4 +53,5 @@
       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).
+!$OMP THREADPRIVATE(fluxsurf_lw,fluxsurf_sw,fluxsurfabs_sw)
 
       real,dimension(:),allocatable,save :: fluxtop_lw      ! Outgoing LW (IR) flux to space (W.m-2).
@@ -53,4 +59,5 @@
       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).
+!$OMP THREADPRIVATE(fluxtop_lw,fluxabs_sw,fluxtop_dn,fluxdyn)
 
       real,dimension(:,:),allocatable,save :: OLR_nu        ! Outgoing LW radiation in each band (Normalized to the band width (W/m2/cm-1)).
@@ -59,12 +66,16 @@
       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).
+!$OMP THREADPRIVATE(OLR_nu,OSR_nu,zdtlw,zdtsw)
+
       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 ().
-
-!$OMPTHREADPRIVATE(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))
+!$OMP THREADPRIVATE(int_dtaui,int_dtauv) 
 
       real,allocatable,dimension(:,:),save :: qsurf_hist
 !$OMP THREADPRIVATE(qsurf_hist)
+
+      ! For chemistry
+      real, dimension(:,:,:), allocatable, save   :: dycchi  ! NB : Only for chem tracers. Saved since chemistry is not called every step.
+!$OMP THREADPRIVATE(dycchi)
  
 CONTAINS
@@ -119,4 +130,5 @@
         ALLOCATE(int_dtaui(klon,klev,L_NSPECTI))
         ALLOCATE(int_dtauv(klon,klev,L_NSPECTV))
+        allocate(dycchi(klon,klev,nkim))
         ! This is defined in comsaison_h
         ALLOCATE(mu0(klon))
@@ -126,4 +138,12 @@
         ALLOCATE(gzlat_ig(klev))
         ALLOCATE(Cmk(klev))
+        ! This is defined in surfdat_h
+        ALLOCATE(albedodat(klon))
+        ALLOCATE(phisfi(klon))
+        ALLOCATE(zmea(klon))
+        ALLOCATE(zstd(klon))
+        ALLOCATE(zsig(klon))
+        ALLOCATE(zgam(klon))
+        ALLOCATE(zthe(klon))
         ! This is defined in turb_mod
         allocate(wstar(klon))
@@ -171,4 +191,5 @@
         DEALLOCATE(int_dtaui)
         DEALLOCATE(int_dtauv)
+        DEALLOCATE(dycchi)
         DEALLOCATE(mu0)
         DEALLOCATE(fract)
@@ -176,4 +197,11 @@
         DEALLOCATE(gzlat_ig)
         DEALLOCATE(Cmk)
+        DEALLOCATE(phisfi)
+        DEALLOCATE(albedodat)
+        DEALLOCATE(zmea)
+        DEALLOCATE(zstd)
+        DEALLOCATE(zsig)
+        DEALLOCATE(zgam)
+        DEALLOCATE(zthe)
         deallocate(wstar)
         deallocate(ustar)
Index: trunk/LMDZ.TITAN/libf/phytitan/physiq_mod.F90
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/physiq_mod.F90	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/physiq_mod.F90	(revision 2366)
@@ -16,5 +16,4 @@
       use radinc_h, only : L_NSPECTI,L_NSPECTV
       use radcommon_h, only: sigma, gzlat, grav, BWNV
-      use surfdat_h, only: phisfi, zmea, zstd, zsig, zgam, zthe
       use comchem_h, only: nkim, cnames, nlaykim_up, ykim_up, ykim_tot, botCH4
       use comdiurn_h, only: coslat, sinlat, coslon, sinlon
@@ -34,7 +33,9 @@
       use comcstfi_mod, only: pi, g, rcp, r, rad, mugaz, cpp
       use time_phylmdz_mod, only: daysec
+#ifndef MESOSCALE
       use logic_mod, only: moyzon_ch
       use moyzon_mod, only:  zphibar, zphisbar, zplevbar, zplaybar, &
                              zzlevbar, zzlaybar, ztfibar, zqfibar
+#endif
       use callkeys_mod
       use phys_state_var_mod
@@ -42,5 +43,4 @@
 #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
@@ -56,5 +56,4 @@
       use wxios, only: wxios_context_init, xios_context_finalize
 #endif
-      use MMP_OPTICS
       use muphy_diag
       implicit none
@@ -177,5 +176,4 @@
 !   -------
 
-
       integer,intent(in) :: ngrid             ! Number of atmospheric columns.
       integer,intent(in) :: nlayer            ! Number of atmospheric layers.
@@ -211,8 +209,7 @@
 ! Local saved variables:
 ! ----------------------
-
       integer,save :: day_ini                                      ! Initial date of the run (sol since Ls=0).
       integer,save :: icount                                       ! Counter of calls to physiq during the run.
-
+!$OMP THREADPRIVATE(day_ini,icount)
 
 ! Local variables :
@@ -289,5 +286,4 @@
 
 
-
 ! local variables for DIAGNOSTICS : (diagfi & stat)
 ! -------------------------------------------------
@@ -299,5 +295,4 @@
       real zdtdyn(ngrid,nlayer)                          ! Dynamical Heating (K/s).
       real zdudyn(ngrid,nlayer)                          ! Dynamical Zonal Wind tendency (m.s-2).
-!$OMP THREADPRIVATE(ztprevious,zuprevious)
 
       real zhorizwind(ngrid,nlayer) ! Horizontal Wind ( sqrt(u**+v*v))
@@ -329,6 +324,4 @@
       real tf, ntf    
 
-!$OMP THREADPRIVATE(qsurf_hist)
-   
       ! Miscellaneous :
       character(len=10) :: tmp1
@@ -336,4 +329,6 @@
       
       character*2 :: str2
+
+#ifndef MESOSCALE
 
 ! Local variables for Titan chemistry and microphysics
@@ -348,6 +343,4 @@
 
       ! Molar fraction tendencies ( chemistry, condensation and evaporation ) for tracers (mol/mol/s)
-      real, dimension(:,:,:), allocatable, save   :: dycchi         ! NB : Only for chem tracers. Saved since chemistry is not called every step.
-!$OMP THREADPRIVATE(dycchi)
       real, dimension(ngrid,nlayer,nq)            :: dyccond        ! Condensation rate. NB : for all tracers, as we want to use indx on it.
       real, dimension(ngrid,nlayer,nq)            :: dyccondbar     ! For 2D chemistry
@@ -360,7 +353,9 @@
       real :: i2e(ngrid,nlayer)      ! int 2 ext factor ( X.kg-1 -> X.m-3 for diags )
 
+#ifdef USE_QTEST
       real,save,dimension(:,:,:), allocatable :: tpq ! Tracers for decoupled microphysical tests ( temporary in 01/18 )
 !$OMP THREADPRIVATE(tpq)
       real,dimension(ngrid,nlayer,nq) :: dtpq ! (temporary in 01/18)
+#endif
 
       logical file_ok
@@ -385,4 +380,6 @@
       END SUBROUTINE calmufi
     END INTERFACE
+
+#endif
       
 !==================================================================================================
@@ -396,8 +393,9 @@
 ! --------------------------------
       if (firstcall) then
-#ifndef MESOSCALE
+
+#ifdef USE_QTEST
         allocate(tpq(ngrid,nlayer,nq))
         tpq(:,:,:) = pq(:,:,:)
-
+#endif
         ! Initialisation of nmicro as well as tracers names, indexes ...
         if (ngrid.ne.1) then ! Already done in rcm1d
@@ -405,6 +403,7 @@
         endif
 
-        call phys_state_var_init(nq)
-
+        ! Allocate saved arrays (except for 1D model, where this has already been done)
+#ifndef MESOSCALE
+        if (ngrid>1) call phys_state_var_init(nq)
 #endif
 
@@ -453,4 +452,5 @@
          endif
 
+#ifndef MESOSCALE
 !        Initialize names and timestep for chemistry
 !        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -463,7 +463,5 @@
                stop
             endif
-
-            allocate(dycchi(ngrid,nlayer,nkim)) ! only for chemical tracers
-            
+           
             ! Chemistry timestep
             ctimestep = ptimestep*REAL(ichim)
@@ -482,4 +480,5 @@
 
          ENDIF
+#endif
 
 #ifdef CPP_XIOS
@@ -492,5 +491,6 @@
 !        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 #ifndef MESOSCALE
-         call phyetat0(startphy_file,ngrid,nlayer,"startfi.nc",0,0,nsoilmx,nq,      &
+         call phyetat0(startphy_file,                                 &
+                       ngrid,nlayer,"startfi.nc",0,0,nsoilmx,nq,      &
                        day_ini,time_phys,tsurf,tsoil,emis,q2,qsurf,tankCH4)                       
 #else
@@ -498,4 +498,5 @@
          q2(:,:)=0.0
          qsurf(:,:)=0.0
+         tankCH4(:)=0.0
          day_ini = pday
 #endif
@@ -534,4 +535,5 @@
          call iniorbit(apoastr,periastr,year_day,peri_day,obliquit)
 
+
          if(tlocked)then
             print*,'Planet is tidally locked at resonance n=',nres
@@ -576,11 +578,10 @@
 
 #ifndef MESOSCALE
-         if (ngrid.ne.1) then
-            ! Note : no need to create a restart file in 1d.
+         if (ngrid.ne.1) then ! Note : no need to create a restart file in 1d.
             call physdem0("restartfi.nc",longitude,latitude,nsoilmx,ngrid,nlayer,nq, &
-                          ptimestep,pday+nday,time_phys,cell_area,          &
-                          albedo_bareground,inertiedat,zmea,zstd,zsig,zgam,zthe)
-         endif
-#endif
+                         ptimestep,pday+nday,time_phys,cell_area,          &
+                         albedo_bareground,inertiedat,zmea,zstd,zsig,zgam,zthe)
+         endif
+#endif         
          
          ! XIOS outputs
@@ -624,5 +625,5 @@
          call stellarlong(zday,zls)
       else
-         call stellarlong(float(day_ini),zls)
+         call stellarlong(noseason_day,zls)
       end if
 
@@ -686,4 +687,5 @@
       ! JVO 19 : We shall always have correct altitudes in chemistry no matter what's in physics
       ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#ifndef MESOSCALE
       if (moyzon_ch) then ! Zonal averages
          
@@ -716,4 +718,5 @@
 
       else !  if not moyzon
+#endif
       
         DO ig=1,ngrid
@@ -730,5 +733,7 @@
         ENDDO
 
+#ifndef MESOSCALE
       endif  ! moyzon
+#endif
 
       ! -------------------------------------------------------------------------------------
@@ -1028,4 +1033,8 @@
       if (tracer) then
 
+
+#ifndef MESOSCALE
+!! JVO 20 : For now, no chemistry or microphysics in MESOSCALE, but why not in the future ?
+
   ! -------------------
   !   V.1 Microphysics
@@ -1195,4 +1204,6 @@
             
          endif ! end of 'callchim'
+
+#endif
 
   ! ---------------
Index: trunk/LMDZ.TITAN/libf/phytitan/radcommon_h.F90
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/radcommon_h.F90	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/radcommon_h.F90	(revision 2366)
@@ -1,4 +1,4 @@
 module radcommon_h
-      use radinc_h, only: L_NSPECTI, L_NSPECTV, NTstar, NTstop
+      use radinc_h, only: L_NSPECTI, L_NSPECTV, NTstart, NTstop
       implicit none
 
@@ -78,5 +78,5 @@
       REAL,SAVE :: tstellar ! Stellar brightness temperature (SW)
 
-      real*8,save :: planckir(L_NSPECTI,NTstop-NTstar+1)
+      REAL*8, DIMENSION(:,:), ALLOCATABLE, SAVE :: planckir
 
       real*8,save :: PTOP
Index: trunk/LMDZ.TITAN/libf/phytitan/radinc_h.F90
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/radinc_h.F90	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/radinc_h.F90	(revision 2366)
@@ -72,26 +72,33 @@
 
       ! For Planck function integration: 
-      ! equivalent temperatures are 1/NTfac of these values
-      integer, parameter :: NTstar = 500
-      integer, parameter :: NTstop = 15000 ! new default for all non hot Jupiter runs
-      real*8, parameter :: NTfac = 1.0D+1  
-      !integer, parameter :: NTstar = 1000
-      !integer, parameter :: NTstop = 25000
-      !real*8,parameter :: NTfac = 5.0D+1    
-      !integer, parameter :: NTstar = 2000
-      !integer, parameter :: NTstop = 50000
-      !real*8,parameter :: NTfac = 1.0D+2    
+      ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+      ! Integration boundary temperatures are NTstart/NTfac and Ntstop/NTfac
+      ! -- JVO 20 : Now read boundary T and integration dT as inputs in callphys.def
+      !             NTstart, Nstop and NTfac then set by ini_radinc_h
+      !             Smart user can adjust values depending he's running hot or cold atm
+      !             Default is wide range : 30K-1500K, with 0.1K step
+      !             ->  NTstart=300, Nstop=15000, NTfac=10
+      integer :: NTstart, NTstop
+      real*8  :: NTfac
+
 
 contains
 
-  subroutine ini_radinc_h(nbp_lev)
+  subroutine ini_radinc_h(nbp_lev,tplanckmin,tplanckmax,dtplanck)
   ! Initialize module variables
   implicit none
   integer,intent(in) :: nbp_lev
+  real*8, intent(in) :: tplanckmin
+  real*8, intent(in) :: tplanckmax
+  real*8, intent(in) :: dtplanck
   
   L_NLAYRAD = nbp_lev
-  L_LEVELS = 2*(nbp_lev-1)+3
+  L_LEVELS  = 2*(nbp_lev-1)+3
   L_NLEVRAD = nbp_lev+1
-  
+
+  NTfac   = 1.D0 / dtplanck
+  NTstart = int(tplanckmin * NTfac)
+  NTstop  = int(tplanckmax * NTfac)
+ 
   end subroutine
 
Index: trunk/LMDZ.TITAN/libf/phytitan/setspi.F90
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/setspi.F90	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/setspi.F90	(revision 2366)
@@ -22,5 +22,5 @@
 !==================================================================
 
-      use radinc_h,    only: L_NSPECTI,NTstar,NTstop,NTfac
+      use radinc_h,    only: L_NSPECTI,NTstart,NTstop,NTfac
       use radcommon_h, only: BWNI,WNOI,DWNI,WAVEI,planckir,sigma
       use datafile_mod, only: datadir, corrkdir, banddir
@@ -151,5 +151,7 @@
       print*,''
       print*,'setspi: Current Planck integration range:'
-      print*,'T = ',dble(NTstar)/NTfac, ' to ',dble(NTstop)/NTfac,' K.'
+      print*,'T = ',dble(NTstart)/NTfac, ' to ',dble(NTstop)/NTfac,' K.'
+
+      IF(.NOT.ALLOCATED(planckir)) ALLOCATE(planckir(L_NSPECTI,NTstop-NTstart+1))
 
       do NW=1,L_NSPECTI
@@ -158,5 +160,5 @@
          bpa = (b+a)/2.0D0
          bma = (b-a)/2.0D0
-         do nt=NTstar,NTstop
+         do nt=NTstart,NTstop
             T   = dble(NT)/NTfac
             ans = 0.0D0
@@ -167,5 +169,5 @@
             end do
 
-            planckir(NW,nt-NTstar+1) = ans*bma/(PI*DWNI(NW))
+            planckir(NW,nt-NTstart+1) = ans*bma/(PI*DWNI(NW))
          end do
       end do
@@ -174,5 +176,5 @@
       if(forceEC)then
          print*,'setspi: Force F=sigma*eps*T^4 for all values of T!'
-         do nt=NTstar,NTstop
+         do nt=NTstart,NTstop
             plancksum=0.0D0
             T=dble(NT)/NTfac
@@ -180,10 +182,10 @@
             do NW=1,L_NSPECTI
                plancksum=plancksum+  &
-                  planckir(NW,nt-NTstar+1)*DWNI(NW)*pi
+                  planckir(NW,nt-NTstart+1)*DWNI(NW)*pi
             end do
 
             do NW=1,L_NSPECTI
-               planckir(NW,nt-NTstar+1)=     &
-                  planckir(NW,nt-NTstar+1)*  &
+               planckir(NW,nt-NTstart+1)=     &
+                  planckir(NW,nt-NTstart+1)*  &
                           sigma*(dble(nt)/NTfac)**4/plancksum
             end do
@@ -194,7 +196,7 @@
          ! check energy conservation at lower temperature boundary
          plancksum=0.0D0
-         nt=NTstar
+         nt=NTstart
          do NW=1,L_NSPECTI
-            plancksum=plancksum+planckir(NW,nt-NTstar+1)*DWNI(NW)*pi
+            plancksum=plancksum+planckir(NW,nt-NTstart+1)*DWNI(NW)*pi
          end do
          print*,'setspi: At lower limit:'
@@ -206,5 +208,5 @@
          nt=NTstop
          do NW=1,L_NSPECTI
-            plancksum=plancksum+planckir(NW,nt-NTstar+1)*DWNI(NW)*pi
+            plancksum=plancksum+planckir(NW,nt-NTstart+1)*DWNI(NW)*pi
          end do
          print*,'setspi: At upper limit:'
Index: trunk/LMDZ.TITAN/libf/phytitan/sfluxi.F
===================================================================
--- trunk/LMDZ.TITAN/libf/phytitan/sfluxi.F	(revision 2365)
+++ trunk/LMDZ.TITAN/libf/phytitan/sfluxi.F	(revision 2366)
@@ -67,6 +67,6 @@
       TSURF = TLEV(L_LEVELS)
 
-      NTS   = int(TSURF*NTfac)-NTstar+1
-      NTT   = int(TTOP *NTfac)-NTstar+1
+      NTS   = int(TSURF*NTfac)-NTstart+1
+      NTT   = int(TTOP *NTfac)-NTstart+1
 
 !JL12 corrects the surface planck function so that its integral is equal to sigma Tsurf^4
