Index: trunk/LMDZ.MARS/changelog.txt
===================================================================
--- trunk/LMDZ.MARS/changelog.txt	(revision 3368)
+++ trunk/LMDZ.MARS/changelog.txt	(revision 3369)
@@ -4664,2 +4664,9 @@
 - Correction for the script "launch_orb_1Dchained.sh" in the deftank.
 - Small cleanings related to error detection.
+
+== 12/06/2024 == EM
+Change the way the rate of outputs for diagfi.nc files is specified:
+IMPORTANT: Specifying "ecritphy" no longer possible and will trigger an error.
+Use "outputs_per_sol" to specify output rate instead.
+This should makes things (hopefully) clearer for users and also better
+enforces a cleaner and clearer separation between dynamics and physics.
Index: trunk/LMDZ.MARS/deftank/callphys.def.GCM5
===================================================================
--- trunk/LMDZ.MARS/deftank/callphys.def.GCM5	(revision 3368)
+++ trunk/LMDZ.MARS/deftank/callphys.def.GCM5	(revision 3369)
@@ -3,4 +3,7 @@
 #Run with or without tracer transport ?
 tracer=.true.
+
+# Number of outputs per sol for diagfi.nc files
+outputs_per_sol=4
 
 #Diurnal cycle ?  if diurnal=False, diurnal averaged solar heating
Index: trunk/LMDZ.MARS/deftank/callphys.def.GCM6
===================================================================
--- trunk/LMDZ.MARS/deftank/callphys.def.GCM6	(revision 3368)
+++ trunk/LMDZ.MARS/deftank/callphys.def.GCM6	(revision 3369)
@@ -3,4 +3,7 @@
 #Directory where external input files are:
 datadir=datadir
+
+# Number of outputs per sol for diagfi.nc files
+outputs_per_sol=8
 
 #Run with or without tracer transport ?
Index: trunk/LMDZ.MARS/deftank/callphys.def.MCD5
===================================================================
--- trunk/LMDZ.MARS/deftank/callphys.def.MCD5	(revision 3368)
+++ trunk/LMDZ.MARS/deftank/callphys.def.MCD5	(revision 3369)
@@ -3,4 +3,7 @@
 #Run with or without tracer transport ?
 tracer=.true.
+
+# Number of outputs per sol for diagfi.nc files
+outputs_per_sol=4
 
 #Directory where external input files are:
Index: trunk/LMDZ.MARS/deftank/callphys.def.MCD6
===================================================================
--- trunk/LMDZ.MARS/deftank/callphys.def.MCD6	(revision 3368)
+++ trunk/LMDZ.MARS/deftank/callphys.def.MCD6	(revision 3369)
@@ -3,4 +3,7 @@
 #Directory where external input files are:
 datadir=./datadir
+
+# Number of outputs per sol for diagfi.nc files
+outputs_per_sol=8
 
 #Run with or without tracer transport ?
Index: trunk/LMDZ.MARS/deftank/callphys.def.co2clouds.GCM5
===================================================================
--- trunk/LMDZ.MARS/deftank/callphys.def.co2clouds.GCM5	(revision 3368)
+++ trunk/LMDZ.MARS/deftank/callphys.def.co2clouds.GCM5	(revision 3369)
@@ -3,4 +3,7 @@
 #Run with or without tracer transport ?
 tracer=.true.
+
+# Number of outputs per sol for diagfi.nc files
+outputs_per_sol=4
 
 # check input fields when entering physics? 
Index: trunk/LMDZ.MARS/deftank/callphys.def.hdo.GCM5
===================================================================
--- trunk/LMDZ.MARS/deftank/callphys.def.hdo.GCM5	(revision 3368)
+++ trunk/LMDZ.MARS/deftank/callphys.def.hdo.GCM5	(revision 3369)
@@ -3,4 +3,7 @@
 #Run with or without tracer transport ?
 tracer=.true.
+
+# Number of outputs per sol for diagfi.nc files
+outputs_per_sol=4
 
 #Diurnal cycle ?  if diurnal=False, diurnal averaged solar heating
Index: trunk/LMDZ.MARS/deftank/run.def.32x24x25.GCM5
===================================================================
--- trunk/LMDZ.MARS/deftank/run.def.32x24x25.GCM5	(revision 3368)
+++ trunk/LMDZ.MARS/deftank/run.def.32x24x25.GCM5	(revision 3369)
@@ -61,7 +61,4 @@
   grireg=.true.
 
-# Output in diagfi file every ecritphy dynamical steps 
- ecritphy=120
-
 # longitude (degrees) of zoom center
    clon=63.
Index: trunk/LMDZ.MARS/deftank/run.def.32x24x32.GCM5
===================================================================
--- trunk/LMDZ.MARS/deftank/run.def.32x24x32.GCM5	(revision 3368)
+++ trunk/LMDZ.MARS/deftank/run.def.32x24x32.GCM5	(revision 3369)
@@ -61,7 +61,4 @@
   grireg=.true.
 
-# Output in diagfi file every ecritphy dynamical steps 
- ecritphy=120
-
 # longitude (degrees) of zoom center
    clon=63.
Index: trunk/LMDZ.MARS/deftank/run.def.64x48x32.GCM5
===================================================================
--- trunk/LMDZ.MARS/deftank/run.def.64x48x32.GCM5	(revision 3368)
+++ trunk/LMDZ.MARS/deftank/run.def.64x48x32.GCM5	(revision 3369)
@@ -67,7 +67,4 @@
   grireg=.true.
 
-# Output in diagfi file every ecritphy dynamical steps 
- ecritphy=240
-
 # longitude (degrees) of zoom center
    clon=63.
Index: trunk/LMDZ.MARS/deftank/run.def.64x48x49.MCD5
===================================================================
--- trunk/LMDZ.MARS/deftank/run.def.64x48x49.MCD5	(revision 3368)
+++ trunk/LMDZ.MARS/deftank/run.def.64x48x49.MCD5	(revision 3369)
@@ -67,7 +67,4 @@
   grireg=.true.
 
-# Output in diagfi file every ecritphy dynamical steps 
- ecritphy=240
-
 # longitude (degrees) of zoom center
    clon=63.
Index: trunk/LMDZ.MARS/deftank/run.def.64x48x54.GCM6
===================================================================
--- trunk/LMDZ.MARS/deftank/run.def.64x48x54.GCM6	(revision 3368)
+++ trunk/LMDZ.MARS/deftank/run.def.64x48x54.GCM6	(revision 3369)
@@ -67,7 +67,4 @@
   grireg=.true.
 
-# Output in diagfi file every ecritphy dynamical steps 
- ecritphy=240
-
 # longitude (degrees) of zoom center
    clon=63.
Index: trunk/LMDZ.MARS/deftank/run.def.64x48x73.MCD6
===================================================================
--- trunk/LMDZ.MARS/deftank/run.def.64x48x73.MCD6	(revision 3368)
+++ trunk/LMDZ.MARS/deftank/run.def.64x48x73.MCD6	(revision 3369)
@@ -67,7 +67,4 @@
   grireg=.true.
 
-# Output in diagfi file every ecritphy dynamical steps 
- ecritphy=120
-
 # longitude (degrees) of zoom center
    clon=63.
Index: trunk/LMDZ.MARS/libf/phymars/conf_phys.F
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/conf_phys.F	(revision 3368)
+++ trunk/LMDZ.MARS/libf/phymars/conf_phys.F	(revision 3369)
@@ -22,6 +22,6 @@
      &                     frost_albedo_threshold, inert_h2o_ice,
      &                     frost_metam_threshold,old_wsublimation_scheme
-      use time_phylmdz_mod, only: ecritphy,day_step,iphysiq,ecritstart,
-     &                            daysec,dtphys
+      use time_phylmdz_mod, only: steps_per_sol,outputs_per_sol,iphysiq,
+     &                            ecritstart,daysec,dtphys
       use dimradmars_mod, only: naerkind, name_iaer,
      &                      ini_scatterers,tauvis
@@ -55,4 +55,6 @@
       INTEGER ierr,j
       character(len=20),parameter :: modname="conf_phys"
+      
+      real :: ecritphy ! to check that this obsolete flag is no longer used...
  
       CHARACTER ch1*12
@@ -60,9 +62,24 @@
       ! read in some parameters from "run.def" for physics,
       ! or shared between dynamics and physics.
-      ecritphy=240 ! default value
+      ecritphy=-666 ! dummy default value
       call getin_p("ecritphy",ecritphy) ! frequency of outputs in physics,
                                       ! in dynamical steps
-      day_step=960 ! default value
-      call getin_p("day_step",day_step) ! number of dynamical steps per day
+      if (ecritphy/=-666) then
+        call abort_physic(modname,
+     &     "Error: parameter ecritphy is obsolete! Remove it! "//
+     &     "And use outputs_per_sol instead",1)
+      endif
+      
+      outputs_per_sol=4 ! default value, 4 outputs per sol
+      call getin_p("outputs_per_sol",outputs_per_sol)
+      ! check that indeed it is possible for given physics time step
+      if (modulo(steps_per_sol,outputs_per_sol)/=0) then
+        write(*,*) "Error: outputs_per_sol = ",outputs_per_sol
+        write(*,*) " is not a divisor of number of steps per sol = ",
+     &             steps_per_sol
+        call abort_physic(modname,
+     &     "Error: inadequate value for outputs_per_sol",1)
+      endif 
+      
       iphysiq=20 ! default value
       call getin_p("iphysiq",iphysiq) ! call physics every iphysiq dyn step
Index: trunk/LMDZ.MARS/libf/phymars/dyn1d/init_testphys1d_mod.F90
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/dyn1d/init_testphys1d_mod.F90	(revision 3368)
+++ trunk/LMDZ.MARS/libf/phymars/dyn1d/init_testphys1d_mod.F90	(revision 3369)
@@ -11,5 +11,5 @@
 use ioipsl_getincom,          only: getin ! To use 'getin'
 use comcstfi_h,               only: pi, rad, omeg, g, mugaz, rcp, r, cpp
-use time_phylmdz_mod,         only: daysec, day_step, ecritphy, iphysiq
+use time_phylmdz_mod, only: daysec, steps_per_sol, outputs_per_sol, iphysiq
 use planete_h,                only: year_day, periheli, aphelie, peri_day, obliquit, emin_turb, lmixmin
 use surfdat_h,                only: albedodat, z0_default, z0, emissiv, emisice, albedice, iceradius, dtemisice,      &
@@ -287,10 +287,10 @@
 nsoil = nsoilmx
 
-day_step = 48 ! Default value for day_step
+steps_per_sol = 48 ! Default value for day_step (old name for steps_per_sol)
 write(*,*)'Number of time steps per sol?'
-call getin("day_step",day_step)
-write(*,*) " day_step = ",day_step
-
-ecritphy = day_step ! Default value for ecritphy, output every time step
+call getin("day_step",steps_per_sol)
+write(*,*) " steps_per_sol (aka day_step) = ",steps_per_sol
+
+outputs_per_sol = steps_per_sol ! Default value for outputs_per_sol
 
 ndt = 10 ! Default value for ndt
@@ -300,6 +300,6 @@
 
 dayn = day0 + ndt
-ndt = ndt*day_step
-dttestphys = daysec/day_step
+ndt = ndt*steps_per_sol
+dttestphys = daysec/steps_per_sol
 
 ! Imposed surface pressure
Index: trunk/LMDZ.MARS/libf/phymars/dyn1d/testphys1d.F90
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/dyn1d/testphys1d.F90	(revision 3368)
+++ trunk/LMDZ.MARS/libf/phymars/dyn1d/testphys1d.F90	(revision 3369)
@@ -8,5 +8,5 @@
 use tracer_mod,          only: igcm_h2o_vap, igcm_h2o_ice, igcm_co2, noms
 use comcstfi_h,          only: pi, g, rcp, cpp
-use time_phylmdz_mod,    only: daysec, day_step
+use time_phylmdz_mod, only: daysec
 use dimradmars_mod,      only: tauvis, totcloudfrac, albedo
 use dust_param_mod,      only: tauscaling
Index: trunk/LMDZ.MARS/libf/phymars/physiq_mod.F
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/physiq_mod.F	(revision 3368)
+++ trunk/LMDZ.MARS/libf/phymars/physiq_mod.F	(revision 3369)
@@ -65,5 +65,6 @@
       use conc_mod, only: init_r_cp_mu, update_r_cp_mu_ak, rnew,
      &                    cpnew, mmean
-      use time_phylmdz_mod, only: iphysiq, day_step, ecritstart, daysec
+      use time_phylmdz_mod, only: steps_per_sol
+      use time_phylmdz_mod, only: iphysiq, ecritstart, daysec
       use dimradmars_mod, only: aerosol, totcloudfrac,
      &                          dtrad, fluxrad_sky, fluxrad, albedo,
@@ -1007,6 +1008,7 @@
            ENDIF !end callnlte
 
-c          Find number of layers for LTE radiation calculations
-           IF(MOD(iphysiq*(icount-1),day_step).EQ.0)
+!          Find number of layers for LTE radiation calculations
+!          (done only once per sol)
+           IF(MOD((icount-1),steps_per_sol).EQ.0)
      &          CALL nlthermeq(ngrid,nlayer,zplev,zplay)
 
Index: trunk/LMDZ.MARS/libf/phymars/time_phylmdz_mod.F90
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/time_phylmdz_mod.F90	(revision 3368)
+++ trunk/LMDZ.MARS/libf/phymars/time_phylmdz_mod.F90	(revision 3369)
@@ -4,9 +4,11 @@
     REAL,SAVE    :: dtphys      ! physics time step (s)
 !$OMP THREADPRIVATE(dtphys)
-    INTEGER,SAVE :: day_step    ! number of dynamical steps per day
-                                ! (set via conf_phys)
-!$OMP THREADPRIVATE(day_step)
+
     REAL,SAVE    :: daysec     ! length of day (s)
 !$OMP THREADPRIVATE(daysec)
+
+    INTEGER,SAVE :: steps_per_sol ! number of physics steps per sol 
+!$OMP THREADPRIVATE(steps_per_sol)
+
     INTEGER,SAVE :: day_ini     ! initial day of the run
 !$OMP THREADPRIVATE(day_ini)
@@ -17,7 +19,8 @@
 !$OMP THREADPRIVATE(hour_ini)
 
-    INTEGER,SAVE :: ecritphy    ! for diagfi.nc outputs, write every ecritphy
-                                ! dynamical steps (set via conf_phys)
-!$OMP THREADPRIVATE(ecritphy)
+    INTEGER,SAVE :: outputs_per_sol ! for diagfi.nc outputs, number of outputs
+                                    ! per sol (set via conf_phys)
+!$OMP THREADPRIVATE(outputs_per_sol)
+
     INTEGER,SAVE :: iphysiq   ! call physics every iphysiq dynamical step
                               ! (set via conf_phys)
@@ -43,4 +46,7 @@
     dtphys=dtphys_
     
+    ! compute number of physics steps per sol
+    steps_per_sol=nint(daysec/dtphys)
+    
   END SUBROUTINE init_time
 
Index: trunk/LMDZ.MARS/libf/phymars/writediagfi.F
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/writediagfi.F	(revision 3368)
+++ trunk/LMDZ.MARS/libf/phymars/writediagfi.F	(revision 3369)
@@ -41,5 +41,6 @@
       use surfdat_h, only: phisfi
       use geometry_mod, only: cell_area
-      use time_phylmdz_mod, only: ecritphy, day_step, iphysiq, day_ini
+      use time_phylmdz_mod, only: steps_per_sol, outputs_per_sol
+      use time_phylmdz_mod, only: day_ini
       USE mod_phys_lmdz_para, only : is_parallel, is_mpi_root,
      &                               is_master, gather
@@ -73,5 +74,5 @@
       REAL area((nbp_lon+1),nbp_lat)
 
-      integer irythme
+      integer isample
       integer ierr,ierr2
       integer i,j,l, ig0
@@ -121,7 +122,7 @@
 
 !***************************************************************
-!Sortie des variables au rythme voulu
-
-      irythme = int(ecritphy) ! output rate set by ecritphy
+! Compute the output rate
+
+      isample=steps_per_sol/outputs_per_sol
 
 !***************************************************************
@@ -267,5 +268,5 @@
 !------------------------------------------------------------------------
       if (nom.eq.firstnom) then
-          zitau = zitau + iphysiq
+          zitau = zitau + 1
       end if
 
@@ -274,5 +275,5 @@
 !--------------------------------------------------------
 
-      if ( MOD(zitau+1,irythme) .eq.0.) then
+      if ( MOD(zitau+1,isample) .eq.0.) then
 
 ! Compute/write/extend 'Time' coordinate (date given in days)
@@ -287,5 +288,5 @@
            ntime=ntime+1 ! increment # of stored time steps
            ! compute corresponding date (in days and fractions thereof)
-           date=(zitau +1.)/day_step
+           date=(zitau +1.)/steps_per_sol
            ! Get NetCDF ID of 'Time' variable
            ierr= NF_INQ_VARID(nid,"Time",varid)
@@ -620,5 +621,5 @@
         endif ! of if (dim.eq.3) elseif(dim.eq.2)...
 
-      endif ! of if ( MOD(zitau+1,irythme) .eq.0.)
+      endif ! of if ( MOD(zitau+1,isample) .eq.0.)
 
       if (is_master) then
Index: trunk/LMDZ.MARS/libf/phymars/writediagmicrofi.F
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/writediagmicrofi.F	(revision 3368)
+++ trunk/LMDZ.MARS/libf/phymars/writediagmicrofi.F	(revision 3369)
@@ -45,5 +45,6 @@
       use surfdat_h, only: phisfi
       use geometry_mod, only: cell_area
-      use time_phylmdz_mod, only: ecritphy, day_step, iphysiq, day_ini
+      use time_phylmdz_mod, only: steps_per_sol, outputs_per_sol
+      use time_phylmdz_mod, only: day_ini
       USE mod_phys_lmdz_para, only : is_parallel, is_mpi_root,
      &                               is_master, gather
@@ -80,5 +81,5 @@
       REAL area((nbp_lon+1),nbp_lat)
 
-      integer irythme
+      integer isample
       integer ierr,ierr2
       integer i,j,l, ig0
@@ -124,7 +125,7 @@
 
 !***************************************************************
-!Sortie des variables au rythme voulu
-
-      irythme = int(ecritphy) ! output rate set by ecritphy
+! Compute the output rate
+
+      isample = steps_per_sol/outputs_per_sol
 
 !***************************************************************
@@ -280,5 +281,5 @@
 !------------------------------------------------------------------------
       if ((nom.eq.firstnom) .and. (microstep.eq.1)) then
-          zitau = zitau + iphysiq
+          zitau = zitau + 1
       end if
 
@@ -287,5 +288,5 @@
 !--------------------------------------------------------
 
-      if ( MOD(zitau+1,irythme) .eq.0.) then
+      if ( MOD(zitau+1,isample) .eq.0.) then
 
 ! Compute/write/extend 'Time' coordinate (date given in days)
@@ -300,5 +301,5 @@
            ntime=ntime+1 ! increment # of stored time steps
            ! compute corresponding date (in days and fractions thereof)
-           date=(zitau +1.)/day_step
+           date=(zitau +1.)/steps_per_sol
            subdate=0.
            ! Get NetCDF ID of 'Time' variable
@@ -668,5 +669,5 @@
         endif ! of if (dim.eq.3) elseif(dim.eq.2)...
 
-      endif ! of if ( MOD(zitau+1,irythme) .eq.0.)
+      endif ! of if ( MOD(zitau+1,isample) .eq.0.)
 
       if (is_master) then
Index: trunk/LMDZ.MARS/libf/phymars/writediagsoil.F90
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/writediagsoil.F90	(revision 3368)
+++ trunk/LMDZ.MARS/libf/phymars/writediagsoil.F90	(revision 3369)
@@ -23,5 +23,5 @@
 use comsoil_h, only: mlayer, nsoilmx, inertiedat
 use geometry_mod, only: cell_area
-use time_phylmdz_mod, only: ecritphy, day_step, iphysiq
+use time_phylmdz_mod, only: steps_per_sol, outputs_per_sol
 use mod_phys_lmdz_para, only: is_mpi_root, is_master, gather
 use mod_grid_phy_lmdz, only: klon_glo, Grid1Dto2D_glo, nbp_lon, nbp_lat
@@ -109,5 +109,5 @@
   
   ! Set output sample rate
-  isample=int(ecritphy) ! same as for diagfi outputs
+  isample=steps_per_sol/outputs_per_sol ! same as for diagfi outputs
   ! Note ecritphy is known from control.h
   
@@ -175,6 +175,5 @@
 if (name.eq.firstname) then
   ! if we run across 'firstname', then it is a new time step
-  zitau=zitau+iphysiq
-  ! Note iphysiq is known from control.h
+  zitau=zitau+1
 endif
 
@@ -185,6 +184,5 @@
   if (name.eq.firstname) then
     ntime=ntime+1
-    date=float(zitau+1)/float(day_step)
-    ! Note: day_step is known from control.h
+    date=float(zitau+1)/float(steps_per_sol)
     
     if (is_master) then
