Index: /trunk/LMDZ.MARS/libf/phymars/meso_inc/meso_inc_ini_restart.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/meso_inc/meso_inc_ini_restart.F	(revision 674)
+++ /trunk/LMDZ.MARS/libf/phymars/meso_inc/meso_inc_ini_restart.F	(revision 674)
@@ -0,0 +1,12 @@
+! Init soil temperatures
+       ! in meso_inc_ini
+! Init fluxrad
+       fluxrad(:)=wfluxrad(:)
+! Init co2ice
+       ! in meso_inc_ini
+! Init q2
+       ! in meso_inc_ini
+! Init qsurf
+       ! in meso_inc_ini
+! Init wstar
+       wstar(:)=wwstar(:)
Index: /trunk/LMDZ.MARS/libf/phymars/physiq.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/physiq.F	(revision 673)
+++ /trunk/LMDZ.MARS/libf/phymars/physiq.F	(revision 674)
@@ -368,7 +368,11 @@
          aerosol(:,:,:)=0
          dtrad(:,:)=0
+
+#ifndef MESOSCALE
          fluxrad(:)=0
-
          wstar(:)=0.
+#else
+#include "meso_inc/meso_inc_ini_restart.F"
+#endif
 
 c        read startfi 
@@ -1257,4 +1261,9 @@
 c  10. Write output files
 c  ----------------------
+
+c Save variables for eventual restart in MMM and LES
+#ifdef MESOSCALE
+#include "meso_inc/meso_inc_save_restart.F"
+#endif
 
 c    -------------------------------
Index: /trunk/MESOSCALE/LMD_MM_MARS/SRC/LES/modif_mars/Registry.EM
===================================================================
--- /trunk/MESOSCALE/LMD_MM_MARS/SRC/LES/modif_mars/Registry.EM	(revision 673)
+++ /trunk/MESOSCALE/LMD_MM_MARS/SRC/LES/modif_mars/Registry.EM	(revision 674)
@@ -224,5 +224,9 @@
 state  real   mars_cice       ij   misc  1  -  i012rd  "MARS_CICE"   "co2 ice"                 "kg"
 state  real   mars_wice       ij   misc  1  -  i012rd  "MARS_WICE"   "h2o ice"                 "kg/m2"
-state  real   mars_tsoil     ilj   misc  1  -  i012rd  "MARS_TSOIL"  "soil temperatures"       "K"
+state  real   mars_tsurf      ij   misc  1  -  i012rd  "MARS_TSURF"   "surface temperature" "K"
+state  real   mars_fluxrad    ij   misc  1  -  i012rd  "MARS_FLUXRAD" "net rad flux at surf"     "W.m-2"
+state  real   mars_wstar      ij   misc  1  -  i012rd  "MARS_WSTAR"   "free convection velocity" "m.s-1"
+state  real   mars_tsoil     ilj   misc  1  -  i012rd  "MARS_TSOIL"   "soil temperatures"        "K"
+state  real   mars_q2        ikj   misc  1  Z  i012rd  "MARS_Q2"      "turbulent kinetic energy" "kg.m-3"
 state  real   mars_isoil     ilj   misc  1  -  i012rd  "MARS_ISOIL"  "soil thermal inertia"    "tiu"
 state  real   mars_dsoil     ilj   misc  1  -  i012rd  "MARS_DSOIL"  "soil depths"             "m"
Index: /trunk/MESOSCALE/LMD_MM_MARS/SRC/LES/modif_mars/module_first_rk_step_part1.F
===================================================================
--- /trunk/MESOSCALE/LMD_MM_MARS/SRC/LES/modif_mars/module_first_rk_step_part1.F	(revision 673)
+++ /trunk/MESOSCALE/LMD_MM_MARS/SRC/LES/modif_mars/module_first_rk_step_part1.F	(revision 674)
@@ -622,4 +622,8 @@
      &        ,MARS_WICE=grid%mars_wice         &
      &        ,MARS_TSOIL=grid%mars_tsoil                                 &
+     &        ,MARS_Q2=grid%mars_q2                                       &
+     &        ,MARS_FLUXRAD=grid%mars_fluxrad                             &
+     &        ,MARS_WSTAR=grid%mars_wstar                                 &
+     &        ,MARS_TSURF=grid%mars_tsurf                                 &
 #ifdef NEWPHYS
      &        ,MARS_ISOIL=grid%mars_isoil       &
@@ -652,5 +656,5 @@
 #include "module_lmd_driver_output4.inc"
 #endif 
-     &        ,SLPX=grid%slpx,SLPY=grid%slpy)
+     &        ,SLPX=grid%slpx,SLPY=grid%slpy,RESTART=config_flags%restart)
 ENDIF
 !!!!!!!!!!!!!!!!!!!!!!!
Index: /trunk/MESOSCALE/LMD_MM_MARS/SRC/LES/modif_mars/module_initialize_les.F
===================================================================
--- /trunk/MESOSCALE/LMD_MM_MARS/SRC/LES/modif_mars/module_initialize_les.F	(revision 673)
+++ /trunk/MESOSCALE/LMD_MM_MARS/SRC/LES/modif_mars/module_initialize_les.F	(revision 674)
@@ -340,4 +340,10 @@
     grid%mars_cice(i,j)=0.
     grid%mars_wice(i,j)=0.
+!! >> Used for restarts only:
+    grid%mars_q2(i,:,j)=0.
+    grid%mars_fluxrad(i,j)=0.
+    grid%mars_wstar(i,j)=0.
+    grid%mars_tsurf(i,j)=0. 
+!! <<
     grid%slpx(i,j) = 0.
     grid%slpy(i,j) = 0.
Index: /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/Registry/Registry.EM
===================================================================
--- /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/Registry/Registry.EM	(revision 673)
+++ /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/Registry/Registry.EM	(revision 674)
@@ -228,16 +228,20 @@
 ####
 ############# in module_initialize ################## in solve_em and lmd_driver ############################### 
-state  real   albedo_gcm      ij   misc  1  -  i012rd  "MARS_ALB"    "albedo of naked ground"  "0 - 1 fraction"
-state  real   therm_inert     ij   misc  1  -  i012rd  "MARS_TI"     "thermal inertia"         "J/m2/K/s0.5"
-state  real   mars_z0         ij   misc  1  -  i012rd  "MARS_Z0"     "surface roughness"       "m"
-state  real   slpx            ij   misc  1  -  i012rd  "SLOPEX"      "slope x direction"       "rad"
-state  real   slpy            ij   misc  1  -  i012rd  "SLOPEY"      "slope y direction"       "rad"
-state  real   mars_emiss      ij   misc  1  -  i012rd  "MARS_EMISS"  "emissivity"              "0 - 1 fraction"
-state  real   mars_cice       ij   misc  1  -  i012rd  "MARS_CICE"   "co2 ice"                 "kg/m2"
-state  real   mars_wice       ij   misc  1  -  i012rd  "MARS_WICE"   "h2o ice"                 "kg/m2"
-state  real   mars_tsoil     ilj   misc  1  -  i012rd  "MARS_TSOIL"  "soil temperatures"       "K"
-state  real   mars_isoil     ilj   misc  1  -  i012rd  "MARS_ISOIL"  "soil thermal inertia"    "tiu"
-state  real   mars_dsoil     ilj   misc  1  -  i012rd  "MARS_DSOIL"  "soil depths"             "m"
-state  real   mars_gw        ilj   misc  1  -  i012rd  "MARS_GW"     "gwparam"                 " "
+state  real   albedo_gcm      ij   misc  1  -  i012rd  "MARS_ALB"     "albedo of naked ground"   "0 - 1 fraction"
+state  real   therm_inert     ij   misc  1  -  i012rd  "MARS_TI"      "thermal inertia"          "J/m2/K/s0.5"
+state  real   mars_z0         ij   misc  1  -  i012rd  "MARS_Z0"      "surface roughness"        "m"
+state  real   slpx            ij   misc  1  -  i012rd  "SLOPEX"       "slope x direction"        "rad"
+state  real   slpy            ij   misc  1  -  i012rd  "SLOPEY"       "slope y direction"        "rad"
+state  real   mars_emiss      ij   misc  1  -  i012rd  "MARS_EMISS"   "emissivity"               "0 - 1 fraction"
+state  real   mars_cice       ij   misc  1  -  i012rd  "MARS_CICE"    "co2 ice"                  "kg/m2"
+state  real   mars_wice       ij   misc  1  -  i012rd  "MARS_WICE"    "h2o ice"                  "kg/m2"
+state  real   mars_fluxrad    ij   misc  1  -  i012rd  "MARS_FLUXRAD" "net rad flux at surf"     "W.m-2"
+state  real   mars_wstar      ij   misc  1  -  i012rd  "MARS_WSTAR"   "free convection velocity" "m.s-1"
+state  real   mars_tsurf      ij   misc  1  -  i012rd  "MARS_TSURF"   "surface temperature" "K"
+state  real   mars_tsoil     ilj   misc  1  -  i012rd  "MARS_TSOIL"   "soil temperatures"        "K"
+state  real   mars_q2        ikj   misc  1  Z  i012rd  "MARS_Q2"      "turbulent kinetic energy" "kg.m-3"
+state  real   mars_isoil     ilj   misc  1  -  i012rd  "MARS_ISOIL"   "soil thermal inertia"     "tiu"
+state  real   mars_dsoil     ilj   misc  1  -  i012rd  "MARS_DSOIL"   "soil depths"              "m"
+state  real   mars_gw        ilj   misc  1  -  i012rd  "MARS_GW"      "gwparam"                  " "
 ####
 ####
Index: /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/call_meso_physiq1.inc
===================================================================
--- /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/call_meso_physiq1.inc	(revision 673)
+++ /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/call_meso_physiq1.inc	(revision 674)
@@ -14,5 +14,7 @@
 #endif
                wday_ini,                      &
-	       output_tab2d, output_tab3d, flag_LES)
+	       output_tab2d, output_tab3d,    &
+               wfluxrad,wwstar,               &
+               flag_LES)
 
 
Index: /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/call_meso_physiq2.inc
===================================================================
--- /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/call_meso_physiq2.inc	(revision 673)
+++ /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/call_meso_physiq2.inc	(revision 674)
@@ -17,5 +17,7 @@
 #endif
                wday_ini,                      &
-               output_tab2d, output_tab3d, flag_LES)
+               output_tab2d, output_tab3d,    &
+               wfluxrad,wwstar,               &
+               flag_LES)
 
        CASE(2)
@@ -29,5 +31,7 @@
 #endif
                wday_ini,                      &
-               output_tab2d, output_tab3d, flag_LES)
+               output_tab2d, output_tab3d,    &
+               wfluxrad,wwstar,               &
+               flag_LES)
 
 !       CASE(3:)
Index: /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/call_meso_physiq3.inc
===================================================================
--- /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/call_meso_physiq3.inc	(revision 673)
+++ /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/call_meso_physiq3.inc	(revision 674)
@@ -17,5 +17,7 @@
 #endif
                wday_ini,                      &
-               output_tab2d, output_tab3d, flag_LES)
+               output_tab2d, output_tab3d,    &
+               wfluxrad,wwstar,               &
+               flag_LES)
 
        CASE(2)
@@ -29,5 +31,7 @@
 #endif
                wday_ini,                      &
-               output_tab2d, output_tab3d, flag_LES)
+               output_tab2d, output_tab3d,    &
+               wfluxrad,wwstar,               &
+               flag_LES)
 
        CASE(3)
@@ -41,5 +45,7 @@
 #endif
                wday_ini,                      &
-               output_tab2d, output_tab3d, flag_LES)
+               output_tab2d, output_tab3d,    &
+               wfluxrad,wwstar,               &
+               flag_LES)
 
 !       CASE(3:)
Index: /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/call_meso_physiq4.inc
===================================================================
--- /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/call_meso_physiq4.inc	(revision 673)
+++ /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/call_meso_physiq4.inc	(revision 674)
@@ -17,5 +17,7 @@
 #endif
                wday_ini,                      &
-               output_tab2d, output_tab3d, flag_LES)
+               output_tab2d, output_tab3d,    &
+               wfluxrad,wwstar,               &
+               flag_LES)
 
        CASE(2)
@@ -29,5 +31,7 @@
 #endif
                wday_ini,                      &
-               output_tab2d, output_tab3d, flag_LES)
+               output_tab2d, output_tab3d,    &
+               wfluxrad,wwstar,               &
+               flag_LES)
 
        CASE(3)
@@ -41,5 +45,7 @@
 #endif
                wday_ini,                      &
-               output_tab2d, output_tab3d, flag_LES)
+               output_tab2d, output_tab3d,    &
+               wfluxrad,wwstar,               &
+               flag_LES)
 
        CASE(4)
@@ -53,6 +59,7 @@
 #endif
                wday_ini,                      &
-               output_tab2d, output_tab3d, flag_LES)
-
+               output_tab2d, output_tab3d,    &
+               wfluxrad,wwstar,               &
+               flag_LES)
 
 !       CASE(3:)
Index: /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/call_meso_physiq5.inc
===================================================================
--- /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/call_meso_physiq5.inc	(revision 673)
+++ /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/call_meso_physiq5.inc	(revision 674)
@@ -17,5 +17,7 @@
 #endif
                wday_ini,                      &
-               output_tab2d, output_tab3d, flag_LES)
+               output_tab2d, output_tab3d,    &
+               wfluxrad,wwstar,               &
+               flag_LES)
 
        CASE(2)
@@ -29,5 +31,7 @@
 #endif
                wday_ini,                      &
-               output_tab2d, output_tab3d, flag_LES)
+               output_tab2d, output_tab3d,    &
+               wfluxrad,wwstar,               &
+               flag_LES)
 
        CASE(3)
@@ -41,5 +45,7 @@
 #endif
                wday_ini,                      &
-               output_tab2d, output_tab3d, flag_LES)
+               output_tab2d, output_tab3d,    &
+               wfluxrad,wwstar,               &
+               flag_LES)
 
        CASE(4)
@@ -53,5 +59,7 @@
 #endif
                wday_ini,                      &
-               output_tab2d, output_tab3d, flag_LES)
+               output_tab2d, output_tab3d,    &
+               wfluxrad,wwstar,               &
+               flag_LES)
 
        CASE(5)
@@ -65,5 +73,7 @@
 #endif
                wday_ini,                      &
-               output_tab2d, output_tab3d, flag_LES)
+               output_tab2d, output_tab3d,    &
+               wfluxrad,wwstar,               &
+               flag_LES)
 
 
Index: /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/dyn_em/module_initialize_quarter_ss.F
===================================================================
--- /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/dyn_em/module_initialize_quarter_ss.F	(revision 673)
+++ /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/dyn_em/module_initialize_quarter_ss.F	(revision 674)
@@ -456,4 +456,10 @@
     grid%mars_cice(i,j)=0.
     grid%mars_wice(i,j)=0.
+!! >> Used for restarts only:
+    grid%mars_q2(i,:,j)=0.
+    grid%mars_fluxrad(i,j)=0.
+    grid%mars_wstar(i,j)=0.
+    grid%mars_tsurf(i,j)=0.
+!! <<
     write(6,*) 'NOTE TO SELF. slpx and slpy set to 0 which means no slope insolation.'
     grid%slpx(i,j) = 0.
Index: /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/dyn_em/module_initialize_real.F
===================================================================
--- /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/dyn_em/module_initialize_real.F	(revision 673)
+++ /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/dyn_em/module_initialize_real.F	(revision 674)
@@ -278,4 +278,10 @@
               grid%mars_cice(i,j)=grid%st010040(i,j)
               grid%mars_wice(i,j)=grid%sm100200(i,j)
+!! >> Used for restarts only:
+              grid%mars_q2(i,:,j)=0.
+              grid%mars_fluxrad(i,j)=0.
+              grid%mars_wstar(i,j)=0.
+              grid%mars_tsurf(i,j)=0. 
+!! <<
                   !! one more security ... co2ice cannot be negative
                   IF (grid%mars_cice(i,j) .lt. 0.) grid%mars_cice(i,j)=0.
Index: /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/dyn_em/solve_em.F
===================================================================
--- /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/dyn_em/solve_em.F	(revision 673)
+++ /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/dyn_em/solve_em.F	(revision 674)
@@ -863,4 +863,8 @@
      &        ,MARS_WICE=grid%mars_wice         &
      &        ,MARS_TSOIL=grid%mars_tsoil       &
+     &        ,MARS_Q2=grid%mars_q2             &
+     &        ,MARS_FLUXRAD=grid%mars_fluxrad   &
+     &        ,MARS_WSTAR=grid%mars_wstar       &
+     &        ,MARS_TSURF=grid%mars_tsurf       &
 #ifdef NEWPHYS
      &        ,MARS_ISOIL=grid%mars_isoil       &
@@ -889,5 +893,5 @@
 #include "module_lmd_driver_output4.inc"
 #endif
-     &        ,SLPX=grid%slpx,SLPY=grid%slpy)
+     &        ,SLPX=grid%slpx,SLPY=grid%slpy,RESTART=config_flags%restart)
 ENDIF
 
Index: /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/phys/module_lmd_driver.F
===================================================================
--- /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/phys/module_lmd_driver.F	(revision 673)
+++ /trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/phys/module_lmd_driver.F	(revision 674)
@@ -32,4 +32,8 @@
         MARS_WICE, &
         MARS_TSOIL, &
+        MARS_Q2, &
+        MARS_FLUXRAD, &
+        MARS_WSTAR, &
+        MARS_TSURF, &
 #ifdef NEWPHYS
         MARS_ISOIL, &
@@ -53,5 +57,5 @@
 #include "module_lmd_driver_output1.inc"
 #endif
-        SLPX,SLPY)
+        SLPX,SLPY,RESTART)
 ! NB: module_lmd_driver_output1.inc : output arguments generated from Registry
 
@@ -115,10 +119,14 @@
      MSFT,MSFU,MSFV, &
      XLAT,XLONG,HT,  &
-     MARS_ALB,MARS_TI,MARS_EMISS,MARS_CICE, &
-     MARS_WICE, &
+     MARS_ALB,MARS_TI,MARS_EMISS, &
      SLPX,SLPY
+REAL, DIMENSION( ims:ime, jms:jme ), INTENT(INOUT   )  :: &
+     MARS_CICE,MARS_WICE, &
+     MARS_FLUXRAD,MARS_WSTAR,MARS_TSURF
 ! 3D arrays 
 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), INTENT(IN ) :: &
      dz8w,p8w,p,exner,t,t8w,rho,u,v,w,z,th
+REAL, DIMENSION( ims:ime, kms:kme+1, jms:jme ), INTENT(INOUT ) :: &
+     MARS_Q2
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), INTENT(INOUT ) :: &
@@ -126,5 +134,5 @@
 INTEGER, INTENT(IN   ) :: HISTORY_INTERVAL
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-REAL, DIMENSION( ims:ime, NUM_SOIL_LAYERS, jms:jme ), INTENT(IN   )  :: &
+REAL, DIMENSION( ims:ime, NUM_SOIL_LAYERS, jms:jme ), INTENT(INOUT )  :: &
      MARS_TSOIL 
 #ifdef NEWPHYS
@@ -141,4 +149,6 @@
 REAL, DIMENSION( ims:ime, kms:kme, jms:jme, 1:num_3d_s ), INTENT(INOUT ) :: &
      scalar
+! Logical
+LOGICAL, INTENT(IN ) :: restart
 
 !-------------------------------------------
@@ -187,4 +197,5 @@
    REAL :: zmea_val,zstd_val,zsig_val,zgam_val,zthe_val
    REAL :: theta_val, psi_val
+   REAL :: wstar_val,fluxrad_val
    LOGICAL :: firstcall,lastcall,tracerdyn
    REAL,DIMENSION(:),ALLOCATABLE :: q2_val, qsurf_val, tsoil_val
@@ -198,5 +209,5 @@
    REAL,DIMENSION(:),ALLOCATABLE :: wtheta, wpsi
    ! v--- can they be modified ?
-   REAL,DIMENSION(:),ALLOCATABLE :: wtsurf,wco2ice,wemis
+   REAL,DIMENSION(:),ALLOCATABLE :: wtsurf,wco2ice,wemis,wwstar,wfluxrad
    REAL,DIMENSION(:,:),ALLOCATABLE :: wq2,wqsurf,wtsoil 
 #ifdef NEWPHYS
@@ -257,4 +268,20 @@
 #endif
 
+!! FOR RESTART
+      REAL, DIMENSION(:,:), ALLOCATABLE, SAVE :: &
+             save_tsoil_restart
+      REAL, DIMENSION(:), ALLOCATABLE, SAVE :: &
+             save_tsurf_restart
+      REAL, DIMENSION(:), ALLOCATABLE, SAVE :: &
+             save_fluxrad_restart
+      REAL, DIMENSION(:), ALLOCATABLE, SAVE :: &
+             save_co2ice_restart
+      REAL, DIMENSION(:,:), ALLOCATABLE, SAVE :: &
+             save_q2_restart
+      REAL, DIMENSION(:,:), ALLOCATABLE, SAVE :: &
+             save_qsurf_restart
+      REAL, DIMENSION(:), ALLOCATABLE, SAVE :: &
+             save_wstar_restart
+
 !!!IDEALIZED IDEALIZED
       REAL :: lat_input, lon_input, ls_input, lct_input
@@ -402,4 +429,21 @@
 flag_first_restart=.false.
 #endif
+
+! Restart save arrays
+ALLOCATE(save_tsoil_restart(ngrid,nsoil))
+ALLOCATE(save_fluxrad_restart(ngrid))
+ALLOCATE(save_co2ice_restart(ngrid))
+ALLOCATE(save_q2_restart(ngrid,nlayer+1))
+ALLOCATE(save_qsurf_restart(ngrid,nq))
+ALLOCATE(save_wstar_restart(ngrid))
+ALLOCATE(save_tsurf_restart(ngrid))
+save_tsoil_restart(:,:)=0.
+save_fluxrad_restart(:)=0.
+save_co2ice_restart(:)=0.
+save_q2_restart(:,:)=0.
+save_qsurf_restart(:,:)=0.
+save_wstar_restart(:)=0.
+save_tsurf_restart(:)=0.
+
 !! put here some general information you'd like to print just once
     print *, 'TILES: ', i_start,i_end, j_start, j_end  ! numbers for simple runs, arrays for parallel runs
@@ -622,4 +666,6 @@
 ALLOCATE(wqsurf(ngrid,nq))       !!!!!
 ALLOCATE(wtsoil(ngrid,nsoil))    !!!!!
+ALLOCATE(wfluxrad(ngrid))
+ALLOCATE(wwstar(ngrid))
 #ifdef NEWPHYS
 ALLOCATE(wisoil(ngrid,nsoil))    !!!!!
@@ -769,8 +815,8 @@
   !!! CAS DU CO2
   DO iii=1,nq 
-   IF ( wtnom(iii) .eq. 'co2' ) q_prof(:,iii) = 0.95
+   IF ( wtnom(iii) .eq. 'co2' .and. (.not. restart)) q_prof(:,iii) = 0.95
   ENDDO
   IF ((MARS_MODE .EQ. 20) .OR. (MARS_MODE .EQ. 21)) THEN
-   IF (firstcall .EQV. .true.) THEN
+   IF (firstcall .EQV. .true. .and. (.not. restart)) THEN
       q_prof(:,:) = 0.95
    ENDIF
@@ -892,5 +938,10 @@
 ! Ground temperature, emissivity, CO2 ice cover !
 !-----------------------------------------------!
-tsurf_val=tsk(i,j)
+IF (.not. restart) THEN
+   tsurf_val=tsk(i,j) ! because tsk is not updated in lmd_driver, the stored value in restart is at t, not t+dt
+                      ! note to aslmd: i dont know why we dont update tsk, so I use MARS_TSURF to be conservative
+ELSE
+   tsurf_val=MARS_TSURF(i,j)
+ENDIF
 emis_val=MARS_EMISS(i,j)
 co2ice_val=MARS_CICE(i,j)
@@ -912,5 +963,13 @@
   IF ( (i == ips) .AND. (j == jps) ) PRINT *,'** Mars ** IDEALIZED SIMULATION tsoil is set to tsurf'
   do k=1,nsoil
-   tsoil_val(k) = tsurf_val
+   IF (.not.restart) THEN
+     tsoil_val(k) = tsurf_val
+   ELSE
+     !this is a restart run. We must not set tsoil to tsurf in the init.
+     !tsoil was saved in physiq.F under the name MARS_TSOIL in the restart file
+     !(see Registry)
+     tsoil_val(k)=MARS_TSOIL(i,k,j)
+   ENDIF
+
 #ifdef NEWPHYS
    IF ( nsoil .lt. 18 ) THEN
@@ -1028,5 +1087,13 @@
 !-------------------------!
 !-------------------------!
-q2_val(:)=0.      !PBL wind variance
+IF (.not. restart) THEN
+   q2_val(:)=0.      !PBL wind variance
+   fluxrad_val=0.
+   wstar_val=0.
+ELSE
+   q2_val(:)=MARS_Q2(i,:,j)
+   fluxrad_val=MARS_FLUXRAD(i,j)
+   wstar_val=MARS_WSTAR(i,j)
+ENDIF
 
 !-----------------!
@@ -1048,4 +1115,6 @@
 wemis(subs) = emis_val
 wq2(subs,:) = q2_val(:)
+wfluxrad(subs) = fluxrad_val
+wwstar(subs) = wstar_val
 wqsurf(subs,:) = qsurf_val(:)
 wtsoil(subs,:) = tsoil_val(:)
@@ -1206,10 +1275,12 @@
 DEALLOCATE(pw)
 DEALLOCATE(pq)
-DEALLOCATE(wtsurf)
-DEALLOCATE(wco2ice)
+!DEALLOCATE(wtsurf)
+!DEALLOCATE(wco2ice)
 DEALLOCATE(wemis)
-DEALLOCATE(wq2)
-DEALLOCATE(wqsurf)
-DEALLOCATE(wtsoil)
+!DEALLOCATE(wq2)
+!DEALLOCATE(wqsurf)
+!DEALLOCATE(wtsoil)
+!DEALLOCATE(wwstar)
+!DEALLOCATE(wfluxrad)
 #ifdef NEWPHYS
 DEALLOCATE(wisoil)
@@ -1271,5 +1342,18 @@
 dq_save(:,:,:)=pdq(:,:,:)
 #endif
-
+save_tsoil_restart(:,:)=wtsoil(:,:)
+save_fluxrad_restart(:)=wfluxrad(:)
+save_co2ice_restart(:)=wco2ice(:)
+save_q2_restart(:,:)=wq2(:,:)
+save_qsurf_restart(:,:)=wqsurf(:,:)
+save_wstar_restart(:)=wwstar(:)
+save_tsurf_restart(:)=wtsurf(:)
+DEALLOCATE(wtsoil)
+DEALLOCATE(wfluxrad)
+DEALLOCATE(wco2ice)
+DEALLOCATE(wq2)
+DEALLOCATE(wqsurf)
+DEALLOCATE(wwstar)
+DEALLOCATE(wtsurf)
 ENDIF call_physics
 
@@ -1351,4 +1435,19 @@
 !---------------------------!
 PSFC(i,j)=PSFC(i,j)+pdpsrf(subs)*dt    !!! here dt is needed
+
+!------------------------------------!
+! Save key variables for restart !  
+!------------------------------------!
+
+MARS_TSOIL(i,:,j)=save_tsoil_restart(subs,:)
+MARS_FLUXRAD(i,j)=save_fluxrad_restart(subs)
+MARS_CICE(i,j)=save_co2ice_restart(subs)
+MARS_Q2(i,:,j)=save_q2_restart(subs,:)
+SELECT CASE (MARS_MODE)
+   CASE (1,11,12)
+     MARS_WICE(i,j)=save_qsurf_restart(subs,2)
+END SELECT
+MARS_WSTAR(i,j)=save_wstar_restart(subs)
+MARS_TSURF(i,j)=save_tsurf_restart(subs)
 
 !---------!
Index: /trunk/MESOSCALE/LMD_MM_MARS/makemeso
===================================================================
--- /trunk/MESOSCALE/LMD_MM_MARS/makemeso	(revision 673)
+++ /trunk/MESOSCALE/LMD_MM_MARS/makemeso	(revision 674)
@@ -35,5 +35,5 @@
 phys=""
 scenario=""
-while getopts "drc:njhgpfs:x" options; do
+while getopts "drc:njhgbpfs:x" options; do
   case $options in
    d ) donotcompile=1;;       ## just to check the compile folder
@@ -380,4 +380,10 @@
                        sed s+"O3"+"O3 -mcmodel=large -shared-intel"+g configure.wrf > yeah ; mv -f yeah configure.wrf 
                        sed s+"-llmd"+"-llmd $NETCDF/lib/libnetcdf.a"+g     configure.wrf > yeah ; mv -f yeah configure.wrf
+                       if [ ${debug} -ne 0 ]   # not working for xlf!
+                             then
+                             echo 'DEBUG DEBUG DEBUG DEBUG'
+                             sed s+"#-g"+" -g -no-ftz -traceback -ftrapuv -fp-stack-check -check"+g configure.wrf > yeah
+                             mv -f yeah configure.wrf
+                       fi
                        \rm conf > /dev/null ;;
 
@@ -422,4 +428,10 @@
      ifort_64_single)  echo 5 | configure > log_compile 2> log_error 
                        sed s+"-DIFORT_KLUDGE"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf 
+                       if [ ${debug} -ne 0 ]   # not working for xlf!
+                             then
+                             echo 'DEBUG DEBUG DEBUG DEBUG'
+                             sed s+"#-g"+" -g -no-ftz -traceback -ftrapuv -fp-stack-check -check"+g configure.wrf > yeah
+                             mv -f yeah configure.wrf
+                       fi
                          ## !!! NETCDF must be defined
                          sed s+"lio_grib_share"+"lio_grib_share -L../mars_lmd/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah 
@@ -431,4 +443,10 @@
                        sed s+"-cc=icc"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf 
                        sed s+"-DIFORT_KLUDGE"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf 
+                       if [ ${debug} -ne 0 ]   # not working for xlf!
+                             then
+                             echo 'DEBUG DEBUG DEBUG DEBUG'
+                             sed s+"#-g"+" -g -no-ftz -traceback -ftrapuv -fp-stack-check -check"+g configure.wrf > yeah
+                             mv -f yeah configure.wrf
+                       fi
                        sed s+"O3"+"O2"+g configure.wrf > yeah ; mv -f yeah configure.wrf 
                                         #sed s+"O3"+"O0"+g configure.wrf > yeah ; mv -f yeah configure.wrf  ### pour compilation rapide
@@ -535,5 +553,5 @@
   then
     echo 'DEBUG DEBUG DEBUG DEBUG'
-    sed s+"#-g"+"-g -Ktrap=fp -Mbounds"+g configure.wrf > yeah
+    sed s+"#-g"+" -g -no-ftz -traceback -ftrapuv -fp-stack-check -check"+g configure.wrf > yeah
     #sed s+"#-g"+"-g"+g configure.wrf > yeah
     mv -f yeah configure.wrf
