Index: trunk/LMDZ.COMMON/libf/dyn3d/conf_gcm.F
===================================================================
--- trunk/LMDZ.COMMON/libf/dyn3d/conf_gcm.F	(revision 1021)
+++ trunk/LMDZ.COMMON/libf/dyn3d/conf_gcm.F	(revision 1022)
@@ -162,4 +162,9 @@
       CALL getin('nday',nday)
 
+      ! alternative to specifying nday (see also 'less1day' and 'fractday'
+      ! options below: sopecify numbre of dynamic steps to run:
+      ndynstep = -9999 ! default value ; if ndynstep <0 then option not used.
+      call getin('ndynstep',ndynstep)
+      
 !Config  Key  = starttime
 !Config  Desc = Heure de depart de la simulation
@@ -900,4 +905,6 @@
       write(lunout,*)' anneeref = ', anneeref
       write(lunout,*)' nday = ', nday
+      if (ndynstep.ne.-9999) write(lunout,*)' ndynstep = ', ndynstep
+      if (less1day) write(lunout,*)' fractday = ', fractday
       write(lunout,*)' day_step = ', day_step
       write(lunout,*)' iperiod = ', iperiod
Index: trunk/LMDZ.COMMON/libf/dyn3d/control_mod.F90
===================================================================
--- trunk/LMDZ.COMMON/libf/dyn3d/control_mod.F90	(revision 1021)
+++ trunk/LMDZ.COMMON/libf/dyn3d/control_mod.F90	(revision 1022)
@@ -27,4 +27,7 @@
   LOGICAL :: less1day   ! allows to run less than 1 day (for Venus)
   REAL    :: 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
 
 END MODULE
Index: trunk/LMDZ.COMMON/libf/dyn3d/gcm.F
===================================================================
--- trunk/LMDZ.COMMON/libf/dyn3d/gcm.F	(revision 1021)
+++ trunk/LMDZ.COMMON/libf/dyn3d/gcm.F	(revision 1022)
@@ -21,5 +21,8 @@
       USE filtreg_mod
       USE infotrac
-      USE control_mod
+      USE control_mod, only: planet_type,nday,day_step,iperiod,iphysiq,
+     &                       raz_date,anneeref,starttime,dayref,
+     &                       ok_dyn_ins,ok_dyn_ave,iecri,periodav,
+     &                       less1day,fractday,ndynstep
       use cpdet_mod, only: ini_cpdet
 
@@ -496,8 +499,14 @@
 c   ------------------------
 
-
-      day_end = day_ini + nday
-      WRITE(lunout,300)day_ini,day_end
- 300  FORMAT('1'/,15x,'run du jour',i7,2x,'au jour',i7//)
+      day_end=day_ini+nday
+      if (less1day) then
+        day_end=day_ini+floor(time_0+fractday)
+      endif
+      if (ndynstep.gt.0) then
+        day_end=day_ini+floor(time_0+float(ndynstep)/float(day_step))
+      endif
+      
+      WRITE(lunout,'(a,i7,a,i7)')
+     &             "run from day ",day_ini,"  to day",day_end
 
 #ifdef CPP_IOIPSL
Index: trunk/LMDZ.COMMON/libf/dyn3d/leapfrog.F
===================================================================
--- trunk/LMDZ.COMMON/libf/dyn3d/leapfrog.F	(revision 1021)
+++ trunk/LMDZ.COMMON/libf/dyn3d/leapfrog.F	(revision 1022)
@@ -15,5 +15,9 @@
       USE guide_mod, ONLY : guide_main
       USE write_field
-      USE control_mod
+      USE control_mod, only: planet_type,nday,day_step,iperiod,iphysiq,
+     &                       less1day,fractday,ndynstep,iconser,
+     &                       dissip_period,offline,ip_ebil_dyn,
+     &                       ok_dynzon,periodav,ok_dyn_ave,iecri,
+     &                       ok_dyn_ins,output_grads_dyn
       use cpdet_mod, only: cpdet,tpot2t,t2tpot
       use sponge_mod, only: callsponge,mode_sponge,sponge
@@ -212,4 +216,8 @@
 c MODIF VENUS: to run less than one day:
         itaufin   = int(fractday*day_step)
+      endif
+      if (ndynstep.gt.0) then
+        ! running a given number of dynamical steps
+        itaufin=ndynstep
       endif
       itaufinp1 = itaufin +1
Index: trunk/LMDZ.COMMON/libf/dyn3d/sortvarc.F
===================================================================
--- trunk/LMDZ.COMMON/libf/dyn3d/sortvarc.F	(revision 1021)
+++ trunk/LMDZ.COMMON/libf/dyn3d/sortvarc.F	(revision 1022)
@@ -154,10 +154,32 @@
       END IF
 
-      etot= etot/etot0
+      ! compute relative changes in etot,... (except if 'reference' values
+      ! are zero, which can happen when using iniacademic)
+      if (etot0.ne.0) then
+        etot= etot/etot0
+      else
+        etot=1.
+      endif
       rmsv= SQRT(rmsv/ptot)
-      ptot= ptot/ptot0
-      ztot= ztot/ztot0
-      stot= stot/stot0
-      ang = ang /ang0
+      if (ptot0.ne.0) then
+        ptot= ptot/ptot0
+      else
+        ptot=1.
+      endif
+      if (ztot0.ne.0) then
+        ztot= ztot/ztot0
+      else
+        ztot=1.
+      endif
+      if (stot0.ne.0) then
+        stot= stot/stot0
+      else
+        stot=1.
+      endif
+      if (ang0.ne.0) then
+        ang = ang /ang0
+      else
+        ang=1.
+      endif
 
       firstcal = .false.
