Changeset 3571 for trunk/LMDZ.COMMON
- Timestamp:
- Jan 10, 2025, 5:45:03 PM (10 days ago)
- Location:
- trunk/LMDZ.COMMON/libf/evolution
- Files:
-
- 11 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.COMMON/libf/evolution/adsorption_mod.F90
r3554 r3571 3 3 implicit none 4 4 5 logical 6 real, save,allocatable, dimension(:,:,:) :: co2_adsorbed_phys ! co2 that is in the regolith [kg/m^2]7 real, save,allocatable, dimension(:,:,:) :: h2o_adsorbed_phys ! h2o that is in the regolith [kg/m^2]5 logical :: adsorption_pem ! True by default, to compute adsorption/desorption. Read in pem.def 6 real, allocatable, dimension(:,:,:) :: co2_adsorbed_phys ! co2 that is in the regolith [kg/m^2] 7 real, allocatable, dimension(:,:,:) :: h2o_adsorbed_phys ! h2o that is in the regolith [kg/m^2] 8 8 9 9 !======================================================================= -
trunk/LMDZ.COMMON/libf/evolution/changelog.txt
r3563 r3571 528 528 == 17/12/2024 == JBC 529 529 Correction of Norbert Schorghofer's code due to missing initialization and bad shape array as subroutine argument + some cleanings. 530 531 == 10/01/2025 == JBC 532 - New way to manage the pressure: now the PEM manages only the average pressure and keeps the pressure deviation with the instantaneous pressure from the start to reconstruct the pressure at the end ('ps_avg = ps_start + ps_dev'). As a consequence, everything related to pressure in the PEM is modified accordingly. 533 - Surface temperatures management is now simpler. It follows the strategy for the pressure (and soil temperature) described above. 534 - Soil temperatures are now adapted to match the surface temperature changes occured during the PEM by modifying the soil temperature deviation at the end. 535 - Few simplifications/optimizations: notably, the two PCM years are now read in one go in 'read_data_PCM_mod.F90' and only the needed variables are extracted. 536 - Deletion of unused variables and unnecessary intermediate variables (memory saving and loop deletion in some cases). 537 - Renaming of variables and subroutines to make everything clearer. In particular, the suffixes: '_avg' = average, '_start' = PCM start file, '_dev' = deviation, '_ini' or '0' = initial, '_dyn' = dynamical grid, '_timeseries' = daily average of last PCM year. 538 - Cosmetic cleanings for readability. -
trunk/LMDZ.COMMON/libf/evolution/evol_ice_mod.F90
r3556 r3571 77 77 78 78 ! OUTPUT 79 real, dimension(ngrid,nslope), intent(inout) :: h2o_ice 80 real, dimension(ngrid,nslope), intent(inout) :: d_h2oice 81 integer, intent(inout) :: stopPEM 79 real, dimension(ngrid,nslope), intent(inout) :: h2o_ice ! Previous and actual density of h2o ice (kg/m^2) 80 real, dimension(ngrid,nslope), intent(inout) :: d_h2oice ! Evolution of perennial ice over one year (kg/m^2/year) 81 integer, intent(inout) :: stopPEM ! Stopping criterion code 82 82 real, dimension(ngrid,nslope), intent(out) :: zshift_surf ! Elevation shift for the surface [m] 83 83 -
trunk/LMDZ.COMMON/libf/evolution/get_timelen_PCM_mod.F90
r3570 r3571 1 MODULE nb_time_step_PCM_mod1 MODULE get_timelen_PCM_mod 2 2 3 3 use netcdf, only: nf90_open, NF90_NOWRITE, nf90_noerr, nf90_strerror, & … … 13 13 !======================================================================= 14 14 15 SUBROUTINE nb_time_step_PCM(fichnom,timelen)15 SUBROUTINE get_timelen_PCM(fichnom,timelen) 16 16 17 17 implicit none … … 30 30 character(len = *), intent(in) :: fichnom !--- FILE NAME 31 31 !======================================================================= 32 ! Local Variables32 ! Local variables 33 33 integer :: fID, vID, ierr 34 34 integer :: timelen ! number of times stored in the file 35 35 !----------------------------------------------------------------------- 36 modname = " nb_time_step_PCM"36 modname = "get_timelen_PCM" 37 37 38 38 ! Open initial state NetCDF file … … 52 52 write(*,*)"read_data_PCM: Le champ <Time> est absent" 53 53 write(*,*)trim(nf90_strerror(ierr)) 54 call abort_gcm(" nb_time_step_PCM", "", 1)54 call abort_gcm("get_timelen_PCM", "", 1) 55 55 endif 56 56 ! Get the length of the "Time" dimension … … 72 72 write(*,*) "The number of timestep of the PCM run data=", timelen 73 73 74 END SUBROUTINE nb_time_step_PCM74 END SUBROUTINE get_timelen_PCM 75 75 76 76 !======================================================================= … … 98 98 END SUBROUTINE error_msg 99 99 100 END MODULE nb_time_step_PCM_mod100 END MODULE get_timelen_PCM_mod -
trunk/LMDZ.COMMON/libf/evolution/glaciers_mod.F90
r3553 r3571 21 21 !======================================================================= 22 22 23 SUBROUTINE flow_co2glaciers(timelen,ngrid,nslope,iflat,subslope_dist,def_slope_mean,vmr_co2_PEM,ps_PCM, global_avg_ps_PCM,global_avg_ps_PEM,co2ice,flag_co2flow,flag_co2flow_mesh)23 SUBROUTINE flow_co2glaciers(timelen,ngrid,nslope,iflat,subslope_dist,def_slope_mean,vmr_co2_PEM,ps_PCM,ps_avg_global_ini,ps_avg_global,co2ice,flag_co2flow,flag_co2flow_mesh) 24 24 25 25 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! … … 38 38 !-------- 39 39 integer, intent(in) :: timelen, ngrid, nslope, iflat ! number of time sample, physical points, subslopes, index of the flat subslope 40 real, dimension(ngrid,nslope), intent(in) :: subslope_dist ! Physicalpoints x Slopes: Distribution of the subgrid slopes41 real, dimension(ngrid), intent(in) :: def_slope_mean ! Physicalpoints: values of the sub grid slope angles42 real, dimension(ngrid,timelen), intent(in) :: vmr_co2_PEM ! Physicalx Time field : VMR of co2 in the first layer [mol/mol]43 real, dimension(ngrid,timelen), intent(in) :: ps_PCM ! Physicalx Time field: surface pressure given by the PCM [Pa]44 real, intent(in) :: global_avg_ps_PCM ! Global averaged surface pressure from the PCM[Pa]45 real, intent(in) :: global_avg_ps_PEM ! global averaged surface pressure during the PEM iteration [Pa]40 real, dimension(ngrid,nslope), intent(in) :: subslope_dist ! Grid points x Slopes: Distribution of the subgrid slopes 41 real, dimension(ngrid), intent(in) :: def_slope_mean ! Grid points: values of the sub grid slope angles 42 real, dimension(ngrid,timelen), intent(in) :: vmr_co2_PEM ! Grid points x Time field : VMR of co2 in the first layer [mol/mol] 43 real, dimension(ngrid,timelen), intent(in) :: ps_PCM ! Grid points x Time field: surface pressure given by the PCM [Pa] 44 real, intent(in) :: ps_avg_global_ini ! Global averaged surface pressure at the beginning [Pa] 45 real, intent(in) :: ps_avg_global ! Global averaged surface pressure during the PEM iteration [Pa] 46 46 47 47 ! Ouputs: 48 48 !-------- 49 real, dimension(ngrid,nslope), intent(inout) :: co2ice ! Physicalx Slope field: co2 ice on the subgrid slopes [kg/m^2]49 real, dimension(ngrid,nslope), intent(inout) :: co2ice ! Grid points x Slope field: co2 ice on the subgrid slopes [kg/m^2] 50 50 real, dimension(ngrid,nslope), intent(inout) :: flag_co2flow ! flag to see if there is flow on the subgrid slopes 51 51 real, dimension(ngrid), intent(inout) :: flag_co2flow_mesh ! same but within the mesh … … 53 53 !------ 54 54 real, dimension(ngrid,nslope) :: Tcond ! Physical field: CO2 condensation temperature [K] 55 real, dimension(ngrid,nslope) :: hmax ! Physicalx Slope field: maximum thickness for co2 glacier before flow55 real, dimension(ngrid,nslope) :: hmax ! Grid points x Slope field: maximum thickness for co2 glacier before flow 56 56 57 57 write(*,*) "Flow of CO2 glaciers" 58 call computeTcondCO2(timelen,ngrid,nslope,vmr_co2_PEM,ps_PCM, global_avg_ps_PCM,global_avg_ps_PEM,Tcond)58 call computeTcondCO2(timelen,ngrid,nslope,vmr_co2_PEM,ps_PCM,ps_avg_global_ini,ps_avg_global,Tcond) 59 59 call compute_hmaxglaciers(ngrid,nslope,iflat,def_slope_mean,Tcond,"co2",hmax) 60 call transfer_ice_duringflow(ngrid,nslope,iflat, subslope_dist,def_slope_mean,hmax,Tcond,"co2",co2ice,flag_co2flow,flag_co2flow_mesh)60 call transfer_ice_duringflow(ngrid,nslope,iflat,subslope_dist,def_slope_mean,hmax,Tcond,co2ice,flag_co2flow,flag_co2flow_mesh) 61 61 62 62 END SUBROUTINE flow_co2glaciers … … 64 64 !======================================================================= 65 65 66 SUBROUTINE flow_h2oglaciers( timelen,ngrid,nslope,iflat,subslope_dist,def_slope_mean,Tice,h2oice,flag_h2oflow,flag_h2oflow_mesh)66 SUBROUTINE flow_h2oglaciers(ngrid,nslope,iflat,subslope_dist,def_slope_mean,Tice,h2oice,flag_h2oflow,flag_h2oflow_mesh) 67 67 68 68 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! … … 82 82 83 83 ! Inputs: 84 integer, intent(in) :: timelen,ngrid, nslope, iflat ! number of time sample, physical points, subslopes, index of the flat subslope85 real, dimension(ngrid,nslope), intent(in) :: subslope_dist ! Physicalpoints x Slopes : Distribution of the subgrid slopes84 integer, intent(in) :: ngrid, nslope, iflat ! number of time sample, physical points, subslopes, index of the flat subslope 85 real, dimension(ngrid,nslope), intent(in) :: subslope_dist ! Grid points x Slopes : Distribution of the subgrid slopes 86 86 real, dimension(ngrid), intent(in) :: def_slope_mean ! Slopes: values of the sub grid slope angles 87 87 real, dimension(ngrid,nslope), intent(in) :: Tice ! Ice Temperature [K] 88 88 ! Ouputs: 89 real, dimension(ngrid,nslope), intent(inout) :: h2oice ! Physicalx Slope field: co2 ice on the subgrid slopes [kg/m^2]89 real, dimension(ngrid,nslope), intent(inout) :: h2oice ! Grid points x Slope field: co2 ice on the subgrid slopes [kg/m^2] 90 90 real, dimension(ngrid,nslope), intent(inout) :: flag_h2oflow ! flag to see if there is flow on the subgrid slopes 91 91 real, dimension(ngrid), intent(inout) :: flag_h2oflow_mesh ! same but within the mesh 92 92 ! Local 93 real, dimension(ngrid,nslope) :: hmax ! Physicalx Slope field: maximum thickness for co2 glacier before flow93 real, dimension(ngrid,nslope) :: hmax ! Grid points x Slope field: maximum thickness for co2 glacier before flow 94 94 95 95 write(*,*) "Flow of H2O glaciers" 96 96 call compute_hmaxglaciers(ngrid,nslope,iflat,def_slope_mean,Tice,"h2o",hmax) 97 call transfer_ice_duringflow(ngrid,nslope,iflat, subslope_dist,def_slope_mean,hmax,Tice,"h2o",h2oice,flag_h2oflow,flag_h2oflow_mesh)97 call transfer_ice_duringflow(ngrid,nslope,iflat,subslope_dist,def_slope_mean,hmax,Tice,h2oice,flag_h2oflow,flag_h2oflow_mesh) 98 98 99 99 END SUBROUTINE flow_h2oglaciers … … 161 161 !======================================================================= 162 162 163 SUBROUTINE transfer_ice_duringflow(ngrid,nslope,iflat,subslope_dist,def_slope_mean,hmax,Tice, name_ice,qice,flag_flow,flag_flowmesh)163 SUBROUTINE transfer_ice_duringflow(ngrid,nslope,iflat,subslope_dist,def_slope_mean,hmax,Tice,qice,flag_flow,flag_flowmesh) 164 164 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 165 165 !!! … … 188 188 real, dimension(ngrid,nslope), intent(in) :: hmax ! maximum height of the glaciers before initiating flow [m] 189 189 real, dimension(ngrid,nslope), intent(in) :: Tice ! Ice temperature[K] 190 character(3), intent(in) :: name_ice ! Nature of the ice191 190 ! Outputs 192 191 !-------- … … 232 231 !======================================================================= 233 232 234 SUBROUTINE computeTcondCO2(timelen,ngrid,nslope,vmr_co2_PEM,ps_PCM, global_avg_ps_PCM,global_avg_ps_PEM,Tcond)233 SUBROUTINE computeTcondCO2(timelen,ngrid,nslope,vmr_co2_PEM,ps_PCM,ps_avg_global_ini,ps_avg_global,Tcond) 235 234 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 236 235 !!! … … 241 240 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 242 241 243 use constants_marspem_mod, only: alpha_clap_co2, beta_clap_co2242 use constants_marspem_mod, only: alpha_clap_co2, beta_clap_co2 244 243 245 244 implicit none … … 250 249 ! INPUT 251 250 integer, intent(in) :: timelen, ngrid, nslope ! # of timesample, physical points, subslopes 252 real, dimension(ngrid,timelen), intent(in) :: vmr_co2_PEM ! Physicalpoints x times field: VMR of CO2 in the first layer [mol/mol]253 real, dimension(ngrid,timelen), intent(in) :: ps_PCM ! Physicalpoints x times field: surface pressure in the PCM [Pa]254 real, intent(in) :: global_avg_ps_PCM! Global averaged surfacepressure in the PCM [Pa]255 real, intent(in) :: global_avg_ps_PEM! Global averaged surface pressure computed during the PEM iteration251 real, dimension(ngrid,timelen), intent(in) :: vmr_co2_PEM ! Grid points x times field: VMR of CO2 in the first layer [mol/mol] 252 real, dimension(ngrid,timelen), intent(in) :: ps_PCM ! Grid points x times field: surface pressure in the PCM [Pa] 253 real, intent(in) :: ps_avg_global_ini ! Global averaged surfacepressure in the PCM [Pa] 254 real, intent(in) :: ps_avg_global ! Global averaged surface pressure computed during the PEM iteration 256 255 257 256 ! OUTPUT 258 real, dimension(ngrid,nslope), intent(out) :: Tcond ! Physicalpoints: condensation temperature of CO2, yearly averaged257 real, dimension(ngrid,nslope), intent(out) :: Tcond ! Grid points: condensation temperature of CO2, yearly averaged 259 258 260 259 ! LOCAL 261 260 integer :: ig, it ! For loop 262 real :: ave ! Intermediate to compute average263 261 264 262 do ig = 1,ngrid 265 ave= 0263 Tcond(ig,:) = 0 266 264 do it = 1,timelen 267 ave = ave + beta_clap_co2/(alpha_clap_co2 - log(vmr_co2_PEM(ig,it)*ps_PCM(ig,it)*global_avg_ps_PCM/global_avg_ps_PEM/100))265 Tcond(ig,:) = Tcond(ig,:) + beta_clap_co2/(alpha_clap_co2 - log(vmr_co2_PEM(ig,it)*ps_PCM(ig,it)*ps_avg_global_ini/ps_avg_global/100)) 268 266 enddo 269 Tcond(ig,:) = ave/timelen267 Tcond(ig,:) = Tcond(ig,:)/timelen 270 268 enddo 271 269 -
trunk/LMDZ.COMMON/libf/evolution/ice_table_mod.F90
r3532 r3571 383 383 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 384 384 385 use comsoil_h_PEM, only: layer_PEM,mlayer_PEM385 use comsoil_h_PEM, only: mlayer_PEM 386 386 use abort_pem_mod, only: abort_pem 387 387 -
trunk/LMDZ.COMMON/libf/evolution/lask_param_mod.F90
r3149 r3571 11 11 implicit none 12 12 13 real, dimension(:), allocatable , save:: yearlask ! year before present from Laskar et al. Tab14 real, dimension(:), allocatable , save:: obllask ! obliquity [deg]15 real, dimension(:), allocatable , save:: ecclask ! eccentricity [deg]16 real, dimension(:), allocatable , save:: lsplask ! ls perihelie [deg]17 integer , save:: last_ilask ! Index of the line in the file year_obl_lask.asc corresponding to the closest lower year to the current year13 real, dimension(:), allocatable :: yearlask ! year before present from Laskar et al. Tab 14 real, dimension(:), allocatable :: obllask ! obliquity [deg] 15 real, dimension(:), allocatable :: ecclask ! eccentricity [deg] 16 real, dimension(:), allocatable :: lsplask ! ls perihelie [deg] 17 integer :: last_ilask ! Index of the line in the file year_obl_lask.asc corresponding to the closest lower year to the current year 18 18 19 19 !======================================================================= -
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 -
trunk/LMDZ.COMMON/libf/evolution/pemetat0.F90
r3563 r3571 8 8 9 9 SUBROUTINE pemetat0(filename,ngrid,nsoil_PCM,nsoil_PEM,nslope,timelen,timestep,TI_PEM,tsoil_PEM,icetable_depth,icetable_thickness, & 10 ice_porefilling,tsurf_avg_yr1,tsurf_avg_yr2,q_co2,q_h2o,ps_ inst,tsoil_inst,d_h2oice,d_co2ice,co2_ice,h2o_ice,&11 global_avg_pressure,watersurf_avg,watersoil_avg,m_co2_regolith_phys,deltam_co2_regolith_phys,&12 m_h2o_regolith_phys,deltam_h2o_regolith_phys,stratif)10 ice_porefilling,tsurf_avg_yr1,tsurf_avg_yr2,q_co2,q_h2o,ps_timeseries,ps_avg_global, & 11 watersurf_avg,watersoil_avg,m_co2_regolith_phys,deltam_co2_regolith_phys, & 12 d_h2oice,d_co2ice,co2_ice,h2o_ice,m_h2o_regolith_phys,deltam_h2o_regolith_phys,stratif) 13 13 14 14 use iostart_PEM, only: open_startphy, close_startphy, get_field, get_var, inquire_dimension, inquire_dimension_length 15 use comsoil_h_PEM, only: soil_pem, layer_PEM, mlayer_PEM,fluxgeo, inertiedat_PEM, ini_huge_h2oice, depth_breccia, depth_bedrock, index_breccia, index_bedrock16 use comsoil_h, only: volcapa,inertiedat15 use comsoil_h_PEM, only: soil_pem, layer_PEM, fluxgeo, inertiedat_PEM, ini_huge_h2oice, depth_breccia, depth_bedrock, index_breccia, index_bedrock 16 use comsoil_h, only: inertiedat 17 17 use adsorption_mod, only: regolith_adsorption, adsorption_pem 18 18 use ice_table_mod, only: computeice_table_equilibrium, icetable_equilibrium, icetable_dynamic … … 22 22 use abort_pem_mod, only: abort_pem 23 23 use compute_soiltemp_mod, only: ini_tsoil_pem, compute_tsoil_pem 24 use comslope_mod, only: def_slope_mean, subslope_dist25 24 use layering_mod, only: layering, array2stratif, nb_str_max, layering_algo 26 25 … … 36 35 include "callkeys.h" 37 36 38 character(*), intent(in) :: filename 39 integer, intent(in) :: ngrid 40 integer, intent(in) :: nsoil_PCM 41 integer, intent(in) :: nsoil_PEM 42 integer, intent(in) :: nslope 43 integer, intent(in) :: timelen 44 real, intent(in) :: timestep 45 real, intent(in) :: global_avg_pressure! mean average pressure on the planet [Pa]46 real, dimension(ngrid,nslope), intent(in) :: tsurf_avg_yr1 47 real, dimension(ngrid,nslope), intent(in) :: tsurf_avg_yr2 48 real, dimension(ngrid,timelen), intent(in) :: q_co2 49 real, dimension(ngrid,timelen), intent(in) :: q_h2o 50 real, dimension(ngrid,timelen), intent(in) :: ps_ inst! surface pressure [Pa]51 real, dimension(ngrid,nslope), intent(in) :: d_h2oice 52 real, dimension(ngrid,nslope), intent(in) :: d_co2ice 53 real, dimension(ngrid,nslope), intent(in) :: watersurf_avg 37 character(*), intent(in) :: filename ! name of the startfi_PEM.nc 38 integer, intent(in) :: ngrid ! # of physical grid points 39 integer, intent(in) :: nsoil_PCM ! # of vertical grid points in the PCM 40 integer, intent(in) :: nsoil_PEM ! # of vertical grid points in the PEM 41 integer, intent(in) :: nslope ! # of sub-grid slopes 42 integer, intent(in) :: timelen ! # time samples 43 real, intent(in) :: timestep ! time step [s] 44 real, intent(in) :: ps_avg_global ! mean average pressure on the planet [Pa] 45 real, dimension(ngrid,nslope), intent(in) :: tsurf_avg_yr1 ! surface temperature at the first year of PCM call [K] 46 real, dimension(ngrid,nslope), intent(in) :: tsurf_avg_yr2 ! surface temperature at the second year of PCM call [K] 47 real, dimension(ngrid,timelen), intent(in) :: q_co2 ! MMR tracer co2 [kg/kg] 48 real, dimension(ngrid,timelen), intent(in) :: q_h2o ! MMR tracer h2o [kg/kg] 49 real, dimension(ngrid,timelen), intent(in) :: ps_timeseries ! surface pressure [Pa] 50 real, dimension(ngrid,nslope), intent(in) :: d_h2oice ! tendencies on h2o ice 51 real, dimension(ngrid,nslope), intent(in) :: d_co2ice ! tendencies on co2 ice 52 real, dimension(ngrid,nslope), intent(in) :: watersurf_avg ! surface water ice density, yearly averaged (kg/m^3) 54 53 ! outputs 55 real, dimension(ngrid), intent(out) :: deltam_co2_regolith_phys ! mass of co2 that is exchanged due to adsorption desorption [kg/m^2] 56 real, dimension(ngrid), intent(out) :: deltam_h2o_regolith_phys ! mass of h2o that is exchanged due to adsorption desorption [kg/m^2] 57 real, dimension(ngrid,nslope), intent(out) :: h2o_ice ! h2o ice amount [kg/m^2] 58 real, dimension(ngrid,nslope), intent(out) :: co2_ice ! co2 ice amount [kg/m^2] 59 type(layering), dimension(ngrid,nslope), intent(inout) :: stratif ! stratification (layerings) 60 real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: TI_PEM ! soil (mid-layer) thermal inertia in the PEM grid [SI] 61 real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: tsoil_PEM ! soil (mid-layer) temperature [K] 62 real, dimension(ngrid,nslope), intent(inout) :: icetable_depth ! Ice table depth [m] 63 real, dimension(ngrid,nslope), intent(inout) :: icetable_thickness ! Ice table thickness [m] 64 real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: ice_porefilling ! Subsurface ice pore filling [m3/m3] 65 real, dimension(ngrid,nsoil_PEM,nslope,timelen), intent(inout) :: tsoil_inst ! instantaneous soil (mid-layer) temperature [K] 66 real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: m_co2_regolith_phys ! mass of co2 adsorbed [kg/m^2] 67 real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: m_h2o_regolith_phys ! mass of h2o adsorbed [kg/m^2] 68 real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: watersoil_avg ! surface water ice density, yearly averaged (kg/m^3) 54 real, dimension(ngrid), intent(out) :: deltam_co2_regolith_phys ! mass of co2 that is exchanged due to adsorption desorption [kg/m^2] 55 real, dimension(ngrid), intent(out) :: deltam_h2o_regolith_phys ! mass of h2o that is exchanged due to adsorption desorption [kg/m^2] 56 real, dimension(ngrid,nslope), intent(out) :: h2o_ice ! h2o ice amount [kg/m^2] 57 real, dimension(ngrid,nslope), intent(out) :: co2_ice ! co2 ice amount [kg/m^2] 58 type(layering), dimension(ngrid,nslope), intent(inout) :: stratif ! stratification (layerings) 59 real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: TI_PEM ! soil (mid-layer) thermal inertia in the PEM grid [SI] 60 real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: tsoil_PEM ! soil (mid-layer) temperature [K] 61 real, dimension(ngrid,nslope), intent(inout) :: icetable_depth ! Ice table depth [m] 62 real, dimension(ngrid,nslope), intent(inout) :: icetable_thickness ! Ice table thickness [m] 63 real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: ice_porefilling ! Subsurface ice pore filling [m3/m3] 64 real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: m_co2_regolith_phys ! mass of co2 adsorbed [kg/m^2] 65 real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: m_h2o_regolith_phys ! mass of h2o adsorbed [kg/m^2] 66 real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: watersoil_avg ! surface water ice density, yearly averaged (kg/m^3) 69 67 ! local 70 real, dimension(ngrid,nsoil_PEM,nslope) :: tsoil_startPEM ! soil temperature saved in the start [K] 71 real, dimension(ngrid,nsoil_PEM,nslope) :: TI_startPEM ! soil thermal inertia saved in the start [SI] 72 logical :: found, found2 ! check if variables are found in the start 73 integer :: iloop, ig, islope, it, isoil, k ! index for loops 74 real :: kcond ! Thermal conductivity, intermediate variable [SI] 75 real :: delta ! Depth of the interface regolith-breccia, breccia -bedrock [m] 76 character(2) :: num ! intermediate string to read PEM start sloped variables 77 real, dimension(ngrid,nsoil_PEM,nslope) :: tsoil_tmp_yr1 ! intermediate soil temperature during yr 1 [K] 78 real, dimension(ngrid,nsoil_PEM,nslope) :: tsoil_tmp_yr2 ! intermediate soil temperature during yr 2 [K] 79 logical :: startpem_file ! boolean to check if we read the startfile or not 80 real, dimension(:,:,:,:), allocatable :: stratif_array ! Array for stratification (layerings) 68 real, dimension(ngrid,nsoil_PEM,nslope) :: tsoil_startpem ! soil temperature saved in the start [K] 69 real, dimension(ngrid,nsoil_PEM,nslope) :: TI_startPEM ! soil thermal inertia saved in the start [SI] 70 logical :: found, found2 ! check if variables are found in the start 71 integer :: iloop, ig, islope, isoil ! index for loops 72 real :: delta ! Depth of the interface regolith-breccia, breccia -bedrock [m] 73 character(2) :: num ! intermediate string to read PEM start sloped variables 74 logical :: startpem_file ! boolean to check if we read the startfile or not 75 real, dimension(:,:,:,:), allocatable :: stratif_array ! Array for stratification (layerings) 81 76 82 77 #ifdef CPP_STD … … 210 205 else ! found 211 206 do iloop = nsoil_PCM + 1,nsoil_PEM 212 TI_PEM(:,iloop,islope) = TI_startPEM(:,iloop,islope) !! 1st layers can change because of the presence of ice at the surface, so we don't change it here.207 TI_PEM(:,iloop,islope) = TI_startPEM(:,iloop,islope) ! 1st layers can change because of the presence of ice at the surface, so we don't change it here. 213 208 enddo 214 209 endif ! not found … … 258 253 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 259 254 !2. Soil Temperature 260 do islope =1,nslope255 do islope = 1,nslope 261 256 write(num,fmt='(i2.2)') islope 262 call get_field("tsoil_PEM_slope"//num,tsoil_start PEM(:,:,islope),found)257 call get_field("tsoil_PEM_slope"//num,tsoil_startpem(:,:,islope),found) 263 258 if (.not. found) then 264 259 write(*,*)'PEM settings: failed loading <tsoil_PEM_slope'//num//'>' … … 267 262 call compute_tsoil_pem(ngrid,nsoil_PEM,.true.,TI_PEM(:,:,islope),timestep,tsurf_avg_yr2(:,islope),tsoil_PEM(:,:,islope)) 268 263 else 269 ! predictor corrector: restart from year 1 of the PCM and build the evolution of tsoil at depth 270 tsoil_tmp_yr1(:,:,islope) = tsoil_startPEM(:,:,islope) 271 call compute_tsoil_pem(ngrid,nsoil_PEM,.true.,TI_PEM(:,:,islope),timestep,tsurf_avg_yr1(:,islope),tsoil_tmp_yr1(:,:,islope)) 272 call compute_tsoil_pem(ngrid,nsoil_PEM,.false.,TI_PEM(:,:,islope),timestep,tsurf_avg_yr1(:,islope),tsoil_tmp_yr1(:,:,islope)) 273 tsoil_tmp_yr2(:,:,islope) = tsoil_tmp_yr1(:,:,islope) 274 call compute_tsoil_pem(ngrid,nsoil_PEM,.false.,TI_PEM(:,:,islope),timestep,tsurf_avg_yr2(:,islope),tsoil_tmp_yr2(:,:,islope)) 264 ! predictor-corrector: due to changes of surface temperature in the PCM, the tsoil_startpem is adapted firstly 265 ! for PCM year 1 and then for PCM year 2 in order to build the evolution of the profile at depth 266 call compute_tsoil_pem(ngrid,nsoil_PEM,.true.,TI_PEM(:,:,islope),timestep,tsurf_avg_yr1(:,islope),tsoil_startpem(:,:,islope)) 267 call compute_tsoil_pem(ngrid,nsoil_PEM,.false.,TI_PEM(:,:,islope),timestep,tsurf_avg_yr1(:,islope),tsoil_startpem(:,:,islope)) 268 call compute_tsoil_pem(ngrid,nsoil_PEM,.false.,TI_PEM(:,:,islope),timestep,tsurf_avg_yr2(:,islope),tsoil_startpem(:,:,islope)) 275 269 276 270 do iloop = nsoil_PCM + 1,nsoil_PEM 277 tsoil_PEM(:,iloop,islope) = tsoil_ tmp_yr2(:,iloop,islope)271 tsoil_PEM(:,iloop,islope) = tsoil_startpem(:,iloop,islope) 278 272 enddo 279 273 endif !found 280 274 281 do it = 1,timelen282 tsoil_inst(:,nsoil_PCM + 1:nsoil_PEM,islope,it) = tsoil_PEM(:,nsoil_PCM + 1:nsoil_PEM,islope)283 enddo284 275 do isoil = nsoil_PCM + 1,nsoil_PEM 285 276 watersoil_avg(:,isoil,islope) = exp(beta_clap_h2o/tsoil_PEM(:,isoil,islope) + alpha_clap_h2o)/tsoil_PEM(:,isoil,islope)*mmol(igcm_h2o_vap)/(mugaz*r) … … 296 287 write(*,*)'will reconstruct the values of the ice table given the current state' 297 288 call computeice_table_equilibrium(ngrid,nslope,nsoil_PEM,watercaptag,watersurf_avg,watersoil_avg,TI_PEM(:,1,:),icetable_depth,icetable_thickness) 298 call update_soil_thermalproperties(ngrid,nslope,nsoil_PEM,d_h2oice,h2o_ice, global_avg_pressure,icetable_depth,icetable_thickness,ice_porefilling,icetable_equilibrium,icetable_dynamic,TI_PEM)289 call update_soil_thermalproperties(ngrid,nslope,nsoil_PEM,d_h2oice,h2o_ice,ps_avg_global,icetable_depth,icetable_thickness,ice_porefilling,icetable_equilibrium,icetable_dynamic,TI_PEM) 299 290 do islope = 1,nslope 300 291 call ini_tsoil_pem(ngrid,nsoil_PEM,TI_PEM(:,:,islope),tsurf_avg_yr2(:,islope),tsoil_PEM(:,:,islope)) … … 309 300 write(*,*)'PEM settings: failed loading <icetable_depth>' 310 301 write(*,*)'will reconstruct the values of the ice table given the current state' 311 call update_soil_thermalproperties(ngrid,nslope,nsoil_PEM,d_h2oice,h2o_ice, global_avg_pressure,icetable_depth,icetable_thickness,ice_porefilling,icetable_equilibrium,icetable_dynamic,TI_PEM)302 call update_soil_thermalproperties(ngrid,nslope,nsoil_PEM,d_h2oice,h2o_ice,ps_avg_global,icetable_depth,icetable_thickness,ice_porefilling,icetable_equilibrium,icetable_dynamic,TI_PEM) 312 303 do islope = 1,nslope 313 304 call ini_tsoil_pem(ngrid,nsoil_PEM,TI_PEM(:,:,islope),tsurf_avg_yr2(:,islope),tsoil_PEM(:,:,islope)) … … 328 319 endif 329 320 enddo 330 do islope =1,nslope321 do islope = 1,nslope 331 322 write(num,fmt='(i2.2)') islope 332 323 call get_field("mh2o_reg_ads_slope"//num,m_h2o_regolith_phys(:,:,islope),found2) … … 337 328 enddo 338 329 339 call regolith_adsorption(ngrid,nslope,nsoil_PEM,timelen,d_h2oice,d_co2ice,h2o_ice,co2_ice,tsoil_PEM,TI_PEM,ps_ inst,q_co2,q_h2o, &340 m_h2o_regolith_phys,deltam_h2o_regolith_phys,m_co2_regolith_phys,deltam_co2_regolith_phys)330 call regolith_adsorption(ngrid,nslope,nsoil_PEM,timelen,d_h2oice,d_co2ice,h2o_ice,co2_ice,tsoil_PEM,TI_PEM,ps_timeseries,q_co2,q_h2o, & 331 m_h2o_regolith_phys,deltam_h2o_regolith_phys,m_co2_regolith_phys,deltam_co2_regolith_phys) 341 332 342 333 if (.not. found) deltam_co2_regolith_phys = 0. … … 441 432 442 433 ! First raw initialization 443 do it = 1,timelen444 do isoil = nsoil_PCM + 1,nsoil_PEM445 tsoil_inst(:,isoil,islope,it) = tsoil_PEM(:,isoil,islope)446 enddo447 enddo448 449 do it = 1,timelen450 do isoil = nsoil_PCM + 1,nsoil_PEM451 call ini_tsoil_pem(ngrid,nsoil_PEM,TI_PEM(:,:,islope),tsurf_avg_yr2(:,islope),tsoil_inst(:,:,islope,it))452 enddo453 enddo454 455 434 do isoil = nsoil_PCM + 1,nsoil_PEM 456 435 do ig = 1,ngrid … … 465 444 if (icetable_equilibrium) then 466 445 call computeice_table_equilibrium(ngrid,nslope,nsoil_PEM,watercaptag,watersurf_avg,watersoil_avg,TI_PEM(:,1,:),icetable_depth,icetable_thickness) 467 call update_soil_thermalproperties(ngrid,nslope,nsoil_PEM,d_h2oice,h2o_ice, global_avg_pressure,icetable_depth,icetable_thickness,ice_porefilling,icetable_equilibrium,icetable_dynamic,TI_PEM)446 call update_soil_thermalproperties(ngrid,nslope,nsoil_PEM,d_h2oice,h2o_ice,ps_avg_global,icetable_depth,icetable_thickness,ice_porefilling,icetable_equilibrium,icetable_dynamic,TI_PEM) 468 447 do islope = 1,nslope 469 448 call ini_tsoil_pem(ngrid,nsoil_PEM,TI_PEM(:,:,islope),tsurf_avg_yr2(:,islope),tsoil_PEM(:,:,islope)) … … 471 450 write(*,*) 'PEMETAT0: Ice table done' 472 451 else if (icetable_dynamic) then 473 call update_soil_thermalproperties(ngrid,nslope,nsoil_PEM,d_h2oice,h2o_ice, global_avg_pressure,icetable_depth,icetable_thickness,ice_porefilling,icetable_equilibrium,icetable_dynamic,TI_PEM)452 call update_soil_thermalproperties(ngrid,nslope,nsoil_PEM,d_h2oice,h2o_ice,ps_avg_global,icetable_depth,icetable_thickness,ice_porefilling,icetable_equilibrium,icetable_dynamic,TI_PEM) 474 453 do islope = 1,nslope 475 454 call ini_tsoil_pem(ngrid,nsoil_PEM,TI_PEM(:,:,islope),tsurf_avg_yr2(:,islope),tsoil_PEM(:,:,islope)) … … 483 462 m_co2_regolith_phys = 0. 484 463 m_h2o_regolith_phys = 0. 485 call regolith_adsorption(ngrid,nslope,nsoil_PEM,timelen,d_h2oice,d_co2ice,h2o_ice,co2_ice,tsoil_PEM,TI_PEM,ps_ inst,q_co2,q_h2o, &464 call regolith_adsorption(ngrid,nslope,nsoil_PEM,timelen,d_h2oice,d_co2ice,h2o_ice,co2_ice,tsoil_PEM,TI_PEM,ps_timeseries,q_co2,q_h2o, & 486 465 m_h2o_regolith_phys,deltam_h2o_regolith_phys, m_co2_regolith_phys,deltam_co2_regolith_phys) 487 466 deltam_co2_regolith_phys = 0. -
trunk/LMDZ.COMMON/libf/evolution/pemredem.F90
r3554 r3571 77 77 real, dimension(ngrid,nsoil_PEM,nslope), intent(in) :: tsoil_slope_PEM ! under mesh bining according to slope 78 78 real, dimension(ngrid,nsoil_PEM,nslope), intent(in) :: inertiesoil_slope_PEM ! under mesh bining according to slope 79 real, dimension(ngrid,nslope), intent(in) :: icetable_depth ! under mesh bining according to slope80 real, dimension(ngrid,nslope), intent(in) :: icetable_thickness ! under mesh bining according to slope79 real, dimension(ngrid,nslope), intent(in) :: icetable_depth ! under mesh bining according to slope 80 real, dimension(ngrid,nslope), intent(in) :: icetable_thickness ! under mesh bining according to slope 81 81 real, dimension(ngrid,nsoil_PEM,nslope), intent(in) :: ice_porefilling ! under mesh bining according to slope 82 82 real, dimension(ngrid,nsoil_PEM,nslope), intent(in) :: m_co2_regolith, m_h2o_regolith … … 119 119 call put_field("tsoil_PEM_slope"//num,"Soil temperature by slope type",tsoil_slope_PEM(:,:,islope),Year) 120 120 call put_field("TI_PEM_slope"//num,"Soil Thermal Inertia by slope type",inertiesoil_slope_PEM(:,:,islope),Year) 121 call put_field("mco2_reg_ads_slope"//num, "Mass of co2 adsorbed in the regolith",m_co2_regolith(:,:,islope),Year)122 call put_field("mh2o_reg_ads_slope"//num, "Mass of h2oadsorbed in the regolith",m_h2o_regolith(:,:,islope),Year)121 call put_field("mco2_reg_ads_slope"//num, "Mass of CO2 adsorbed in the regolith",m_co2_regolith(:,:,islope),Year) 122 call put_field("mh2o_reg_ads_slope"//num, "Mass of H2O adsorbed in the regolith",m_h2o_regolith(:,:,islope),Year) 123 123 enddo 124 124 call put_field("icetable_depth","Depth of ice table",icetable_depth,Year) -
trunk/LMDZ.COMMON/libf/evolution/read_data_PCM_mod.F90
r3367 r3571 15 15 !======================================================================= 16 16 17 SUBROUTINE read_data_PCM(filename,timelen,iim_input,jjm_input,ngrid,nslope,vmr_co2_PCM_phys,ps_timeseries, & 18 min_co2_ice,min_h2o_ice,tsurf_avg,tsoil_avg,tsurf_PCM,tsoil_PCM,q_co2,q_h2o, & 19 watersurf_density_avg,watersoil_density) 17 SUBROUTINE read_data_PCM(filename1,filename2,timelen,iim_input,jjm_input,ngrid,nslope,vmr_co2_PCM,ps_timeseries,ps_avg,tsurf_avg_yr1,tsurf_avg, & 18 tsoil_avg,tsoil_timeseries,min_co2_ice,min_h2o_ice,q_co2,q_h2o,watersurf_density_avg,watersoil_density_timeseries) 20 19 use comsoil_h, only: nsoilmx 21 20 use comsoil_h_PEM, only: soil_pem … … 34 33 35 34 !======================================================================= 36 ! Arguments:37 character(*), intent(in) :: filename ! File name38 integer, intent(in) :: timelen ! number of times stored in the file39 integer, intent(in) :: iim_input, jjm_input, ngrid, nslope ! number of points in the lat x lon dynamical grid, number of subgrid slopes35 ! Inputs: 36 character(*), intent(in) :: filename1, filename2 ! File names 37 integer, intent(in) :: timelen ! Number of times stored in the file 38 integer, intent(in) :: iim_input, jjm_input, ngrid, nslope ! Number of points in the lat x lon dynamical grid, number of subgrid slopes 40 39 ! Ouputs 41 real, dimension(ngrid,nslope), intent(out) :: min_co2_ice ! Minimum of co2 ice per slope of the year [kg/m^2] 42 real, dimension(ngrid,nslope), intent(out) :: min_h2o_ice ! Minimum of h2o ice per slope of the year [kg/m^2] 43 real, dimension(ngrid,timelen), intent(out) :: vmr_co2_PCM_phys ! Physics x Times co2 volume mixing ratio retrieve from the PCM [m^3/m^3] 44 real, dimension(ngrid,timelen), intent(out) :: ps_timeseries ! Surface Pressure [Pa] 45 real, dimension(ngrid,timelen), intent(out) :: q_co2 ! CO2 mass mixing ratio in the first layer [kg/m^3] 46 real, dimension(ngrid,timelen), intent(out) :: q_h2o ! H2O mass mixing ratio in the first layer [kg/m^3] 47 !SOIL 48 real, dimension(ngrid,nslope), intent(out) :: tsurf_avg ! Average surface temperature of the concatenated file [K] 49 real, dimension(ngrid,nsoilmx,nslope), intent(out) :: tsoil_avg ! Average soil temperature of the concatenated file [K] 50 real, dimension(ngrid,nslope,timelen), intent(out) :: tsurf_PCM ! Surface temperature of the concatenated file, time series [K] 51 real, dimension(ngrid,nsoilmx,nslope,timelen), intent(out) :: tsoil_PCM ! Soil temperature of the concatenated file, time series [K] 52 real, dimension(ngrid,nslope), intent(out) :: watersurf_density_avg ! Water density at the surface [kg/m^3] 53 real, dimension(ngrid,nsoilmx,nslope,timelen), intent(out) :: watersoil_density ! Water density in the soil layer, time series [kg/m^3] 54 !======================================================================= 55 ! Local Variables 56 integer :: i, j, l, t ! loop variables 57 real :: A, B, mmean ! Molar Mass of co2 and no co2, A;B intermediate variables to compute the mean molar mass of the layer 58 integer :: islope ! loop for variables 59 character(2) :: num ! for reading sloped variables 60 real, dimension(iim_input + 1,jjm_input + 1,nslope,timelen) :: h2o_ice_s_dyn ! h2o ice per slope of the concatenated file [kg/m^2] 40 real, dimension(ngrid,nslope,2), intent(out) :: min_co2_ice ! Minimum of co2 ice per slope of the year [kg/m^2] 41 real, dimension(ngrid,nslope,2), intent(out) :: min_h2o_ice ! Minimum of h2o ice per slope of the year [kg/m^2] 42 real, dimension(ngrid,timelen), intent(out) :: vmr_co2_PCM ! Grid points x Times co2 volume mixing ratio retrieve from the PCM [m^3/m^3] 43 real, dimension(ngrid,timelen), intent(out) :: q_co2 ! CO2 mass mixing ratio in the first layer [kg/m^3] 44 real, dimension(ngrid,timelen), intent(out) :: q_h2o ! H2O mass mixing ratio in the first layer [kg/m^3] 45 real, dimension(ngrid,timelen), intent(out) :: ps_timeseries ! Surface pressure timeseries [Pa] 46 real, dimension(ngrid), intent(out) :: ps_avg ! Averaged surface pressure [K] 47 real, dimension(ngrid,nslope), intent(out) :: tsurf_avg ! Averaged surface temperature [K] 48 real, dimension(ngrid,nslope), intent(out) :: tsurf_avg_yr1 ! Averaged surface temperature for year 1 [K] 49 real, dimension(ngrid,nsoilmx,nslope), intent(out) :: tsoil_avg ! Averaged soil temperature for year 2 [K] 50 real, dimension(ngrid,nsoilmx,nslope,timelen), intent(out) :: tsoil_timeseries ! Soil temperature timeseries [K] 51 real, dimension(ngrid,nslope), intent(out) :: watersurf_density_avg ! Water density at the surface [kg/m^3] 52 real, dimension(ngrid,nsoilmx,nslope,timelen), intent(out) :: watersoil_density_timeseries ! Water density timeseries in the soil layer [kg/m^3] 53 ! Local variables 54 integer :: i, j, l, t, islope ! Loop variables 55 real :: A, B, mmean ! Molar Mass of co2 and no co2, A;B intermediate variables to compute the mean molar mass of the layer 56 character(2) :: num ! Hor reading sloped variables 57 real, dimension(iim_input + 1,jjm_input + 1,nslope,timelen) :: h2o_ice_s_dyn ! H2O ice per slope of the concatenated file [kg/m^2] 61 58 real, dimension(iim_input + 1,jjm_input + 1,nslope,timelen) :: watercap 62 59 real, dimension(iim_input + 1,jjm_input + 1,nslope,timelen) :: perennial_co2ice 63 real, dimension(iim_input + 1,jjm_input + 1,timelen) :: vmr_co2_PCM ! CO2 volume mixing ratio in the first layer [mol/m^3] 64 real, dimension(iim_input + 1,jjm_input + 1,timelen) :: ps_PCM ! Surface Pressure [Pa] 60 real, dimension(iim_input + 1,jjm_input + 1,timelen) :: vmr_co2_dyn ! CO2 volume mixing ratio in the first layer [mol/m^3] 61 real, dimension(iim_input + 1,jjm_input + 1,timelen) :: ps_dyn ! Surface pressure [Pa] 62 real, dimension(iim_input + 1,jjm_input + 1) :: ps_avg_dyn ! Averaged surface pressure of the concatenated file [Pa] 65 63 real, dimension(iim_input + 1,jjm_input + 1,nslope) :: min_co2_ice_dyn 66 64 real, dimension(iim_input + 1,jjm_input + 1,nslope) :: min_h2o_ice_dyn 67 real, dimension(iim_input + 1,jjm_input + 1,nslope) :: tsurf_avg_dyn ! Average surface temperature of the concatenated file [K]68 real, dimension(iim_input + 1,jjm_input + 1,nsoilmx,nslope) :: tsoil_avg_dyn ! Average soil temperature of the concatenated file [K]69 real, dimension(iim_input + 1,jjm_input + 1,nslope,timelen) :: tsurf_ PCM_dyn! Surface temperature of the concatenated file, time series [K]70 real, dimension(iim_input + 1,jjm_input + 1,nsoilmx,nslope,timelen) :: tsoil_ PCM_dyn! Soil temperature of the concatenated file, time series [K]65 real, dimension(iim_input + 1,jjm_input + 1,nslope) :: tsurf_avg_dyn ! Averaged surface temperature of the concatenated file [K] 66 real, dimension(iim_input + 1,jjm_input + 1,nsoilmx,nslope) :: tsoil_avg_dyn ! Averaged soil temperature of the concatenated file [K] 67 real, dimension(iim_input + 1,jjm_input + 1,nslope,timelen) :: tsurf_dyn ! Surface temperature of the concatenated file, time series [K] 68 real, dimension(iim_input + 1,jjm_input + 1,nsoilmx,nslope,timelen) :: tsoil_dyn ! Soil temperature of the concatenated file, time series [K] 71 69 real, dimension(iim_input + 1,jjm_input + 1,timelen) :: q_co2_dyn ! CO2 mass mixing ratio in the first layer [kg/m^3] 72 70 real, dimension(iim_input + 1,jjm_input + 1,timelen) :: q_h2o_dyn ! H2O mass mixing ratio in the first layer [kg/m^3] … … 76 74 real, dimension(iim_input + 1,jjm_input + 1,nsoilmx,nslope,timelen) :: watersoil_density_dyn ! Water density in the soil layer, time series [kg/m^3] 77 75 !----------------------------------------------------------------------- 76 77 !------------------ Year 1 ------------------ 78 78 ! Open the NetCDF file 79 write(*,*) "Opening "//filename//"..." 80 call error_msg(NF90_OPEN(filename,NF90_NOWRITE,fID),"open",filename) 81 82 ! Download the data from the file 83 call get_var3("ps",ps_PCM) 84 write(*,*) "Data for surface pressure downloaded!" 85 86 call get_var3("co2_layer1",q_co2_dyn) 87 write(*,*) "Data for vmr co2 downloaded!" 88 89 call get_var3("h2o_layer1",q_h2o_dyn) 90 write(*,*) "Data for vmr h2o downloaded!" 91 79 write(*,*) "Opening "//filename1//"..." 80 call error_msg(NF90_OPEN(filename1,NF90_NOWRITE,fID),"open",filename1) 81 82 ! Compute averages over the year for each point 83 write(*,*) "Computing the average of tsurf..." 92 84 if (nslope == 1) then ! There is no slope 93 85 call get_var3("co2ice",co2_ice_slope_dyn(:,:,1,:)) … … 97 89 write(*,*) "Data for h2o_ice_s downloaded!" 98 90 99 call get_var3("tsurf",tsurf_ PCM_dyn(:,:,1,:))91 call get_var3("tsurf",tsurf_dyn(:,:,1,:)) 100 92 write(*,*) "Data for tsurf downloaded!" 101 93 … … 106 98 call get_var3("perennial_co2ice",perennial_co2ice(:,:,1,:)) 107 99 write(*,*) "Data for perennial_co2ice downloaded!" 108 109 if (soil_pem) then110 call get_var4("soiltemp",tsoil_PCM_dyn(:,:,:,1,:))111 write(*,*) "Data for soiltemp downloaded!"112 113 call get_var4("waterdensity_soil",watersoil_density_dyn(:,:,:,1,:))114 write(*,*) "Data for waterdensity_soil downloaded!"115 116 call get_var3("waterdensity_surface",watersurf_density_dyn(:,:,1,:))117 write(*,*) "Data for waterdensity_surface downloaded!"118 endif !soil_pem119 100 #endif 120 101 else ! We use slopes … … 133 114 do islope = 1,nslope 134 115 write(num,'(i2.2)') islope 135 call get_var3("tsurf_slope"//num,tsurf_ PCM_dyn(:,:,islope,:))116 call get_var3("tsurf_slope"//num,tsurf_dyn(:,:,islope,:)) 136 117 enddo 137 118 write(*,*) "Data for tsurf downloaded!" … … 149 130 enddo 150 131 write(*,*) "Data for perennial_co2ice downloaded!" 151 152 if (soil_pem) then153 do islope = 1,nslope154 write(num,'(i2.2)') islope155 call get_var4("soiltemp_slope"//num,tsoil_PCM_dyn(:,:,:,islope,:))156 enddo157 write(*,*) "Data for soiltemp downloaded!"158 159 do islope = 1,nslope160 write(num,'(i2.2)') islope161 call get_var4("waterdensity_soil_slope"//num,watersoil_density_dyn(:,:,:,islope,:))162 enddo163 write(*,*) "Data for waterdensity_soil downloaded!"164 165 do islope = 1,nslope166 write(num,'(i2.2)') islope167 call get_var3("waterdensity_surface"//num,watersurf_density_dyn(:,:,islope,:))168 enddo169 write(*,*) "Data for waterdensity_surface downloaded!"170 endif !soil_pem171 132 #endif 172 133 endif 173 134 174 135 ! Close the NetCDF file 175 write(*,*) "Closing "//filename //"..."176 call error_msg(nf90_close(fID),"close",filename )136 write(*,*) "Closing "//filename1//"..." 137 call error_msg(nf90_close(fID),"close",filename1) 177 138 178 139 ! Compute the minimum over the year for each point … … 186 147 ! Compute averages over the year for each point 187 148 write(*,*) "Computing the average of tsurf..." 188 tsurf_avg_dyn = sum(tsurf_PCM_dyn,4)/timelen 149 tsurf_avg_dyn = sum(tsurf_dyn,4)/timelen 150 151 #ifndef CPP_1D 152 call gr_dyn_fi(nslope,iim_input + 1,jjm_input + 1,ngrid,tsurf_avg_dyn,tsurf_avg) 153 do islope = 1,nslope 154 call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,min_co2_ice_dyn(:,:,islope),min_co2_ice(:,islope,1)) 155 call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,min_h2o_ice_dyn(:,:,islope),min_h2o_ice(:,islope,1)) 156 enddo 157 #else 158 tsurf_avg_yr1(1,:) = tsurf_avg_dyn(1,1,:) 159 min_co2_ice(1,:,1) = min_co2_ice_dyn(1,1,:) 160 min_h2o_ice(1,:,1) = min_h2o_ice_dyn(1,1,:) 161 #endif 162 write(*,*) "Downloading data Y1 done!" 163 164 !------------------ Year 2 ------------------ 165 166 ! Open the NetCDF file 167 write(*,*) "Opening "//filename2//"..." 168 call error_msg(NF90_OPEN(filename2,NF90_NOWRITE,fID),"open",filename2) 169 170 ! Download the data from the file 171 call get_var3("ps",ps_dyn) 172 write(*,*) "Data for surface pressure downloaded!" 173 174 call get_var3("co2_layer1",q_co2_dyn) 175 write(*,*) "Data for vmr co2 downloaded!" 176 177 call get_var3("h2o_layer1",q_h2o_dyn) 178 write(*,*) "Data for vmr h2o downloaded!" 179 180 if (nslope == 1) then ! There is no slope 181 call get_var3("co2ice",co2_ice_slope_dyn(:,:,1,:)) 182 write(*,*) "Data for co2_ice downloaded!" 183 184 call get_var3("h2o_ice_s",h2o_ice_s_dyn(:,:,1,:)) 185 write(*,*) "Data for h2o_ice_s downloaded!" 186 187 call get_var3("tsurf",tsurf_dyn(:,:,1,:)) 188 write(*,*) "Data for tsurf downloaded!" 189 190 #ifndef CPP_STD 191 call get_var3("watercap",watercap(:,:,1,:)) 192 write(*,*) "Data for watercap downloaded!" 193 194 call get_var3("perennial_co2ice",perennial_co2ice(:,:,1,:)) 195 write(*,*) "Data for perennial_co2ice downloaded!" 196 197 if (soil_pem) then 198 call get_var4("soiltemp",tsoil_dyn(:,:,:,1,:)) 199 write(*,*) "Data for soiltemp downloaded!" 200 201 call get_var4("waterdensity_soil",watersoil_density_dyn(:,:,:,1,:)) 202 write(*,*) "Data for waterdensity_soil downloaded!" 203 204 call get_var3("waterdensity_surface",watersurf_density_dyn(:,:,1,:)) 205 write(*,*) "Data for waterdensity_surface downloaded!" 206 endif !soil_pem 207 #endif 208 else ! We use slopes 209 do islope = 1,nslope 210 write(num,'(i2.2)') islope 211 call get_var3("co2ice_slope"//num,co2_ice_slope_dyn(:,:,islope,:)) 212 enddo 213 write(*,*) "Data for co2_ice downloaded!" 214 215 do islope = 1,nslope 216 write(num,'(i2.2)') islope 217 call get_var3("h2o_ice_s_slope"//num,h2o_ice_s_dyn(:,:,islope,:)) 218 enddo 219 write(*,*) "Data for h2o_ice_s downloaded!" 220 221 do islope = 1,nslope 222 write(num,'(i2.2)') islope 223 call get_var3("tsurf_slope"//num,tsurf_dyn(:,:,islope,:)) 224 enddo 225 write(*,*) "Data for tsurf downloaded!" 226 227 #ifndef CPP_STD 228 do islope = 1,nslope 229 write(num,'(i2.2)') islope 230 call get_var3("watercap_slope"//num,watercap(:,:,islope,:)) 231 enddo 232 write(*,*) "Data for watercap downloaded!" 233 234 do islope = 1,nslope 235 write(num,'(i2.2)') islope 236 call get_var3("perennial_co2ice_slope"//num,perennial_co2ice(:,:,islope,:)) 237 enddo 238 write(*,*) "Data for perennial_co2ice downloaded!" 239 240 if (soil_pem) then 241 do islope = 1,nslope 242 write(num,'(i2.2)') islope 243 call get_var4("soiltemp_slope"//num,tsoil_dyn(:,:,:,islope,:)) 244 enddo 245 write(*,*) "Data for soiltemp downloaded!" 246 247 do islope = 1,nslope 248 write(num,'(i2.2)') islope 249 call get_var4("waterdensity_soil_slope"//num,watersoil_density_dyn(:,:,:,islope,:)) 250 enddo 251 write(*,*) "Data for waterdensity_soil downloaded!" 252 253 do islope = 1,nslope 254 write(num,'(i2.2)') islope 255 call get_var3("waterdensity_surface"//num,watersurf_density_dyn(:,:,islope,:)) 256 enddo 257 write(*,*) "Data for waterdensity_surface downloaded!" 258 endif !soil_pem 259 #endif 260 endif 261 262 ! Close the NetCDF file 263 write(*,*) "Closing "//filename2//"..." 264 call error_msg(nf90_close(fID),"close",filename2) 265 266 ! Compute the minimum over the year for each point 267 write(*,*) "Computing the min of h2o_ice..." 268 where (h2o_ice_s_dyn < 0.) h2o_ice_s_dyn = 0. 269 min_h2o_ice_dyn = minval(h2o_ice_s_dyn + watercap,4) 270 write(*,*) "Computing the min of co2_ice..." 271 where (co2_ice_slope_dyn < 0.) co2_ice_slope_dyn = 0. 272 min_co2_ice_dyn = minval(co2_ice_slope_dyn + perennial_co2ice,4) 273 274 ! Compute averages over the year for each point 275 write(*,*) "Computing the average of tsurf..." 276 tsurf_avg_dyn = sum(tsurf_dyn,4)/timelen 277 278 write(*,*) "Computing the average of Ps..." 279 ps_avg_dyn = sum(ps_dyn,3)/timelen 189 280 190 281 if (soil_pem) then 191 write(*,*) "Computing average of tsoil..."192 tsoil_avg_dyn = sum(tsoil_ PCM_dyn,5)/timelen193 write(*,*) "Computing average of waterdensity_surface..."282 write(*,*) "Computing the average of tsoil..." 283 tsoil_avg_dyn = sum(tsoil_dyn,5)/timelen 284 write(*,*) "Computing the average of waterdensity_surface..." 194 285 watersurf_density_dyn_avg = sum(watersurf_density_dyn,4)/timelen 195 286 endif … … 212 303 endif 213 304 mmean = 1/(A*q_co2_dyn(i,j,t) + B) 214 vmr_co2_ PCM(i,j,t) = q_co2_dyn(i,j,t)*mmean/m_co2305 vmr_co2_dyn(i,j,t) = q_co2_dyn(i,j,t)*mmean/m_co2 215 306 enddo 216 307 enddo … … 218 309 219 310 #ifndef CPP_1D 220 call gr_dyn_fi(timelen,iim_input + 1,jjm_input + 1,ngrid,vmr_co2_PCM,vmr_co2_PCM_phys) 221 call gr_dyn_fi(timelen,iim_input + 1,jjm_input + 1,ngrid,ps_PCM,ps_timeseries) 311 call gr_dyn_fi(timelen,iim_input + 1,jjm_input + 1,ngrid,vmr_co2_dyn,vmr_co2_PCM) 312 call gr_dyn_fi(timelen,iim_input + 1,jjm_input + 1,ngrid,ps_dyn,ps_timeseries) 313 call gr_dyn_fi(timelen,iim_input + 1,jjm_input + 1,ngrid,ps_avg_dyn,ps_avg) 222 314 call gr_dyn_fi(timelen,iim_input + 1,jjm_input + 1,ngrid,q_co2_dyn,q_co2) 223 315 call gr_dyn_fi(timelen,iim_input + 1,jjm_input + 1,ngrid,q_h2o_dyn,q_h2o) 224 225 do islope = 1,nslope 226 call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,min_co2_ice_dyn(:,:,islope),min_co2_ice(:,islope)) 227 call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,min_h2o_ice_dyn(:,:,islope),min_h2o_ice(:,islope)) 316 do islope = 1,nslope 317 call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,min_co2_ice_dyn(:,:,islope),min_co2_ice(:,islope,2)) 318 call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,min_h2o_ice_dyn(:,:,islope),min_h2o_ice(:,islope,2)) 228 319 if (soil_pem) then 229 320 do l = 1,nsoilmx 230 321 call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,tsoil_avg_dyn(:,:,l,islope),tsoil_avg(:,l,islope)) 231 322 do t = 1,timelen 232 call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,tsoil_ PCM_dyn(:,:,l,islope,t),tsoil_PCM(:,l,islope,t))233 call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,watersoil_density_dyn(:,:,l,islope,t),watersoil_density (:,l,islope,t))323 call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,tsoil_dyn(:,:,l,islope,t),tsoil_timeseries(:,l,islope,t)) 324 call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,watersoil_density_dyn(:,:,l,islope,t),watersoil_density_timeseries(:,l,islope,t)) 234 325 enddo 235 326 enddo 236 327 call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,watersurf_density_dyn_avg(:,:,islope),watersurf_density_avg(:,islope)) 237 328 endif ! soil_pem 238 do t = 1,timelen 239 call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,tsurf_PCM_dyn(:,:,islope,t),tsurf_PCM(:,islope,t)) 240 enddo 241 enddo 242 329 enddo 243 330 call gr_dyn_fi(nslope,iim_input + 1,jjm_input + 1,ngrid,tsurf_avg_dyn,tsurf_avg) 244 331 #else 245 vmr_co2_PCM_phys(1,:) = vmr_co2_PCM(1,1,:) 246 ps_timeseries(1,:) = ps_PCM(1,1,:) 332 vmr_co2_PCM(1,:) = vmr_co2_dyn(1,1,:) 333 ps_timeseries(1,:) = ps_dyn(1,1,:) 334 ps_avg(1) = ps_avg_dyn(1,1) 247 335 q_co2(1,:) = q_co2_dyn(1,1,:) 248 336 q_h2o(1,:) = q_h2o_dyn(1,1,:) 249 min_co2_ice(1,: ) = min_co2_ice_dyn(1,1,:)250 min_h2o_ice(1,: ) = min_h2o_ice_dyn(1,1,:)337 min_co2_ice(1,:,2) = min_co2_ice_dyn(1,1,:) 338 min_h2o_ice(1,:,2) = min_h2o_ice_dyn(1,1,:) 251 339 if (soil_pem) then 340 tsoil_timeseries(1,:,:,:) = tsoil_dyn(1,1,:,:,:) 252 341 tsoil_avg(1,:,:) = tsoil_avg_dyn(1,1,:,:) 253 tsoil_PCM(1,:,:,:) = tsoil_PCM_dyn(1,1,:,:,:) 254 watersoil_density(1,:,:,:) = watersoil_density_dyn(1,1,:,:,:) 342 watersoil_density_timeseries(1,:,:,:) = watersoil_density_dyn(1,1,:,:,:) 255 343 watersurf_density_avg(1,:) = watersurf_density_dyn_avg(1,1,:) 256 344 endif ! soil_pem 257 tsurf_PCM(1,:,:) = tsurf_PCM_dyn(1,1,:,:)258 345 tsurf_avg(1,:) = tsurf_avg_dyn(1,1,:) 259 346 #endif 347 write(*,*) "Downloading data Y2 done!" 260 348 261 349 END SUBROUTINE read_data_PCM -
trunk/LMDZ.COMMON/libf/evolution/recomp_tend_co2_mod.F90
r3570 r3571 1 MODULE recomp_tend_co2_ slope_mod1 MODULE recomp_tend_co2_mod 2 2 3 3 implicit none … … 8 8 9 9 SUBROUTINE recomp_tend_co2(ngrid,nslope,timelen,d_co2ice_phys,d_co2ice_ini,co2ice,emissivity, & 10 vmr_co2_PCM,vmr_co2_PEM,ps_PCM _2,global_avg_press_PCM,global_avg_press_new)10 vmr_co2_PCM,vmr_co2_PEM,ps_PCM,ps_avg_global_ini,ps_avg_global) 11 11 12 12 use constants_marspem_mod, only : alpha_clap_co2, beta_clap_co2, sigmaB, Lco2, sols_per_my, sec_per_sol … … 20 20 !======================================================================= 21 21 22 ! arguments: 23 ! ---------- 24 ! INPUT 22 ! Inputs 23 ! ------ 25 24 integer, intent(in) :: timelen, ngrid, nslope 26 real, dimension(ngrid,timelen), intent(in) :: vmr_co2_PCM ! physical point field: Volume mixing ratio of co2 in the first layer 27 real, dimension(ngrid,timelen), intent(in) :: vmr_co2_PEM ! physical point field: Volume mixing ratio of co2 in the first layer 28 real, dimension(ngrid,timelen), intent(in) :: ps_PCM_2 ! physical point field: Surface pressure in the PCM 29 real, intent(in) :: global_avg_press_PCM ! global averaged pressure at previous timestep 30 real, intent(in) :: global_avg_press_new ! global averaged pressure at current timestep 31 real, dimension(ngrid,nslope), intent(in) :: d_co2ice_ini ! physical point field: Evolution of perennial ice over one year 32 real, dimension(ngrid,nslope), intent(in) :: co2ice ! CO2 ice per mesh and sub-grid slope (kg/m^2) 33 real, dimension(ngrid,nslope), intent(in) :: emissivity ! Emissivity per mesh and sub-grid slope(1) 34 ! OUTPUT 25 real, dimension(ngrid,timelen), intent(in) :: vmr_co2_PCM ! physical point field: Volume mixing ratio of co2 in the first layer 26 real, dimension(ngrid,timelen), intent(in) :: vmr_co2_PEM ! physical point field: Volume mixing ratio of co2 in the first layer 27 real, dimension(ngrid,timelen), intent(in) :: ps_PCM ! physical point field: Surface pressure in the PCM 28 real, intent(in) :: ps_avg_global_ini ! global averaged pressure at previous timestep 29 real, intent(in) :: ps_avg_global ! global averaged pressure at current timestep 30 real, dimension(ngrid,nslope), intent(in) :: d_co2ice_ini ! physical point field: Evolution of perennial ice over one year 31 real, dimension(ngrid,nslope), intent(in) :: co2ice ! CO2 ice per mesh and sub-grid slope (kg/m^2) 32 real, dimension(ngrid,nslope), intent(in) :: emissivity ! Emissivity per mesh and sub-grid slope(1) 33 ! Outputs 34 ! ------- 35 35 real, dimension(ngrid,nslope), intent(inout) :: d_co2ice_phys ! physical point field: Evolution of perennial ice over one year 36 36 37 ! local:38 ! 37 ! Local: 38 ! ------ 39 39 integer :: i, t, islope 40 real :: coef, av e40 real :: coef, avg 41 41 42 42 write(*,*) "Update of the CO2 tendency from the current pressure" … … 46 46 do islope = 1,nslope 47 47 coef = sols_per_my*sec_per_sol*emissivity(i,islope)*sigmaB/Lco2 48 av e= 0.48 avg = 0. 49 49 if (co2ice(i,islope) > 1.e-4 .and. abs(d_co2ice_phys(i,islope)) > 1.e-5) then 50 50 do t = 1,timelen 51 av e = ave + (beta_clap_co2/(alpha_clap_co2-log(vmr_co2_PCM(i,t)*ps_PCM_2(i,t)/100.)))**4 &52 - (beta_clap_co2/(alpha_clap_co2-log(vmr_co2_PEM(i,t)*ps_PCM _2(i,t)*(global_avg_press_new/global_avg_press_PCM)/100.)))**451 avg = avg + (beta_clap_co2/(alpha_clap_co2-log(vmr_co2_PCM(i,t)*ps_PCM(i,t)/100.)))**4 & 52 - (beta_clap_co2/(alpha_clap_co2-log(vmr_co2_PEM(i,t)*ps_PCM(i,t)*(ps_avg_global/ps_avg_global_ini)/100.)))**4 53 53 enddo 54 if (av e < 1.e-4) ave= 0.55 d_co2ice_phys(i,islope) = d_co2ice_ini(i,islope) - coef*av e/timelen54 if (avg < 1.e-4) avg = 0. 55 d_co2ice_phys(i,islope) = d_co2ice_ini(i,islope) - coef*avg/timelen 56 56 endif 57 57 enddo … … 59 59 60 60 END SUBROUTINE recomp_tend_co2 61 !======================================================================= 61 62 62 END MODULE recomp_tend_co2_slope_mod 63 SUBROUTINE recomp_tend_h2o(ngrid,nslope,timelen,d_h2oice,PCM_temp,PEM_temp) 64 65 implicit none 66 67 !======================================================================= 68 ! 69 ! Routine that compute the evolution of the tendencie for h2o ice 70 ! 71 !======================================================================= 72 73 ! Inputs 74 ! ------ 75 integer, intent(in) :: timelen, ngrid, nslope 76 real, dimension(:), intent(in) :: PCM_temp, PEM_temp 77 ! Outputs 78 ! ------- 79 real, dimension(ngrid,nslope), intent(inout) :: d_h2oice ! physical point field: Evolution of perennial ice over one year 80 81 ! Local: 82 ! ------ 83 84 write(*,*) "Update of the H2O tendency due to lag layer" 85 86 ! Flux correction due to lag layer 87 !~ Rz_old = h2oice_depth_old*0.0325/4.e-4 ! resistance from PCM 88 !~ Rz_new = h2oice_depth_new*0.0325/4.e-4 ! new resistance based on new depth 89 !~ R_dec = (1./Rz_old)/(1./Rz_new) ! decrease because of resistance 90 !~ soil_psv_old = psv(max(PCM_temp(h2oice_depth_old))) ! the maxmimum annual mean saturation vapor pressure at the temperature of the GCM run temperature at the old ice location 91 !~ soil_psv_new = psv(max(PEM_temp(h2oice_depth_new))) ! the maxmimum annual mean saturation vapor pressure at the temperature of the PEM run temperature at the new ice location 92 !~ hum_dec = soil_psv_old/soil_psv_new ! decrease because of lower water vapor pressure at the new depth 93 !~ d_h2oice = d_h2oice*R_dec*hum_dec ! decrease of flux 94 95 END SUBROUTINE recomp_tend_h2o 96 97 END MODULE recomp_tend_co2_mod -
trunk/LMDZ.COMMON/libf/evolution/stopping_crit_mod.F90
r3432 r3571 14 14 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 15 15 16 SUBROUTINE stopping_crit_h2o_ice(cell_area,h2oice_ini_surf,i ni_h2oice_sublim,h2o_ice,stopPEM,ngrid)16 SUBROUTINE stopping_crit_h2o_ice(cell_area,h2oice_ini_surf,is_h2oice_sublim_ini,h2o_ice,stopPEM,ngrid) 17 17 18 18 use time_evol_mod, only: h2o_ice_crit … … 28 28 ! Inputs 29 29 !------- 30 integer, intent(in) :: ngrid ! # of physical grid points31 real, dimension(ngrid), intent(in) :: cell_area ! Area of the cells32 real, dimension(ngrid,nslope), intent(in) :: h2o_ice ! Actual density of h2o ice33 real, intent(in) :: h2oice_ini_surf ! Initial surface of sublimating h2o ice34 logical, dimension(ngrid,nslope), intent(in) :: i ni_h2oice_sublim! Grid points where h2o ice was initially sublimating30 integer, intent(in) :: ngrid ! # of physical grid points 31 real, dimension(ngrid), intent(in) :: cell_area ! Area of the cells 32 real, dimension(ngrid,nslope), intent(in) :: h2o_ice ! Actual density of h2o ice 33 real, intent(in) :: h2oice_ini_surf ! Initial surface of sublimating h2o ice 34 logical, dimension(ngrid,nslope), intent(in) :: is_h2oice_sublim_ini ! Grid points where h2o ice was initially sublimating 35 35 ! Outputs 36 36 !-------- … … 48 48 do i = 1,ngrid 49 49 do islope = 1,nslope 50 if (i ni_h2oice_sublim(i,islope) .and. h2o_ice(i,islope) > 0.) h2oice_now_surf = h2oice_now_surf + cell_area(i)*subslope_dist(i,islope)50 if (is_h2oice_sublim_ini(i,islope) .and. h2o_ice(i,islope) > 0.) h2oice_now_surf = h2oice_now_surf + cell_area(i)*subslope_dist(i,islope) 51 51 enddo 52 52 enddo … … 75 75 !======================================================================= 76 76 77 SUBROUTINE stopping_crit_co2(cell_area,co2ice_ ini_surf,ini_co2ice_sublim,co2_ice,stopPEM,ngrid,global_avg_press_PCM,global_avg_press_new,nslope)77 SUBROUTINE stopping_crit_co2(cell_area,co2ice_sublim_surf_ini,is_co2ice_sublim_ini,co2_ice,stopPEM,ngrid,ps_avg_global_ini,ps_avg_global,nslope) 78 78 79 79 use time_evol_mod, only: co2_ice_crit, ps_criterion … … 89 89 ! Inputs 90 90 !------- 91 integer, intent(in) :: ngrid, nslope ! # of grid physical grid points92 real, dimension(ngrid), intent(in) :: cell_area ! Area of the cells93 real, dimension(ngrid,nslope), intent(in) :: co2_ice ! Actual density of co2 ice94 real, intent(in) :: co2ice_ ini_surf! Initial surface of sublimatingco2 ice95 logical, dimension(ngrid,nslope), intent(in) :: i ni_co2ice_sublim! Grid points where co2 ice was initially sublimating96 real, intent(in) :: global_avg_press_PCM! Planet average pressure from the PCM start files97 real, intent(in) :: global_avg_press_new! Planet average pressure from the PEM computations91 integer, intent(in) :: ngrid, nslope ! # of grid physical grid points 92 real, dimension(ngrid), intent(in) :: cell_area ! Area of the cells 93 real, dimension(ngrid,nslope), intent(in) :: co2_ice ! Actual density of co2 ice 94 real, intent(in) :: co2ice_sublim_surf_ini ! Initial surface of sublimatingco2 ice 95 logical, dimension(ngrid,nslope), intent(in) :: is_co2ice_sublim_ini ! Grid points where co2 ice was initially sublimating 96 real, intent(in) :: ps_avg_global_ini ! Planet average pressure from the PCM start files 97 real, intent(in) :: ps_avg_global ! Planet average pressure from the PEM computations 98 98 ! Outputs 99 99 !-------- … … 112 112 do i = 1,ngrid 113 113 do islope = 1,nslope 114 if (i ni_co2ice_sublim(i,islope) .and. co2_ice(i,islope) > 0.) co2ice_now_surf = co2ice_now_surf + cell_area(i)*subslope_dist(i,islope)114 if (is_co2ice_sublim_ini(i,islope) .and. co2_ice(i,islope) > 0.) co2ice_now_surf = co2ice_now_surf + cell_area(i)*subslope_dist(i,islope) 115 115 enddo 116 116 enddo 117 117 118 118 ! Check of the criterion 119 if (co2ice_now_surf < co2ice_ ini_surf*(1. - co2_ice_crit)) then119 if (co2ice_now_surf < co2ice_sublim_surf_ini*(1. - co2_ice_crit)) then 120 120 stopPEM = 3 121 121 write(*,*) "Reason of stopping: the surface of co2 ice sublimating reaches the threshold" 122 write(*,*) "co2ice_now_surf < co2ice_ ini_surf*(1. - co2_ice_crit)", co2ice_now_surf < co2ice_ini_surf*(1. - co2_ice_crit)123 write(*,*) "Initial surface of co2 ice sublimating =", co2ice_ ini_surf122 write(*,*) "co2ice_now_surf < co2ice_sublim_surf_ini*(1. - co2_ice_crit)", co2ice_now_surf < co2ice_sublim_surf_ini*(1. - co2_ice_crit) 123 write(*,*) "Initial surface of co2 ice sublimating =", co2ice_sublim_surf_ini 124 124 write(*,*) "Current surface of co2 ice sublimating =", co2ice_now_surf 125 125 write(*,*) "Percentage of change accepted =", co2_ice_crit*100. 126 else if (co2ice_now_surf > co2ice_ ini_surf*(1. + co2_ice_crit)) then126 else if (co2ice_now_surf > co2ice_sublim_surf_ini*(1. + co2_ice_crit)) then 127 127 stopPEM = 3 128 128 write(*,*) "Reason of stopping: the surface of co2 ice sublimating reaches the threshold" 129 write(*,*) "co2ice_now_surf > co2ice_ ini_surf*(1. + co2_ice_crit)", co2ice_now_surf > co2ice_ini_surf*(1. + co2_ice_crit)129 write(*,*) "co2ice_now_surf > co2ice_sublim_surf_ini*(1. + co2_ice_crit)", co2ice_now_surf > co2ice_sublim_surf_ini*(1. + co2_ice_crit) 130 130 write(*,*) "Current surface of co2 ice sublimating =", co2ice_now_surf 131 write(*,*) "Initial surface of co2 ice sublimating =", co2ice_ ini_surf131 write(*,*) "Initial surface of co2 ice sublimating =", co2ice_sublim_surf_ini 132 132 write(*,*) "Percentage of change accepted =", co2_ice_crit*100. 133 133 endif 134 134 135 if (abs(co2ice_ ini_surf) < 1.e-5) stopPEM = 0135 if (abs(co2ice_sublim_surf_ini) < 1.e-5) stopPEM = 0 136 136 137 if ( global_avg_press_new < global_avg_press_PCM*(1. - ps_criterion)) then137 if (ps_avg_global < ps_avg_global_ini*(1. - ps_criterion)) then 138 138 stopPEM = 4 139 139 write(*,*) "Reason of stopping: the global pressure reaches the threshold" 140 write(*,*) " global_avg_press_new < global_avg_press_PCM*(1. - ps_criterion)", global_avg_press_new < global_avg_press_PCM*(1. - ps_criterion)141 write(*,*) "Initial global pressure =", global_avg_press_PCM142 write(*,*) "Current global pressure =", global_avg_press_new140 write(*,*) "ps_avg_global < ps_avg_global_ini*(1. - ps_criterion)", ps_avg_global < ps_avg_global_ini*(1. - ps_criterion) 141 write(*,*) "Initial global pressure =", ps_avg_global_ini 142 write(*,*) "Current global pressure =", ps_avg_global 143 143 write(*,*) "Percentage of change accepted =", ps_criterion*100. 144 else if ( global_avg_press_new > global_avg_press_PCM*(1. + ps_criterion)) then144 else if (ps_avg_global > ps_avg_global_ini*(1. + ps_criterion)) then 145 145 stopPEM = 4 146 146 write(*,*) "Reason of stopping: the global pressure reaches the threshold" 147 write(*,*) " global_avg_press_new > global_avg_press_PCM*(1. + ps_criterion)", global_avg_press_new > global_avg_press_PCM*(1. + ps_criterion)148 write(*,*) "Initial global pressure =", global_avg_press_PCM149 write(*,*) "Current global pressure =", global_avg_press_new147 write(*,*) "ps_avg_global > ps_avg_global_ini*(1. + ps_criterion)", ps_avg_global > ps_avg_global_ini*(1. + ps_criterion) 148 write(*,*) "Initial global pressure =", ps_avg_global_ini 149 write(*,*) "Current global pressure =", ps_avg_global 150 150 write(*,*) "Percentage of change accepted =", ps_criterion*100. 151 151 endif
Note: See TracChangeset
for help on using the changeset viewer.