Index: /trunk/LMDZ.COMMON/libf/dyn3d/gcm.F90
===================================================================
--- /trunk/LMDZ.COMMON/libf/dyn3d/gcm.F90	(revision 3304)
+++ /trunk/LMDZ.COMMON/libf/dyn3d/gcm.F90	(revision 3305)
@@ -467,9 +467,9 @@
      ! Physics:
 #ifdef CPP_PHYS
-     CALL iniphysiq(iim,jjm,llm, &
-          (jjm-1)*iim+2,comm_lmdz, &
-          daysec,day_ini,dtphys/nsplit_phys, &
-          rlatu,rlatv,rlonu,rlonv,aire,cu,cv,rad,g,r,cpp, &
-          iflag_phys)
+     CALL iniphysiq('startfi.nc',iim,jjm,llm,                       &
+                    (jjm-1)*iim+2,comm_lmdz,                        &
+                    daysec,day_ini,dtphys/nsplit_phys,              &
+                    rlatu,rlatv,rlonu,rlonv,aire,cu,cv,rad,g,r,cpp, &
+                    iflag_phys)
 #endif
   ENDIF ! of IF ((iflag_phys==1).or.(iflag_phys>=100))
@@ -502,6 +502,5 @@
     t_ops =((1.0*iecri)/day_step) * daysec  
     t_wrt = daysec ! iecri * daysec ! write output every t_wrt
-    CALL inithist(day_ref,annee_ref,time_step, &
-                   t_ops,t_wrt)
+    CALL inithist(day_ref,annee_ref,time_step,t_ops,t_wrt)
   endif
 
@@ -510,6 +509,5 @@
     t_ops = iperiod * time_step ! do operations every t_ops
     t_wrt = periodav * daysec   ! write output every t_wrt
-    CALL initdynav(day_ref,annee_ref,time_step, &
-            t_ops,t_wrt)
+    CALL initdynav(day_ref,annee_ref,time_step,t_ops,t_wrt)
   END IF
   dtav = iperiod*dtvr/daysec
Index: /trunk/LMDZ.COMMON/libf/dyn3dpar/gcm.F
===================================================================
--- /trunk/LMDZ.COMMON/libf/dyn3dpar/gcm.F	(revision 3304)
+++ /trunk/LMDZ.COMMON/libf/dyn3dpar/gcm.F	(revision 3305)
@@ -487,5 +487,5 @@
 ! Physics
 #ifdef CPP_PHYS
-         CALL iniphysiq(iim,jjm,llm,
+         CALL iniphysiq('startfi.nc',iim,jjm,llm,
      &                distrib_phys(mpi_rank),comm_lmdz,
      &                daysec,day_ini,dtphys/nsplit_phys,
Index: /trunk/LMDZ.MARS/changelog.txt
===================================================================
--- /trunk/LMDZ.MARS/changelog.txt	(revision 3304)
+++ /trunk/LMDZ.MARS/changelog.txt	(revision 3305)
@@ -4611,2 +4611,7 @@
 == 16/04/2024 == CS
 Correction of a misspelled stats output variable name.
+
+== 18/04/2024 == JBC
+- Addition of the "startfi" file name as an argument for "phys_state_var_init_mod.F90"/"iniphysiq_mod.F90" to be able to initialize correctly the 3D PEM with its dedicated "startfi" file name.
+- Small update of xml files for XIOS in the deftank, mainly to make the 3D PEM run with slopes.
+- Few cleanings in "phyetat0_mod.F90".
Index: /trunk/LMDZ.MARS/deftank/field_def_physics_mars.xml
===================================================================
--- /trunk/LMDZ.MARS/deftank/field_def_physics_mars.xml	(revision 3304)
+++ /trunk/LMDZ.MARS/deftank/field_def_physics_mars.xml	(revision 3305)
@@ -1292,5 +1292,4 @@
                    unit="m^2/s" />
 
-
         </field_group>
 
Index: /trunk/LMDZ.MARS/deftank/file_def_physics_mars.xml
===================================================================
--- /trunk/LMDZ.MARS/deftank/file_def_physics_mars.xml	(revision 3304)
+++ /trunk/LMDZ.MARS/deftank/file_def_physics_mars.xml	(revision 3305)
@@ -1,5 +1,5 @@
 <!-- =========================================================================================================== -->
-<!-- file_def_physics_mars.xml                                                                                  -->
-<!-- Definition of output files from Martian physics                                -->
+<!-- file_def_physics_mars.xml                                                                                   -->
+<!-- Definition of output files from Martian physics                                                             -->
 <!-- =========================================================================================================== -->
 
@@ -125,5 +125,5 @@
         <!-- FILE 4 :diurnal averages outputs for PEM with sub-slopes; output_freq is every day -->
         <file id="diurnalave_s"
-              name="Xdiurnalave_s"
+              name="Xdiurnalave"
               output_freq="1d"
               type="one_file"
Index: /trunk/LMDZ.MARS/deftank/iodef.xml
===================================================================
--- /trunk/LMDZ.MARS/deftank/iodef.xml	(revision 3304)
+++ /trunk/LMDZ.MARS/deftank/iodef.xml	(revision 3305)
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
 <simulation> 
-        
+
         <context  id="xios">
             <variable_definition>
@@ -24,8 +24,6 @@
             </variable_definition>
         </context>
-        
 
         <context id="LMDZ" src="./context_lmdz_physics.xml"/>
 
-
 </simulation>
Index: /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/iniphysiq_mod.F90
===================================================================
--- /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/iniphysiq_mod.F90	(revision 3304)
+++ /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/iniphysiq_mod.F90	(revision 3305)
@@ -3,15 +3,15 @@
 CONTAINS
 
-subroutine iniphysiq(ii,jj,nlayer, &
-                     nbp, communicator, &
-                     punjours, pdayref,ptimestep, &
+subroutine iniphysiq(filename,ii,jj,nlayer,               &
+                     nbp, communicator,                   &
+                     punjours, pdayref,ptimestep,         &
                      rlatudyn,rlatvdyn,rlonudyn,rlonvdyn, &
-                     airedyn,cudyn,cvdyn, &
+                     airedyn,cudyn,cvdyn,                 &
                      prad,pg,pr,pcpp,iflag_phys)
 
 ! Modules from the dynamics:
-use infotrac, only : nqtot, & ! number of advected tracers
-                     tname, & ! tracer names
-                     nqperes,nqfils! MVals: variables isotopes
+use infotrac, only : nqtot, &        ! number of advected tracers
+                     tname, &        ! tracer names
+                     nqperes, nqfils ! MVals: variables isotopes
 use temps_mod, only: day_ini, day_end, hour_ini
 
@@ -23,5 +23,5 @@
 use geometry_mod, only: cell_area, & ! physics grid area (m2)
                         longitude, & ! longitudes (rad)
-                        latitude ! latitudes (rad)
+                        latitude     ! latitudes (rad)
 use phys_state_var_init_mod, only: phys_state_var_init
 use mod_phys_lmdz_para, only: klon_omp ! number of columns (on local omp grid)
@@ -32,4 +32,5 @@
 include "iniprint.h"
 
+character(*), intent(in) :: filename ! Name of the "startfi.nc" file
 real,intent(in) :: prad ! radius of the planet (m)
 real,intent(in) :: pg ! gravitational acceleration (m/s2)
@@ -57,9 +58,9 @@
   ! --> initialize physics distribution, global fields and geometry
   ! (i.e. things in phy_common or dynphy_lonlat)
-  CALL inigeomphy(ii,jj,nlayer, &
-               nbp, communicator, &
-               rlatudyn,rlatvdyn, &
-               rlonudyn,rlonvdyn, &
-               airedyn,cudyn,cvdyn)
+  CALL inigeomphy(ii,jj,nlayer,      &
+                  nbp, communicator, &
+                  rlatudyn,rlatvdyn, &
+                  rlonudyn,rlonvdyn, &
+                  airedyn,cudyn,cvdyn)
 
   ! the distinct part for all planetary physics (ie. things in phymars)
@@ -71,8 +72,8 @@
 !$OMP PARALLEL COPYIN(day_ini,day_end,hour_ini)
 
-call phys_state_var_init(klon_omp,nlayer,nqtot,tname, &
-                         day_ini,day_end,hour_ini,&
-                         punjours,ptimestep, &
-                         prad,pg,pr,pcpp, &
+call phys_state_var_init(filename,klon_omp,nlayer,nqtot,tname, &
+                         day_ini,day_end,hour_ini,             &
+                         punjours,ptimestep,                   &
+                         prad,pg,pr,pcpp,                      &
                          nqperes,nqfils) ! MVals: variables isotopes
 call ini_fillgeom(klon_omp,latitude,longitude,cell_area)
Index: /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/newstart.F
===================================================================
--- /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/newstart.F	(revision 3304)
+++ /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/newstart.F	(revision 3305)
@@ -391,10 +391,9 @@
 
 ! Initialize the physics
-         CALL iniphysiq(iim,jjm,llm,
+         CALL iniphysiq('startfi.nc',iim,jjm,llm,
      &                  (jjm-1)*iim+2,comm_lmdz,
      &                  daysec,day_ini,dtphys,
      &                  rlatu,rlatv,rlonu,rlonv,
-     &                  aire,cu,cv,rad,g,r,cpp,
-     &                  1)
+     &                  aire,cu,cv,rad,g,r,cpp,1)
 
 c=======================================================================
Index: /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/nogcm.F90
===================================================================
--- /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/nogcm.F90	(revision 3304)
+++ /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/nogcm.F90	(revision 3305)
@@ -458,7 +458,7 @@
      ! Physics:
 #ifdef CPP_PHYS
-     CALL iniphysiq(iim,jjm,llm, &
-          (jjm-1)*iim+2,comm_lmdz, &
-          daysec,day_ini,dtphys/nsplit_phys, &
+     CALL iniphysiq('startfi.nc',iim,jjm,llm,             &
+          (jjm-1)*iim+2,comm_lmdz,                        &
+          daysec,day_ini,dtphys/nsplit_phys,              &
           rlatu,rlatv,rlonu,rlonv,aire,cu,cv,rad,g,r,cpp, &
           iflag_phys)
Index: /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/start2archive.F
===================================================================
--- /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/start2archive.F	(revision 3304)
+++ /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/start2archive.F	(revision 3305)
@@ -160,12 +160,12 @@
 
 ! Initialize the physics
-         CALL iniphysiq(iim,jjm,llm,
+      fichnom = 'startfi.nc'
+
+         CALL iniphysiq(fichnom,iim,jjm,llm,
      &                  (jjm-1)*iim+2,comm_lmdz,
      &                  daysec,day_ini,dtphys,
      &                  rlatu,rlatv,rlonu,rlonv,
-     &                  aire,cu,cv,rad,g,r,cpp,
-     &                  1)
-
-      fichnom = 'startfi.nc'
+     &                  aire,cu,cv,rad,g,r,cpp,1)
+
       Lmodif=0
 
Index: /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/start2archive_SSO.F
===================================================================
--- /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/start2archive_SSO.F	(revision 3304)
+++ /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/start2archive_SSO.F	(revision 3305)
@@ -173,12 +173,12 @@
 
 ! Initialize the physics
-         CALL iniphysiq(iim,jjm,llm,
+      fichnom = 'startfi.nc'
+
+         CALL iniphysiq(fichnom,iim,jjm,llm,
      &                  (jjm-1)*iim+2,comm_lmdz,
      &                  daysec,day_ini,dtphys,
      &                  rlatu,rlatv,rlonu,rlonv,
-     &                  aire,cu,cv,rad,g,r,cpp,
-     &                  1)
-
-      fichnom = 'startfi.nc'
+     &                  aire,cu,cv,rad,g,r,cpp,1)
+
       Lmodif=0
 
Index: /trunk/LMDZ.MARS/libf/phymars/phyetat0_mod.F90
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/phyetat0_mod.F90	(revision 3304)
+++ /trunk/LMDZ.MARS/libf/phymars/phyetat0_mod.F90	(revision 3305)
@@ -2,41 +2,44 @@
 
 implicit none
-  real,save :: tab_cntrl_mod(100)
+
+real, save :: tab_cntrl_mod(100)
 
 !$OMP THREADPRIVATE(tab_cntrl_mod)
 
+!======================================================================
 contains
-
-subroutine phyetat0 (fichnom,tab0,Lmodif,nsoil,ngrid,nlay,nq,nqsoil, &
-                     day_ini,time0,tsurf,tsoil,albedo,emis,q2,qsurf,qsoil, &
-                     tauscaling,totcloudfrac,wstar,watercap,perennial_co2ice, &
-                     def_slope,def_slope_mean,subslope_dist)
-
-  use tracer_mod, only: noms ! tracer names
-  use surfdat_h, only: phisfi, albedodat, z0, z0_default,&
-                       zmea, zstd, zsig, zgam, zthe, hmons, summit, base,&
-                       watercaptag
-  use iostart, only: nid_start, open_startphy, close_startphy, &
-                     get_field, get_var, inquire_field, &
-                     inquire_dimension, inquire_dimension_length
-  use nonoro_gwd_ran_mod, only: du_nonoro_gwd, dv_nonoro_gwd
-  use nonoro_gwd_mix_mod, only: du_eddymix_gwd, dv_eddymix_gwd, de_eddymix_rto, &
-                                df_eddymix_flx !dr_depflux_gwd
-
-  use compute_dtau_mod, only: dtau
-  use dust_rad_adjust_mod, only: dust_rad_adjust_prev,dust_rad_adjust_next
-  use dust_param_mod, only: dustscaling_mode
-  USE ioipsl_getin_p_mod, ONLY : getin_p
-  use comsoil_h, only: flux_geo
-  USE comslope_mod, ONLY: nslope, major_slope
-  USE paleoclimate_mod, ONLY: paleoclimate, h2o_ice_depth, lag_co2_ice, d_coef
-  USE comcstfi_h, only: pi
-  use geometry_mod, only: latitude
-  implicit none
-  
-  include "callkeys.h"
+!======================================================================
+
+subroutine phyetat0(fichnom,tab0,Lmodif,nsoil,ngrid,nlay,nq,nqsoil,          &
+                    day_ini,time0,tsurf,tsoil,albedo,emis,q2,qsurf,qsoil,    &
+                    tauscaling,totcloudfrac,wstar,watercap,perennial_co2ice, &
+                    def_slope,def_slope_mean,subslope_dist)
+
+use tracer_mod,          only: noms ! tracer names
+use surfdat_h,           only: phisfi, albedodat, z0, z0_default, zmea, zstd, &
+                               zsig, zgam, zthe, hmons, summit, base, watercaptag
+use iostart,             only: nid_start, open_startphy, close_startphy, &
+                               get_field, get_var, inquire_field,        &
+                               inquire_dimension, inquire_dimension_length
+use nonoro_gwd_ran_mod,  only: du_nonoro_gwd, dv_nonoro_gwd
+use nonoro_gwd_mix_mod,  only: du_eddymix_gwd, dv_eddymix_gwd, de_eddymix_rto, &
+                               df_eddymix_flx !dr_depflux_gwd
+use compute_dtau_mod,    only: dtau
+use dust_rad_adjust_mod, only: dust_rad_adjust_prev,dust_rad_adjust_next
+use dust_param_mod,      only: dustscaling_mode
+USE ioipsl_getin_p_mod,  only: getin_p
+use comsoil_h,           only: flux_geo
+USE comslope_mod,        only: nslope, major_slope
+USE paleoclimate_mod,    only: paleoclimate, h2o_ice_depth, lag_co2_ice, d_coef
+USE comcstfi_h,          only: pi
+use geometry_mod,        only: latitude
+
+implicit none
+
+include "callkeys.h"
+
 !======================================================================
 ! Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818
-!  Adaptation � Mars : Yann Wanherdrick 
+!  Adaptation � Mars : Yann Wanherdrick
 ! Objet: Lecture de l etat initial pour la physique
 ! Modifs: Aug.2010 EM : use NetCDF90 to load variables (enables using
@@ -54,79 +57,74 @@
 !  ---------
 !  inputs:
-!  logical,intent(in) :: startphy_file ! .true. if reading start file
-  character*(*),intent(in) :: fichnom ! "startfi.nc" file
-  integer,intent(in) :: tab0
-  integer,intent(in) :: Lmodif
-  integer,intent(in) :: nsoil ! # of soil layers
-  integer,intent(in) :: ngrid ! # of atmospheric columns
-  integer,intent(in) :: nlay ! # of atmospheric layers
-  integer,intent(in) :: nq
-  integer,intent(in) :: nqsoil ! # of tracers in the soil
-  integer :: day_ini
-  real :: time0
+character(*), intent(in) :: fichnom ! "startfi.nc" file
+integer,      intent(in) :: tab0
+integer,      intent(in) :: Lmodif
+integer,      intent(in) :: nsoil   ! # of soil layers
+integer,      intent(in) :: ngrid   ! # of atmospheric columns
+integer,      intent(in) :: nlay    ! # of atmospheric layers
+integer,      intent(in) :: nq
+integer,      intent(in) :: nqsoil  ! # of tracers in the soil
+integer, intent(inout) :: day_ini
+real,    intent(inout) :: time0
 
 !  outputs:
-  real,intent(out) :: tsurf(ngrid,nslope) ! surface temperature
-  real,intent(out) :: tsoil(ngrid,nsoil,nslope) ! soil temperature
-  real,intent(out) :: albedo(ngrid,2,nslope) ! surface albedo
-  real,intent(out) :: emis(ngrid,nslope) ! surface emissivity
-  real,intent(out) :: q2(ngrid,nlay+1) ! 
-  real,intent(out) :: qsurf(ngrid,nq,nslope) ! tracers on surface
-  real,intent(out) :: qsoil(ngrid,nsoil,nqsoil,nslope) ! tracers in the subsurface
-  real,intent(out) :: tauscaling(ngrid) ! dust conversion factor
-  real,intent(out) :: totcloudfrac(ngrid) ! total cloud fraction
-  real,intent(out) :: wstar(ngrid) ! Max vertical velocity in thermals (m/s)
-  real,intent(out) :: watercap(ngrid,nslope) ! h2o_ice_cover
-  real,intent(out) :: perennial_co2ice(ngrid,nslope) ! perennial co2 ice(kg/m^2)
-  real,intent(out) :: def_slope(nslope+1) !boundaries for bining of the slopes
-  real,intent(out) :: def_slope_mean(nslope)
-  real,intent(out) :: subslope_dist(ngrid,nslope) !undermesh statistics
+real, intent(out) :: tsurf(ngrid,nslope)              ! surface temperature
+real, intent(out) :: tsoil(ngrid,nsoil,nslope)        ! soil temperature
+real, intent(out) :: albedo(ngrid,2,nslope)           ! surface albedo
+real, intent(out) :: emis(ngrid,nslope)               ! surface emissivity
+real, intent(out) :: q2(ngrid,nlay+1)
+real, intent(out) :: qsurf(ngrid,nq,nslope)           ! tracers on surface
+real, intent(out) :: qsoil(ngrid,nsoil,nqsoil,nslope) ! tracers in the subsurface
+real, intent(out) :: tauscaling(ngrid)                ! dust conversion factor
+real, intent(out) :: totcloudfrac(ngrid)              ! total cloud fraction
+real, intent(out) :: wstar(ngrid)                     ! Max vertical velocity in thermals (m/s)
+real, intent(out) :: watercap(ngrid,nslope)           ! h2o_ice_cover
+real, intent(out) :: perennial_co2ice(ngrid,nslope)   ! perennial co2 ice(kg/m^2)
+real, intent(out) :: def_slope(nslope+1)              ! boundaries for bining of the slopes
+real, intent(out) :: def_slope_mean(nslope)
+real, intent(out) :: subslope_dist(ngrid,nslope)      ! undermesh statistics
 !======================================================================
 !  Local variables:
-
-      real surffield(ngrid) ! to temporarily store a surface field
-      real xmin,xmax ! to display min and max of a field
-!
-      INTEGER ig,iq,lmax,islope
-      INTEGER nid, nvarid
-      INTEGER ierr, i, nsrf
-!      integer isoil 
-!      INTEGER length
-!      PARAMETER (length=100)
-      CHARACTER*7 str7
-      CHARACTER*2 str2
-      CHARACTER*1 yes
-!
-      REAL p_rad,p_omeg,p_g,p_mugaz,p_daysec
-      INTEGER nqold
+real :: surffield(ngrid) ! to temporarily store a surface field
+real :: xmin, xmax       ! to display min and max of a field
+
+integer :: ig, iq, lmax, islope, nid, nvarid, ierr, i, nsrf, nqold
+! integer :: isoil
+! INTEGER :: length
+! PARAMETER (length=100)
+CHARACTER(7) :: str7
+CHARACTER(2) :: str2
+CHARACTER(1) :: yes
+
+REAL :: p_rad, p_omeg, p_g, p_mugaz, p_daysec
 
 ! flag which identifies if 'startfi.nc' file is using old names (qsurf01,...)
-      logical :: oldtracernames=.false.
-      integer :: count
-      character(len=30) :: txt ! to store some text
-
-! specific for time 
-      REAL,ALLOCATABLE :: time(:) ! times stored in start
-      INTEGER timelen ! number of times stored in the file
-      INTEGER indextime ! index of selected time
-
-      INTEGER :: edges(3),corner(3)
-      LOGICAL :: found
-
-      REAL :: timestart ! to pick which initial state to start from
-      REAL :: surfemis  ! constant emissivity when no startfi
-      REAL :: surfalbedo  ! constant albedo when no startfi
-
-      REAL :: watercaptag_tmp(ngrid)
+logical       :: oldtracernames = .false.
+integer       :: count
+character(30) :: txt ! to store some text
+
+! specific for time
+REAL, ALLOCATABLE :: time(:)   ! times stored in start
+INTEGER           :: timelen   ! number of times stored in the file
+INTEGER           :: indextime ! index of selected time
+
+INTEGER :: edges(3),corner(3)
+LOGICAL :: found
+REAL    :: timestart  ! to pick which initial state to start from
+REAL    :: surfemis   ! constant emissivity when no startfi
+REAL    :: surfalbedo ! constant albedo when no startfi
+REAL    :: watercaptag_tmp(ngrid)
 
 ! Sub-grid scale slopes
-      LOGICAL :: startphy_slope !to be retrocompatible and add the nslope dimension
-      REAL, ALLOCATABLE :: default_def_slope(:)
-      REAL :: sum_dist
-      REAL :: current_max !var to find max distrib slope
+LOGICAL           :: startphy_slope ! to be retrocompatible and add the nslope dimension
+REAL, ALLOCATABLE :: default_def_slope(:)
+REAL              :: sum_dist
+REAL              :: current_max !var to find max distrib slope
+
 ! Variables for CO2 index
-      INTEGER :: igcm_co2_tmp
-
-      CHARACTER(len=5) :: modname="phyetat0"
+INTEGER :: igcm_co2_tmp
+
+CHARACTER(5) :: modname="phyetat0"
+!======================================================================
 
 write(*,*) "phyetat0: startphy_file", startphy_file
@@ -147,5 +145,5 @@
 if (startphy_file) then
    call get_var("def_slope",def_slope,found)
-   if (.not. found) then 
+   if (.not. found) then
        startphy_slope=.false.
        write(*,*)'slope_settings: Problem while reading <def_slope>'
@@ -166,5 +164,5 @@
        startphy_slope=.true.
        call get_field("subslope_dist",subslope_dist,found,indextime)
-       if (.not. found) then 
+       if (.not. found) then
            write(*,*)'slope_settings: Problem while reading <subslope_dist>'
            write(*,*)'We have to abort.'
@@ -183,10 +181,10 @@
         call abort_physic(modname,"phyetat0: No startfi and nslope!=1",1)
     endif
-endif   
+endif
 
 do islope = 1,nslope
     def_slope_mean(islope) = (def_slope(islope) + def_slope(islope + 1))/2.
 enddo
- 
+
 DO ig = 1,ngrid
     sum_dist = 0.
@@ -255,5 +253,4 @@
             minval(zmea), maxval(zmea)
 
-
 ! ZSTD
 if (startphy_file) then
@@ -269,5 +266,4 @@
             minval(zstd), maxval(zstd)
 
-
 ! ZSIG
 if (startphy_file) then
@@ -283,5 +279,4 @@
             minval(zsig), maxval(zsig)
 
-
 ! ZGAM
 if (startphy_file) then
@@ -296,5 +291,4 @@
 write(*,*) "phyetat0: <ZGAM> range:", &
             minval(zgam), maxval(zgam)
-
 
 ! ZTHE
@@ -335,5 +329,4 @@
             minval(hmons), maxval(hmons)
 
-
 ! summit
 if (startphy_file) then
@@ -355,11 +348,10 @@
    endif ! if (.not.found)
 else
-   summit(:)=0.  
+   summit(:)=0.
 endif ! if (startphy_file)
 write(*,*) "phyetat0: <summit> range:", &
             minval(summit), maxval(summit)
 
-
-! base 
+! base
 if (startphy_file) then
    call get_field("base",base,found)
@@ -421,5 +413,5 @@
             PRINT*, time(i)
          ENDDO
-         call abort_physic(modname,"phyetat0: Time error",1) 
+         call abort_physic(modname,"phyetat0: Time error",1)
        ENDIF
      ENDIF ! of IF (timestart .lt. 0)
@@ -428,5 +420,5 @@
      time0 = time(indextime) + time0
      day_ini = day_ini + INT(time0)
-     time0 = time0 - INT(time0)    
+     time0 = time0 - INT(time0)
      PRINT*, "phyetat0: Selected time ",time(indextime), &
              " at index ",indextime
@@ -489,5 +481,4 @@
             minval(dtau), maxval(dtau)
 
-
 ! Sub-grid cloud fraction
 if (startphy_file) then
@@ -503,5 +494,4 @@
             minval(totcloudfrac), maxval(totcloudfrac)
 
-
 ! Max vertical velocity in thermals
 if (startphy_file) then
@@ -516,5 +506,4 @@
 write(*,*) "phyetat0: Max vertical velocity in thermals <wstar> range:", &
             minval(wstar),maxval(wstar)
-
 
 ! Surface temperature :
@@ -581,5 +570,4 @@
             minval(z0), maxval(z0)
 
-
 ! pbl wind variance
 if (startphy_file) then
@@ -596,5 +584,5 @@
 
 ! Non-orographic gravity waves
-if (startphy_file) then 
+if (startphy_file) then
    call get_field("du_nonoro_gwd",du_nonoro_gwd,found,indextime)
    if (.not.found) then
@@ -609,5 +597,5 @@
              minval(du_nonoro_gwd), maxval(du_nonoro_gwd)
 
-if (startphy_file) then 
+if (startphy_file) then
    call get_field("dv_nonoro_gwd",dv_nonoro_gwd,found,indextime)
    if (.not.found) then
@@ -621,5 +609,5 @@
 write(*,*) " <dv_nonoro_gwd> range:", &
              minval(dv_nonoro_gwd), maxval(dv_nonoro_gwd)
-if (startphy_file) then 
+if (startphy_file) then
    call get_field("du_eddymix_gwd",du_eddymix_gwd,found,indextime)
    if (.not.found) then
@@ -633,7 +621,6 @@
 write(*,*) " <du_eddymix_gwd> range:", &
              minval(du_eddymix_gwd), maxval(du_eddymix_gwd)
- 
-
-if (startphy_file) then 
+
+if (startphy_file) then
    call get_field("dv_nonoro_gwd",dv_nonoro_gwd,found,indextime)
    if (.not.found) then
@@ -648,5 +635,5 @@
              minval(dv_nonoro_gwd), maxval(dv_nonoro_gwd)
 
-if (startphy_file) then 
+if (startphy_file) then
    call get_field("dv_eddymix_gwd",dv_eddymix_gwd,found,indextime)
    if (.not.found) then
@@ -661,5 +648,5 @@
              minval(dv_eddymix_gwd), maxval(dv_eddymix_gwd)
 
-!if (startphy_file) then 
+!if (startphy_file) then
 !   call get_field("dr_depflux_gwd",dr_depflux_gwd,found,indextime)
 !   if (.not.found) then
@@ -674,5 +661,5 @@
 !             minval(dr_depflux_gwd), maxval(dr_depflux_gwd)
 
-if (startphy_file) then 
+if (startphy_file) then
    call get_field("de_eddymix_rto",de_eddymix_rto,found,indextime)
    if (.not.found) then
@@ -687,5 +674,5 @@
              minval(de_eddymix_rto), maxval(de_eddymix_rto)
 
-if (startphy_file) then 
+if (startphy_file) then
    call get_field("df_eddymix_flx ",df_eddymix_flx ,found,indextime)
    if (.not.found) then
@@ -699,6 +686,4 @@
 write(*,*) " <df_eddymix_flx > range:", &
              minval(df_eddymix_flx ), maxval(df_eddymix_flx )
-
-
 
 ! tracer on surface
@@ -789,5 +774,5 @@
 else
    watercap(:,:)=0
-endif ! of if (startphy_file) 
+endif ! of if (startphy_file)
 write(*,*) "phyetat0: Surface water ice <watercap> range:", &
             minval(watercap), maxval(watercap)
@@ -833,5 +818,5 @@
    endif
 
-! Diffusion coeficent 
+! Diffusion coeficent
    call get_field("d_coef",d_coef,found,indextime)
    if (.not.found) then
@@ -882,38 +867,37 @@
 end subroutine phyetat0
 
-
+!======================================================================
 subroutine ini_tab_controle_dyn_xios(idayref)
 
-      USE comcstfi_h, only: g, mugaz, omeg, rad, rcp
-      USE time_phylmdz_mod, ONLY: hour_ini, daysec, dtphys
-      USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, nbp_lev
-      IMPLICIT NONE
-
-
-      INTEGER*4,intent(in) :: idayref  ! date (initial date for this run)
-
-
-      INTEGER length,l
-      parameter (length = 100)
-      REAL tab_cntrl(length) ! run parameters are stored in this array
-
-      DO l=1,length
-         tab_cntrl(l)=0.
-      ENDDO
-      tab_cntrl(1)  = real(nbp_lon)
-      tab_cntrl(2)  = real(nbp_lat-1)
-      tab_cntrl(3)  = real(nbp_lev)
-      tab_cntrl(4)  = real(idayref)
-      tab_cntrl(5)  = rad
-      tab_cntrl(6)  = omeg
-      tab_cntrl(7)  = g
-      tab_cntrl(8)  = mugaz
-      tab_cntrl(9)  = rcp
-      tab_cntrl(10) = daysec
-      tab_cntrl(11) = dtphys
-
-      tab_cntrl(27) = hour_ini
-
-      tab_cntrl_mod = tab_cntrl
+USE comcstfi_h,        only: g, mugaz, omeg, rad, rcp
+USE time_phylmdz_mod,  ONLY: hour_ini, daysec, dtphys
+USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, nbp_lev
+
+IMPLICIT NONE
+
+INTEGER*4, intent(in) :: idayref ! date (initial date for this run)
+
+INTEGER :: length,l
+parameter (length = 100)
+REAL    :: tab_cntrl(length) ! run parameters are stored in this array
+
+DO l=1,length
+    tab_cntrl(l)=0.
+ENDDO
+tab_cntrl(1)  = real(nbp_lon)
+tab_cntrl(2)  = real(nbp_lat-1)
+tab_cntrl(3)  = real(nbp_lev)
+tab_cntrl(4)  = real(idayref)
+tab_cntrl(5)  = rad
+tab_cntrl(6)  = omeg
+tab_cntrl(7)  = g
+tab_cntrl(8)  = mugaz
+tab_cntrl(9)  = rcp
+tab_cntrl(10) = daysec
+tab_cntrl(11) = dtphys
+
+tab_cntrl(27) = hour_ini
+
+tab_cntrl_mod = tab_cntrl
 
 end subroutine ini_tab_controle_dyn_xios
Index: /trunk/LMDZ.MARS/libf/phymars/phys_state_var_init_mod.F90
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/phys_state_var_init_mod.F90	(revision 3304)
+++ /trunk/LMDZ.MARS/libf/phymars/phys_state_var_init_mod.F90	(revision 3305)
@@ -3,5 +3,5 @@
 CONTAINS
 
-      SUBROUTINE phys_state_var_init(ngrid,nlayer,nq,tname, &
+      SUBROUTINE phys_state_var_init(filename,ngrid,nlayer,nq,tname, &
                                      day_ini,day_end,hour_ini,pdaysec,ptimestep, &
                                      prad,pg,pr,pcpp, &
@@ -69,18 +69,17 @@
 
       IMPLICIT NONE
-      
-      INTEGER,INTENT(IN) :: ngrid,nlayer,nq
-      CHARACTER(len=*),INTENT(IN) :: tname(nq)
-      INTEGER,INTENT(IN) :: day_ini, day_end
-      REAL,INTENT(IN) :: hour_ini
-      REAL,INTENT(IN) :: pdaysec,ptimestep,prad,pg,pr,pcpp
+
+      character(*), intent(in) :: filename ! Name of the "startfi.nc" file
+      integer,      intent(IN) :: ngrid,nlayer,nq
+      character(*), intent(IN) :: tname(nq)
+      integer,      intent(IN) :: day_ini, day_end
+      real,         intent(IN) :: hour_ini
+      real,         intent(IN) :: pdaysec, ptimestep, prad, pg, pr, pcpp
 !MVals isotopes
-      INTEGER,INTENT(in) :: dyn_nqperes
-      INTEGER,INTENT(in) :: dyn_nqfils(nq)
-      character(len=10) :: filename  ! name of the startfi.nc
+      integer,      intent(in) :: dyn_nqperes
+      integer,      intent(in) :: dyn_nqfils(nq)
       integer :: ncid, status, nslope_dim_id
       integer :: nslope_read
 
-      filename="startfi.nc"
       if(is_master) then
         status = nf90_open(filename, nf90_nowrite, ncid)
