Index: /trunk/LMDZ.MARS/changelog.txt
===================================================================
--- /trunk/LMDZ.MARS/changelog.txt	(revision 3116)
+++ /trunk/LMDZ.MARS/changelog.txt	(revision 3117)
@@ -4315,3 +4315,4 @@
 for water sublimation is 1 when adsorption is activated (otherwise it crashes)
 
-
+== 08/11/2023 == JBC
+Correction of the case when startfiles1D = .true. and there is no "startfi.nc": the flags used in "init_testphys1d_mod.F90" were not correct so the model crashed and didn't create a "startfi.nc" from scratch as intended.
Index: /trunk/LMDZ.MARS/libf/phymars/dyn1d/init_testphys1d_mod.F90
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/dyn1d/init_testphys1d_mod.F90	(revision 3116)
+++ /trunk/LMDZ.MARS/libf/phymars/dyn1d/init_testphys1d_mod.F90	(revision 3117)
@@ -136,5 +136,5 @@
     endif
 
-    write(*,*)'Do you want to use starting files?'
+    write(*,*)'Do you want to use starting files and/or to write restarting files?'
     call getin("startfiles_1D",startfiles_1D)
     write(*,*) " startfiles_1D = ", startfiles_1D
@@ -295,5 +295,5 @@
 ! Date and local time at beginning of run
 ! ---------------------------------------
-if (.not. startfiles_1D) then
+if (.not. therestartfi) then
     ! Date (in sols since spring solstice) at beginning of run
     day0 = 0 ! default value for day0
@@ -321,5 +321,5 @@
     call get_var("Time",time,found)
     call close_startphy
-endif !startfiles_1D
+endif !(.not. therestartfi)
 
 ! Discretization (Definition of grid and time steps)
@@ -369,5 +369,5 @@
 ! Orbital parameters
 ! ------------------
-if (.not. startfiles_1D) then
+if (.not. therestartfi) then
     paleomars = .false. ! Default: no water ice reservoir
     call getin("paleomars",paleomars)
@@ -410,5 +410,5 @@
         write(*,*) " obliquit = ",obliquit
      endif
-endif !(.not. startfiles_1D )
+endif !(.not. therestartfi)
 
 ! Latitude/longitude
@@ -462,5 +462,5 @@
 ! Initialize albedo / soil thermal inertia
 ! ----------------------------------------
-if (.not. startfiles_1D) then
+if (.not. therestartfi) then
     albedodat(1) = 0.2 ! default value for albedodat
     write(*,*)'Albedo of bare ground?'
@@ -482,5 +482,5 @@
     call getin("z0",z0(1))
     write(*,*) " z0 = ",z0(1)
-endif !(.not. startfiles_1D )
+endif !(.not. therestartfi)
 
 ! Initialize local slope parameters (only matters if "callslope"
@@ -566,14 +566,14 @@
 if (igcm_co2 == 0) error stop "init_testphys1d error, missing co2 tracer!"
 
-if (.not. startfiles_1D) then
+if (.not. therestartfi) then
     qsurf(1,igcm_co2,1) = 0. ! default value for co2ice
     write(*,*)'Initial CO2 ice on the surface (kg.m-2)'
     call getin("co2ice",qsurf(1,igcm_co2,1))
     write(*,*) " co2ice = ",qsurf(1,igcm_co2,1)
-endif !(.not. startfiles_1D )
+endif !(.not. therestartfi)
 
 ! emissivity
 ! ----------
-if (.not. startfiles_1D) then
+if (.not. therestartfi) then
     emis(:,1) = emissiv
     if (qsurf(1,igcm_co2,1) == 1.) then
@@ -581,5 +581,5 @@
         if (latitude(1) < 0) emis(:,1) = emisice(2) ! southern hemisphere
     endif
-endif !(.not. startfiles_1D )
+endif !(.not. therestartfi)
 
 ! Compute pressures and altitudes of atmospheric levels
@@ -622,5 +622,5 @@
 volcapa = 1.e6 ! volumetric heat capacity
 
-if (.not. startfiles_1D) then
+if (.not. therestartfi) then
     ! Initialize depths
     ! -----------------
@@ -655,5 +655,5 @@
     inertiesoil(1,:,1) = inertiedat(1,:)
     tsoil(:,:,1) = tsurf(1,1) ! soil temperature
-endif !(.not. startfiles_1D)
+endif !(.not. therestartfi)
 
 flux_geo_tmp = 0.
@@ -663,18 +663,15 @@
 ! Initialize soil content
 ! -----------------
-if (.not. startfiles_1D) then
-    qsoil(:,:,:,:) = 0.
-endif
+if (.not. therestartfi) qsoil(:,:,:,:) = 0.
 
 ! Initialize depths
 ! -----------------
 do isoil = 0,nsoil - 1
-    mlayer(isoil) = 2.e-4*(1+isoil**2.9*(1-exp(-real(isoil)/20.))) ! mid layer depth
+    mlayer(isoil) = 2.e-4*(1 + isoil**2.9*(1 - exp(-real(isoil)/20.))) ! mid layer depth
 enddo
-
 do isoil = 1,nsoil - 1
-    layer(isoil)=(mlayer(isoil)+mlayer(isoil-1))/2
+    layer(isoil) = (mlayer(isoil) + mlayer(isoil - 1))/2
 enddo
-layer(nsoil)=2*mlayer(nsoil-1) - mlayer(nsoil-2)
+layer(nsoil) = 2*mlayer(nsoil - 1) - mlayer(nsoil - 2)
 
 ! Initialize traceurs
@@ -704,5 +701,5 @@
 ! Check if the surface is a water ice reservoir
 ! ---------------------------------------------
-if (.not. startfiles_1D) watercap(1,:) = 0 ! Initialize watercap
+if (.not. therestartfi) watercap(1,:) = 0 ! Initialize watercap
 watercaptag(1) = .false. ! Default: no water ice reservoir
 write(*,*)'Water ice cap on ground?'
Index: /trunk/LMDZ.MARS/libf/phymars/dyn1d/testphys1d.F90
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/dyn1d/testphys1d.F90	(revision 3116)
+++ /trunk/LMDZ.MARS/libf/phymars/dyn1d/testphys1d.F90	(revision 3117)
@@ -127,5 +127,5 @@
                   llm,nq,dttestphys,float(day0),0.,cell_area,    &
                   albedodat,inertiedat,def_slope,subslope_dist)
-    call physdem1("startfi.nc",nsoilmx,ngrid,llm,nq,nqsoil,dttestphys,time,       &
+    call physdem1("startfi.nc",nsoilmx,ngrid,llm,nq,nqsoil,dttestphys,time,      &
                   tsurf,tsoil,inertiesoil,albedo,emis,q2,qsurf,qsoil,tauscaling, &
                   totcloudfrac,wstar,watercap,perenial_co2ice)
