Index: trunk/LMDZ.COMMON/libf/dyn3dpar/calfis_p.F
===================================================================
--- trunk/LMDZ.COMMON/libf/dyn3dpar/calfis_p.F	(revision 1086)
+++ trunk/LMDZ.COMMON/libf/dyn3dpar/calfis_p.F	(revision 1107)
@@ -31,5 +31,5 @@
       USE mod_phys_lmdz_para, mpi_root_xx=>mpi_root 
       USE mod_interface_dyn_phys
-      USE IOPHY
+!      USE IOPHY
 #endif
       USE parallel_lmdz, ONLY : omp_chunk, using_mpi, AllGather_Field
@@ -933,29 +933,35 @@
      .             tracerdyn)      !! tracerdyn <-- utilite ???
 
-      else ! a moduler pour Mars
-        CALL physiq (klon,
-     .             llm,
-     .             nqtot,
-     .             debut_split,
-     .             lafin_split,
-     .             jD_cur,
-     .             jH_cur_split,
-     .             zdt_split,
-     .             zplev_omp,
-     .             zplay_omp,
-     .             zpk_omp,
-     .             zphi_omp,
-     .             zphis_omp,
-     .             presnivs_omp,
-     .             zufi_omp,
-     .             zvfi_omp,
-     .             ztfi_omp,
-     .             zqfi_omp,
-     .             flxwfi_omp,
-     .             zdufi_omp,
-     .             zdvfi_omp,
-     .             zdtfi_omp,
-     .             zdqfi_omp,
-     .             zdpsrf_omp)
+      else if ( planet_type=="mars" ) then
+
+        CALL physiq (klon,       ! ngrid
+     .             llm,          ! nlayer
+     .             nqtot,        ! nq
+     .             debut_split,  ! firstcall
+     .             lafin_split,  ! lastcall
+     .             jD_cur,       ! pday
+     .             jH_cur_split, ! ptime
+     .             zdt_split,    ! ptimestep
+     .             zplev_omp,    ! pplev
+     .             zplay_omp,    ! pplay
+     .             zphi_omp,     ! pphi
+     .             zufi_omp,     ! pu
+     .             zvfi_omp,     ! pv
+     .             ztfi_omp,     ! pt
+     .             zqfi_omp,     ! pq
+     .             flxwfi_omp,   ! pw
+     .             zdufi_omp,    ! pdu
+     .             zdvfi_omp,    ! pdv
+     .             zdtfi_omp,    ! pdt
+     .             zdqfi_omp,    ! pdq
+     .             zdpsrf_omp,   ! pdpsrf
+     .             tracerdyn)    ! tracerdyn (somewhat obsolete)
+
+      else ! unknown "planet_type"
+
+        write(lunout,*) "calfis_p: error, unknown planet_type: ",
+     &                  trim(planet_type)
+        stop
+
       endif ! planet_type
          zufi_omp(:,:)=zufi_omp(:,:)+zdufi_omp(:,:)*zdt_split
Index: trunk/LMDZ.COMMON/libf/dyn3dpar/control_mod.F90
===================================================================
--- trunk/LMDZ.COMMON/libf/dyn3dpar/control_mod.F90	(revision 1086)
+++ trunk/LMDZ.COMMON/libf/dyn3dpar/control_mod.F90	(revision 1107)
@@ -10,24 +10,44 @@
   IMPLICIT NONE
 
-  REAL    :: periodav, starttime
-  INTEGER :: nday,day_step,iperiod,iapp_tracvl,nsplit_phys
-  INTEGER :: iconser,iecri,dissip_period,iphysiq,iecrimoy
-  INTEGER :: dayref,anneeref, raz_date, ip_ebil_dyn
-  LOGICAL :: offline
-  CHARACTER (len=4)  :: config_inca
-  CHARACTER (len=10) :: planet_type ! planet type ('earth','mars',...)
-  LOGICAL output_grads_dyn ! output dynamics diagnostics in
-                           ! binary grads file 'dyn.dat' (y/n)
-  LOGICAL ok_dynzon  ! output zonal transports in dynzon.nc file
-  LOGICAL ok_dyn_ins ! output instantaneous values of fields
-                     ! in the dynamics in NetCDF files dyn_hist*nc
-  LOGICAL ok_dyn_ave ! output averaged values of fields in the dynamics
-                     ! in NetCDF files dyn_hist*ave.nc
-  LOGICAL :: resetvarc  ! allows to reset the variables in sortvarc
-  LOGICAL :: less1day   ! allows to run less than 1 day (for Venus)
-  REAL    :: fractday   ! fraction of the day to run in this case
+  real,save :: periodav
+  real,save :: starttime
+  integer,save :: nday
+  integer,save :: day_step ! # of dynamical time steps per day
+  integer,save :: iperiod ! make a Matsuno step before avery iperiod-1 LF steps
+  integer,save :: iapp_tracvl ! apply (cumulated) traceur advection every
+                              ! iapp_tracvl dynamical steps
+  integer,save :: nsplit_phys ! number of sub-cycle steps in call to physics
+  integer,save :: iconser
+  integer,save :: iecri
+  integer,save :: dissip_period ! apply dissipation every dissip_period
+                                ! dynamical step
+  integer,save :: iphysiq ! call physics every iphysiq dynamical steps
+  integer,save :: iecrimoy
+  integer,save :: dayref
+  integer,save :: anneeref ! reference year # 
+  integer,save :: raz_date
+  integer,save :: ip_ebil_dyn
+  logical,save :: offline
+  character(len=4),save :: config_inca
+  character(len=10),save :: planet_type ! planet type ('earth','mars',...)
+  logical,save :: output_grads_dyn ! output dynamics diagnostics in
+                                   ! binary grads file 'dyn.dat' (y/n)
+  logical,save :: ok_dynzon  ! output zonal transports in dynzon.nc file
+  logical,save :: ok_dyn_ins ! output instantaneous values of fields
+                             ! in the dynamics in NetCDF files dyn_hist*nc
+  logical,save :: ok_dyn_ave ! output averaged values of fields in the dynamics
+                             ! in NetCDF files dyn_hist*ave.nc
+  logical,save :: resetvarc  ! allows to reset the variables in sortvarc
+  logical,save :: less1day   ! allows to run less than 1 day (for Venus)
+  real,save :: fractday   ! fraction of the day to run in this case
   
-  integer :: ndynstep ! Alternative to using less1day&fractday; user may
-                      ! specify number of dynamical steps to run
+  integer,save :: ndynstep ! Alternative to using less1day&fractday; user may
+                           ! specify number of dynamical steps to run
+
+  integer,save :: ecritphy ! (Mars/generic) output (writediagfi) every
+                           ! ecritphy dynamical steps
+  integer,save :: ecritstart ! (Mars) output data in "start.nc" every
+                             !ecritstart dynamical steps 
+  real,save :: timestart ! (Mars) time start for run in "start.nc"
 
 END MODULE
Index: trunk/LMDZ.COMMON/libf/dyn3dpar/dynetat0.F
===================================================================
--- trunk/LMDZ.COMMON/libf/dyn3dpar/dynetat0.F	(revision 1086)
+++ trunk/LMDZ.COMMON/libf/dyn3dpar/dynetat0.F	(revision 1107)
@@ -3,10 +3,12 @@
 !
       SUBROUTINE dynetat0(fichnom,vcov,ucov,
-     .                    teta,q,masse,ps,phis,time)
-
-      USE infotrac
-      use netcdf, only: nf90_get_var
-
-      use control_mod, only : planet_type
+     .                    teta,q,masse,ps,phis,time0)
+
+      USE infotrac, only: tname, nqtot
+      use netcdf, only: nf90_open,NF90_NOWRITE,nf90_noerr,nf90_strerror,
+     &                  nf90_get_var, nf90_inq_varid, nf90_inq_dimid,
+     &                  nf90_inquire_dimension,nf90_close
+
+      use control_mod, only : planet_type, timestart
 
       IMPLICIT NONE
@@ -43,10 +45,13 @@
 c   ----------
 
-      CHARACTER*(*) fichnom
-      REAL vcov(iip1, jjm,llm),ucov(iip1, jjp1,llm),teta(iip1, jjp1,llm)
-      REAL q(iip1,jjp1,llm,nqtot),masse(iip1, jjp1,llm)
-      REAL ps(iip1, jjp1),phis(iip1, jjp1)
-
-      REAL time
+      CHARACTER(len=*),INTENT(IN) :: fichnom
+      REAL,INTENT(OUT) :: vcov(iip1,jjm,llm)
+      REAL,INTENT(OUT) :: ucov(iip1,jjp1,llm)
+      REAL,INTENT(OUT) :: teta(iip1,jjp1,llm)
+      REAL,INTENT(OUT) :: q(iip1,jjp1,llm,nqtot)
+      REAL,INTENT(OUT) :: masse(iip1,jjp1,llm)
+      REAL,INTENT(OUT) :: ps(iip1,jjp1)
+      REAL,INTENT(OUT) :: phis(iip1,jjp1)
+      REAL,INTENT(OUT) :: time0
 
 c   Variables 
@@ -60,24 +65,35 @@
       INTEGER idecal
 
+
+      REAL,ALLOCATABLE :: time(:) ! times stored in start
+      INTEGER timelen ! number of times stored in the file
+      INTEGER indextime ! index of selected time
+      !REAL  hour_ini ! fraction of day of stored date. Equivalent of day_ini, but 0=<hour_ini<1
+
+      INTEGER edges(4),corner(4)
+      integer :: i
+
 c-----------------------------------------------------------------------
 
 c  Ouverture NetCDF du fichier etat initial
 
-      ierr = NF_OPEN (fichnom, NF_NOWRITE,nid)
-      IF (ierr.NE.NF_NOERR) THEN
+      ierr=nf90_open(fichnom,NF90_NOWRITE,nid)
+      IF (ierr.NE.nf90_noerr) THEN
         write(lunout,*)'dynetat0: Pb d''ouverture du fichier start.nc'
-        write(lunout,*)' ierr = ', ierr
+        write(lunout,*)trim(nf90_strerror(ierr))
         CALL ABORT
       ENDIF
 
 c
-      ierr = NF_INQ_VARID (nid, "controle", nvarid)
-      IF (ierr .NE. NF_NOERR) THEN
+      ierr = nf90_inq_varid (nid, "controle", nvarid)
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Le champ <controle> est absent"
+         write(lunout,*)trim(nf90_strerror(ierr))
          CALL abort
       ENDIF
       ierr = nf90_get_var(nid, nvarid, tab_cntrl)
-      IF (ierr .NE. NF_NOERR) THEN
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Lecture echoue pour <controle>"
+         write(lunout,*)trim(nf90_strerror(ierr))
          CALL abort
       ENDIF
@@ -138,4 +154,10 @@
       ENDIF
 
+      if (planet_type=="mars") then ! so far this is only for Mars
+        hour_ini = tab_cntrl(29)
+      else
+        hour_ini=0
+      endif
+
       if (start_file_type.eq."earth") then
         day_ini = tab_cntrl(30)
@@ -150,5 +172,5 @@
 c
 c
-      write(lunout,*)'dynetat0: rad,omeg,g,cpp,kappa',
+      write(lunout,*)'dynetat0: rad,omeg,g,cpp,kappa ',
      &               rad,omeg,g,cpp,kappa
 
@@ -164,146 +186,247 @@
       ENDIF
 
-      ierr = NF_INQ_VARID (nid, "rlonu", nvarid)
-      IF (ierr .NE. NF_NOERR) THEN
+      ierr=nf90_inq_varid(nid, "rlonu", nvarid)
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Le champ <rlonu> est absent"
+         write(lunout,*)trim(nf90_strerror(ierr))
          CALL abort
       ENDIF
       ierr = nf90_get_var(nid, nvarid, rlonu)
-      IF (ierr .NE. NF_NOERR) THEN
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Lecture echouee pour <rlonu>"
-         CALL abort
-      ENDIF
-
-      ierr = NF_INQ_VARID (nid, "rlatu", nvarid)
-      IF (ierr .NE. NF_NOERR) THEN
+         write(lunout,*)trim(nf90_strerror(ierr))
+         CALL abort
+      ENDIF
+
+      ierr = nf90_inq_varid (nid, "rlatu", nvarid)
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Le champ <rlatu> est absent"
+         write(lunout,*)trim(nf90_strerror(ierr))
          CALL abort
       ENDIF
       ierr = nf90_get_var(nid, nvarid, rlatu)
-      IF (ierr .NE. NF_NOERR) THEN
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Lecture echouee pour <rlatu>"
-         CALL abort
-      ENDIF
-
-      ierr = NF_INQ_VARID (nid, "rlonv", nvarid)
-      IF (ierr .NE. NF_NOERR) THEN
+         write(lunout,*)trim(nf90_strerror(ierr))
+         CALL abort
+      ENDIF
+
+      ierr = nf90_inq_varid (nid, "rlonv", nvarid)
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Le champ <rlonv> est absent"
+         write(lunout,*)trim(nf90_strerror(ierr))
          CALL abort
       ENDIF
       ierr = nf90_get_var(nid, nvarid, rlonv)
-      IF (ierr .NE. NF_NOERR) THEN
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Lecture echouee pour <rlonv>"
-         CALL abort
-      ENDIF
-
-      ierr = NF_INQ_VARID (nid, "rlatv", nvarid)
-      IF (ierr .NE. NF_NOERR) THEN
+         write(lunout,*)trim(nf90_strerror(ierr))
+         CALL abort
+      ENDIF
+
+      ierr = nf90_inq_varid (nid, "rlatv", nvarid)
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Le champ <rlatv> est absent"
+         write(lunout,*)trim(nf90_strerror(ierr))
          CALL abort
       ENDIF
       ierr = nf90_get_var(nid, nvarid, rlatv)
-      IF (ierr .NE. NF_NOERR) THEN
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Lecture echouee pour rlatv"
-         CALL abort
-      ENDIF
-
-      ierr = NF_INQ_VARID (nid, "cu", nvarid)
-      IF (ierr .NE. NF_NOERR) THEN
+         write(lunout,*)trim(nf90_strerror(ierr))
+         CALL abort
+      ENDIF
+
+      ierr = nf90_inq_varid (nid, "cu", nvarid)
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Le champ <cu> est absent"
+         write(lunout,*)trim(nf90_strerror(ierr))
          CALL abort
       ENDIF
       ierr = nf90_get_var(nid, nvarid, cu)
-      IF (ierr .NE. NF_NOERR) THEN
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Lecture echouee pour <cu>"
-         CALL abort
-      ENDIF
-
-      ierr = NF_INQ_VARID (nid, "cv", nvarid)
-      IF (ierr .NE. NF_NOERR) THEN
+         write(lunout,*)trim(nf90_strerror(ierr))
+         CALL abort
+      ENDIF
+
+      ierr = nf90_inq_varid (nid, "cv", nvarid)
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Le champ <cv> est absent"
+         write(lunout,*)trim(nf90_strerror(ierr))
          CALL abort
       ENDIF
       ierr = nf90_get_var(nid, nvarid, cv)
-      IF (ierr .NE. NF_NOERR) THEN
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Lecture echouee pour <cv>"
-         CALL abort
-      ENDIF
-
-      ierr = NF_INQ_VARID (nid, "aire", nvarid)
-      IF (ierr .NE. NF_NOERR) THEN
+         write(lunout,*)trim(nf90_strerror(ierr))
+         CALL abort
+      ENDIF
+
+      ierr = nf90_inq_varid (nid, "aire", nvarid)
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Le champ <aire> est absent"
+         write(lunout,*)trim(nf90_strerror(ierr))
          CALL abort
       ENDIF
       ierr = nf90_get_var(nid, nvarid, aire)
-      IF (ierr .NE. NF_NOERR) THEN
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Lecture echouee pour <aire>"
-         CALL abort
-      ENDIF
-
-      ierr = NF_INQ_VARID (nid, "phisinit", nvarid)
-      IF (ierr .NE. NF_NOERR) THEN
+         write(lunout,*)trim(nf90_strerror(ierr))
+         CALL abort
+      ENDIF
+
+      ierr = nf90_inq_varid (nid, "phisinit", nvarid)
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Le champ <phisinit> est absent"
+         write(lunout,*)trim(nf90_strerror(ierr))
          CALL abort
       ENDIF
       ierr = nf90_get_var(nid, nvarid, phis)
-      IF (ierr .NE. NF_NOERR) THEN
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Lecture echouee pour <phisinit>"
-         CALL abort
-      ENDIF
-
-      ierr = NF_INQ_VARID (nid, "temps", nvarid)
-      IF (ierr .NE. NF_NOERR) THEN
-         write(lunout,*)"dynetat0: Le champ <temps> est absent"
-         write(lunout,*)"dynetat0: J essaie <Time>"
-         ierr = NF_INQ_VARID (nid, "Time", nvarid)
-         IF (ierr .NE. NF_NOERR) THEN
-            write(lunout,*)"dynetat0: Le champ <Time> est absent"
-            CALL abort
-         ENDIF
-      ENDIF
-      ierr = nf90_get_var(nid, nvarid, time)
-      IF (ierr .NE. NF_NOERR) THEN
-         write(lunout,*)"dynetat0: Lecture echouee <temps>"
-         CALL abort
-      ENDIF
-
-      ierr = NF_INQ_VARID (nid, "ucov", nvarid)
-      IF (ierr .NE. NF_NOERR) THEN
+         write(lunout,*)trim(nf90_strerror(ierr))
+         CALL abort
+      ENDIF
+
+! read time axis
+      ierr = nf90_inq_varid (nid, "temps", nvarid)
+      IF (ierr .NE. nf90_noerr) THEN
+        write(lunout,*)"dynetat0: Le champ <temps> est absent"
+        write(lunout,*)"dynetat0: J essaie <Time>"
+        ierr = nf90_inq_varid (nid, "Time", nvarid)
+        IF (ierr .NE. nf90_noerr) THEN
+           write(lunout,*)"dynetat0: Le champ <Time> est absent"
+           write(lunout,*)trim(nf90_strerror(ierr))
+           CALL abort
+        ENDIF
+        ! Get the length of the "Time" dimension
+        ierr = nf90_inq_dimid(nid,"Time",nvarid)
+        ierr = nf90_inquire_dimension(nid,nvarid,len=timelen)
+        allocate(time(timelen))
+        ! Then look for the "Time" variable
+        ierr  =nf90_inq_varid(nid,"Time",nvarid)
+        ierr = nf90_get_var(nid, nvarid, time)
+        IF (ierr .NE. nf90_noerr) THEN
+           write(lunout,*)"dynetat0: Lecture echouee <Time>"
+           write(lunout,*)trim(nf90_strerror(ierr))
+           CALL abort
+        ENDIF
+      ELSE   
+        ! Get the length of the "temps" dimension
+        ierr = nf90_inq_dimid(nid,"temps",nvarid)
+        ierr = nf90_inquire_dimension(nid,nvarid,len=timelen)
+        allocate(time(timelen))
+        ! Then look for the "temps" variable
+        ierr = nf90_inq_varid (nid, "temps", nvarid)
+        ierr = nf90_get_var(nid, nvarid, time)
+        IF (ierr .NE. nf90_noerr) THEN
+           write(lunout,*)"dynetat0: Lecture echouee <temps>"
+           write(lunout,*)trim(nf90_strerror(ierr))
+           CALL abort
+        ENDIF
+      ENDIF
+
+! select the desired time
+      IF (timestart .lt. 0) THEN  ! default: we use the last time value
+        indextime = timelen
+      ELSE  ! else we look for the desired value in the time axis
+       indextime = 0
+        DO i=1,timelen
+          IF (abs(time(i) - timestart) .lt. 0.01) THEN
+             indextime = i
+             EXIT
+          ENDIF
+        ENDDO
+        IF (indextime .eq. 0) THEN
+          write(lunout,*)"Time", timestart," is not in "
+     &                                      //trim(fichnom)//"!!"
+          write(lunout,*)"Stored times are:"
+          DO i=1,timelen
+             PRINT*, time(i)
+          ENDDO
+          CALL abort
+        ENDIF
+      ENDIF
+
+      if (planet_type=="mars") then
+        ! In start the absolute date is day_ini + hour_ini + time
+        ! For now on, in the GCM dynamics, it is day_ini + time0
+        time0 = time(indextime) + hour_ini
+        day_ini = day_ini + INT(time0)
+        time0 = time0 - INT(time0) ! time0 devient le nouveau hour_ini
+        hour_ini = time0
+      else
+        time0 = time(indextime) 
+      endif
+      
+      PRINT*, "dynetat0: Selected time ",time(indextime),
+     .        " at index ",indextime
+      
+      DEALLOCATE(time)
+
+! read vcov
+      corner(1)=1
+      corner(2)=1
+      corner(3)=1
+      corner(4)=indextime
+      edges(1)=iip1
+      edges(2)=jjm
+      edges(3)=llm
+      edges(4)=1
+      ierr=nf90_inq_varid(nid,"vcov",nvarid)
+      IF (ierr .NE. nf90_noerr) THEN
+         write(lunout,*)"dynetat0: Le champ <vcov> est absent"
+         write(lunout,*)trim(nf90_strerror(ierr))
+         CALL abort
+      ENDIF
+      ierr=nf90_get_var(nid,nvarid,vcov,corner,edges)
+      IF (ierr .NE. nf90_noerr) THEN
+         write(lunout,*)"dynetat0: Lecture echouee pour <vcov>"
+         write(lunout,*)trim(nf90_strerror(ierr))
+         CALL abort
+      ENDIF
+
+! read ucov
+      corner(1)=1
+      corner(2)=1
+      corner(3)=1
+      corner(4)=indextime
+      edges(1)=iip1
+      edges(2)=jjp1
+      edges(3)=llm
+      edges(4)=1
+      ierr=nf90_inq_varid(nid,"ucov",nvarid)
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Le champ <ucov> est absent"
-         CALL abort
-      ENDIF
-      ierr = nf90_get_var(nid, nvarid, ucov)
-      IF (ierr .NE. NF_NOERR) THEN
+         write(lunout,*)trim(nf90_strerror(ierr))
+         CALL abort
+      ENDIF
+      ierr=nf90_get_var(nid,nvarid,ucov,corner,edges)
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Lecture echouee pour <ucov>"
+         write(lunout,*)trim(nf90_strerror(ierr))
          CALL abort
       ENDIF
  
-      ierr = NF_INQ_VARID (nid, "vcov", nvarid)
-      IF (ierr .NE. NF_NOERR) THEN
-         write(lunout,*)"dynetat0: Le champ <vcov> est absent"
-         CALL abort
-      ENDIF
-      ierr = nf90_get_var(nid, nvarid, vcov)
-      IF (ierr .NE. NF_NOERR) THEN
-         write(lunout,*)"dynetat0: Lecture echouee pour <vcov>"
-         CALL abort
-      ENDIF
-
-      ierr = NF_INQ_VARID (nid, "teta", nvarid)
-      IF (ierr .NE. NF_NOERR) THEN
+! read teta (same corner/edges as ucov)
+      ierr=nf90_inq_varid(nid,"teta",nvarid)
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Le champ <teta> est absent"
-         CALL abort
-      ENDIF
-      ierr = nf90_get_var(nid, nvarid, teta)
-      IF (ierr .NE. NF_NOERR) THEN
+         write(lunout,*)trim(nf90_strerror(ierr))
+         CALL abort
+      ENDIF
+      ierr=nf90_get_var(nid,nvarid,teta,corner,edges)
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Lecture echouee pour <teta>"
-         CALL abort
-      ENDIF
-
-
+         write(lunout,*)trim(nf90_strerror(ierr))
+         CALL abort
+      ENDIF
+
+! read tracers (same corner/edges as ucov)
       IF(nqtot.GE.1) THEN
       DO iq=1,nqtot
-        ierr =  NF_INQ_VARID (nid, tname(iq), nvarid)
-        IF (ierr .NE. NF_NOERR) THEN
+        ierr= nf90_inq_varid(nid,tname(iq),nvarid)
+        IF (ierr .NE. nf90_noerr) THEN
            write(lunout,*)"dynetat0: Le traceur <"//trim(tname(iq))//
      &                    "> est absent"
@@ -311,7 +434,9 @@
            q(:,:,:,iq)=0.
         ELSE
-           ierr = NF90_GET_VAR(nid, nvarid, q(:,:,:,iq))
-          IF (ierr .NE. NF_NOERR) THEN
-            write(lunout,*)"dynetat0: Lecture echouee pour "//tname(iq)
+           ierr=nf90_get_var(nid,nvarid,q(:,:,:,iq),corner,edges)
+          IF (ierr .NE. nf90_noerr) THEN
+            write(lunout,*)"dynetat0: Lecture echouee pour "
+     &                                //trim(tname(iq))
+            write(lunout,*)trim(nf90_strerror(ierr))
             CALL abort
           ENDIF
@@ -320,30 +445,44 @@
       ENDIF
 
-      ierr = NF_INQ_VARID (nid, "masse", nvarid)
-      IF (ierr .NE. NF_NOERR) THEN
+!read masse (same corner/edges as ucov)
+      ierr=nf90_inq_varid(nid,"masse",nvarid)
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Le champ <masse> est absent"
-         CALL abort
-      ENDIF
-      ierr = nf90_get_var(nid, nvarid, masse)
-      IF (ierr .NE. NF_NOERR) THEN
+         write(lunout,*)trim(nf90_strerror(ierr))
+         CALL abort
+      ENDIF
+      ierr=nf90_get_var(nid,nvarid,masse,corner,edges)
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Lecture echouee pour <masse>"
-         CALL abort
-      ENDIF
-
-      ierr = NF_INQ_VARID (nid, "ps", nvarid)
-      IF (ierr .NE. NF_NOERR) THEN
+         write(lunout,*)trim(nf90_strerror(ierr))
+         CALL abort
+      ENDIF
+
+! read ps
+      corner(1)=1
+      corner(2)=1
+      corner(3)=indextime
+      edges(1)=iip1
+      edges(2)=jjp1
+      edges(3)=1
+      ierr=nf90_inq_varid(nid,"ps",nvarid)
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Le champ <ps> est absent"
-         CALL abort
-      ENDIF
-      ierr = nf90_get_var(nid, nvarid, ps)
-      IF (ierr .NE. NF_NOERR) THEN
+         write(lunout,*)trim(nf90_strerror(ierr))
+         CALL abort
+      ENDIF
+      ierr=nf90_get_var(nid,nvarid,ps,corner,edges)
+      IF (ierr .NE. nf90_noerr) THEN
          write(lunout,*)"dynetat0: Lecture echouee pour <ps>"
-         CALL abort
-      ENDIF
-
-      ierr = NF_CLOSE(nid)
-
-       day_ini=day_ini+INT(time)
-       time=time-INT(time)
+         write(lunout,*)trim(nf90_strerror(ierr))
+         CALL abort
+      ENDIF
+
+      ierr=nf90_close(nid)
+
+      if (planet_type/="mars") then
+       day_ini=day_ini+INT(time0) ! obsolete stuff ; 0<time<1 anyways
+       time0=time0-INT(time0)
+      endif
 
   1   FORMAT(//10x,'la valeur de im =',i4,2x,'lue sur le fichier de dem
Index: trunk/LMDZ.COMMON/libf/dyn3dpar/dynredem.F
===================================================================
--- trunk/LMDZ.COMMON/libf/dyn3dpar/dynredem.F	(revision 1086)
+++ trunk/LMDZ.COMMON/libf/dyn3dpar/dynredem.F	(revision 1107)
@@ -95,5 +95,6 @@
          tab_cntrl(4)=REAL(day_ref)
        else
-         tab_cntrl(4)=REAL(day_end)
+         !tab_cntrl(4)=REAL(day_end)
+         tab_cntrl(4)=REAL(iday_end)
        endif
        tab_cntrl(5)  = REAL(annee_ref)
@@ -142,4 +143,8 @@
 c start_time: start_time of simulation (not necessarily 0.)
        tab_cntrl(idecal+27) = start_time
+      endif
+
+      if (planet_type=="mars") then ! For Mars only
+        tab_cntrl(29)=hour_ini
       endif
 c
@@ -680,5 +685,5 @@
          CALL abort_gcm(modname,abort_message,ierr)
       ENDIF
-      call NF95_PUT_VAR(nid,nvarid,ucov)
+      call NF95_PUT_VAR(nid,nvarid,ucov,start=(/1,1,1,nb/))
 
       ierr = NF_INQ_VARID(nid, "vcov", nvarid)
@@ -688,5 +693,5 @@
          CALL abort_gcm(modname,abort_message,ierr)
       ENDIF
-      call NF95_PUT_VAR(nid,nvarid,vcov)
+      call NF95_PUT_VAR(nid,nvarid,vcov,start=(/1,1,1,nb/))
 
       ierr = NF_INQ_VARID(nid, "teta", nvarid)
@@ -696,5 +701,5 @@
          CALL abort_gcm(modname,abort_message,ierr)
       ENDIF
-      call NF95_PUT_VAR(nid,nvarid,teta)
+      call NF95_PUT_VAR(nid,nvarid,teta,start=(/1,1,1,nb/))
 
       IF (type_trac == 'inca') THEN
@@ -718,5 +723,5 @@
                CALL abort_gcm(modname,abort_message,ierr)
             ENDIF
-            call NF95_PUT_VAR(nid,nvarid,q(:,:,:,iq))
+            call NF95_PUT_VAR(nid,nvarid,q(:,:,:,iq),start=(/1,1,1,nb/))
         ELSE ! type_trac = inca
 ! lecture de la valeur du traceur dans start_trac.nc
@@ -765,5 +770,6 @@
                    CALL abort_gcm(modname,abort_message,ierr)
              ENDIF
-             call NF95_PUT_VAR(nid,nvarid,q(:,:,:,iq))
+             call NF95_PUT_VAR(nid,nvarid,q(:,:,:,iq),
+     &                  start=(/1,1,1,nb/))
           ENDIF ! (ierr_file .ne. 2)
        END IF   !type_trac
@@ -778,5 +784,5 @@
          CALL abort_gcm(modname,abort_message,ierr)
       ENDIF
-      call NF95_PUT_VAR(nid,nvarid,masse)
+      call NF95_PUT_VAR(nid,nvarid,masse,start=(/1,1,1,nb/))
 c
       ierr = NF_INQ_VARID(nid, "ps", nvarid)
@@ -786,5 +792,5 @@
          CALL abort_gcm(modname,abort_message,ierr)
       ENDIF
-      call NF95_PUT_VAR(nid,nvarid,ps)
+      call NF95_PUT_VAR(nid,nvarid,ps,start=(/1,1,nb/))
 
       ierr = NF_CLOSE(nid)
Index: trunk/LMDZ.COMMON/libf/dyn3dpar/dynredem_p.F
===================================================================
--- trunk/LMDZ.COMMON/libf/dyn3dpar/dynredem_p.F	(revision 1086)
+++ trunk/LMDZ.COMMON/libf/dyn3dpar/dynredem_p.F	(revision 1107)
@@ -98,5 +98,6 @@
          tab_cntrl(4)=REAL(day_ref)
        else
-         tab_cntrl(4)=REAL(day_end)
+         !tab_cntrl(4)=REAL(day_end)
+         tab_cntrl(4)=REAL(iday_end)
        endif
        tab_cntrl(5)  = REAL(annee_ref)
@@ -145,4 +146,8 @@
 c start_time: start_time of simulation (not necessarily 0.)
        tab_cntrl(idecal+27) = start_time
+      endif
+
+      if (planet_type=="mars") then ! For Mars only
+        tab_cntrl(29)=hour_ini
       endif
 c
@@ -695,5 +700,5 @@
          CALL abort
       ENDIF
-      call NF95_PUT_VAR(nid,nvarid,ucov)
+      call NF95_PUT_VAR(nid,nvarid,ucov,start=(/1,1,1,nb/))
 
       ierr = NF_INQ_VARID(nid, "vcov", nvarid)
@@ -702,5 +707,5 @@
          CALL abort
       ENDIF
-      call NF95_PUT_VAR(nid,nvarid,vcov)
+      call NF95_PUT_VAR(nid,nvarid,vcov,start=(/1,1,1,nb/))
 
       ierr = NF_INQ_VARID(nid, "teta", nvarid)
@@ -709,5 +714,5 @@
          CALL abort
       ENDIF
-      call NF95_PUT_VAR(nid,nvarid,teta)
+      call NF95_PUT_VAR(nid,nvarid,teta,start=(/1,1,1,nb/))
 
       IF (type_trac == 'inca') THEN
@@ -734,5 +739,5 @@
                CALL abort
             ENDIF
-            call NF95_PUT_VAR(nid,nvarid,q(:,:,:,iq))
+            call NF95_PUT_VAR(nid,nvarid,q(:,:,:,iq),start=(/1,1,1,nb/))
         ELSE ! type_trac = inca
 ! lecture de la valeur du traceur dans start_trac.nc
@@ -771,5 +776,6 @@
                 CALL abort
              ENDIF
-             call NF95_PUT_VAR(nid,nvarid,q(:,:,:,iq))
+             call NF95_PUT_VAR(nid,nvarid,q(:,:,:,iq),
+     &                  start=(/1,1,1,nb/))
           ENDIF ! (ierr_file .ne. 2)
        END IF   !type_trac
@@ -785,5 +791,5 @@
          CALL abort
       ENDIF
-      call NF95_PUT_VAR(nid,nvarid,masse)
+      call NF95_PUT_VAR(nid,nvarid,masse,start=(/1,1,1,nb/))
 c
       ierr = NF_INQ_VARID(nid, "ps", nvarid)
@@ -792,5 +798,5 @@
          CALL abort
       ENDIF
-      call NF95_PUT_VAR(nid,nvarid,ps)
+      call NF95_PUT_VAR(nid,nvarid,ps,start=(/1,1,nb/))
 
       ierr = NF_CLOSE(nid)
Index: trunk/LMDZ.COMMON/libf/dyn3dpar/gcm.F
===================================================================
--- trunk/LMDZ.COMMON/libf/dyn3dpar/gcm.F	(revision 1086)
+++ trunk/LMDZ.COMMON/libf/dyn3dpar/gcm.F	(revision 1107)
@@ -302,12 +302,6 @@
         endif
 
-        if (planet_type.eq."mars") then
-! POUR MARS, METTRE UNE FONCTION A PART, genre dynetat0_mars
-         abort_message = 'dynetat0_mars A FAIRE'
-         call abort_gcm(modname,abort_message,0)
-        else
-         CALL dynetat0("start.nc",vcov,ucov,
+        CALL dynetat0("start.nc",vcov,ucov,
      &              teta,q,masse,ps,phis, time_0)
-        endif ! of if (planet_type.eq."mars")
        
         ! Load relaxation fields (simple nudging). AS 09/2013
@@ -558,12 +552,10 @@
 #endif
 
-      if (planet_type.eq."mars") then
-! POUR MARS, METTRE UNE FONCTION A PART, genre dynredem0_mars
-         abort_message = 'dynredem0_mars A FAIRE'
-         call abort_gcm(modname,abort_message,0)
+      if (planet_type=="mars") then
+         ! For Mars we transmit day_ini
+        CALL dynredem0_p("restart.nc", day_ini, phis)
       else
         CALL dynredem0_p("restart.nc", day_end, phis)
-      endif ! of if (planet_type.eq."mars")
-
+      endif
       ecripar = .TRUE.
 
Index: trunk/LMDZ.COMMON/libf/dyn3dpar/leapfrog_p.F
===================================================================
--- trunk/LMDZ.COMMON/libf/dyn3dpar/leapfrog_p.F	(revision 1086)
+++ trunk/LMDZ.COMMON/libf/dyn3dpar/leapfrog_p.F	(revision 1107)
@@ -844,5 +844,6 @@
      $        + itau/day_step
 
-           IF (planet_type .eq."generic") THEN
+           IF ((planet_type .eq."generic").or.
+     &         (planet_type.eq."mars")) THEN
               ! AS: we make jD_cur to be pday
               jD_cur = int(day_ini + itau/day_step)
@@ -1727,14 +1728,11 @@
 c$OMP MASTER
 
-              if (planet_type.eq."mars") then
-! POUR MARS, METTRE UNE FONCTION A PART, genre dynredem1_mars
-                abort_message = 'dynredem1_mars A FAIRE'
-                call abort_gcm(modname,abort_message,0)
+              if (planet_type=="mars") then
+                CALL dynredem1_p("restart.nc",REAL(itau)/REAL(day_step),
+     &                           vcov,ucov,teta,q,masse,ps)
               else
-! Write an Earth-format restart file
-                CALL dynredem1_p("restart.nc",0.0,
+                CALL dynredem1_p("restart.nc",start_time,
      &                           vcov,ucov,teta,q,masse,ps)
-              endif ! of if (planet_type.eq."mars")
-
+              endif
 !              CLOSE(99)
 c$OMP END MASTER
@@ -1942,14 +1940,15 @@
 
               IF(itau.EQ.itaufin) THEN
-                if (planet_type.eq."mars") then
-! POUR MARS, METTRE UNE FONCTION A PART, genre dynredem1_mars
-                  abort_message = 'dynredem1_mars A FAIRE'
-                  call abort_gcm(modname,abort_message,0)
+c$OMP MASTER
+                if (planet_type=="mars") then
+                  CALL dynredem1_p("restart.nc",
+     &                              REAL(itau)/REAL(day_step),
+     &                               vcov,ucov,teta,q,masse,ps)
                 else
-c$OMP MASTER
-                   CALL dynredem1_p("restart.nc",0.0,
-     .                               vcov,ucov,teta,q,masse,ps)
-c$OMP END MASTER
-                endif ! of if (planet_type.eq."mars")
+                  CALL dynredem1_p("restart.nc",start_time,
+     &                               vcov,ucov,teta,q,masse,ps)
+                
+                endif
+c$OMP END MASTER
               ENDIF ! of IF(itau.EQ.itaufin)
 
Index: trunk/LMDZ.COMMON/libf/dyn3dpar/moyzon_mod.F90
===================================================================
--- trunk/LMDZ.COMMON/libf/dyn3dpar/moyzon_mod.F90	(revision 1086)
+++ trunk/LMDZ.COMMON/libf/dyn3dpar/moyzon_mod.F90	(revision 1107)
@@ -31,5 +31,6 @@
 !======================================================================
 SUBROUTINE moyzon_init
-
+#ifdef CPP_PHYS
+! This routine needs physics
 USE dimphy
 USE infotrac, only: nqtot
@@ -41,10 +42,11 @@
       ALLOCATE(ztfibar_mpi(klon,llm),zqfibar_mpi(klon,llm,nqtot))
       ALLOCATE(zpkbar_mpi(klon,llm),ztetabar_mpi(klon,llm))
-
+#endif
 END SUBROUTINE moyzon_init
 
 !======================================================================
 SUBROUTINE moyzon_init_omp(nlon)
-
+#ifdef CPP_PHYS
+! This routine needs physics
 USE dimphy
 USE infotrac, only: nqtot
@@ -58,5 +60,5 @@
       ALLOCATE(ztfibar(nlon,llm),zqfibar(nlon,llm,nqtot))
       ALLOCATE(zzlevbar(nlon,llm+1),zzlaybar(nlon,llm))
-
+#endif
 END SUBROUTINE moyzon_init_omp
 
Index: trunk/LMDZ.COMMON/libf/dyn3dpar/temps.h
===================================================================
--- trunk/LMDZ.COMMON/libf/dyn3dpar/temps.h	(revision 1086)
+++ trunk/LMDZ.COMMON/libf/dyn3dpar/temps.h	(revision 1107)
@@ -1,4 +1,4 @@
 !
-! $Id: temps.h 1279 2009-12-10 09:02:56Z fairhead $
+! $Id: temps.h 1577 2011-10-20 15:06:47Z fairhead $
 !
 !  ATTENTION!!!!: ce fichier include est compatible format fixe/format libre
@@ -13,15 +13,22 @@
 ! INCLUDE 'temps.h'
 
-      COMMON/temps/ dt, jD_ref, jH_ref, start_time,                     &
-     &             day_ini, day_end, annee_ref, day_ref,                &
-     &             itau_dyn, itau_phy, itaufin, calend
+      COMMON/temps_r/dt,jD_ref,jH_ref,start_time,hour_ini
+      COMMON/temps_i/day_ini,day_end,annee_ref,day_ref,                 &
+     &             itau_dyn,itau_phy,itaufin
+      COMMON/temps_c/calend
 
 
-      INTEGER   itaufin
+      INTEGER   itaufin ! total number of dynamical steps for the run
       INTEGER   itau_dyn, itau_phy
-      INTEGER   day_ini, day_end, annee_ref, day_ref
-      REAL      dt, jD_ref, jH_ref, start_time
+      INTEGER   day_ini ! initial day # of simulation sequence
+      INTEGER   day_end ! final day # ; i.e. day # when this simulation ends
+      INTEGER   annee_ref
+      INTEGER   day_ref
+      REAL      dt ! (dynamics) time step (changes if doing Matsuno or LF step)
+      REAL      jD_ref, jH_ref, start_time
       CHARACTER (len=10) :: calend
 
-!$OMP THREADPRIVATE(/temps/)
+      ! Additionnal Mars stuff:
+      real hour_ini ! initial fraction of day of simulation sequence (0=<hour_ini<1)
+
 !-----------------------------------------------------------------------
