Index: trunk/LMDZ.MARS/libf/dyn3d/caldyn.F
===================================================================
--- trunk/LMDZ.MARS/libf/dyn3d/caldyn.F	(revision 790)
+++ trunk/LMDZ.MARS/libf/dyn3d/caldyn.F	(revision 791)
@@ -41,5 +41,5 @@
       REAL dteta(ip1jmp1,llm),dp(ip1jmp1)
       REAL pbaru(ip1jmp1,llm),pbarv(ip1jm,llm)
-      REAL time
+      REAL time ! elapsed time (in days) since begining of the run
 
 c   Local:
Index: trunk/LMDZ.MARS/libf/dyn3d/control.h
===================================================================
--- trunk/LMDZ.MARS/libf/dyn3d/control.h	(revision 790)
+++ trunk/LMDZ.MARS/libf/dyn3d/control.h	(revision 791)
@@ -5,11 +5,18 @@
 !
 
-      COMMON/control/nday,day_step,                                     &
+      COMMON/control_i/day_step,                                        &
      &              iperiod,iconser,idissip,iphysiq ,                   &
-     &              periodav,ecritphy,anneeref
+     &              anneeref
+      COMMON/control_r/periodav,ecritphy,nday_r
 
-      INTEGER   nday,day_step,iperiod,iconser,                          &
-     &          idissip,iphysiq,anneeref
-      REAL periodav, ecritphy
+      INTEGER day_step ! # of dynamical time steps per day
+      INTEGER iperiod  ! make a Matsuno step before avery iperiod-1 LF steps
+      INTEGER iconser !
+      INTEGER idissip ! apply dissipation every idissip dynamical step
+      INTEGER iphysiq ! call physics every iphysiq dynamical steps
+      INTEGER anneeref ! reference year # ! not used
+      REAL periodav
+      REAL ecritphy ! output data in "diagfi.nc" every ecritphy dynamical steps 
+      real nday_r ! number of days to run (possibly including a fraction of day)
 
 !-----------------------------------------------------------------------
Index: trunk/LMDZ.MARS/libf/dyn3d/defrun_new.F
===================================================================
--- trunk/LMDZ.MARS/libf/dyn3d/defrun_new.F	(revision 790)
+++ trunk/LMDZ.MARS/libf/dyn3d/defrun_new.F	(revision 791)
@@ -95,7 +95,7 @@
         WRITE(tapeout,*) ""
         WRITE(tapeout,*) "Number of days to run:"
-        nday=1 ! default value
-        call getin("nday",nday)
-        WRITE(tapeout,*)" nday = ",nday
+        nday_r=1 ! default value
+        call getin("nday",nday_r)
+        WRITE(tapeout,*)" nday = ",nday_r
 
         WRITE(tapeout,*) ""
@@ -110,6 +110,13 @@
         iperiod=5 ! default value
         call getin("iperiod",iperiod)
-        WRITE(tapeout,*)" iperiod = ",iperiod
-
+        ! verify that day_step is a multiple of iperiod
+        if (((1.*day_step)/iperiod).ne.(day_step/iperiod)) then
+          write(tapeout,*)" Error! iperiod must be such that",
+     &    " day_step is a multiple of iperiod, but iperiod=",
+     &    iperiod," and day_step=",day_step
+        else
+          WRITE(tapeout,*)" iperiod = ",iperiod
+        endif
+        
         WRITE(tapeout,*) ""
         WRITE(tapeout,*) "periode de sortie des variables de ",
@@ -207,5 +214,12 @@
         iphysiq=20 ! default value
         call getin("iphysiq",iphysiq)
-        WRITE(tapeout,*)" iphysiq = ",iphysiq
+        ! verify that day_step is a multiple of iphysiq
+        if (((1.*day_step)/iphysiq).ne.(day_step/iphysiq)) then
+          write(tapeout,*)" Error! iphysiq must be such that",
+     &    " day_step is a multiple of iphysiq, but iphysiq=",
+     &    iphysiq," and day_step=",day_step
+        else
+          WRITE(tapeout,*)" iphysiq = ",iphysiq
+        endif
 
         WRITE(tapeout,*) ""
@@ -222,5 +236,12 @@
         ecritphy=240
         call getin("ecritphy",ecritphy)
-        WRITE(tapeout,*)" ecritphy = ",ecritphy
+        ! verify that ecriphy is indeed a multiple of iphysiq
+        if (((1.*ecritphy)/iphysiq).ne.(ecritphy/iphysiq)) then
+          write(tapeout,*)" Error! ecritphy must be a multiple",
+     &    " of iphysiq, but ecritphy=",ecritphy," and iphysiq=",
+     &    iphysiq
+        else
+          WRITE(tapeout,*)" ecritphy = ",ecritphy
+        endif
 
 ccc  ....   P. Le Van , ajout  le 7/03/95 .pour le zoom ...
Index: trunk/LMDZ.MARS/libf/dyn3d/dynetat0.F
===================================================================
--- trunk/LMDZ.MARS/libf/dyn3d/dynetat0.F	(revision 790)
+++ trunk/LMDZ.MARS/libf/dyn3d/dynetat0.F	(revision 791)
@@ -48,5 +48,5 @@
       REAL ps(iip1,jjp1),phis(iip1,jjp1)
 
-      REAL time
+      REAL time ! fraction of day the fields correspond to
 
 c   Variables 
@@ -383,6 +383,6 @@
       ierr=nf90_close(nid)
 
-       day_ini=day_ini+INT(time)
-       time=time-INT(time)
+      ! day_ini=day_ini+INT(time) ! obsolete stuff ; 0<time<1 anyways
+      ! time=time-INT(time)
 
   1   FORMAT(//10x,'la valeur de im =',i4,2x,'lue sur le fichier de dem
Index: trunk/LMDZ.MARS/libf/dyn3d/gcm.F
===================================================================
--- trunk/LMDZ.MARS/libf/dyn3d/gcm.F	(revision 790)
+++ trunk/LMDZ.MARS/libf/dyn3d/gcm.F	(revision 791)
@@ -199,5 +199,16 @@
           iday = iday+1
          ENDIF
-      itaufin   = nday*day_step
+      itaufin=nint(nday_r*day_step) ! nint() to avoid problematic roundoffs
+      ! check that this is compatible with call sequence dyn/phys/dissip
+      ! i.e. that itaufin is a multiple of iphysiq and idissip
+      if ((modulo(itaufin,iphysiq).ne.0).or.
+     &    (modulo(itaufin,idissip).ne.0)) then
+        write(*,*) "gcm: Problem: incompatibility between nday=",nday_r,
+     &  " day_step=",day_step," which imply itaufin=",itaufin
+        write(*,*) "  whereas iphysiq=",iphysiq," and idissip=",
+     &  idissip
+        stop
+      endif
+!      write(*,*)"gcm: itaufin=",itaufin
 c ********************************
 c      itaufin = 120   ! temporaire !!
@@ -205,5 +216,5 @@
       itaufinp1 = itaufin +1
 
-      day_end = day_ini + nday
+      day_end = day_ini + floor(nday_r+time_0)
       PRINT 300, itau,itaufin,day_ini,day_end
  300  FORMAT('1'/,15x,'run du pas',i7,2x,'au pas',i7,2x,  
@@ -231,5 +242,6 @@
       IF( MOD( itau, 10* day_step ).EQ.0 )  THEN
         CALL test_period ( ucov,vcov,teta,q,p,phis )
-        PRINT *,' ----   Test_period apres continue   OK ! -----', itau
+        write(*,*)' GCM ---- Test_period apres continue   OK ! -----',
+     &            ' itau: ',itau
       ENDIF 
 
@@ -508,7 +520,7 @@
 
 
-       PRINT *,' Appel test_period avant redem ', itau
+       write(*,*)' GCM: Appel test_period avant redem ; itau=',itau
        CALL test_period ( ucov,vcov,teta,q,p,phis )
-       CALL dynredem1("restart.nc",0.0,
+       CALL dynredem1("restart.nc",time,
      .                     vcov,ucov,teta,q,nqmx,masse,ps)
 
@@ -585,5 +597,5 @@
 
                  IF(itau.EQ.itaufin)
-     . CALL dynredem1("restart.nc",0.0,
+     . CALL dynredem1("restart.nc",time,
      .                     vcov,ucov,teta,q,nqmx,masse,ps)
 
Index: trunk/LMDZ.MARS/libf/dyn3d/sortvarc.F
===================================================================
--- trunk/LMDZ.MARS/libf/dyn3d/sortvarc.F	(revision 790)
+++ trunk/LMDZ.MARS/libf/dyn3d/sortvarc.F	(revision 791)
@@ -38,5 +38,5 @@
       REAL phi(ip1jmp1,llm),bern(ip1jmp1,llm)
       REAL dp(ip1jmp1)
-      REAL time
+      REAL time ! elapsed time (in days) since begining of the run
       REAL pk(ip1jmp1,llm)
 
@@ -60,5 +60,6 @@
        dtvrs1j   = dtvr/daysec
        rjour     = REAL( INT( itau * dtvrs1j ))
-       heure     = ( itau*dtvrs1j-rjour ) * 24.
+!       heure     = ( itau*dtvrs1j-rjour ) * 24.
+       heure     = (time-floor(time))*24.
        imjmp1    = iim * jjp1
        IF(ABS(heure - 24.).LE.0.0001 ) heure = 0.
Index: trunk/LMDZ.MARS/libf/dyn3d/temps.h
===================================================================
--- trunk/LMDZ.MARS/libf/dyn3d/temps.h	(revision 790)
+++ trunk/LMDZ.MARS/libf/dyn3d/temps.h	(revision 791)
@@ -2,11 +2,12 @@
 c INCLUDE 'temps.h'
 
-      COMMON/temps_i/itaufin,
-     s  day_ini,day_end,anne_ini
+      COMMON/temps_i/day_ini,day_end,anne_ini,itaufin
       COMMON/temps_r/dt
 
-      INTEGER  itaufin
-      INTEGER*4 day_ini,day_end,anne_ini
-      REAL     dt
+      INTEGER  itaufin  ! total number of dynamical steps for the run
+      INTEGER*4 day_ini ! initial day # of simulation sequence
+      INTEGER*4 day_end ! final day # ; i.e. day # when this simulation ends
+      INTEGER*4 anne_ini ! initial year # of simulation sequence ? Not used.
+      REAL dt ! (dynamics) time step (changes if doing Matsuno or LF step) 
 
 c-----------------------------------------------------------------------
