Changeset 3065 for trunk


Ignore:
Timestamp:
Oct 2, 2023, 2:30:47 PM (21 months ago)
Author:
jbclement
Message:

PEM:
Initialization of the PEM in 1D through the subroutine "init_testphys1d_mod.F90" + Some adaptations of the Mars PCM in 1D + Update of "launch_pem.sh" in deftank.
JBC

Location:
trunk
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.COMMON/libf/evolution/changelog.txt

    r3063 r3065  
    7777== 26/09/2023 == JBC
    7878Minor changes concerning the form of the code in the PEM.
     79Addition of a file "changelog.txt" in LMDZ.COMMON/libf/evolution/ specific to the PEM rather than using the one for Mars. Completed with changesets since 01/07/2023.
    7980
    80 == 28/09/2023 == JBC
    81 Addition of a file "changelog.txt" in LMDZ.COMMON/libf/evolution/ specific to the PEM rather than using the one for Mars. Completed with changesets since 01/07/2023.
     81== 02/10/2023 == JBC
     82Initialization of the PEM in 1D through the subroutine "init_testphys1d_mod.F90" + Some adaptations of the Mars PCM in 1D + Update of "launch_pem.sh" in deftank.
  • trunk/LMDZ.COMMON/libf/evolution/pem.F90

    r3050 r3065  
    9696    use physics_distribution_mod, only: init_physics_distribution
    9797    use mod_grid_phy_lmdz,        only: regular_lonlat
    98     use init_pem1d_mod,           only: init_pem1d
     98    use init_testphys1d_mod,      only: init_testphys1d
     99    use comvert_mod,              only: ap, bp
    99100#endif
    100101
     
    111112
    112113! Same variable names as in the GCM
    113 integer :: ngrid     ! Number of physical grid points
    114 integer :: nlayer    ! Number of vertical layer
    115 integer :: nq        ! Number of tracer
    116 integer :: day_ini   ! First day of the simulation
    117 real    :: pday      ! Physical day
    118 real    :: time_phys ! Same as GCM
    119 real    :: ptimestep ! Same as GCM
    120 real    :: ztime_fin ! Same as GCM
     114integer, parameter :: nlayer = llm ! Number of vertical layer
     115integer            :: ngrid        ! Number of physical grid points
     116integer            :: nq           ! Number of tracer
     117integer            :: day_ini      ! First day of the simulation
     118real               :: pday         ! Physical day
     119real               :: time_phys    ! Same as GCM
     120real               :: ptimestep    ! Same as GCM
     121real               :: ztime_fin    ! Same as GCM
    121122
    122123! Variables to read start.nc
     
    124125
    125126! Dynamic variables
    126 real                                :: vcov(ip1jm,llm), ucov(ip1jmp1,llm) ! vents covariants
    127 real                                :: teta(ip1jmp1,llm)                  ! temperature potentielle
    128 real, dimension(:,:,:), allocatable :: q                                  ! champs advectes
    129 real                                :: ps(ip1jmp1)                        ! pression  au sol
    130 real, dimension(:),     allocatable :: ps_start_GCM                       !(ngrid) pression  au sol
    131 real, dimension(:,:),   allocatable :: ps_timeseries                      !(ngrid x timelen) ! pression  au sol instantannées
    132 real                                :: masse(ip1jmp1,llm)                 ! masse d'air
    133 real                                :: phis(ip1jmp1)                      ! geopotentiel au sol
     127real, dimension(ip1jm,llm)          :: vcov          ! vents covariants
     128real, dimension(ip1jmp1,llm)        :: ucov          ! vents covariants
     129real, dimension(ip1jmp1,llm)        :: teta          ! temperature potentielle
     130real, dimension(:,:,:), allocatable :: q             ! champs advectes
     131real, dimension(ip1jmp1)            :: ps            ! pression  au sol
     132real, dimension(:),     allocatable :: ps_start_GCM  ! (ngrid) pression  au sol
     133real, dimension(:,:),   allocatable :: ps_timeseries ! (ngrid x timelen) ! pression  au sol instantannées
     134real, dimension(ip1jmp1,llm)        :: masse         ! masse d'air
     135real, dimension(ip1jmp1)            :: phis          ! geopotentiel au sol
    134136real                                :: time_0
    135137
    136138! Variables to read starfi.nc
    137 character (len = *), parameter :: FILE_NAME = "startfi_evol.nc" !Name of the file used for initialsing the PEM
     139character (len = *), parameter :: FILE_NAME = "startfi_evol.nc" ! Name of the file used for initialsing the PEM
    138140character*2 str2
    139 integer :: ncid, varid,status                       ! Variable for handling opening of files
     141integer :: ncid, varid, status                      ! Variable for handling opening of files
    140142integer :: phydimid, subdimid, nlayerdimid, nqdimid ! Variable ID for Netcdf files
    141143integer :: lonvarid, latvarid, areavarid, sdvarid   ! Variable ID for Netcdf files
     
    143145
    144146! Variables to read starfi.nc and write restartfi.nc
    145 real, dimension(:), allocatable :: longitude     ! Longitude read in FILE_NAME and written in restartfi
    146 real, dimension(:), allocatable :: latitude      ! Latitude read in FILE_NAME and written in restartfi
    147 real, dimension(:), allocatable :: ap            ! Coefficient ap read in FILE_NAME_start and written in restart
    148 real, dimension(:), allocatable :: bp            ! Coefficient bp read in FILE_NAME_start and written in restart
    149 real, dimension(:), allocatable :: cell_area     ! Cell_area read in FILE_NAME and written in restartfi
     147real, dimension(:), allocatable :: longitude     ! Longitude read in FILE_NAME and written in restartfi
     148real, dimension(:), allocatable :: latitude      ! Latitude read in FILE_NAME and written in restartfi
     149real, dimension(:), allocatable :: cell_area     ! Cell_area read in FILE_NAME and written in restartfi
    150150real                            :: Total_surface ! Total surface of the planet
    151151
    152152! Variables for h2o_ice evolution
    153 real                                :: ini_surf_h2o          ! Initial surface of sublimating h2o ice
    154 real                                :: ini_surf_co2          ! Initial surface of sublimating co2 ice
    155 real                                :: global_ave_press_GCM  ! constant: global average pressure retrieved in the GCM [Pa]
    156 real                                :: global_ave_press_old  ! constant: Global average pressure of initial/previous time step
    157 real                                :: global_ave_press_new  ! constant: Global average pressure of current time step
    158 real, dimension(:,:),   allocatable :: zplev_new             ! Physical x Atmospheric field : mass of the atmospheric  layers in the pem at current time step [kg/m^2]
    159 real, dimension(:,:),   allocatable :: zplev_gcm             ! same but retrieved from the gcm [kg/m^2]
    160 real, dimension(:,:,:), allocatable :: zplev_new_timeseries  ! Physical x Atmospheric x Time: same as zplev_new, but in times series [kg/m ^2]
    161 real, dimension(:,:,:), allocatable :: zplev_old_timeseries  ! same but with the time series, for oldest time step
    162 logical                             :: STOPPING_water        ! Logical : is the criterion (% of change in the surface of sublimating water ice) reached?
    163 logical                             :: STOPPING_1_water      ! Logical : is there still water ice to sublimate?
    164 logical                             :: STOPPING_co2          ! Logical : is the criterion (% of change in the surface of sublimating water ice) reached?
    165 logical                             :: STOPPING_pressure     ! Logical : is the criterion (% of change in the surface pressure) reached?
    166 integer                             :: criterion_stop        ! which criterion is reached ? 1= h2o ice surf, 2 = co2 ice surf, 3 = ps, 4 = orb param
    167 real, save                          :: A , B, mmean          ! Molar mass: intermediate A, B for computations of the  mean molar mass of the layer [mol/kg]
    168 real, allocatable                   :: vmr_co2_gcm(:,:)      ! Physics x Times  co2 volume mixing ratio retrieve from the gcm [m^3/m^3]
    169 real, allocatable                   :: vmr_co2_pem_phys(:,:) ! Physics x Times  co2 volume mixing ratio used in the PEM
    170 real, allocatable                   :: q_co2_PEM_phys(:,:)   ! Physics x Times co2 mass mixing ratio in the first layer computed in the PEM, first value comes from GCM [kg/kg]
    171 real, allocatable                   :: q_h2o_PEM_phys(:,:)   ! Physics x Times: h2o mass mixing ratio computed in the PEM, first value comes from GCM [kg/kg]
    172 integer                             :: timelen               ! # time samples
    173 real                                :: ave                   ! intermediate varibale to compute average
    174 real, allocatable                   :: p(:,:)                ! Physics x Atmosphere: pressure to recompute and write in restart (ngrid,llmp1)
    175 real                                :: extra_mass            ! Intermediate variables Extra mass of a tracer if it is greater than 1
     153real                                :: ini_surf_h2o         ! Initial surface of sublimating h2o ice
     154real                                :: ini_surf_co2         ! Initial surface of sublimating co2 ice
     155real                                :: global_ave_press_GCM ! constant: global average pressure retrieved in the GCM [Pa]
     156real                                :: global_ave_press_old ! constant: Global average pressure of initial/previous time step
     157real                                :: global_ave_press_new ! constant: Global average pressure of current time step
     158real, dimension(:,:),   allocatable :: zplev_new            ! Physical x Atmospheric field : mass of the atmospheric  layers in the pem at current time step [kg/m^2]
     159real, dimension(:,:),   allocatable :: zplev_gcm            ! same but retrieved from the gcm [kg/m^2]
     160real, dimension(:,:,:), allocatable :: zplev_new_timeseries ! Physical x Atmospheric x Time: same as zplev_new, but in times series [kg/m ^2]
     161real, dimension(:,:,:), allocatable :: zplev_old_timeseries ! same but with the time series, for oldest time step
     162logical                             :: STOPPING_water       ! Logical: is the criterion (% of change in the surface of sublimating water ice) reached?
     163logical                             :: STOPPING_1_water     ! Logical: is there still water ice to sublimate?
     164logical                             :: STOPPING_co2         ! Logical: is the criterion (% of change in the surface of sublimating water ice) reached?
     165logical                             :: STOPPING_pressure    ! Logical: is the criterion (% of change in the surface pressure) reached?
     166integer                             :: criterion_stop       ! which criterion is reached ? 1= h2o ice surf, 2 = co2 ice surf, 3 = ps, 4 = orb param
     167real, save                          :: A , B, mmean         ! Molar mass: intermediate A, B for computations of the  mean molar mass of the layer [mol/kg]
     168real, dimension(:,:),   allocatable :: vmr_co2_gcm          ! Physics x Times  co2 volume mixing ratio retrieve from the gcm [m^3/m^3]
     169real, dimension(:,:),   allocatable :: vmr_co2_pem_phys    ! Physics x Times  co2 volume mixing ratio used in the PEM
     170real, dimension(:,:),   allocatable :: q_co2_PEM_phys       ! Physics x Times co2 mass mixing ratio in the first layer computed in the PEM, first value comes from GCM [kg/kg]
     171real, dimension(:,:),   allocatable :: q_h2o_PEM_phys       ! Physics x Times: h2o mass mixing ratio computed in the PEM, first value comes from GCM [kg/kg]
     172integer                             :: timelen              ! # time samples
     173real                                :: ave                  ! intermediate varibale to compute average
     174real, dimension(:,:),   allocatable :: p                    ! Physics x Atmosphere: pressure to recompute and write in restart (ngrid,llmp1)
     175real                                :: extra_mass           ! Intermediate variables Extra mass of a tracer if it is greater than 1
    176176
    177177! Variables for slopes
    178 real, dimension(:,:),   allocatable :: min_co2_ice_1          ! ngrid field : minimum of co2 ice at each point for the first year [kg/m^2]
    179 real, dimension(:,:),   allocatable :: min_co2_ice_2          ! ngrid field : minimum of co2 ice at each point for the second year [kg/m^2]
    180 real, dimension(:,:),   allocatable :: min_h2o_ice_1          ! ngrid field : minimum of water ice at each point for the first year [kg/m^2]
    181 real, dimension(:,:),   allocatable :: min_h2o_ice_2          ! ngrid field : minimum of water ice at each point for the second year [kg/m^2]
    182 real, dimension(:,:,:), allocatable :: co2_ice_GCM            ! Physics x NSLOPE x Times field : co2 ice given by the GCM  [kg/m^2]
    183 real, dimension(:,:),   allocatable :: initial_co2_ice_sublim ! physical point field : Logical array indicating sublimating point of co2 ice
    184 real, dimension(:,:),   allocatable :: initial_h2o_ice        ! physical point field : Logical array indicating if there is water ice at initial state
    185 real, dimension(:,:),   allocatable :: initial_co2_ice        ! physical point field : Logical array indicating if there is co2 ice at initial state
    186 real, dimension(:,:),   allocatable :: tendencies_co2_ice     ! physical point xslope field : Tendency of evolution of perenial co2 ice over a year
     178real, dimension(:,:),   allocatable :: min_co2_ice_1          ! ngrid field: minimum of co2 ice at each point for the first year [kg/m^2]
     179real, dimension(:,:),   allocatable :: min_co2_ice_2          ! ngrid field: minimum of co2 ice at each point for the second year [kg/m^2]
     180real, dimension(:,:),   allocatable :: min_h2o_ice_1          ! ngrid field: minimum of water ice at each point for the first year [kg/m^2]
     181real, dimension(:,:),   allocatable :: min_h2o_ice_2          ! ngrid field: minimum of water ice at each point for the second year [kg/m^2]
     182real, dimension(:,:,:), allocatable :: co2_ice_GCM            ! Physics x NSLOPE x Times field: co2 ice given by the GCM  [kg/m^2]
     183real, dimension(:,:),   allocatable :: initial_co2_ice_sublim ! physical point field: Logical array indicating sublimating point of co2 ice
     184real, dimension(:,:),   allocatable :: initial_h2o_ice        ! physical point field: Logical array indicating if there is water ice at initial state
     185real, dimension(:,:),   allocatable :: initial_co2_ice        ! physical point field: Logical array indicating if there is co2 ice at initial state
     186real, dimension(:,:),   allocatable :: tendencies_co2_ice     ! physical point x slope field: Tendency of evolution of perenial co2 ice over a year
    187187real, dimension(:,:),   allocatable :: tendencies_co2_ice_ini ! physical point x slope field x nslope: Tendency of evolution of perenial co2 ice over a year in the GCM
    188 real, dimension(:,:),   allocatable :: tendencies_h2o_ice     ! physical pointx slope  field : Tendency of evolution of perenial h2o ice
    189 real, dimension(:,:),   allocatable :: flag_co2flow(:,:)      ! (ngrid,nslope): Flag where there is a CO2 glacier flow
    190 real, dimension(:),     allocatable :: flag_co2flow_mesh(:)   ! (ngrid)       : Flag where there is a CO2 glacier flow
    191 real, dimension(:,:),   allocatable :: flag_h2oflow(:,:)      ! (ngrid,nslope): Flag where there is a H2O glacier flow
    192 real, dimension(:),     allocatable :: flag_h2oflow_mesh(:)   ! (ngrid)       : Flag where there is a H2O glacier flow
     188real, dimension(:,:),   allocatable :: tendencies_h2o_ice     ! physical point x slope  field: Tendency of evolution of perenial h2o ice
     189real, dimension(:,:),   allocatable :: flag_co2flow           ! (ngrid,nslope): Flag where there is a CO2 glacier flow
     190real, dimension(:),     allocatable :: flag_co2flow_mesh      ! (ngrid)       : Flag where there is a CO2 glacier flow
     191real, dimension(:,:),   allocatable :: flag_h2oflow           ! (ngrid,nslope): Flag where there is a H2O glacier flow
     192real, dimension(:),     allocatable :: flag_h2oflow_mesh      ! (ngrid)       : Flag where there is a H2O glacier flow
    193193
    194194! Variables for surface and soil
    195 real, allocatable :: tsurf_ave(:,:)              ! Physic x SLOPE field : Averaged Surface Temperature [K]
    196 real, allocatable :: tsoil_ave(:,:,:)            ! Physic x SOIL x SLOPE field : Averaged Soil Temperature [K]
    197 real, allocatable :: tsurf_GCM_timeseries(:,:,:) ! ngrid x SLOPE XTULES field : Surface Temperature in timeseries [K]
    198 real, allocatable :: tsoil_phys_PEM_timeseries(:,:,:,:) ! IG x SLOPE XTULES field : NOn averaged Soil Temperature [K]
    199 real, allocatable :: tsoil_GCM_timeseries(:,:,:,:)      ! IG x SLOPE XTULES field : NOn averaged Soil Temperature [K]
    200 real, allocatable :: tsurf_ave_yr1(:,:)                 ! Physic x SLOPE field : Averaged Surface Temperature of first call of the gcm [K]
    201 real, allocatable :: TI_locslope(:,:)    ! Physic x Soil: Intermediate thermal inertia  to compute Tsoil [SI]
    202 real, allocatable :: Tsoil_locslope(:,:) ! Physic x Soil: intermediate when computing Tsoil [K]
    203 real, allocatable :: Tsurf_locslope(:)   ! Physic x Soil: Intermediate surface temperature  to compute Tsoil [K]
    204 real, allocatable :: watersoil_density_timeseries(:,:,:,:)     ! Physic x Soil x Slope x Times water soil density, time series [kg /m^3]
    205 real, allocatable :: watersurf_density_ave(:,:)                ! Physic  x Slope, water surface density, yearly averaged [kg/m^3]
    206 real, allocatable :: watersoil_density_PEM_timeseries(:,:,:,:) ! Physic x Soil x Slope x Times, water soil density, time series [kg/m^3]
    207 real, allocatable :: watersoil_density_PEM_ave(:,:,:)          ! Physic x Soil x SLopes, water soil density, yearly averaged [kg/m^3]
    208 real, allocatable :: Tsurfave_before_saved(:,:)                ! Surface temperature saved from previous time step [K]
    209 real, allocatable :: delta_co2_adsorbded(:)                    ! Physics: quantity of CO2 that is exchanged because of adsorption / desorption [kg/m^2]
    210 real, allocatable :: delta_h2o_adsorbded(:)                    ! Physics: quantity of H2O that is exchanged because of adsorption / desorption [kg/m^2]
    211 real              :: totmassco2_adsorbded                      ! Total mass of CO2 that is exchanged because of adsorption / desoprtion over the planets [kg]
    212 real              :: totmassh2o_adsorbded                      ! Total mass of H2O that is exchanged because of adsorption / desoprtion over the planets [kg]
    213 logical           :: bool_sublim                               ! logical to check if there is sublimation or not
    214 real,allocatable  :: porefillingice_thickness_prev_iter(:,:)   ! ngrid x nslope: Thickness of the ice table at the previous iteration [m]
    215 real,allocatable  :: delta_h2o_icetablesublim(:)               ! ngrid x Total mass of the H2O that has sublimated / condenses from the ice table [kg]
     195real, dimension(:,:),     allocatable :: tsurf_ave                          ! Physic x SLOPE field : Averaged Surface Temperature [K]
     196real, dimension(:,:,:),   allocatable :: tsoil_ave                          ! Physic x SOIL x SLOPE field : Averaged Soil Temperature [K]
     197real, dimension(:,:,:),   allocatable :: tsurf_GCM_timeseries               ! ngrid x SLOPE XTULES field : Surface Temperature in timeseries [K]
     198real, dimension(:,:,:,:), allocatable :: tsoil_phys_PEM_timeseries          ! IG x SLOPE XTULES field : NOn averaged Soil Temperature [K]
     199real, dimension(:,:,:,:), allocatable :: tsoil_GCM_timeseries               ! IG x SLOPE XTULES field : NOn averaged Soil Temperature [K]
     200real, dimension(:,:),     allocatable :: tsurf_ave_yr1                      ! Physic x SLOPE field : Averaged Surface Temperature of first call of the gcm [K]
     201real, dimension(:,:),     allocatable :: TI_locslope                        ! Physic x Soil: Intermediate thermal inertia  to compute Tsoil [SI]
     202real, dimension(:,:),     allocatable :: Tsoil_locslope                     ! Physic x Soil: intermediate when computing Tsoil [K]
     203real, dimension(:),       allocatable :: Tsurf_locslope                     ! Physic x Soil: Intermediate surface temperature  to compute Tsoil [K]
     204real, dimension(:,:,:,:), allocatable :: watersoil_density_timeseries       ! Physic x Soil x Slope x Times water soil density, time series [kg /m^3]
     205real, dimension(:,:),     allocatable :: watersurf_density_ave              ! Physic x Slope, water surface density, yearly averaged [kg/m^3]
     206real, dimension(:,:,:,:), allocatable :: watersoil_density_PEM_timeseries   ! Physic x Soil x Slope x Times, water soil density, time series [kg/m^3]
     207real, dimension(:,:,:),   allocatable :: watersoil_density_PEM_ave          ! Physic x Soil x SLopes, water soil density, yearly averaged [kg/m^3]
     208real, dimension(:,:),     allocatable :: Tsurfave_before_saved              ! Surface temperature saved from previous time step [K]
     209real, dimension(:),       allocatable :: delta_co2_adsorbded                ! Physics: quantity of CO2 that is exchanged because of adsorption / desorption [kg/m^2]
     210real, dimension(:),       allocatable :: delta_h2o_adsorbded                ! Physics: quantity of H2O that is exchanged because of adsorption / desorption [kg/m^2]
     211real                                  :: totmassco2_adsorbded               ! Total mass of CO2 that is exchanged because of adsorption / desoprtion over the planets [kg]
     212real                                  :: totmassh2o_adsorbded               ! Total mass of H2O that is exchanged because of adsorption / desoprtion over the planets [kg]
     213logical                               :: bool_sublim                        ! logical to check if there is sublimation or not
     214real, dimension(:,:),     allocatable :: porefillingice_thickness_prev_iter ! ngrid x nslope: Thickness of the ice table at the previous iteration [m]
     215real, dimension(:),       allocatable :: delta_h2o_icetablesublim(:)        ! ngrid x Total mass of the H2O that has sublimated / condenses from the ice table [kg]
     216
    216217! Some variables for the PEM run
    217218real, parameter :: year_step = 1 ! timestep for the pem
     
    221222integer         :: n_myear       ! Maximum number of Martian years of the chained simulations
    222223real            :: timestep      ! timestep [s]
    223 real            :: watercap_sum  ! total mass of water cap [kg/m^2] 
    224 real            :: water_sum     ! total mass of water in the mesh [kg/m^2] 
     224real            :: watercap_sum  ! total mass of water cap [kg/m^2]
     225real            :: water_sum     ! total mass of water in the mesh [kg/m^2]
    225226
    226227#ifdef CPP_STD
    227     real                 :: frost_albedo_threshold = 0.05 ! frost albedo threeshold to convert fresh frost to old ice
    228     real                 :: albedo_h2o_frost              ! albedo of h2o frost
    229     real,    allocatable :: tsurf_read_generic(:)         ! Temporary variable to do the subslope transfert dimensiion when reading form generic
    230     real,    allocatable :: qsurf_read_generic(:,:)       ! Temporary variable to do the subslope transfert dimensiion when reading form generic
    231     real,    allocatable :: tsoil_read_generic(:,:)       ! Temporary variable to do the subslope transfert dimensiion when reading form generic
    232     real,    allocatable :: emis_read_generic(:)          ! Temporary variable to do the subslope transfert dimensiion when reading form generic
    233     real,    allocatable :: albedo_read_generic(:,:)      ! Temporary variable to do the subslope transfert dimensiion when reading form generic
    234     real,    allocatable :: tsurf(:,:)                    ! Subslope variable, only needed in the GENERIC case
    235     real,    allocatable :: qsurf(:,:,:)                  ! Subslope variable, only needed in the GENERIC case
    236     real,    allocatable :: tsoil(:,:,:)                  ! Subslope variable, only needed in the GENERIC case
    237     real,    allocatable :: emis(:,:)                     ! Subslope variable, only needed in the GENERIC case
    238     real,    allocatable :: watercap(:,:)                 ! Subslope variable, only needed in the GENERIC case =0 no watercap in generic model
    239     logical, allocatable :: WATERCAPTAG(:)                ! Subslope variable, only needed in the GENERIC case =false no watercaptag in generic model
    240     real,    allocatable :: albedo(:,:,:)                 ! Subslope variable, only needed in the GENERIC case
    241     real,    allocatable :: inertiesoil(:,:,:)            ! Subslope variable, only needed in the GENERIC case
     228    real                                :: frost_albedo_threshold = 0.05 ! frost albedo threeshold to convert fresh frost to old ice
     229    real                                :: albedo_h2o_frost              ! albedo of h2o frost
     230    real, dimension(:),     allocatable :: tsurf_read_generic            ! Temporary variable to do the subslope transfert dimensiion when reading form generic
     231    real, dimension(:,:),   allocatable :: qsurf_read_generic            ! Temporary variable to do the subslope transfert dimensiion when reading form generic
     232    real, dimension(:,:),   allocatable :: tsoil_read_generic            ! Temporary variable to do the subslope transfert dimensiion when reading form generic
     233    real, dimension(:),     allocatable :: emis_read_generic             ! Temporary variable to do the subslope transfert dimensiion when reading form generic
     234    real, dimension(:,:),   allocatable :: albedo_read_generic           ! Temporary variable to do the subslope transfert dimensiion when reading form generic
     235    real, dimension(:,:),   allocatable :: tsurf                         ! Subslope variable, only needed in the GENERIC case
     236    real, dimension(:,:,:), allocatable :: qsurf                         ! Subslope variable, only needed in the GENERIC case
     237    real, dimension(:,:,:), allocatable :: tsoil                         ! Subslope variable, only needed in the GENERIC case
     238    real, dimension(:,:),   allocatable :: emis                          ! Subslope variable, only needed in the GENERIC case
     239    real, dimension(:,:),   allocatable :: watercap                      ! Subslope variable, only needed in the GENERIC case =0 no watercap in generic model
     240    logical, dimension(:),  allocatable :: WATERCAPTAG                   ! Subslope variable, only needed in the GENERIC case =false no watercaptag in generic model
     241    real, dimension(:,:,:), allocatable :: albedo                        ! Subslope variable, only needed in the GENERIC case
     242    real, dimension(:,:,:), allocatable :: inertiesoil                   ! Subslope variable, only needed in the GENERIC case
    242243#endif
    243244
    244245#ifdef CPP_1D
    245     integer            :: nsplit_phys
    246     integer, parameter :: jjm_value = jjm - 1
    247     integer            :: ierr
     246    integer                           :: nsplit_phys
     247    integer, parameter                :: jjm_value = jjm - 1
     248    integer                           :: ierr
     249
     250    ! Dummy variables to use the subroutine 'init_testphys1d'
     251    real, dimension(:,:), allocatable :: q_tmp ! Temporary tracer mixing ratio (e.g. kg/kg)
     252    logical                           :: startfiles_1D, therestart1D, therestartfi
     253    integer                           :: ndt, day0
     254    real                              :: ptif, pks, day, gru, grv, atm_wat_profile, atm_wat_tau
     255    real, dimension(:),   allocatable :: zqsat, qsurf_tmp
     256    real, dimension(:,:), allocatable :: dq, dqdyn
     257    real, dimension(nlayer)           :: play, w
     258    real, dimension(nlayer + 1)       :: plev, q2_tmp
     259    real, dimension(nsoilmx)          :: tsoil_tmp
     260    real, dimension(1)                :: tsurf_tmp, emis_tmp
     261    real, dimension(1,1)              :: albedo_tmp
    248262#else
    249     integer, parameter :: jjm_value = jjm
     263    integer, parameter                :: jjm_value = jjm
     264    real, dimension(:), allocatable   :: ap ! Coefficient ap read in FILE_NAME_start and written in restart
     265    real, dimension(:), allocatable   :: bp ! Coefficient bp read in FILE_NAME_start and written in restart
    250266#endif
    251267
     
    262278#endif
    263279
     280! Some constants
    264281day_ini = 0    ! test
    265282time_phys = 0. ! test
    266 
    267 ! Some constants
    268283ngrid = ngridmx
    269 nlayer = llm
    270 
    271284A = (1/m_co2 - 1/m_noco2)
    272285B = 1/m_noco2
    273 
    274286year_day = 669
    275287daysec = 88775.
     
    287299    nq = nqtot
    288300    allocate(q(ip1jmp1,llm,nqtot))
     301    allocate(longitude(ngrid),latitude(ngrid),cell_area(ngrid))
    289302#else
    290     ! load tracer names from file 'traceur.def'
    291     open(90,file = 'traceur.def',status = 'old',form = 'formatted',iostat = ierr)
    292     if (ierr /= 0) then
    293         write(*,*) 'Cannot find required file "traceur.def"'
    294         write(*,*) ' If you want to run with tracers, I need it'
    295         write(*,*) ' ... might as well stop here ...'
    296         stop
    297     else
    298         write(*,*) "pem1d: Reading file traceur.def"
    299         ! read number of tracers:
    300         read(90,*,iostat = ierr) nq
    301         write(*,*) "nq",nq
    302         nqtot = nq ! set value of nqtot (in infotrac module) as nq
    303         if (ierr /= 0) then
    304             write(*,*) "pem1d: error reading number of tracers"
    305             write(*,*) "   (first line of traceur.def) "
    306             stop
    307         endif
    308         if (nq < 1) then
    309             write(*,*) "pem1d: error number of tracers"
    310             write(*,*) "is nq=",nq," but must be >=1!"
    311             stop
    312         endif
    313     endif
    314     nq = nqtot
     303    allocate(longitude(1),latitude(1),cell_area(1))
     304    call init_testphys1d(.true.,ngrid,nlayer,610.,nq,q_tmp,time_0,ps(1),ucov,vcov,teta,startfiles_1D,therestart1D,therestartfi, &
     305                         ndt,ptif,pks,dtphys,zqsat,qsurf_tmp,dq,dqdyn,day0,day,tsurf_tmp,gru,grv,w,q2_tmp,play,plev,tsoil_tmp,              &
     306                         albedo_tmp,emis_tmp,latitude,longitude,cell_area,atm_wat_profile,atm_wat_tau)
     307    ps(2) = ps(1)
    315308    allocate(q(ip1jmp1,llm,nqtot))
    316     allocate(ap(nlayer + 1))
    317     allocate(bp(nlayer + 1))
    318     call init_pem1d(llm,nqtot,ucov,vcov,teta,q,ps,time_0,ap,bp)
    319     pi = 2.*asin(1.)
    320     g = 3.72
     309    q(ip1jmp1,:,:) = q_tmp(:,:)
     310    deallocate(q_tmp,qsurf_tmp)
    321311    nsplit_phys = 1
    322312#endif
     
    356346! Here we simply read them in the startfi_evol.nc file
    357347status =nf90_open(FILE_NAME, NF90_NOWRITE, ncid)
    358 
    359 allocate(longitude(ngrid))
    360 allocate(latitude(ngrid))
    361 allocate(cell_area(ngrid))
    362348
    363349status = nf90_inq_varid(ncid,"longitude",lonvarid)
     
    414400                  qsurf_read_generic,cloudfrac,totcloudfrac,hice,rnat,pctsrf_sic, &
    415401                  tslab, tsea_ice,sea_ice)
    416     call surfini(ngrid,nq,qsurf_read_generic,albedo_read_generic,albedo_bareground,albedo_snow_SPECTV,albedo_co2_ice_SPECTV) 
     402    call surfini(ngrid,nq,qsurf_read_generic,albedo_read_generic,albedo_bareground,albedo_snow_SPECTV,albedo_co2_ice_SPECTV)
    417403
    418404    nslope = 1
     
    452438    endif
    453439    if (noms(nnq) == "co2") igcm_co2 = nnq
    454 enddo 
     440enddo
    455441r = 8.314511*1000./mugaz
    456442
     
    473459allocate(flag_h2oflow_mesh(ngrid))
    474460
    475 flag_co2flow(:,:) = 0     
     461flag_co2flow(:,:) = 0
    476462flag_co2flow_mesh(:) = 0
    477 flag_h2oflow(:,:) = 0     
     463flag_h2oflow(:,:) = 0
    478464flag_h2oflow_mesh(:) = 0
    479465
     
    614600global_ave_press_old = 0.
    615601do i = 1,ngrid
    616        global_ave_press_old = global_ave_press_old + cell_area(i)*ps_start_GCM(i)/Total_surface
     602    global_ave_press_old = global_ave_press_old + cell_area(i)*ps_start_GCM(i)/Total_surface
    617603enddo
    618604
     
    656642    write(*,*) "Tot mass of H2O in the regolith=", totmassh2o_adsorbded
    657643endif ! adsorption
    658 deallocate(tsurf_ave_yr1) 
     644deallocate(tsurf_ave_yr1)
    659645
    660646!------------------------
     
    678664!------------------------
    679665! II  Run
    680 !    II_a Update pressure, ice and tracers 
     666!    II_a Update pressure, ice and tracers
    681667!------------------------
    682668year_iter = 0
     
    688674    do i = 1,ngrid
    689675        do islope = 1,nslope
    690             global_ave_press_new = global_ave_press_new-g*cell_area(i)*tendencies_co2_ice(i,islope)*subslope_dist(i,islope)/cos(pi*def_slope_mean(islope)/180.)/Total_surface
    691         enddo
    692     enddo
    693     call WRITEDIAGFI(ngrid,'ps_ave','Global average pressure','Pa',0,global_ave_press_new)
    694      
     676            global_ave_press_new = global_ave_press_new - g*cell_area(i)*tendencies_co2_ice(i,islope)*subslope_dist(i,islope)/cos(pi*def_slope_mean(islope)/180.)/Total_surface
     677        enddo
     678    enddo
     679    call writediagfi(ngrid,'ps_ave','Global average pressure','Pa',0,global_ave_press_new)
     680
    695681    if (adsorption_pem) then
    696682        do i = 1,ngrid
     
    739725
    740726    do ig = 1,ngrid
    741         do t = 1, timelen
     727        do t = 1,timelen
    742728            q_co2_PEM_phys(ig,t) = q_co2_PEM_phys(ig,t)*(zplev_old_timeseries(ig,l,t) - zplev_old_timeseries(ig,l + 1,t))/ &
    743729                                   (zplev_new_timeseries(ig,l,t) - zplev_new_timeseries(ig,l + 1,t))  &
     
    767753    call evol_co2_ice_s(qsurf(:,igcm_co2,:),tendencies_co2_ice,iim,jjm_value,ngrid,cell_area,nslope)
    768754
    769     do islope=1, nslope
     755    do islope = 1,nslope
    770756        write(str2(1:2),'(i2.2)') islope
    771         call WRITEDIAGFI(ngrid,'h2o_ice_s_slope'//str2,'H2O ice','kg.m-2',2,qsurf(:,igcm_h2o_ice,islope))
    772         call WRITEDIAGFI(ngrid,'tendencies_h2o_ice_slope'//str2,'H2O ice tend','kg.m-2.year-1',2,tendencies_h2o_ice(:,islope))
    773         call WRITEDIAGFI(ngrid,'c2ice_slope'//str2,'CO2 ice','kg.m-2',2,qsurf(:,igcm_co2,islope))
    774         call WRITEDIAGFI(ngrid,'tendencies_co2_ice_slope'//str2,'CO2 ice tend','kg.m-2.year-1',2,tendencies_co2_ice(:,islope))
     757        call writediagfi(ngrid,'h2o_ice_s_slope'//str2,'H2O ice','kg.m-2',2,qsurf(:,igcm_h2o_ice,islope))
     758        call writediagfi(ngrid,'tendencies_h2o_ice_slope'//str2,'H2O ice tend','kg.m-2.year-1',2,tendencies_h2o_ice(:,islope))
     759        call writediagfi(ngrid,'c2ice_slope'//str2,'CO2 ice','kg.m-2',2,qsurf(:,igcm_co2,islope))
     760        call writediagfi(ngrid,'tendencies_co2_ice_slope'//str2,'CO2 ice tend','kg.m-2.year-1',2,tendencies_co2_ice(:,islope))
    775761    enddo
    776762
     
    783769    if (co2glaciersflow) call co2glaciers_evol(timelen,ngrid,nslope,iflat,subslope_dist,def_slope_mean,vmr_co2_pem_phys,ps_timeseries, &
    784770                                               global_ave_press_GCM,global_ave_press_new,qsurf(:,igcm_co2,:),flag_co2flow,flag_co2flow_mesh)
    785  
     771
    786772    write(*,*) "H2O glacier flows"
    787773
     
    790776    do islope = 1,nslope
    791777        write(str2(1:2),'(i2.2)') islope
    792         call WRITEDIAGFI(ngrid,'co2ice_slope'//str2,'CO2 ice','kg.m-2',2,qsurf(:,igcm_co2,islope))
    793         call WRITEDIAGFI(ngrid,'tendencies_co2_ice_slope'//str2,'CO2 ice tend','kg.m-2.year-1',2,tendencies_co2_ice(:,islope))
    794         call WRITEDIAGFI(ngrid,'Flow_co2ice_slope'//str2,'CO2 ice flow','Boolean',2,flag_co2flow(:,islope))
     778        call writediagfi(ngrid,'co2ice_slope'//str2,'CO2 ice','kg.m-2',2,qsurf(:,igcm_co2,islope))
     779        call writediagfi(ngrid,'tendencies_co2_ice_slope'//str2,'CO2 ice tend','kg.m-2.year-1',2,tendencies_co2_ice(:,islope))
     780        call writediagfi(ngrid,'Flow_co2ice_slope'//str2,'CO2 ice flow','Boolean',2,flag_co2flow(:,islope))
    795781    enddo
    796782
     
    835821                else
    836822                    albedo(ig,1,islope) = albedodat(ig)
    837                     albedo(ig,2,islope) = albedodat(ig) 
     823                    albedo(ig,2,islope) = albedodat(ig)
    838824                    emis(ig,islope) = emissiv
    839825                endif
     
    862848
    863849    do t = 1,timelen
    864         tsurf_GCM_timeseries(:,:,t) = tsurf_GCM_timeseries(:,:,t) + (tsurf_ave(:,:) - Tsurfave_before_saved(:,:)) 
     850        tsurf_GCM_timeseries(:,:,t) = tsurf_GCM_timeseries(:,:,t) + (tsurf_ave(:,:) - Tsurfave_before_saved(:,:))
    865851    enddo
    866852    ! for the start
     
    873859    do islope = 1,nslope
    874860        write(str2(1:2),'(i2.2)') islope
    875         call WRITEDIAGFI(ngrid,'tsurf_slope'//str2,'tsurf','K',2,tsurf(:,islope))
     861        call writediagfi(ngrid,'tsurf_slope'//str2,'tsurf','K',2,tsurf(:,islope))
    876862    enddo
    877863
     
    896882                    do isoil = 1,nsoilmx_PEM
    897883                        watersoil_density_PEM_timeseries(ig,isoil,islope,t) = exp(beta_clap_h2o/Tsoil_locslope(ig,isoil) + alpha_clap_h2o)/Tsoil_locslope(ig,isoil)*mmol(igcm_h2o_vap)/(mugaz*r)
    898                         if (isnan(Tsoil_locslope(ig,isoil))) call abort_pem("PEM - Update Tsoil","NaN detected in Tsoil ",1) 
     884                        if (isnan(Tsoil_locslope(ig,isoil))) call abort_pem("PEM - Update Tsoil","NaN detected in Tsoil ",1)
    899885                    enddo
    900886                enddo
     
    1001987    endif
    1002988
    1003     global_ave_press_old=global_ave_press_new
     989    global_ave_press_old = global_ave_press_new
    1004990
    1005991enddo  ! big time iteration loop of the pem
     
    10371023        water_sum = water_sum + qsurf(ig,igcm_h2o_ice,islope)*subslope_dist(ig,islope)/cos(pi*def_slope_mean(islope)/180.)
    10381024    enddo
    1039     if (.not. watercaptag(ig)) then ! let's check if we have an 'infinite' source of water that has been forming. 
     1025    if (.not. watercaptag(ig)) then ! let's check if we have an 'infinite' source of water that has been forming.
    10401026        if (water_sum > threshold_water_frost2perenial) then ! the overall mesh can be considered as an infite source of water. No need to change the albedo: done in II.d.1
    10411027            watercaptag(ig) = .true.
     
    10711057if (soil_pem) then
    10721058    call interpolate_TIPEM_TIGCM(ngrid,nslope,nsoilmx_PEM,nsoilmx,TI_PEM,inertiesoil)
    1073     tsoil(:,:,:) = tsoil_phys_PEM_timeseries(:,1:nsoilmx,:,timelen)     
     1059    tsoil(:,:,:) = tsoil_phys_PEM_timeseries(:,1:nsoilmx,:,timelen)
    10741060endif
    10751061
    10761062! III_a.4 Pressure (for start)
    1077 do i = 1,ip1jmp1
    1078     ps(i) = ps(i)*global_ave_press_new/global_ave_press_GCM
    1079 enddo
    1080 
    1081 do i = 1,ngrid
    1082     ps_start_GCM(i) = ps_start_GCM(i)*global_ave_press_new/global_ave_press_GCM
    1083 enddo
     1063ps(:) = ps(:)*global_ave_press_new/global_ave_press_GCM
     1064ps_start_GCM(:) = ps_start_GCM(:)*global_ave_press_new/global_ave_press_GCM
    10841065
    10851066! III_a.5 Tracer (for start)
     
    10871068
    10881069do l = 1,nlayer + 1
    1089     do ig = 1,ngrid
    1090         zplev_new(ig,l) = ap(l) + bp(l)*ps_start_GCM(ig)
    1091     enddo
     1070    zplev_new(:,l) = ap(l) + bp(l)*ps_start_GCM(:)
    10921071enddo
    10931072
     
    11041083            do ig = 1,ngrid
    11051084                q(ig,l,nnq) = q(ig,l,nnq)*(zplev_gcm(ig,l) - zplev_gcm(ig,l + 1))/(zplev_new(ig,l) - zplev_new(ig,l + 1)) &
    1106                               + ((zplev_new(ig,l) - zplev_new(ig,l + 1)) - (zplev_gcm(ig,l) - zplev_gcm(ig,l + 1)))/ &
     1085                              + ((zplev_new(ig,l) - zplev_new(ig,l + 1)) - (zplev_gcm(ig,l) - zplev_gcm(ig,l + 1)))/      &
    11071086                              (zplev_new(ig,l) - zplev_new(ig,l + 1))
    11081087            enddo
     
    11171096        do l = 1,llm - 1
    11181097            if (q(ig,l,nnq) > 1 .and. (noms(nnq) /= "dust_number") .and. (noms(nnq) /= "ccn_number") .and. (noms(nnq) /= "stormdust_number") .and. (noms(nnq) /= "topdust_number")) then
    1119                 extra_mass=(q(ig,l,nnq)-1)*(zplev_new(ig,l)-zplev_new(ig,l+1))
    1120                 q(ig,l,nnq)=1.
    1121                 q(ig,l+1,nnq)=q(ig,l+1,nnq)+extra_mass*(zplev_new(ig,l+1)-zplev_new(ig,l+2))
     1098                extra_mass = (q(ig,l,nnq) - 1)*(zplev_new(ig,l) - zplev_new(ig,l + 1))
     1099                q(ig,l,nnq) = 1.
     1100                q(ig,l + 1,nnq) = q(ig,l + 1,nnq) + extra_mass*(zplev_new(ig,l + 1) - zplev_new(ig,l + 2))
    11221101                write(*,*) 'extra ',noms(nnq),extra_mass, noms(nnq) /= "dust_number",noms(nnq) /= "ccn_number"
    11231102           endif
     
    11461125    write(*,*) "restart_evol.nc has been written"
    11471126#else
    1148     do nnq = 1, nqtot
    1149         call writeprofile(nlayer,q(1,:,nnq),noms(nnq),nnq,qsurf)
    1150     enddo
     1127    call writerestart1D('restart1D_evol.txt',ps(1),tsurf,nlayer,teta,ucov,vcov,nq,noms,qsurf,q)
     1128    write(*,*) "restart1D_evol.txt has been written"
    11511129#endif
    11521130
     
    11981176
    11991177END PROGRAM pem
    1200 
  • trunk/LMDZ.MARS/deftank/pem/launch_pem.sh

    r3050 r3065  
    8080if [ ! -d "diags" ]; then
    8181    mkdir diags
    82 fi
    83 if [ ! -d "profiles" ]; then
    84     mkdir profiles
    8582fi
    8683
     
    9895((iGCM = ($iPEM - 1)*$nGCM + 1))
    9996cp startfi.nc starts/
    100 for file in profile_*; do
    101     cp $file profiles/${file}_0
    102 done
     97if [ -f "start.nc" ]; then
     98    cp start.nc starts/
     99fi
    103100
    104101# Create a temporary file to manage years of the chained simulation
     
    138135            cp restart.nc starts/restart${iGCM}.nc
    139136            mv restart.nc start.nc
    140         fi
    141         if [ -f "restart1D.txt" ]; then
     137        elif [ -f "restart1D.txt" ]; then
    142138            cp restart1D.txt starts/restart1D${iGCM}.txt
    143139            mv restart1D.txt start1D.txt
    144         fi
    145         if ls profile_out_* 1> /dev/null 2>&1; then
    146             for file in profile_out_*; do
    147                 cp $file profiles/${file/_out/}_${iGCM}
    148                 mv $file ${file/_out/}
    149             done
    150140        fi
    151141        ((iGCM++))
     
    171161    if [ -f "start.nc" ]; then
    172162        cp start.nc start_evol.nc
    173     fi
    174     #if [ -f "start1D.txt" ]; then
    175     #    cp start1D.txt start1D.txt
    176     #fi
     163    elif [ -f "start1D.txt" ]; then
     164        cp start1D.txt start1D_evol.txt
     165    fi
    177166    ./$exePEM > out_runPEM${iPEM} 2>&1
    178167    if [ ! -f "restartfi_evol.nc" ]; then # Check if run ended abnormally
     
    183172    mv out_runPEM${iPEM} out_PEM/run${iPEM}
    184173    mv diagfi.nc diags/diagfi_PEM${iPEM}.nc
     174    cp restartfi_PEM.nc starts/startfi_PEM${iPEM}.nc
     175    mv restartfi_PEM.nc startfi_PEM.nc
    185176    cp restartfi_evol.nc starts/startfi_postPEM${iPEM}.nc
    186177    mv restartfi_evol.nc startfi.nc
    187178    if [ -f "restart_evol.nc" ]; then
    188         cp restart_evol.nc starts/restart${iGCM}.nc
     179        cp restart_evol.nc starts/restart_postPEM${iPEM}.nc
    189180        mv restart_evol.nc start.nc
    190     fi
    191     cp restartfi_PEM.nc starts/startfi_PEM${iPEM}.nc
    192     mv restartfi_PEM.nc startfi_PEM.nc
    193     if ls profile_out_* 1> /dev/null 2>&1; then
    194         for file in profile_out_*; do
    195             cp $file profiles/${file/_out/}PEM_${iPEM}
    196             mv $file ${file/_out/}
    197         done
     181    elif [ -f "restart1D_evol.txt" ]; then
     182        cp restart1D_evol.txt starts/restart1D_postPEM${iPEM}.txt
     183        mv restart1D_evol.txt start1D.txt
    198184    fi
    199185    ((iPEM++))
  • trunk/LMDZ.MARS/libf/phymars/dyn1d/init_testphys1d_mod.F90

    r3060 r3065  
    55contains
    66
    7 SUBROUTINE init_testphys1d(startfiles_1D,therestart1D,therestartfi,ngrid,nlayer,odpref,nq,ndt,ptif,pks,dttestphys, &
    8                            q,zqsat,qsurf,dq,dqdyn,day0,day,time,psurf,tsurf,gru,grv,u,v,w,q2,play,plev,tsoil,temp, &
     7SUBROUTINE init_testphys1d(pem1d,ngrid,nlayer,odpref,nq,q,time,psurf,u,v,temp,startfiles_1D,therestart1D,therestartfi, &
     8                           ndt,ptif,pks,dttestphys,zqsat,qsurf,dq,dqdyn,day0,day,tsurf,gru,grv,w,q2,play,plev,tsoil,  &
    99                           albedo,emis,latitude,longitude,cell_area,atm_wat_profile,atm_wat_tau)
    1010
     
    4747! Arguments
    4848!=======================================================================
    49 logical, intent(in) :: startfiles_1D, therestart1D, therestartfi ! Use of "start1D.txt" and "startfi.nc" files
    50 integer, intent(in) :: ngrid, nlayer
    51 real,    intent(in) :: odpref ! DOD reference pressure (Pa)
     49integer,            intent(in) :: ngrid, nlayer
     50real,               intent(in) :: odpref        ! DOD reference pressure (Pa)
     51logical,            intent(in) :: pem1d         ! If initialization for the 1D PEM
    5252
    5353integer, intent(inout) :: nq
    5454
     55real, dimension(:,:), allocatable, intent(out) :: q     ! tracer mixing ratio (e.g. kg/kg)
     56real,                              intent(out) :: time  ! time (0<time<1; time=0.5 at noon)
     57real,                              intent(out) :: psurf ! Surface pressure
     58real, dimension(nlayer),           intent(out) :: u, v  ! zonal, meridional wind
     59real, dimension(nlayer),           intent(out) :: temp  ! temperature at the middle of the layers
     60logical,                           intent(out) :: startfiles_1D, therestart1D, therestartfi ! Use of starting files for 1D
    5561integer,                           intent(out) :: ndt
    5662real,                              intent(out) :: ptif, pks
    57 real,                              intent(out) :: dttestphys    ! testphys1d timestep
    58 real, dimension(:,:), allocatable, intent(out) :: q             ! tracer mixing ratio (e.g. kg/kg)
    59 real, dimension(:),   allocatable, intent(out) :: zqsat         ! useful for (atm_wat_profile=2)
    60 real, dimension(:),   allocatable, intent(out) :: qsurf         ! tracer surface budget (e.g. kg.m-2)
    61 real, dimension(:,:), allocatable, intent(out) :: dq, dqdyn     ! Physical and dynamical tandencies
    62 integer,                           intent(out) :: day0          ! initial (sol ; =0 at Ls=0) and final date
    63 real,                              intent(out) :: day           ! date during the run
    64 real,                              intent(out) :: time          ! time (0<time<1; time=0.5 at noon)
    65 real,                              intent(out) :: psurf         ! Surface pressure
    66 real, dimension(1),                intent(out) :: tsurf         ! Surface temperature
    67 real,                              intent(out) :: gru, grv      ! prescribed "geostrophic" background wind
    68 real, dimension(nlayer),           intent(out) :: u, v, w       ! zonal, meridional wind
    69 real, dimension(nlayer + 1),       intent(out) :: q2            ! Turbulent Kinetic Energy
    70 real, dimension(nlayer),           intent(out) :: play          ! Pressure at the middle of the layers (Pa)
    71 real, dimension(nlayer + 1),       intent(out) :: plev          ! intermediate pressure levels (pa)
    72 real, dimension(nsoilmx),          intent(out) :: tsoil         ! subsurface soil temperature (K)
    73 real, dimension(nlayer),           intent(out) :: temp          ! temperature at the middle of the layers
    74 real, dimension(1,1),              intent(out) :: albedo        ! surface albedo
    75 real, dimension(1),                intent(out) :: emis          ! surface layer
     63real,                              intent(out) :: dttestphys                   ! testphys1d timestep
     64real, dimension(:),   allocatable, intent(out) :: zqsat                        ! useful for (atm_wat_profile=2)
     65real, dimension(:),   allocatable, intent(out) :: qsurf                        ! tracer surface budget (e.g. kg.m-2)
     66real, dimension(:,:), allocatable, intent(out) :: dq, dqdyn                    ! Physical and dynamical tandencies
     67integer,                           intent(out) :: day0                         ! initial (sol ; =0 at Ls=0) and final date
     68real,                              intent(out) :: day                          ! date during the run
     69real, dimension(1),                intent(out) :: tsurf                        ! Surface temperature
     70real,                              intent(out) :: gru, grv                     ! prescribed "geostrophic" background wind
     71real, dimension(nlayer),           intent(out) :: w                            ! "Dummy wind" in 1D
     72real, dimension(nlayer + 1),       intent(out) :: q2                           ! Turbulent Kinetic Energy
     73real, dimension(nlayer),           intent(out) :: play                         ! Pressure at the middle of the layers (Pa)
     74real, dimension(nlayer + 1),       intent(out) :: plev                         ! intermediate pressure levels (pa)
     75real, dimension(nsoilmx),          intent(out) :: tsoil                        ! subsurface soil temperature (K)
     76real, dimension(1,1),              intent(out) :: albedo                       ! surface albedo
     77real, dimension(1),                intent(out) :: emis                         ! surface layer
    7678real, dimension(1),                intent(out) :: latitude, longitude, cell_area
    77 real,                              intent(out) :: atm_wat_profile, atm_wat_tau
     79real,                              intent(out) :: atm_wat_profile, atm_wat_tau ! Force atmospheric water profiles
    7880
    7981!=======================================================================
     
    8991real, dimension(:,:),     allocatable :: psdyn
    9092
    91 ! RV & JBC: Use of "start1D.txt" and "startfi.nc" files
     93! RV & JBC: Use of starting files for 1D
    9294logical                :: found
    9395character(len = 30)    :: header
     
    102104integer                                        :: ifils, ipere, generation, ierr0
    103105character(len = 30), dimension(:), allocatable :: tnom_transp ! transporting fluid short name
    104 character(len = 80)                            :: line ! to store a line of text
     106character(len = 80)                            :: line        ! to store a line of text
    105107logical                                        :: continu, there
    106108
     
    113115real :: flux_geo_tmp
    114116
     117! JBC: To initialize the 1D PEM
     118character(:), allocatable :: start1Dname, startfiname ! Name of starting files for 1D
     119
    115120!=======================================================================
    116121! Code
    117122!=======================================================================
     123if (.not. pem1d) then
     124    start1Dname = 'start1D.txt'
     125    startfiname = 'startfi.nc'
     126    startfiles_1D = .false.
     127    !------------------------------------------------------
     128    ! Loading run parameters from "run.def" file
     129    !------------------------------------------------------
     130    ! check if 'run.def' file is around. Otherwise reading parameters
     131    ! from callphys.def via getin() routine won't work.
     132    inquire(file = 'run.def',exist = there)
     133    if (.not. there) then
     134        write(*,*) 'Cannot find required file "run.def"'
     135        write(*,*) '  (which should contain some input parameters along with the following line: INCLUDEDEF=callphys.def)'
     136        write(*,*) ' ... might as well stop here ...'
     137        stop
     138    endif
     139
     140    write(*,*)'Do you want to use starting files?'
     141    call getin("startfiles_1D",startfiles_1D)
     142    write(*,*) " startfiles_1D = ", startfiles_1D
     143else
     144    start1dname = 'start1D_evol.txt'
     145    startfiname = 'startfi_evol.nc'
     146    startfiles_1D = .true.
     147endif
     148
     149therestart1D = .false.
     150therestartfi = .false.
     151inquire(file = start1Dname,exist = therestart1D)
     152if (startfiles_1D .and. .not. therestart1D) then
     153    write(*,*) 'There is no "'//start1Dname//'" file!'
     154    if (.not. pem1d) then
     155        write(*,*) 'Initialization is done with default values.'
     156    else
     157        write(*,*) 'Initialization cannot be done for the 1D PEM.'
     158        stop
     159    endif
     160endif
     161inquire(file = startfiname,exist = therestartfi)
     162if (.not. therestartfi) then
     163    write(*,*) 'There is no "'//startfiname//'" file!'
     164    if (.not. pem1d) then
     165        write(*,*) 'Initialization is done with default values.'
     166    else
     167        write(*,*) 'Initialization cannot be done for the 1D PEM.'
     168        stop
     169    endif
     170endif
    118171
    119172!------------------------------------------------------
     
    186239    endif
    187240endif
     241
    188242! allocate arrays:
    189243allocate(tname(nq),q(nlayer,nq),zqsat(nlayer),qsurf(nq))
     
    245299else
    246300    do iq = 1,nq
    247         open(3,file = 'start1D.txt',status = "old",action = "read")
     301        open(3,file = start1Dname,status = "old",action = "read")
    248302        read(3,*) header, qsurf(iq),(q(ilayer,iq), ilayer = 1,nlayer)
    249303        if (trim(tname(iq)) /= trim(header)) then
    250             write(*,*) 'Tracer names not compatible for initialization with "start1D.txt"!'
     304            write(*,*) 'Tracer names not compatible for initialization with "'//trim(start1Dname)//'"!'
    251305            stop
    252306        endif
     
    254308endif
    255309
    256 call init_physics_distribution(regular_lonlat,4,1,1,1,nlayer,COMM_LMDZ)
     310#ifdef CPP_XIOS
     311    call init_physics_distribution(regular_lonlat,4,1,1,1,nlayer,COMM_LMDZ)
     312#else
     313    call init_physics_distribution(regular_lonlat,4,1,1,1,nlayer,1)
     314#endif
    257315
    258316! Date and local time at beginning of run
     
    261319    ! Date (in sols since spring solstice) at beginning of run
    262320    day0 = 0 ! default value for day0
    263     write(*,*) 'Initial date (in martian sols ; =0 at Ls=0)?'
     321    write(*,*) 'Initial date (in martian sols; =0 at Ls=0)?'
    264322    call getin("day0",day0)
    265323    day = float(day0)
     
    272330    time = time/24. ! convert time (hours) to fraction of sol
    273331else
    274     call open_startphy("startfi.nc")
     332    call open_startphy(startfiname)
    275333    call get_var("controle",tab_cntrl,found)
    276334    if (.not. found) then
     
    545603zlay(:) = -200.*r*log(play(:)/plev(1))/g
    546604
    547 
    548605! Initialize temperature profile
    549606! ------------------------------
  • trunk/LMDZ.MARS/libf/phymars/dyn1d/testphys1d.F90

    r3060 r3065  
    11PROGRAM testphys1d
    22
    3 use ioipsl_getincom,         only: getin ! To use 'getin'
    43use comsoil_h,               only: inertiedat, inertiesoil, nsoilmx
    54use surfdat_h,               only: albedodat, perenial_co2ice, watercap
     
    10099character(len = 44)     :: txt
    101100
    102 ! RV & JBC: Use of "start1D.txt" and "startfi.nc" files
     101! RV & JBC: Use of starting files for 1D
    103102logical :: startfiles_1D, therestart1D, therestartfi
    104103
     
    121120!call initcomgeomphy
    122121
    123 !------------------------------------------------------
    124 ! Loading run parameters from "run.def" file
    125 !------------------------------------------------------
    126 ! check if 'run.def' file is around. Otherwise reading parameters
    127 ! from callphys.def via getin() routine won't work.
    128 inquire(file = 'run.def',exist = there)
    129 if (.not. there) then
    130     write(*,*) 'Cannot find required file "run.def"'
    131     write(*,*) '  (which should contain some input parameters along with the following line: INCLUDEDEF=callphys.def)'
    132     write(*,*) ' ... might as well stop here ...'
    133     stop
    134 endif
    135 
    136 write(*,*)'Do you want to use "start1D.txt" and "startfi.nc" files?'
    137 startfiles_1D = .false.
    138 therestart1D = .false.
    139 therestartfi = .false.
    140 call getin("startfiles_1D",startfiles_1D)
    141 write(*,*) " startfiles_1D = ", startfiles_1D
    142 
    143 if (startfiles_1D) then
    144     inquire(file = 'start1D.txt',exist = therestart1D)
    145     if (.not. therestart1D) then
    146         write(*,*) 'There is no "start1D.txt" file!'
    147         write(*,*) 'Initialization is done with default values.'
    148     endif
    149     inquire(file = 'startfi.nc',exist = therestartfi)
    150     if (.not. therestartfi) then
    151         write(*,*) 'There is no "startfi.nc" file!'
    152         write(*,*) 'Initialization is done with default values.'
    153     endif
    154 endif
    155 
    156 call init_testphys1d(startfiles_1D,therestart1D,therestartfi,ngrid,nlayer,odpref,nq,ndt,ptif,pks,dttestphys, &
    157                      q,zqsat,qsurf,dq,dqdyn,day0,day,time,psurf,tsurf,gru,grv,u,v,w,q2,play,plev,tsoil,temp, &
     122call init_testphys1d(.false.,ngrid,nlayer,odpref,nq,q,time,psurf,u,v,temp,startfiles_1D,therestart1D,therestartfi, &
     123                     ndt,ptif,pks,dttestphys,zqsat,qsurf,dq,dqdyn,day0,day,tsurf,gru,grv,w,q2,play,plev,tsoil,     &
    158124                     albedo,emis,latitude,longitude,cell_area,atm_wat_profile,atm_wat_tau)
    159125
     
    265231
    266232! Writing the "restart1D.txt" file for the next run
    267 if (startfiles_1D) call writerestart1D(psurf,tsurf,nlayer,temp,u,v,nq,noms,qsurf,q)
     233if (startfiles_1D) call writerestart1D('restart1D.txt',psurf,tsurf,nlayer,temp,u,v,nq,noms,qsurf,q)
    268234
    269235write(*,*) "testphys1d: everything is cool."
  • trunk/LMDZ.MARS/libf/phymars/dyn1d/writerestart1D.F90

    r3051 r3065  
    1 SUBROUTINE writerestart1D(psurf,tsurf,nlayer,temp,u,v,nq,qnames,qsurf,q)
     1SUBROUTINE writerestart1D(filename,psurf,tsurf,nlayer,temp,u,v,nq,qnames,qsurf,q)
    22
    33implicit none
    44
    55! Arguments
    6 integer, intent(in)                           :: nlayer, nq
    7 real, intent(in)                              :: psurf, tsurf
    8 real, dimension(nlayer), intent(in)           :: temp, u, v
    9 real, dimension(nlayer,nq), intent(in)        :: q
    10 real, dimension(nq), intent(in)               :: qsurf
     6character(len = *),                intent(in) :: filename
     7integer,                           intent(in) :: nlayer, nq
     8real,                              intent(in) :: psurf, tsurf
     9real, dimension(nlayer),           intent(in) :: temp, u, v
     10real, dimension(nlayer,nq),        intent(in) :: q
     11real, dimension(nq),               intent(in) :: qsurf
    1112character(len = *), dimension(nq), intent(in) :: qnames
    1213
     
    1516
    1617! Write the data needed for a restart in "restart1D.txt"
    17 open(1,file = 'restart1D.txt',status = "replace",action = "write")
     18open(1,file = filename,status = "replace",action = "write")
    1819do iq = 1,nq
    1920    write(1,*) qnames(iq), qsurf(iq), (q(il,iq), il = 1,nlayer)
Note: See TracChangeset for help on using the changeset viewer.