Index: trunk/LMDZ.MARS/changelog.txt
===================================================================
--- trunk/LMDZ.MARS/changelog.txt	(revision 3044)
+++ trunk/LMDZ.MARS/changelog.txt	(revision 3045)
@@ -4197,2 +4197,6 @@
 == 13/09/2023 == JBC
 The date and time are redefined at the end of PEM to write the file "restarfi_evol.nc". Like so, the next GCM runs can restart at the date and time given at the beginning of the simulation since the PEM is only progressing by step of one Martian year.
+
+== 21/09/2023 == JBC
+Addition of the pressure profile to be able to run chained simulations in 1D. Like this, the surface pressure can be got from one run to the next.
+Rework of "write_profile.F90" + correction of arguments in its call in "testphys1d.F": 'qsurf' was wrongly given!
Index: trunk/LMDZ.MARS/libf/phymars/dyn1d/testphys1d.F
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/dyn1d/testphys1d.F	(revision 3044)
+++ trunk/LMDZ.MARS/libf/phymars/dyn1d/testphys1d.F	(revision 3045)
@@ -215,7 +215,5 @@
 c  Prescribed constants to be set here
 c ------------------------------------------------------
-
 c      if(.not. startfile_1D ) then
-
       pi=2.E+0*asin(1.E+0)
 
@@ -261,5 +259,4 @@
 c     ----------------------------------------------------
       cell_area(1)=1.E+0
-
 
 ! check if there is a 'traceur.def' file
@@ -354,7 +351,7 @@
        WRITE(*,*) 'nqfils=',nqfils
 
-        ! initialize tracers here:
+        ! Initialize tracers here:
         write(*,*) "testphys1d: initializing tracers"
-        call read_profile(nq, nlayer, qsurf, q)
+        call read_profile(nq,nlayer,qsurf,q)
 
       call init_physics_distribution(regular_lonlat,4,
@@ -398,10 +395,9 @@
 c  Discretization (Definition of grid and time steps)
 c  --------------
-c
       nlevel=nlayer+1
       nsoil=nsoilmx
 
       day_step=48 ! default value for day_step
-      PRINT *,'Number of time steps per sol ?'
+      write(*,*)'Number of time steps per sol ?'
       call getin("day_step",day_step)
       write(*,*) " day_step = ",day_step
@@ -410,5 +406,5 @@
 
       ndt=10 ! default value for ndt
-      PRINT *,'Number of sols to run ?'
+      write(*,*)'Number of sols to run ?'
       call getin("ndt",ndt)
       write(*,*) " ndt = ",ndt
@@ -420,10 +416,20 @@
 c Imposed surface pressure
 c ------------------------------------
-c
-
-      psurf=610. ! default value for psurf
-      PRINT *,'Surface pressure (Pa) ?'
-      call getin("psurf",psurf)
-      write(*,*) " psurf = ",psurf
+      psurf = 610. ! Default value for psurf
+      write(*,*) 'Surface pressure (Pa)?'
+      open(3,file = 'profile_pressure',status = 'old',
+     &     form = 'formatted',iostat = ierr)
+      if (ierr == 0) then
+          write(*,*) 'Reading file ''profile_pressure''...'
+          read(3,*) psurf
+          write(*,*) " psurf = ",psurf
+      else
+          write(*,*) 'File ''profile_pressure'' not found!'
+          write(*,*) 'Reading surface pressure in ''callphys.def''',
+     &' if given...'
+          call getin("psurf",psurf)
+          write(*,*) " psurf = ",psurf
+      endif
+      close(3)
 
 c Reference pressures
@@ -440,5 +446,4 @@
 c Orbital parameters
 c ------------------
-
       if(.not. startfile_1D ) then
 
@@ -449,8 +454,8 @@
         write(*,*) "Orbital parameters from callphys.def"
         write(*,*) "Enter eccentricity & Lsperi"
-        print *, 'Martian eccentricity (0<e<1) ?'
+        write(*,*) 'Martian eccentricity (0<e<1) ?'
         call getin('excentric ',excentric)
         write(*,*)"excentric =",excentric 
-        print *, 'Solar longitude of perihelion (0<Ls<360) ?'
+        write(*,*) 'Solar longitude of perihelion (0<Ls<360) ?'
         call getin('Lsperi',Lsperi )
         write(*,*)"Lsperi=",Lsperi 
@@ -467,17 +472,17 @@
         write(*,*) "Default present-day orbital parameters"
         write(*,*) "Unless specified otherwise"
-        print *,'Min. distance Sun-Mars (Mkm)?'
+        write(*,*)'Min. distance Sun-Mars (Mkm)?'
         call getin("periheli",periheli)
         write(*,*) " periheli = ",periheli
 
-        print *,'Max. distance Sun-Mars (Mkm)?'
+        write(*,*)'Max. distance Sun-Mars (Mkm)?'
         call getin("aphelie",aphelie)
         write(*,*) " aphelie = ",aphelie
 
-        print *,'Day of perihelion?'
+        write(*,*)'Day of perihelion?'
         call getin("periday",peri_day)
         write(*,*) " periday = ",peri_day
 
-        print *,'Obliquity?'
+        write(*,*)'Obliquity?'
         call getin("obliquit",obliquit)
         write(*,*) " obliquit = ",obliquit
@@ -489,5 +494,5 @@
 c  ------------------
       latitude(1)=0 ! default value for latitude
-      PRINT *,'latitude (in degrees) ?'
+      write(*,*)'latitude (in degrees) ?'
       call getin("latitude",latitude(1))
       write(*,*) " latitude = ",latitude
@@ -533,5 +538,5 @@
 
       albedodat(1)=0.2 ! default value for albedodat
-      PRINT *,'Albedo of bare ground ?'
+      write(*,*)'Albedo of bare ground ?'
       call getin("albedo",albedodat(1))
       write(*,*) " albedo = ",albedodat(1)
@@ -539,5 +544,5 @@
 
       inertiedat(1,1)=400 ! default value for inertiedat
-      PRINT *,'Soil thermal inertia (SI) ?'
+      write(*,*)'Soil thermal inertia (SI) ?'
       call getin("inertia",inertiedat(1,1))
       write(*,*) " inertia = ",inertiedat(1,1)
@@ -581,7 +586,7 @@
 c  
       hmons(1)=0.E+0
-      PRINT *,'hmons is initialized to ',hmons(1)
+      write(*,*)'hmons is initialized to ',hmons(1)
       summit(1)=0.E+0
-      PRINT *,'summit is initialized to ',summit(1)
+      write(*,*)'summit is initialized to ',summit(1)
       base(1)=0.E+0
 c
@@ -604,9 +609,10 @@
 c    geostrophic wind
       gru=10. ! default value for gru
-      PRINT *,'zonal eastward component of the geostrophic wind (m/s) ?'
+      write(*,*)'zonal eastward component of the geostrophic',
+     &' wind (m/s) ?'
       call getin("u",gru)
       write(*,*) " u = ",gru
       grv=0. !default value for grv
-      PRINT *,'meridional northward component of the geostrophic',
+      write(*,*)'meridional northward component of the geostrophic',
      &' wind (m/s) ?'
       call getin("v",grv)
@@ -641,5 +647,5 @@
       if(.not. startfile_1D ) then
       qsurf(igcm_co2)=0.E+0 ! default value for co2ice
-      PRINT *,'Initial CO2 ice on the surface (kg.m-2)'
+      write(*,*)'Initial CO2 ice on the surface (kg.m-2)'
       call getin("co2ice",qsurf(igcm_co2))
       write(*,*) " co2ice = ",qsurf(igcm_co2)
@@ -664,5 +670,5 @@
 c    """"""""""""""""""""
       hybrid=.true.
-      PRINT *,'Hybrid coordinates ?'
+      write(*,*)'Hybrid coordinates ?'
       call getin("hybrid",hybrid)
       write(*,*) " hybrid = ", hybrid
@@ -807,5 +813,5 @@
       endif !(.not. startfile_1D )
       watercaptag(1)=.false. ! Default: no water ice reservoir
-      print *,'Water ice cap on ground ?'
+      write(*,*)'Water ice cap on ground ?'
       call getin("watercaptag",watercaptag)
       write(*,*) " watercaptag = ",watercaptag
@@ -816,5 +822,5 @@
       atm_wat_profile = -1. ! Default: free atm wat profile
       if (water) then
-      print *,'Force atmospheric water vapor profile?'
+      write(*,*)'Force atmospheric water vapor profile?'
       call getin("atm_wat_profile",atm_wat_profile)
       write(*,*) "atm_wat_profile = ", atm_wat_profile
@@ -993,12 +999,13 @@
       ENDDO   ! of idt=1,ndt ! end of time stepping loop
 
-      ! update the profiles files at the end of the run
-      write_prof=.false.
+      ! Update the profile files at the end of the run
+      write_prof = .false.
       call getin("write_prof",write_prof)
-      IF (write_prof) then
-              DO iq = 1,nq
-                call writeprofile(nlayer,q(:,iq),noms(iq),qsurf)
-              ENDDO
-      ENDIF
+      if (write_prof) then
+          do iq = 1,nq
+              call writeprofile(nlayer,noms(iq),qsurf(iq),q(:,iq))
+          enddo
+          call writeprofile(nlayer,'pressure',psurf,play)
+      endif
 
       write(*,*) "testphys1d: Everything is cool."
Index: trunk/LMDZ.MARS/libf/phymars/dyn1d/write_profile.F90
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/dyn1d/write_profile.F90	(revision 3044)
+++ trunk/LMDZ.MARS/libf/phymars/dyn1d/write_profile.F90	(revision 3045)
@@ -1,23 +1,23 @@
-SUBROUTINE writeprofile(nlev,data,name2,qsurf)
+SUBROUTINE writeprofile(nlev,profilename,surfdata,profiledata)
 
+implicit none
 
-IMPLICIT NONE
+! arguments
+integer, intent(in)               :: nlev
+real, intent(in)                  :: surfdata
+real, dimension(nlev), intent(in) :: profiledata
+character(len = 30), intent(in)   :: profilename
 
-! arguments:
-INTEGER nlev
-REAL data(nlev)
-REAL qsurf
-CHARACTER(len=30) :: name2
+! Local
+integer :: il
 
-!local
-INTEGER il
+! Write the data
+open(1,file = 'profile_out_'//trim(profilename),form = 'formatted')
+write(1,*) surfdata
+do il = 1,nlev
+    write(1,*) profiledata(il)
+enddo
+close(1)
+return
 
-!write the data
-OPEN(1,file='profile_out_'//trim(name2),form='formatted')
-write(1,*) qsurf
-DO il=1,nlev
-    write(1,*) data(il)
-ENDDO
-CLOSE(1)
-RETURN
 END
