Changeset 3571 for trunk/LMDZ.COMMON/libf/evolution/pem.F90
- Timestamp:
- Jan 10, 2025, 5:45:03 PM (5 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.COMMON/libf/evolution/pem.F90
r3554 r3571 7 7 ! I_e Initialization of the PEM variable and soil 8 8 ! I_f Compute tendencies 9 ! I_g Save the initial situation9 ! I_g Compute global surface pressure 10 10 ! I_h Read the "startpem.nc" 11 11 ! I_i Compute orbit criterion … … 40 40 use pemredem, only: pemdem0, pemdem1 41 41 use glaciers_mod, only: flow_co2glaciers, flow_h2oglaciers, co2ice_flow, h2oice_flow, inf_h2oice_threshold, & 42 metam_h2oice_threshold, metam_co2ice_threshold, metam_h2oice, metam_co2ice 42 metam_h2oice_threshold, metam_co2ice_threshold, metam_h2oice, metam_co2ice, computeTcondCO2 43 43 use stopping_crit_mod, only: stopping_crit_h2o_ice, stopping_crit_co2 44 44 use constants_marspem_mod, only: alpha_clap_co2, beta_clap_co2, alpha_clap_h2o, beta_clap_h2o, m_co2, m_noco2 45 45 use evol_ice_mod, only: evol_co2_ice, evol_h2o_ice 46 use comsoil_h_PEM, only: soil_pem, ini_comsoil_h_PEM, end_comsoil_h_PEM, nsoilmx_PEM, mlayer_PEM,&47 TI_PEM, & ! soil thermal inertia46 use comsoil_h_PEM, only: soil_pem, ini_comsoil_h_PEM, end_comsoil_h_PEM, nsoilmx_PEM, & 47 TI_PEM, & ! Soil thermal inertia 48 48 tsoil_PEM, layer_PEM, & ! Soil temp, number of subsurface layers, soil mid layer depths 49 49 fluxgeo ! Geothermal flux for the PEM and PCM 50 50 use adsorption_mod, only: regolith_adsorption, adsorption_pem, & ! Bool to check if adsorption, main subroutine 51 51 ini_adsorption_h_PEM, end_adsorption_h_PEM, & ! Allocate arrays 52 co2_adsorbed_phys, h2o_adsorbed_phys ! Mass of co2 and h2O adsorbed52 co2_adsorbed_phys, h2o_adsorbed_phys ! Mass of co2 and h2O adsorbed 53 53 use time_evol_mod, only: dt, evol_orbit_pem, Max_iter_pem, convert_years, year_bp_ini 54 54 use orbit_param_criterion_mod, only: orbit_param_criterion … … 62 62 use compute_tend_mod, only: compute_tend 63 63 use info_PEM_mod, only: info_PEM 64 use nb_time_step_PCM_mod, only: nb_time_step_PCM64 use get_timelen_PCM_mod, only: get_timelen_PCM 65 65 use pemetat0_mod, only: pemetat0 66 66 use read_data_PCM_mod, only: read_data_PCM 67 use recomp_tend_co2_ slope_mod,only: recomp_tend_co267 use recomp_tend_co2_mod, only: recomp_tend_co2 68 68 use compute_soiltemp_mod, only: compute_tsoil_pem, shift_tsoil2surf 69 69 use writediagpem_mod, only: writediagpem, writediagsoilpem … … 77 77 albedodat, zmea, zstd, zsig, zgam, zthe, & 78 78 albedo_h2o_frost,frost_albedo_threshold, & 79 emissiv, watercaptag, perennial_co2ice , emisice, albedice79 emissiv, watercaptag, perennial_co2ice 80 80 use dimradmars_mod, only: totcloudfrac, albedo 81 81 use dust_param_mod, only: tauscaling … … 128 128 real :: time_phys ! Same as in PCM 129 129 real :: ptimestep ! Same as in PCM 130 real :: ztime_fin 131 132 ! Variables to read start.nc130 real :: ztime_fin ! Same as in PCM 131 132 ! Variables to read "start.nc" 133 133 character(*), parameter :: start_name = "start.nc" ! Name of the file used to initialize the PEM 134 134 … … 136 136 real, dimension(ip1jm,llm) :: vcov ! vents covariants 137 137 real, dimension(ip1jmp1,llm) :: ucov ! vents covariants 138 real, dimension(ip1jmp1,llm) :: teta ! temperature potentielle138 real, dimension(ip1jmp1,llm) :: teta ! Potential temperature 139 139 real, dimension(:,:,:), allocatable :: q ! champs advectes 140 real, dimension(ip1jmp1) :: ps ! pression au sol 141 real, dimension(ip1jmp1) :: ps0 ! pression au sol initiale 142 real, dimension(:), allocatable :: ps_start_PCM ! (ngrid) surface pressure 143 real, dimension(:,:), allocatable :: ps_timeseries ! (ngrid x timelen) instantaneous surface pressure 144 real, dimension(ip1jmp1,llm) :: masse ! masse d'air 140 real, dimension(ip1jmp1) :: ps_start_dyn ! surface pressure in the start file (dynamic grid) 141 real, dimension(:), allocatable :: ps_start ! surface pressure in the start file 142 real, dimension(:), allocatable :: ps_start0 ! surface pressure in the start file at the beginning 143 real, dimension(:), allocatable :: ps_avg ! (ngrid) Averaged surface pressure 144 real, dimension(:), allocatable :: ps_dev ! (ngrid x timelen) Surface pressure deviation 145 real, dimension(:,:), allocatable :: ps_timeseries ! (ngrid x timelen) Instantaneous surface pressure 146 real, dimension(ip1jmp1,llm) :: masse ! Air mass 145 147 real, dimension(ip1jmp1) :: phis ! geopotentiel au sol 146 148 real :: time_0 … … 157 159 real, dimension(:), allocatable :: latitude ! Latitude read in startfi_name and written in restartfi 158 160 real, dimension(:), allocatable :: cell_area ! Cell_area read in startfi_name and written in restartfi 159 real :: Total_surface ! Total surface of the planet161 real :: total_surface ! Total surface of the planet 160 162 161 163 ! Variables for h2o_ice evolution 162 164 real, dimension(:,:), allocatable :: h2o_ice ! h2o ice in the PEM 165 real, dimension(:,:), allocatable :: d_h2oice ! physical point x slope field: Tendency of evolution of perennial h2o ice 163 166 real, dimension(:,:,:), allocatable :: min_h2o_ice ! Minima of h2o ice at each point for the PCM years [kg/m^2] 164 167 real :: h2oice_ini_surf ! Initial surface of sublimating h2o ice 165 logical, dimension(:,:), allocatable :: i ni_h2oice_sublim! Logical array to know if h2o ice is sublimating166 real :: global_avg_press_PCM ! constant: global average pressure retrieved in the PCM[Pa]167 real :: global_avg_press_old ! constant: Global average pressure of initial/previous time step168 real :: global_avg_press_new! constant: Global average pressure of current time step169 real, dimension(:,:), allocatable :: zplev_new ! Physical x Atmospheric field: mass of the atmosphericlayers in the pem at current time step [kg/m^2]170 real, dimension(:,:), allocatable :: zplev_ PCM ! same but retrieved from the PCM[kg/m^2]171 real, dimension(:,:,:), allocatable :: zplev_ new_timeseries ! Physicalx Atmospheric x Time: same as zplev_new, but in times series [kg/m ^2]172 real, dimension(:,:,:), allocatable :: zplev_ old_timeseries ! same but with the time series, for oldesttime step168 logical, dimension(:,:), allocatable :: is_h2oice_sublim_ini ! Logical array to know if h2o ice is sublimating 169 real :: ps_avg_global_ini ! constant: Global average pressure at initialization [Pa] 170 real :: ps_avg_global_old ! constant: Global average pressure of previous time step 171 real :: ps_avg_global_new ! constant: Global average pressure of current time step 172 real, dimension(:,:), allocatable :: zplev_new ! Grid points x Atmospheric field: mass of the atmospheric layers in the pem at current time step [kg/m^2] 173 real, dimension(:,:), allocatable :: zplev_start0 ! Grid points x Atmospheric field: mass of the atmospheric layers in the start [kg/m^2] 174 real, dimension(:,:,:), allocatable :: zplev_timeseries_new ! Grid points x Atmospheric x Time: same as zplev_new, but in times series [kg/m ^2] 175 real, dimension(:,:,:), allocatable :: zplev_timeseries_old ! same but with the time series, for previous time step 173 176 integer :: stopPEM ! which criterion is reached? 0 = no stopping; 1 = h2o ice surf; 2 = no h2o ice; 3 = co2 ice surf; 4 = ps; 5 = orb param; 6 = end of simu 174 real , save:: A, B, mmean ! Molar mass: intermediate A, B for computations of the mean molar mass of the layer [mol/kg]175 real, dimension(:,:), allocatable :: q_h2o_PEM_phys ! Physics x Times: h2o mass mixing ratio computed in the PEM, first value comes from PCM [kg/kg]177 real :: A, B, mmean ! Molar mass: intermediate A, B for computations of the mean molar mass of the layer [mol/kg] 178 real, dimension(:,:), allocatable :: q_h2o_PEM_phys ! Grid points x Times: h2o mass mixing ratio computed in the PEM, first value comes from PCM [kg/kg] 176 179 integer :: timelen ! # time samples 177 real :: ave ! intermediate varibale to compute average 178 real, dimension(:,:), allocatable :: p ! Physics x Atmosphere: pressure to recompute and write in restart (ngrid,llmp1) 180 real, dimension(:,:), allocatable :: p ! Grid points x Atmosphere: pressure to recompute and write in restart (ngrid,llmp1) 179 181 real :: extra_mass ! Intermediate variables Extra mass of a tracer if it is greater than 1 180 182 181 183 ! Variables for co2_ice evolution 182 real, dimension(:,:), allocatable :: co2_ice ! co2 ice in the PEM 183 logical, dimension(:,:), allocatable :: is_co2ice_ini ! Was there co2 ice initially in the PEM? 184 real, dimension(:,:,:), allocatable :: min_co2_ice ! Minimum of co2 ice at each point for the first year [kg/m^2] 185 real :: co2ice_ini_surf ! Initial surface of sublimating co2 ice 186 logical, dimension(:,:), allocatable :: ini_co2ice_sublim ! Logical array to know if co2 ice is sublimating 187 real, dimension(:,:), allocatable :: vmr_co2_PCM ! Physics x Times co2 volume mixing ratio retrieve from the PCM [m^3/m^3] 188 real, dimension(:,:), allocatable :: vmr_co2_PEM_phys ! Physics x Times co2 volume mixing ratio used in the PEM 189 real, 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 PCM [kg/kg] 184 real, dimension(:,:), allocatable :: co2_ice ! co2 ice in the PEM 185 real, dimension(:,:), allocatable :: d_co2ice ! physical point x slope field: Tendency of evolution of perennial co2 ice over a year 186 real, dimension(:,:), allocatable :: d_co2ice_ini ! physical point x slope field: Tendency of evolution of perennial co2 ice over a year in the PCM 187 logical, dimension(:,:), allocatable :: is_co2ice_ini ! Was there co2 ice initially in the PEM? 188 real, dimension(:,:,:), allocatable :: min_co2_ice ! Minimum of co2 ice at each point for the first year [kg/m^2] 189 real :: co2ice_sublim_surf_ini ! Initial surface of sublimating co2 ice 190 logical, dimension(:,:), allocatable :: is_co2ice_sublim_ini ! Logical array to know if co2 ice is sublimating 191 real, dimension(:,:), allocatable :: vmr_co2_PCM ! Grid points x Times co2 volume mixing ratio retrieve from the PCM [m^3/m^3] 192 real, dimension(:,:), allocatable :: vmr_co2_PEM_phys ! Grid points x Times co2 volume mixing ratio used in the PEM 193 real, dimension(:,:), allocatable :: q_co2_PEM_phys ! Grid points x Times co2 mass mixing ratio in the first layer computed in the PEM, first value comes from PCM [kg/kg] 190 194 191 195 ! Variables for stratification (layering) evolution … … 195 199 196 200 ! Variables for slopes 197 real, dimension(:,:), allocatable :: d_co2ice ! physical point x slope field: Tendency of evolution of perennial co2 ice over a year198 real, dimension(:,:), allocatable :: d_co2ice_ini ! physical point x slope field: Tendency of evolution of perennial co2 ice over a year in the PCM199 real, dimension(:,:), allocatable :: d_h2oice ! physical point x slope field: Tendency of evolution of perennial h2o ice200 201 real, dimension(:,:), allocatable :: flag_co2flow ! (ngrid,nslope): Flag where there is a CO2 glacier flow 201 202 real, dimension(:), allocatable :: flag_co2flow_mesh ! (ngrid) : Flag where there is a CO2 glacier flow … … 204 205 205 206 ! Variables for surface and soil 206 real, dimension(:,:), allocatable :: tsurf_avg ! Physic x SLOPE field: Averaged Surface Temperature [K]207 real, dimension(:,: ,:), allocatable :: tsoil_avg ! Physic x SOIL x SLOPE field: Averaged Soil Temperature[K]208 real, dimension(:,: ,:), allocatable :: tsurf_PCM_timeseries ! ngrid x SLOPE x TIMES field: Surface Temperature in timeseries[K]209 real, dimension(:,:,: ,:), allocatable :: tsoil_phys_PEM_timeseries ! IG x SOIL x SLOPE x TIMES field: Non averaged Soil Temperature [K]210 real, dimension(:,: ,:,:), allocatable :: tsoil_anom ! IG x SOIL x SLOPE x TIMES field: Amplitude between instataneous and yearly average soil temperature at the beginning[K]211 real, dimension(:,: ), allocatable :: tsurf_avg_yr1 ! Physic x SLOPE field: Averaged Surface Temperature of first call of the PCM[K]212 real, dimension(:,: ), allocatable :: Tsoil_locslope ! Physic x Soil: Intermediate when computing Tsoil[K]213 real, dimension(: ), allocatable :: Tsurf_locslope ! Physic x Soil: Intermediate surface temperature to compute Tsoil[K]214 real, dimension(:,:,:,:), allocatable :: watersoil_density_timeseries ! Physic x Soil x Slope x Times water soil density, timeseries [kg /m^3]215 real, dimension(:,:), allocatable :: watersurf_density_avg ! Physic x Slope, water surface density, yearly averaged[kg/m^3]216 real, dimension(:,:,:,:), allocatable :: watersoil_density_PEM_timeseries ! Physic x Soil x Slope x Times, water soil density, time series[kg/m^3]217 real, dimension(:,:,:), allocatable :: watersoil_density_PEM_avg ! Physic x Soil x Slopes, water soil density, yearly averaged[kg/m^3]218 real, dimension(:,:), allocatable :: Tsurfavg_before_saved! Surface temperature saved from previous time step [K]207 real, dimension(:,:), allocatable :: tsurf_avg ! Grid points x Slope field: Averaged surface temperature [K] 208 real, dimension(:,:), allocatable :: tsurf_dev ! ngrid x Slope x Times field: Surface temperature deviation [K] 209 real, dimension(:,:), allocatable :: tsurf_avg_yr1 ! Grid points x Slope field: Averaged surface temperature of first call of the PCM [K] 210 real, dimension(:,:,:), allocatable :: tsoil_avg ! Grid points x Soil x Slope field: Averaged Soil Temperature [K] 211 real, dimension(:,:), allocatable :: tsoil_avg_old ! Grid points x Soil field: Averaged Soil Temperature at the previous time step [K] 212 real, dimension(:,:,:), allocatable :: tsoil_dev ! Grid points x Soil x Slope field: Soil temperature deviation [K] 213 real, dimension(:,:,:,:), allocatable :: tsoil_timeseries ! Grid points x Soil x Slope x Times field: Soil temperature timeseries [K] 214 real, dimension(:,:,:,:), allocatable :: tsoil_PEM_timeseries ! Grid points x Soil x Slope x Times field: Soil temperature timeseries for PEM [K] 215 real, dimension(:,:,:,:), allocatable :: watersoil_density_timeseries ! Grid points x Soil x Slope x Times Water soil density timeseries [kg /m^3] 216 real, dimension(:,:), allocatable :: watersurf_density_avg ! Grid points x Slope: Averaged water surface density [kg/m^3] 217 real, dimension(:,:,:,:), allocatable :: watersoil_density_PEM_timeseries ! Grid points x Soil x Slope x Times: Water soil density timeseries for PEM [kg/m^3] 218 real, dimension(:,:,:), allocatable :: watersoil_density_PEM_avg ! Grid points x Soil x Slopes: Averaged water soil density [kg/m^3] 219 real, dimension(:,:), allocatable :: tsurf_avg_old ! Surface temperature saved from previous time step [K] 219 220 real, dimension(:), allocatable :: delta_co2_adsorbed ! Physics: quantity of CO2 that is exchanged because of adsorption / desorption [kg/m^2] 220 221 real, dimension(:), allocatable :: delta_h2o_adsorbed ! Physics: quantity of H2O that is exchanged because of adsorption / desorption [kg/m^2] 221 222 real :: totmassco2_adsorbed ! Total mass of CO2 that is exchanged because of adsorption / desoprtion over the planets [kg] 222 223 real :: totmassh2o_adsorbed ! Total mass of H2O that is exchanged because of adsorption / desoprtion over the planets [kg] 223 logical :: bool_sublim ! logical to check if there is sublimation or not224 224 logical, dimension(:,:), allocatable :: co2ice_disappeared ! logical to check if a co2 ice reservoir already disappeared at a previous timestep 225 225 real, dimension(:,:), allocatable :: icetable_thickness_old ! ngrid x nslope: Thickness of the ice table at the previous iteration [m] … … 233 233 ! Some variables for the PEM run 234 234 real, parameter :: year_step = 1 ! Timestep for the pem 235 real :: i_myear_leg 235 real :: i_myear_leg ! Number of iteration 236 236 real :: n_myear_leg ! Maximum number of iterations before stopping 237 237 real :: i_myear ! Global number of Martian years of the chained simulations … … 249 249 250 250 #ifdef CPP_STD 251 real :: frost_albedo_threshold = 0.05 ! frost albedo threeshold to convert fresh frost to old ice252 real :: albedo_h2o_frost ! albedo of h2o frost251 real :: frost_albedo_threshold = 0.05 ! Frost albedo threeshold to convert fresh frost to old ice 252 real :: albedo_h2o_frost ! Albedo of h2o frost 253 253 real, dimension(:), allocatable :: tsurf_read_generic ! Temporary variable to do the subslope transfert dimension when reading form generic 254 254 real, dimension(:,:), allocatable :: qsurf_read_generic ! Temporary variable to do the subslope transfert dimension when reading form generic … … 286 286 287 287 ! Loop variables 288 integer :: i, l, ig, nnq, t, islope, ig_loop, islope_loop, isoil , icap288 integer :: i, l, ig, nnq, t, islope, ig_loop, islope_loop, isoil 289 289 290 290 ! Elapsed time with system clock … … 379 379 endif 380 380 381 call init_testphys1d('start1D.txt','startfi.nc',therestart1D,therestartfi,ngrid,nlayer,610.,nq,q, &382 time_0,ps (1),ucov,vcov,teta,ndt,ptif,pks,dtphys,zqsat,dq,dqdyn,day0,day,gru,grv,w, &381 call init_testphys1d('start1D.txt','startfi.nc',therestart1D,therestartfi,ngrid,nlayer,610.,nq,q, & 382 time_0,ps_start_dyn(1),ucov,vcov,teta,ndt,ptif,pks,dtphys,zqsat,dq,dqdyn,day0,day,gru,grv,w, & 383 383 play,plev,latitude,longitude,cell_area,atm_wat_profile,atm_wat_tau) 384 ps (2) = ps(1)384 ps_start_dyn(2) = ps_start_dyn(1) 385 385 nsplit_phys = 1 386 386 day_step = steps_per_sol … … 391 391 !------------------------ 392 392 ! I Initialization 393 ! I_b Read of the "start.nc" and starfi_evol.nc393 ! I_b Read of the "start.nc" and "starfi.nc" 394 394 !------------------------ 395 395 ! I_b.1 Read "start.nc" 396 allocate(ps_start _PCM(ngrid))396 allocate(ps_start(ngrid),ps_start0(ngrid)) 397 397 #ifndef CPP_1D 398 call dynetat0(start_name,vcov,ucov,teta,q,masse,ps ,phis,time_0)399 400 call gr_dyn_fi(1,iip1,jjp1,ngridmx,ps ,ps_start_PCM)398 call dynetat0(start_name,vcov,ucov,teta,q,masse,ps_start_dyn,phis,time_0) 399 400 call gr_dyn_fi(1,iip1,jjp1,ngridmx,ps_start_dyn,ps_start) 401 401 402 402 call iniconst !new … … 412 412 status = nf90_close(ncid) 413 413 414 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)414 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) 415 415 #else 416 ps_start _PCM(1) = ps(1)416 ps_start(1) = ps_start_dyn(1) 417 417 #endif 418 418 419 419 ! Save initial surface pressure 420 ps 0 = ps420 ps_start0 = ps_start 421 421 422 422 ! In the PCM, these values are given to the physic by the dynamic. 423 423 ! Here we simply read them in the "startfi.nc" file 424 status = nf90_open(startfi_name, NF90_NOWRITE,ncid)424 status = nf90_open(startfi_name,NF90_NOWRITE,ncid) 425 425 426 426 status = nf90_inq_varid(ncid,"longitude",lonvarid) … … 537 537 !------------------------ 538 538 ! First we read the evolution of water and co2 ice (and the mass mixing ratio) over the first year of the PCM run, saving only the minimum value 539 call nb_time_step_PCM("data_PCM_Y1.nc",timelen) 540 541 allocate(tsoil_avg(ngrid,nsoilmx,nslope)) 539 call get_timelen_PCM("data_PCM_Y1.nc",timelen) 540 542 541 allocate(watersoil_density_PEM_avg(ngrid,nsoilmx_PEM,nslope)) 543 542 allocate(vmr_co2_PCM(ngrid,timelen)) 544 allocate(ps_timeseries(ngrid,timelen) )543 allocate(ps_timeseries(ngrid,timelen),ps_avg(ngrid),ps_dev(ngrid)) 545 544 allocate(min_co2_ice(ngrid,nslope,2),min_h2o_ice(ngrid,nslope,2)) 546 allocate(tsurf_avg_yr1(ngrid,nslope)) 547 allocate(tsurf_avg(ngrid,nslope)) 548 allocate(tsurf_PCM_timeseries(ngrid,nslope,timelen)) 549 allocate(tsoil_anom(ngrid,nsoilmx,nslope,timelen)) 545 allocate(tsurf_avg_yr1(ngrid,nslope),tsurf_avg(ngrid,nslope),tsurf_avg_old(ngrid,nslope),tsurf_dev(ngrid,nslope)) 546 allocate(tsoil_avg(ngrid,nsoilmx,nslope),tsoil_dev(ngrid,nsoilmx,nslope)) 547 allocate(tsoil_timeseries(ngrid,nsoilmx,nslope,timelen),tsoil_PEM_timeseries(ngrid,nsoilmx_PEM,nslope,timelen)) 550 548 allocate(zshift_surf(ngrid,nslope),zlag(ngrid,nslope)) 551 549 allocate(q_co2_PEM_phys(ngrid,timelen),q_h2o_PEM_phys(ngrid,timelen)) 552 550 allocate(watersurf_density_avg(ngrid,nslope)) 553 allocate(watersoil_density_timeseries(ngrid,nsoilmx,nslope,timelen)) 554 allocate(Tsurfavg_before_saved(ngrid,nslope)) 555 allocate(tsoil_phys_PEM_timeseries(ngrid,nsoilmx_PEM,nslope,timelen)) 556 allocate(watersoil_density_PEM_timeseries(ngrid,nsoilmx_PEM,nslope,timelen)) 551 allocate(watersoil_density_timeseries(ngrid,nsoilmx,nslope,timelen),watersoil_density_PEM_timeseries(ngrid,nsoilmx_PEM,nslope,timelen)) 557 552 allocate(delta_co2_adsorbed(ngrid)) 558 553 allocate(co2ice_disappeared(ngrid,nslope)) … … 561 556 allocate(vmr_co2_PEM_phys(ngrid,timelen)) 562 557 563 write(*,*) "Downloading data Y1..." 564 call read_data_PCM("data_PCM_Y1.nc",timelen,iim,jjm_value,ngrid,nslope,vmr_co2_PCM,ps_timeseries,min_co2_ice(:,:,1),min_h2o_ice(:,:,1), & 565 tsurf_avg_yr1,tsoil_avg,tsurf_PCM_timeseries,tsoil_anom,q_co2_PEM_phys,q_h2o_PEM_phys, & 566 watersurf_density_avg,watersoil_density_timeseries) 567 write(*,*) "Downloading data Y1 done!" 568 569 ! Then we read the evolution of water and co2 ice (and the mass mixing ratio) over the second year of the PCM run, saving only the minimum value 570 write(*,*) "Downloading data Y2..." 571 call read_data_PCM("data_PCM_Y2.nc",timelen,iim,jjm_value,ngrid,nslope,vmr_co2_PCM,ps_timeseries,min_co2_ice(:,:,2),min_h2o_ice(:,:,2), & 572 tsurf_avg,tsoil_avg,tsurf_PCM_timeseries,tsoil_anom,q_co2_PEM_phys,q_h2o_PEM_phys, & 573 watersurf_density_avg,watersoil_density_timeseries) 574 write(*,*) "Downloading data Y2 done!" 558 call read_data_PCM("data_PCM_Y1.nc","data_PCM_Y2.nc",timelen,iim,jjm_value,ngrid,nslope,vmr_co2_PCM,ps_timeseries,ps_avg,tsurf_avg_yr1,tsurf_avg, & 559 tsoil_avg,tsoil_timeseries,min_co2_ice,min_h2o_ice,q_co2_PEM_phys,q_h2o_PEM_phys,watersurf_density_avg,watersoil_density_timeseries) 560 561 ! Compute the deviation from the average 562 ps_dev = ps_start - ps_avg 563 tsurf_dev = tsurf - tsurf_avg 564 tsoil_dev = tsoil - tsoil_avg(:,1:nsoilmx,:) 575 565 576 566 !------------------------ … … 586 576 587 577 if (soil_pem) then 588 do t = 1,timelen589 tsoil_anom(:,:,:,t) = tsoil_anom(:,:,:,t) - tsoil_avg ! compute anomaly between Tsoil(t) in the startfi - <Tsoil> to recompute properly tsoil in the restart590 enddo591 578 call soil_settings_PEM(ngrid,nslope,nsoilmx_PEM,nsoilmx,inertiesoil,TI_PEM) 592 579 tsoil_PEM(:,1:nsoilmx,:) = tsoil_avg 593 tsoil_phys_PEM_timeseries(:,1:nsoilmx,:,:) = tsoil_anom594 580 watersoil_density_PEM_timeseries(:,1:nsoilmx,:,:) = watersoil_density_timeseries 581 tsoil_PEM_timeseries(:,1:nsoilmx,:,:) = tsoil_timeseries 595 582 do l = nsoilmx + 1,nsoilmx_PEM 596 583 tsoil_PEM(:,l,:) = tsoil_avg(:,nsoilmx,:) 597 584 watersoil_density_PEM_timeseries(:,l,:,:) = watersoil_density_timeseries(:,nsoilmx,:,:) 585 tsoil_PEM_timeseries(:,l,:,:) = tsoil_timeseries(:,nsoilmx,:,:) 598 586 enddo 599 587 watersoil_density_PEM_avg = sum(watersoil_density_PEM_timeseries,4)/timelen 600 588 endif !soil_pem 601 deallocate(tsoil_avg )589 deallocate(tsoil_avg,watersoil_density_timeseries,tsoil_timeseries) 602 590 603 591 !------------------------ … … 616 604 !------------------------ 617 605 ! I Initialization 618 ! I_g Save the initial situation 619 !------------------------ 620 allocate(zplev_PCM(ngrid,nlayer + 1)) 621 Total_surface = 0. 622 do ig = 1,ngrid 623 Total_surface = Total_surface + cell_area(ig) 624 zplev_PCM(ig,:) = ap + bp*ps_start_PCM(ig) 625 enddo 626 global_avg_press_old = sum(cell_area*ps_start_PCM)/Total_surface 627 global_avg_press_PCM = global_avg_press_old 628 global_avg_press_new = global_avg_press_old 629 write(*,*) "Total surface of the planet =", Total_surface 630 write(*,*) "Initial global average pressure =", global_avg_press_PCM 606 ! I_g Compute global surface pressure 607 !------------------------ 608 total_surface = sum(cell_area) 609 ps_avg_global_ini = sum(cell_area*ps_avg)/total_surface 610 ps_avg_global_new = ps_avg_global_ini 611 write(*,*) "Total surface of the planet =", total_surface 612 write(*,*) "Initial global averaged pressure =", ps_avg_global_ini 631 613 632 614 !------------------------ … … 635 617 !------------------------ 636 618 allocate(co2_ice(ngrid,nslope),h2o_ice(ngrid,nslope)) 637 638 619 allocate(stratif(ngrid,nslope)) 639 620 if (layering_algo) then … … 647 628 call pemetat0("startpem.nc",ngrid,nsoilmx,nsoilmx_PEM,nslope,timelen,timestep,TI_PEM,tsoil_PEM,icetable_depth, & 648 629 icetable_thickness,ice_porefilling,tsurf_avg_yr1,tsurf_avg,q_co2_PEM_phys,q_h2o_PEM_phys, & 649 ps_timeseries, tsoil_phys_PEM_timeseries,d_h2oice,d_co2ice,co2_ice,h2o_ice,&650 global_avg_press_PCM,watersurf_density_avg,watersoil_density_PEM_avg,co2_adsorbed_phys, &651 delta_co2_adsorbed,h2o_adsorbed_phys,delta_h2o_adsorbed,stratif)630 ps_timeseries,ps_avg_global_ini,d_h2oice,d_co2ice,co2_ice,h2o_ice,watersurf_density_avg, & 631 watersoil_density_PEM_avg,co2_adsorbed_phys,delta_co2_adsorbed,h2o_adsorbed_phys,delta_h2o_adsorbed,stratif) 632 deallocate(tsurf_avg_yr1) 652 633 653 634 ! We save the places where h2o ice is sublimating 654 635 ! We compute the surface of h2o ice sublimating 655 allocate(i ni_co2ice_sublim(ngrid,nslope),ini_h2oice_sublim(ngrid,nslope),is_co2ice_ini(ngrid,nslope))656 co2ice_ ini_surf= 0.636 allocate(is_co2ice_sublim_ini(ngrid,nslope),is_h2oice_sublim_ini(ngrid,nslope),is_co2ice_ini(ngrid,nslope)) 637 co2ice_sublim_surf_ini = 0. 657 638 h2oice_ini_surf = 0. 658 i ni_co2ice_sublim= .false.659 i ni_h2oice_sublim= .false.639 is_co2ice_sublim_ini = .false. 640 is_h2oice_sublim_ini = .false. 660 641 is_co2ice_ini = .false. 661 642 co2ice_disappeared = .false. … … 664 645 if (co2_ice(i,islope) > 0.) is_co2ice_ini(i,islope) = .true. 665 646 if (d_co2ice(i,islope) < 0. .and. co2_ice(i,islope) > 0.) then 666 i ni_co2ice_sublim(i,islope) = .true.667 co2ice_ ini_surf = co2ice_ini_surf+ cell_area(i)*subslope_dist(i,islope)647 is_co2ice_sublim_ini(i,islope) = .true. 648 co2ice_sublim_surf_ini = co2ice_sublim_surf_ini + cell_area(i)*subslope_dist(i,islope) 668 649 endif 669 650 if (d_h2oice(i,islope) < 0. .and. h2o_ice(i,islope) > 0.) then 670 i ni_h2oice_sublim(i,islope) = .true.651 is_h2oice_sublim_ini(i,islope) = .true. 671 652 h2oice_ini_surf = h2oice_ini_surf + cell_area(i)*subslope_dist(i,islope) 672 653 endif 673 654 enddo 674 655 enddo 675 write(*,*) "Total initial surface of co2 ice sublimating (slope) =", co2ice_ ini_surf656 write(*,*) "Total initial surface of co2 ice sublimating (slope) =", co2ice_sublim_surf_ini 676 657 write(*,*) "Total initial surface of h2o ice sublimating (slope) =", h2oice_ini_surf 677 658 … … 684 665 do islope = 1,nslope 685 666 do l = 1,nsoilmx_PEM - 1 686 if (l ==1) then667 if (l == 1) then 687 668 totmassco2_adsorbed = totmassco2_adsorbed + co2_adsorbed_phys(ig,l,islope)*(layer_PEM(l))* & 688 669 subslope_dist(ig,islope)/cos(pi*def_slope_mean(islope)/180.)*cell_area(ig) … … 701 682 write(*,*) "Tot mass of H2O in the regolith =", totmassh2o_adsorbed 702 683 endif ! adsorption 703 deallocate(tsurf_avg_yr1)704 684 705 685 !------------------------ … … 741 721 ! II.a.1. Compute updated global pressure 742 722 write(*,*) "Recomputing the new pressure..." 723 ps_avg_global_old = ps_avg_global_new 743 724 do i = 1,ngrid 744 725 do islope = 1,nslope 745 global_avg_press_new = global_avg_press_new - CO2cond_ps*g*cell_area(i)*d_co2ice(i,islope)*subslope_dist(i,islope)/cos(pi*def_slope_mean(islope)/180.)/Total_surface726 ps_avg_global_new = ps_avg_global_old - CO2cond_ps*g*cell_area(i)*d_co2ice(i,islope)*subslope_dist(i,islope)/cos(pi*def_slope_mean(islope)/180.)/total_surface 746 727 enddo 747 728 enddo … … 749 730 if (adsorption_pem) then 750 731 do i = 1,ngrid 751 global_avg_press_new = global_avg_press_new - g*cell_area(i)*delta_co2_adsorbed(i)/Total_surface752 enddo 753 endif 754 write(*,*) 'Global average pressure old time step', global_avg_press_old755 write(*,*) 'Global average pressure new time step', global_avg_press_new756 757 ! II.a.2. Old pressure levels for the timeseries, this value is deleted when unused and recreated each time (big memory consumption)758 allocate(zplev_ old_timeseries(ngrid,nlayer + 1,timelen))759 write(*,*) "Recomputing the old pressure levels timeserieadapted to the old pressure..."732 ps_avg_global_new = ps_avg_global_old - g*cell_area(i)*delta_co2_adsorbed(i)/total_surface 733 enddo 734 endif 735 write(*,*) 'Global average pressure old time step',ps_avg_global_old 736 write(*,*) 'Global average pressure new time step',ps_avg_global_new 737 738 ! II.a.2. Pressure timeseries (the values are deleted when unused because of big memory consumption) 739 allocate(zplev_timeseries_old(ngrid,nlayer + 1,timelen)) 740 write(*,*) "Recomputing the pressure levels timeseries adapted to the old pressure..." 760 741 do l = 1,nlayer + 1 761 742 do ig = 1,ngrid 762 zplev_old_timeseries(ig,l,:) = ap(l) + bp(l)*ps_timeseries(ig,:) 763 enddo 764 enddo 765 766 ! II.a.3. Surface pressure timeseries 767 write(*,*) "Recomputing the surface pressure timeserie adapted to the new pressure..." 743 zplev_timeseries_old(ig,l,:) = ap(l) + bp(l)*ps_timeseries(ig,:) 744 enddo 745 enddo 746 write(*,*) "Recomputing the surface pressure timeseries adapted to the new pressure..." 768 747 do ig = 1,ngrid 769 ps_timeseries(ig,:) = ps_timeseries(ig,:)*global_avg_press_new/global_avg_press_old 770 enddo 771 772 ! II.a.4. New pressure levels timeseries 773 allocate(zplev_new_timeseries(ngrid,nlayer + 1,timelen)) 774 write(*,*) "Recomputing the new pressure levels timeserie adapted to the new pressure..." 748 ps_timeseries(ig,:) = ps_timeseries(ig,:)*ps_avg_global_new/ps_avg_global_old 749 enddo 750 write(*,*) "Recomputing the pressure levels timeseries adapted to the new pressure..." 751 allocate(zplev_timeseries_new(ngrid,nlayer + 1,timelen)) 775 752 do l = 1,nlayer + 1 776 753 do ig = 1,ngrid 777 zplev_ new_timeseries(ig,l,:) = ap(l) + bp(l)*ps_timeseries(ig,:)778 enddo 779 enddo 780 781 ! II.a. 5. Tracers timeseries754 zplev_timeseries_new(ig,l,:) = ap(l) + bp(l)*ps_timeseries(ig,:) 755 enddo 756 enddo 757 758 ! II.a.3. Tracers timeseries 782 759 write(*,*) "Recomputing of tracer VMR timeseries for the new pressure..." 783 784 760 l = 1 785 761 do ig = 1,ngrid 786 762 do t = 1,timelen 787 q_h2o_PEM_phys(ig,t) = q_h2o_PEM_phys(ig,t)*(zplev_old_timeseries(ig,l,t) - zplev_old_timeseries(ig,l + 1,t))/ & 788 (zplev_new_timeseries(ig,l,t) - zplev_new_timeseries(ig,l + 1,t)) 763 ! H2O 764 q_h2o_PEM_phys(ig,t) = q_h2o_PEM_phys(ig,t)*(zplev_timeseries_old(ig,l,t) - zplev_timeseries_old(ig,l + 1,t))/ & 765 (zplev_timeseries_new(ig,l,t) - zplev_timeseries_new(ig,l + 1,t)) 789 766 if (q_h2o_PEM_phys(ig,t) < 0) then 790 767 q_h2o_PEM_phys(ig,t) = 1.e-30 … … 792 769 q_h2o_PEM_phys(ig,t) = 1. 793 770 endif 794 enddo 795 enddo 796 797 do ig = 1,ngrid 798 do t = 1,timelen 799 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))/ & 800 (zplev_new_timeseries(ig,l,t) - zplev_new_timeseries(ig,l + 1,t)) & 801 + ((zplev_new_timeseries(ig,l,t) - zplev_new_timeseries(ig,l + 1,t)) & 802 - (zplev_old_timeseries(ig,l,t) - zplev_old_timeseries(ig,l + 1,t)))/ & 803 (zplev_new_timeseries(ig,l,t) - zplev_new_timeseries(ig,l + 1,t)) 771 ! CO2 772 q_co2_PEM_phys(ig,t) = q_co2_PEM_phys(ig,t)*(zplev_timeseries_old(ig,l,t) - zplev_timeseries_old(ig,l + 1,t))/ & 773 (zplev_timeseries_new(ig,l,t) - zplev_timeseries_new(ig,l + 1,t)) & 774 + ((zplev_timeseries_new(ig,l,t) - zplev_timeseries_new(ig,l + 1,t)) & 775 - (zplev_timeseries_old(ig,l,t) - zplev_timeseries_old(ig,l + 1,t)))/ & 776 (zplev_timeseries_new(ig,l,t) - zplev_timeseries_new(ig,l + 1,t)) 804 777 if (q_co2_PEM_phys(ig,t) < 0) then 805 778 q_co2_PEM_phys(ig,t) = 1.e-30 … … 807 780 q_co2_PEM_phys(ig,t) = 1. 808 781 endif 809 mmean =1/(A*q_co2_PEM_phys(ig,t) + B)782 mmean = 1./(A*q_co2_PEM_phys(ig,t) + B) 810 783 vmr_co2_PEM_phys(ig,t) = q_co2_PEM_phys(ig,t)*mmean/m_co2 811 784 enddo 812 785 enddo 813 814 deallocate(zplev_new_timeseries,zplev_old_timeseries) 786 deallocate(zplev_timeseries_new,zplev_timeseries_old) 815 787 816 788 !------------------------ … … 834 806 ! II_c Flow of glaciers 835 807 !------------------------ 836 if (co2ice_flow .and. nslope > 1) call flow_co2glaciers(timelen,ngrid,nslope,iflat,subslope_dist,def_slope_mean,vmr_co2_PEM_phys, ps_timeseries,&837 global_avg_press_PCM,global_avg_press_new,co2_ice,flag_co2flow,flag_co2flow_mesh)838 if (h2oice_flow .and. nslope > 1) call flow_h2oglaciers( timelen,ngrid,nslope,iflat,subslope_dist,def_slope_mean,tsurf_avg,h2o_ice,flag_h2oflow,flag_h2oflow_mesh)808 if (co2ice_flow .and. nslope > 1) call flow_co2glaciers(timelen,ngrid,nslope,iflat,subslope_dist,def_slope_mean,vmr_co2_PEM_phys, & 809 ps_timeseries,ps_avg_global_old,ps_avg_global_new,co2_ice,flag_co2flow,flag_co2flow_mesh) 810 if (h2oice_flow .and. nslope > 1) call flow_h2oglaciers(ngrid,nslope,iflat,subslope_dist,def_slope_mean,tsurf_avg,h2o_ice,flag_h2oflow,flag_h2oflow_mesh) 839 811 840 812 !------------------------ … … 844 816 ! II_d.1 Update Tsurf 845 817 write(*,*) "Updating the new Tsurf" 846 bool_sublim = .false.847 Tsurfavg_before_saved = tsurf_avg848 818 do ig = 1,ngrid 849 819 do islope = 1,nslope 850 if (is_co2ice_ini(ig,islope) .and. co2_ice(ig,islope) < 1.e-10 .and. .not. co2ice_disappeared(ig,islope)) then ! co2 ice disappeared, look for closest point without co2ice 820 ! CO2 ice disappeared so we look for the closest point without CO2 ice 821 if (is_co2ice_ini(ig,islope) .and. co2_ice(ig,islope) < 1.e-10 .and. .not. co2ice_disappeared(ig,islope)) then 851 822 co2ice_disappeared(ig,islope) = .true. 852 823 if (latitude_deg(ig) > 0) then 853 do ig_loop = ig,ngrid824 outer1: do ig_loop = ig,ngrid 854 825 do islope_loop = islope,iflat,-1 855 826 if (.not. is_co2ice_ini(ig_loop,islope_loop) .and. co2_ice(ig_loop,islope_loop) < 1.e-10) then 856 827 tsurf_avg(ig,islope) = tsurf_avg(ig_loop,islope_loop) 857 bool_sublim = .true. 858 exit 828 exit outer1 859 829 endif 860 830 enddo 861 if (bool_sublim) exit 862 enddo 831 enddo outer1 863 832 else 864 do ig_loop = ig,1,-1833 outer2: do ig_loop = ig,1,-1 865 834 do islope_loop = islope,iflat 866 835 if (.not. is_co2ice_ini(ig_loop,islope_loop) .and. co2_ice(ig_loop,islope_loop) < 1.e-10) then 867 836 tsurf_avg(ig,islope) = tsurf_avg(ig_loop,islope_loop) 868 bool_sublim = .true. 869 exit 837 exit outer2 870 838 endif 871 839 enddo 872 if (bool_sublim) exit 873 enddo 840 enddo outer2 874 841 endif 875 if ( (co2_ice(ig,islope) < 1.e-10) .and. (h2o_ice(ig,islope) > frost_albedo_threshold)) then842 if (h2o_ice(ig,islope) > frost_albedo_threshold) then 876 843 albedo(ig,1,islope) = albedo_h2o_frost 877 844 albedo(ig,2,islope) = albedo_h2o_frost … … 881 848 emis(ig,islope) = emissiv 882 849 endif 883 else if ((co2_ice(ig,islope) > 1.e-3) .and. (d_co2ice(ig,islope) > 1.e-10)) then ! Put tsurf as tcond co2 884 ave = 0. 885 do t = 1,timelen 886 ave = ave + beta_clap_co2/(alpha_clap_co2 - log(vmr_co2_PEM_phys(ig,t)*ps_timeseries(ig,t)/100.)) 887 enddo 888 tsurf_avg(ig,islope) = ave/timelen 850 else if (co2_ice(ig,islope) > 1.e-10 .and. d_co2ice(ig,islope) > 1.e-10) then ! Put tsurf as tcond CO2 851 call computeTcondCO2(timelen,ngrid,nslope,vmr_co2_PEM_phys,ps_timeseries,ps_avg_global_ini,ps_avg_global_new,tsurf_avg) 889 852 endif 890 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! SUBLIMATION??? !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!891 enddo892 enddo893 894 do t = 1,timelen895 tsurf_PCM_timeseries(:,:,t) = tsurf_PCM_timeseries(:,:,t) + tsurf_avg - Tsurfavg_before_saved896 enddo897 ! for the start898 do ig = 1,ngrid899 do islope = 1,nslope900 tsurf(ig,islope) = tsurf(ig,islope) - (Tsurfavg_before_saved(ig,islope) - tsurf_avg(ig,islope))901 853 enddo 902 854 enddo … … 908 860 ! II_d.3 Update soil temperature 909 861 write(*,*)"Updating soil temperature" 910 allocate( Tsoil_locslope(ngrid,nsoilmx_PEM))862 allocate(tsoil_avg_old(ngrid,nsoilmx_PEM)) 911 863 do islope = 1,nslope 864 tsoil_avg_old = tsoil_PEM(:,:,islope) 912 865 call compute_tsoil_pem(ngrid,nsoilmx_PEM,.true.,TI_PEM(:,:,islope),timestep,tsurf_avg(:,islope),tsoil_PEM(:,:,islope)) 913 866 call compute_tsoil_pem(ngrid,nsoilmx_PEM,.false.,TI_PEM(:,:,islope),timestep,tsurf_avg(:,islope),tsoil_PEM(:,:,islope)) 914 867 915 868 do t = 1,timelen 916 Tsoil_locslope(:,1:nsoilmx) = tsoil_PEM(:,1:nsoilmx,islope) + tsoil_anom(:,:,islope,t)917 Tsoil_locslope(:,nsoilmx + 1:) = tsoil_PEM(:,nsoilmx + 1:,islope)918 869 do ig = 1,ngrid 919 870 do isoil = 1,nsoilmx_PEM 920 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) 871 ! Update of soil temperature timeseries which is needed to compute the water soil density timeseries 872 tsoil_PEM_timeseries(ig,isoil,islope,t) = tsoil_PEM_timeseries(ig,isoil,islope,t)*tsoil_PEM(ig,isoil,islope)/tsoil_avg_old(ig,isoil) 873 ! Update of watersoil density 874 watersoil_density_PEM_timeseries(ig,isoil,islope,t) = exp(beta_clap_h2o/tsoil_PEM_timeseries(ig,isoil,islope,t) + alpha_clap_h2o)/tsoil_PEM_timeseries(ig,isoil,islope,t)*mmol(igcm_h2o_vap)/(mugaz*r) 921 875 if (isnan(tsoil_PEM(ig,isoil,islope))) call abort_pem("PEM - Update Tsoil","NaN detected in tsoil_PEM",1) 922 876 enddo … … 925 879 enddo 926 880 watersoil_density_PEM_avg = sum(watersoil_density_PEM_timeseries,4)/timelen 927 881 deallocate(tsoil_avg_old) 928 882 write(*,*) "Update of soil temperature done" 929 930 deallocate(Tsoil_locslope)931 883 932 884 ! II_d.4 Update the ice table … … 942 894 do ig = 1,ngrid 943 895 do islope = 1,nslope 944 call dyn_ss_ice_m(icetable_depth(ig,islope),tsurf_avg(ig,islope),tsoil_PEM(ig,:,islope),nsoilmx_PEM,TI_PEM(ig,1,nslope),ps (ig),(/sum(q_h2o_PEM_phys(ig,:))/size(q_h2o_PEM_phys,2)/),ice_porefilling(ig,:,islope),porefill,ssi_depth)896 call dyn_ss_ice_m(icetable_depth(ig,islope),tsurf_avg(ig,islope),tsoil_PEM(ig,:,islope),nsoilmx_PEM,TI_PEM(ig,1,nslope),ps_avg(ig),(/sum(q_h2o_PEM_phys(ig,:))/size(q_h2o_PEM_phys,2)/),ice_porefilling(ig,:,islope),porefill,ssi_depth) 945 897 icetable_depth(ig,islope) = ssi_depth 946 898 ice_porefilling(ig,:,islope) = porefill … … 952 904 953 905 ! II_d.5 Update the soil thermal properties 954 call update_soil_thermalproperties(ngrid,nslope,nsoilmx_PEM,d_h2oice,h2o_ice, global_avg_press_new,icetable_depth,icetable_thickness,ice_porefilling,icetable_equilibrium,icetable_dynamic,TI_PEM)906 call update_soil_thermalproperties(ngrid,nslope,nsoilmx_PEM,d_h2oice,h2o_ice,ps_avg_global_new,icetable_depth,icetable_thickness,ice_porefilling,icetable_equilibrium,icetable_dynamic,TI_PEM) 955 907 956 908 ! II_d.6 Update the mass of the regolith adsorbed 957 909 if (adsorption_pem) then 958 call regolith_adsorption(ngrid,nslope,nsoilmx_PEM,timelen,d_h2oice,d_co2ice, 959 h2o_ice,co2_ice,tsoil_PEM,TI_PEM,ps_timeseries,q_co2_PEM_phys,q_h2o_PEM_phys,&910 call regolith_adsorption(ngrid,nslope,nsoilmx_PEM,timelen,d_h2oice,d_co2ice,h2o_ice,co2_ice, & 911 tsoil_PEM,TI_PEM,ps_timeseries,q_co2_PEM_phys,q_h2o_PEM_phys, & 960 912 h2o_adsorbed_phys,delta_h2o_adsorbed,co2_adsorbed_phys,delta_co2_adsorbed) 961 913 … … 988 940 ! II_e Outputs 989 941 !------------------------ 990 call writediagpem(ngrid,'ps_avg','Global average pressure','Pa',0,(/ global_avg_press_new/))942 call writediagpem(ngrid,'ps_avg','Global average pressure','Pa',0,(/ps_avg_global_new/)) 991 943 do islope = 1,nslope 992 944 write(str2(1:2),'(i2.2)') islope … … 996 948 call writediagpem(ngrid,'d_co2ice_slope'//str2,'CO2 ice tend','kg.m-2.year-1',2,d_co2ice(:,islope)) 997 949 call writediagpem(ngrid,'Flow_co2ice_slope'//str2,'CO2 ice flow','Boolean',2,flag_co2flow(:,islope)) 998 call writediagpem(ngrid,'tsurf_slope'//str2,'tsurf','K',2,tsurf (:,islope))950 call writediagpem(ngrid,'tsurf_slope'//str2,'tsurf','K',2,tsurf_avg(:,islope)) 999 951 if (icetable_equilibrium) then 1000 952 call writediagpem(ngrid,'ssi_depth_slope'//str2,'ice table depth','m',2,icetable_depth(:,islope)) … … 1005 957 1006 958 if (soil_pem) then 1007 call writediagsoilpem(ngrid,'tsoil_PEM_slope'//str2,'tsoil _PEM','K',3,tsoil_PEM(:,:,islope))1008 call writediagsoilpem(ngrid,'inertiesoil_PEM_slope'//str2,'TI _PEM','K',3,TI_PEM(:,:,islope))959 call writediagsoilpem(ngrid,'tsoil_PEM_slope'//str2,'tsoil','K',3,tsoil_PEM(:,:,islope)) 960 call writediagsoilpem(ngrid,'inertiesoil_PEM_slope'//str2,'TI','K',3,TI_PEM(:,:,islope)) 1009 961 if (icetable_dynamic) call writediagsoilpem(ngrid,'ice_porefilling'//str2,'ice pore filling','-',3,ice_porefilling(:,:,islope)) 1010 962 if (adsorption_pem) then … … 1019 971 ! II_f Update the tendencies 1020 972 !------------------------ 1021 call recomp_tend_co2(ngrid,nslope,timelen,d_co2ice,d_co2ice_ini,co2_ice,emis,vmr_co2_PCM,vmr_co2_PEM_phys,ps_timeseries, global_avg_press_PCM,global_avg_press_new)973 call recomp_tend_co2(ngrid,nslope,timelen,d_co2ice,d_co2ice_ini,co2_ice,emis,vmr_co2_PCM,vmr_co2_PEM_phys,ps_timeseries,ps_avg_global_old,ps_avg_global_new) 1022 974 1023 975 !------------------------ … … 1026 978 !------------------------ 1027 979 write(*,*) "Checking the stopping criteria..." 1028 call stopping_crit_h2o_ice(cell_area,h2oice_ini_surf,i ni_h2oice_sublim,h2o_ice,stopPEM,ngrid)1029 call stopping_crit_co2(cell_area,co2ice_ ini_surf,ini_co2ice_sublim,co2_ice,stopPEM,ngrid,global_avg_press_PCM,global_avg_press_new,nslope)980 call stopping_crit_h2o_ice(cell_area,h2oice_ini_surf,is_h2oice_sublim_ini,h2o_ice,stopPEM,ngrid) 981 call stopping_crit_co2(cell_area,co2ice_sublim_surf_ini,is_co2ice_sublim_ini,co2_ice,stopPEM,ngrid,ps_avg_global_ini,ps_avg_global_new,nslope) 1030 982 i_myear_leg = i_myear_leg + dt 1031 983 i_myear = i_myear + dt … … 1061 1013 write(*,*) "Number of simulated Martian years: i_myear =", i_myear 1062 1014 endif 1063 1064 global_avg_press_old = global_avg_press_new1065 1066 1015 enddo ! big time iteration loop of the pem 1067 1016 !------------------------------ END RUN -------------------------------- … … 1072 1021 ! III_a Update surface value for the PCM start files 1073 1022 !------------------------ 1074 ! III_a.1 Ice update (for startfi)1023 ! III_a.1 Ice update for start file 1075 1024 watercap = 0. 1076 1025 perennial_co2ice = co2_ice … … 1100 1049 enddo 1101 1050 1102 ! III_a.2 Tsoil update (for startfi) 1051 ! III.a.2. Tsurf update for start file 1052 tsurf = tsurf_avg + tsurf_dev 1053 1054 ! III_a.3 Tsoil update for start file 1103 1055 if (soil_pem) then 1104 1056 inertiesoil = TI_PEM(:,:nsoilmx,:) 1105 tsoil = tsoil_PEM(:,1:nsoilmx,:) + tsoil_anom(:,:,:,timelen) 1057 ! Tsurf has evolved and so the soil temperature profile needs to be adapted to match this new value 1058 do isoil = 1,nsoilmx 1059 tsoil_dev(:,isoil,:) = tsoil_dev(:,isoil,:)*(tsurf_avg(:,:) - tsoil_PEM(:,1,:))/tsoil_dev(:,1,:) 1060 enddo 1061 tsoil = tsoil_PEM(:,1:nsoilmx,:) + tsoil_dev 1106 1062 #ifndef CPP_STD 1107 1063 flux_geo = fluxgeo 1108 1064 #endif 1109 1065 endif 1110 deallocate(tsoil_anom) 1111 1112 ! III_a.4 Pressure (for start) 1113 ps = ps*global_avg_press_new/global_avg_press_PCM 1114 ps_start_PCM = ps_start_PCM*global_avg_press_new/global_avg_press_PCM 1115 1116 ! III_a.5 Tracer (for start) 1117 allocate(zplev_new(ngrid,nlayer + 1)) 1118 1066 1067 ! III_a.4 Pressure update for start file 1068 ps_start = ps_avg + ps_dev 1069 1070 ! III_a.5 Tracers update for start file 1071 allocate(zplev_start0(ngrid,nlayer + 1),zplev_new(ngrid,nlayer + 1)) 1119 1072 do l = 1,nlayer + 1 1120 zplev_new(:,l) = ap(l) + bp(l)*ps_start_PCM 1073 zplev_start0(:,l) = ap(l) + bp(l)*ps_start0 1074 zplev_new(:,l) = ap(l) + bp(l)*ps_start 1121 1075 enddo 1122 1076 … … 1125 1079 do l = 1,llm - 1 1126 1080 do ig = 1,ngrid 1127 q(ig,l,nnq) = q(ig,l,nnq)*(zplev_ PCM(ig,l) - zplev_PCM(ig,l + 1))/(zplev_new(ig,l) - zplev_new(ig,l + 1))1081 q(ig,l,nnq) = q(ig,l,nnq)*(zplev_start0(ig,l) - zplev_start0(ig,l + 1))/(zplev_new(ig,l) - zplev_new(ig,l + 1)) 1128 1082 enddo 1129 1083 q(:,llm,nnq) = q(:,llm - 1,nnq) … … 1132 1086 do l = 1,llm - 1 1133 1087 do ig = 1,ngrid 1134 q(ig,l,nnq) = q(ig,l,nnq)*(zplev_ PCM(ig,l) - zplev_PCM(ig,l + 1))/(zplev_new(ig,l) - zplev_new(ig,l + 1)) &1135 + ((zplev_new(ig,l) - zplev_new(ig,l + 1)) - (zplev_ PCM(ig,l) - zplev_PCM(ig,l + 1)))/(zplev_new(ig,l) - zplev_new(ig,l + 1))1088 q(ig,l,nnq) = q(ig,l,nnq)*(zplev_start0(ig,l) - zplev_start0(ig,l + 1))/(zplev_new(ig,l) - zplev_new(ig,l + 1)) & 1089 + ((zplev_new(ig,l) - zplev_new(ig,l + 1)) - (zplev_start0(ig,l) - zplev_start0(ig,l + 1)))/(zplev_new(ig,l) - zplev_new(ig,l + 1)) 1136 1090 enddo 1137 1091 q(:,llm,nnq) = q(:,llm - 1,nnq) … … 1140 1094 enddo 1141 1095 1142 ! Conserving the tracers mass for PCM start files1096 ! Conserving the tracers mass for start file 1143 1097 do nnq = 1,nqtot 1144 1098 do ig = 1,ngrid … … 1154 1108 enddo 1155 1109 enddo 1110 deallocate(zplev_start0,zplev_new) 1156 1111 1157 1112 if (evol_orbit_pem) call recomp_orb_param(i_myear,i_myear_leg) … … 1171 1126 do l = 1,nlayer 1172 1127 do i = 1,ip1jmp1 1173 teta(i,l)= teta(i,l)*(ps 0(i)/ps(i))**kappa1128 teta(i,l)= teta(i,l)*(ps_start0(i)/ps_start(i))**kappa 1174 1129 enddo 1175 1130 enddo 1176 1131 ! Correction on atmospheric pressure 1177 call pression(ip1jmp1,ap,bp,ps ,p)1132 call pression(ip1jmp1,ap,bp,ps_start,p) 1178 1133 ! Correction on the mass of atmosphere 1179 1134 call massdair(p,masse) 1180 1135 call dynredem0("restart.nc",day_ini,phis) 1181 call dynredem1("restart.nc",time_0,vcov,ucov,teta,q,masse,ps )1136 call dynredem1("restart.nc",time_0,vcov,ucov,teta,q,masse,ps_start) 1182 1137 write(*,*) "restart.nc has been written" 1183 1138 #else 1184 call writerestart1D('restart1D.txt',ps (1),tsurf(1,:),nlayer,size(tsurf,2),teta,ucov,vcov,nq,noms,qsurf(1,:,:),q)1139 call writerestart1D('restart1D.txt',ps_start(1),tsurf(1,:),nlayer,size(tsurf,2),teta,ucov,vcov,nq,noms,qsurf(1,:,:),q) 1185 1140 write(*,*) "restart1D.txt has been written" 1186 1141 #endif … … 1231 1186 deallocate(new_str,new_lag1,new_lag2,current1,current2) 1232 1187 endif 1233 deallocate(vmr_co2_PCM,ps_timeseries,tsurf_PCM_timeseries,q_co2_PEM_phys,q_h2o_PEM_phys) 1234 deallocate(watersurf_density_avg,watersoil_density_timeseries,Tsurfavg_before_saved) 1235 deallocate(tsoil_phys_PEM_timeseries,watersoil_density_PEM_timeseries,watersoil_density_PEM_avg) 1236 deallocate(delta_co2_adsorbed,delta_h2o_adsorbed,vmr_co2_PEM_phys,delta_h2o_icetablesublim) 1188 deallocate(ps_start,ps_start0,ps_timeseries,ps_avg,ps_dev) 1189 deallocate(tsurf_avg,tsurf_dev,tsurf_avg_old) 1190 deallocate(tsoil_PEM,tsoil_dev,tsoil_PEM_timeseries) 1191 deallocate(vmr_co2_PCM,vmr_co2_PEM_phys,q_co2_PEM_phys,q_h2o_PEM_phys) 1192 deallocate(watersurf_density_avg,watersoil_density_PEM_timeseries,watersoil_density_PEM_avg) 1193 deallocate(delta_co2_adsorbed,delta_h2o_adsorbed,delta_h2o_icetablesublim) 1237 1194 deallocate(icetable_thickness_old,ice_porefilling_old,zshift_surf,zlag) 1238 deallocate(is_co2ice_ini,co2ice_disappeared,i ni_co2ice_sublim,ini_h2oice_sublim,stratif)1195 deallocate(is_co2ice_ini,co2ice_disappeared,is_co2ice_sublim_ini,is_h2oice_sublim_ini,stratif) 1239 1196 !----------------------------- END OUTPUT ------------------------------ 1240 1197
Note: See TracChangeset
for help on using the changeset viewer.