[3076] | 1 | MODULE pemetat0_mod |
---|
[3019] | 2 | |
---|
[3076] | 3 | implicit none |
---|
| 4 | |
---|
| 5 | !======================================================================= |
---|
| 6 | contains |
---|
| 7 | !======================================================================= |
---|
| 8 | |
---|
[3537] | 9 | SUBROUTINE pemetat0(filename,ngrid,nsoil_PCM,nsoil_PEM,nslope,timelen,timestep,TI_PEM,tsoil_PEM,icetable_depth,icetable_thickness, & |
---|
[3525] | 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, & |
---|
[3297] | 12 | m_h2o_regolith_phys,deltam_h2o_regolith_phys,stratif) |
---|
[3076] | 13 | |
---|
[3297] | 14 | use iostart_PEM, only: open_startphy, close_startphy, get_field, get_var, inquire_dimension, inquire_dimension_length |
---|
[3161] | 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_bedrock |
---|
[3149] | 16 | use comsoil_h, only: volcapa, inertiedat |
---|
[3076] | 17 | use adsorption_mod, only: regolith_adsorption, adsorption_pem |
---|
[3537] | 18 | use ice_table_mod, only: computeice_table_equilibrium, icetable_equilibrium, icetable_dynamic |
---|
[3076] | 19 | use constants_marspem_mod, only: alpha_clap_h2o, beta_clap_h2o, TI_breccia, TI_bedrock |
---|
| 20 | use soil_thermalproperties_mod, only: update_soil_thermalproperties |
---|
| 21 | use tracer_mod, only: mmol, igcm_h2o_vap ! tracer names and molar masses |
---|
| 22 | use abort_pem_mod, only: abort_pem |
---|
[3178] | 23 | use compute_soiltemp_mod, only: ini_tsoil_pem, compute_tsoil_pem |
---|
[3161] | 24 | use comslope_mod, only: def_slope_mean, subslope_dist |
---|
[3319] | 25 | use layering_mod, only: layering, array2stratif, nb_str_max, layering_algo |
---|
[3076] | 26 | |
---|
[3019] | 27 | #ifndef CPP_STD |
---|
[3161] | 28 | use comcstfi_h, only: r, mugaz, pi |
---|
| 29 | use surfdat_h, only: watercaptag, watercap, perennial_co2ice |
---|
[3019] | 30 | #else |
---|
[3161] | 31 | use comcstfi_mod, only: r, mugaz, pi |
---|
[3019] | 32 | #endif |
---|
| 33 | |
---|
[3076] | 34 | implicit none |
---|
[3019] | 35 | |
---|
[3076] | 36 | include "callkeys.h" |
---|
[2835] | 37 | |
---|
[3297] | 38 | character(*), intent(in) :: filename ! name of the startfi_PEM.nc |
---|
[3076] | 39 | integer, intent(in) :: ngrid ! # of physical grid points |
---|
[3149] | 40 | integer, intent(in) :: nsoil_PCM ! # of vertical grid points in the PCM |
---|
[3076] | 41 | integer, intent(in) :: nsoil_PEM ! # of vertical grid points in the PEM |
---|
| 42 | integer, intent(in) :: nslope ! # of sub-grid slopes |
---|
| 43 | integer, intent(in) :: timelen ! # time samples |
---|
| 44 | real, intent(in) :: timestep ! time step [s] |
---|
[3149] | 45 | real, intent(in) :: global_avg_pressure ! mean average pressure on the planet [Pa] |
---|
| 46 | real, dimension(ngrid,nslope), intent(in) :: tsurf_avg_yr1 ! surface temperature at the first year of PCM call [K] |
---|
[3532] | 47 | real, dimension(ngrid,nslope), intent(in) :: tsurf_avg_yr2 ! surface temperature at the second year of PCM call [K] |
---|
[3076] | 48 | real, dimension(ngrid,timelen), intent(in) :: q_co2 ! MMR tracer co2 [kg/kg] |
---|
| 49 | real, dimension(ngrid,timelen), intent(in) :: q_h2o ! MMR tracer h2o [kg/kg] |
---|
| 50 | real, dimension(ngrid,timelen), intent(in) :: ps_inst ! surface pressure [Pa] |
---|
[3498] | 51 | real, dimension(ngrid,nslope), intent(in) :: d_h2oice ! tendencies on h2o ice |
---|
| 52 | real, dimension(ngrid,nslope), intent(in) :: d_co2ice ! tendencies on co2 ice |
---|
[3149] | 53 | real, dimension(ngrid,nslope), intent(in) :: watersurf_avg ! surface water ice density, yearly averaged (kg/m^3) |
---|
[2794] | 54 | ! outputs |
---|
[3076] | 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] |
---|
[3149] | 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] |
---|
[3297] | 59 | type(layering), dimension(ngrid,nslope), intent(inout) :: stratif ! stratification (layerings) |
---|
[3076] | 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] |
---|
[3537] | 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] |
---|
[3493] | 64 | real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: ice_porefilling ! Subsurface ice pore filling [m3/m3] |
---|
[3076] | 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] |
---|
[3149] | 68 | real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: watersoil_avg ! surface water ice density, yearly averaged (kg/m^3) |
---|
[2794] | 69 | ! local |
---|
[3297] | 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) |
---|
[2835] | 81 | |
---|
[3076] | 82 | #ifdef CPP_STD |
---|
[3149] | 83 | logical, dimension(ngrid) :: watercaptag |
---|
[3159] | 84 | watercaptag = .false. |
---|
[2985] | 85 | #endif |
---|
| 86 | |
---|
[2794] | 87 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 88 | !!! |
---|
| 89 | !!! Purpose: read start_pem. Need a specific iostart_PEM |
---|
| 90 | !!! |
---|
[2888] | 91 | !!! Order: 0. Previous year of the PEM run |
---|
[3149] | 92 | !!! Ice initialization |
---|
[3076] | 93 | !!! 1. Thermal Inertia |
---|
[2888] | 94 | !!! 2. Soil Temperature |
---|
| 95 | !!! 3. Ice table |
---|
| 96 | !!! 4. Mass of CO2 & H2O adsorbed |
---|
[2794] | 97 | !!! |
---|
| 98 | !!! /!\ This order must be respected ! |
---|
| 99 | !!! Author: LL |
---|
| 100 | !!! |
---|
| 101 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
[2779] | 102 | |
---|
[3170] | 103 | !0.1 Check if the start_PEM exist. |
---|
[2863] | 104 | |
---|
[3143] | 105 | inquire(file = filename,exist = startpem_file) |
---|
[2863] | 106 | |
---|
[3498] | 107 | write(*,*)'Is there a "startpem" file?',startpem_file |
---|
[2863] | 108 | |
---|
[3170] | 109 | !0.2 Set to default values |
---|
[3537] | 110 | icetable_depth = -1. ! by default, no ice table |
---|
| 111 | icetable_thickness = -1. |
---|
| 112 | ice_porefilling = 0. |
---|
[2794] | 113 | !1. Run |
---|
| 114 | if (startpem_file) then |
---|
[3214] | 115 | write(*,*)'There is a "startpem.nc"!' |
---|
[3076] | 116 | ! open pem initial state file: |
---|
| 117 | call open_startphy(filename) |
---|
[2835] | 118 | |
---|
[3149] | 119 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
[3430] | 120 | #ifndef CPP_STD |
---|
| 121 | ! h2o ice |
---|
| 122 | h2o_ice = 0. |
---|
| 123 | call get_field("h2o_ice",h2o_ice,found) |
---|
| 124 | if (.not. found) then |
---|
| 125 | write(*,*)'Pemetat0: failed loading <h2o_ice>' |
---|
| 126 | write(*,*)'will reconstruct the values from watercaptag' |
---|
| 127 | write(*,*)'with default value ''ini_huge_h2oice''' |
---|
| 128 | do ig = 1,ngrid |
---|
| 129 | if (watercaptag(ig)) h2o_ice(ig,:) = ini_huge_h2oice |
---|
| 130 | enddo |
---|
| 131 | else |
---|
| 132 | ! The variations of infinite reservoirs during the PCM years are taken into account |
---|
| 133 | h2o_ice = h2o_ice + watercap |
---|
| 134 | endif |
---|
| 135 | |
---|
| 136 | ! co2 ice |
---|
| 137 | co2_ice = perennial_co2ice |
---|
| 138 | #endif |
---|
| 139 | |
---|
| 140 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
[3297] | 141 | ! Stratification (layerings) |
---|
[3430] | 142 | nb_str_max = 1 |
---|
[3319] | 143 | if (layering_algo) then |
---|
| 144 | found = inquire_dimension("nb_str_max") |
---|
| 145 | if (.not. found) then |
---|
| 146 | write(*,*) 'Pemetat0: failed loading <nb_str_max>!' |
---|
| 147 | write(*,*) '''nb_str_max'' is set to 3!' |
---|
| 148 | else |
---|
| 149 | nb_str_max = int(inquire_dimension_length('nb_str_max')) |
---|
| 150 | endif |
---|
| 151 | allocate(stratif_array(ngrid,nslope,nb_str_max,6)) |
---|
| 152 | stratif_array = 0. |
---|
| 153 | do islope = 1,nslope |
---|
| 154 | write(num,'(i2.2)') islope |
---|
| 155 | call get_field('stratif_slope'//num//'_thickness',stratif_array(:,islope,:,1),found) |
---|
| 156 | call get_field('stratif_slope'//num//'_top_elevation',stratif_array(:,islope,:,2),found2) |
---|
| 157 | found = found .or. found2 |
---|
| 158 | call get_field('stratif_slope'//num//'_co2ice_volfrac',stratif_array(:,islope,:,3),found2) |
---|
| 159 | found = found .or. found2 |
---|
| 160 | call get_field('stratif_slope'//num//'_h2oice_volfrac',stratif_array(:,islope,:,4),found2) |
---|
| 161 | found = found .or. found2 |
---|
| 162 | call get_field('stratif_slope'//num//'_dust_volfrac',stratif_array(:,islope,:,5),found2) |
---|
| 163 | found = found .or. found2 |
---|
| 164 | call get_field('stratif_slope'//num//'_air_volfrac',stratif_array(:,islope,:,6),found2) |
---|
| 165 | found = found .or. found2 |
---|
| 166 | if (.not. found) then |
---|
| 167 | write(*,*) 'Pemetat0: failed loading at least one of the properties of <stratif_slope'//num//'>' |
---|
| 168 | endif ! not found |
---|
| 169 | enddo ! islope |
---|
| 170 | call array2stratif(stratif_array,ngrid,nslope,stratif) |
---|
| 171 | deallocate(stratif_array) |
---|
[3297] | 172 | endif |
---|
| 173 | |
---|
[3039] | 174 | if (soil_pem) then |
---|
[3076] | 175 | |
---|
[3149] | 176 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
[2794] | 177 | !1. Thermal Inertia |
---|
| 178 | ! a. General case |
---|
[3149] | 179 | do islope = 1,nslope |
---|
| 180 | write(num,'(i2.2)') islope |
---|
| 181 | call get_field("TI_PEM_slope"//num,TI_startPEM(:,:,islope),found) |
---|
| 182 | if (.not. found) then |
---|
| 183 | write(*,*)'PEM settings: failed loading < TI_PEM_slope'//num//'>' |
---|
| 184 | write(*,*)'will reconstruct the values of TI_PEM' |
---|
[2779] | 185 | |
---|
[3149] | 186 | do ig = 1,ngrid |
---|
| 187 | if (TI_PEM(ig,index_breccia,islope) < TI_breccia) then |
---|
| 188 | !!! transition |
---|
| 189 | delta = depth_breccia |
---|
[3430] | 190 | TI_PEM(ig,index_breccia + 1,islope) = sqrt((layer_PEM(index_breccia + 1) - layer_PEM(index_breccia))/ & |
---|
| 191 | (((delta - layer_PEM(index_breccia))/(TI_PEM(ig,index_breccia,islope)**2)) + & |
---|
| 192 | ((layer_PEM(index_breccia + 1) - delta)/(TI_breccia**2)))) |
---|
| 193 | do iloop=index_breccia + 2,index_bedrock |
---|
[3149] | 194 | TI_PEM(ig,iloop,islope) = TI_breccia |
---|
| 195 | enddo |
---|
[3159] | 196 | else ! we keep the high TI values |
---|
[3149] | 197 | do iloop = index_breccia + 1,index_bedrock |
---|
| 198 | TI_PEM(ig,iloop,islope) = TI_PEM(ig,index_breccia,islope) |
---|
| 199 | enddo |
---|
| 200 | endif ! TI PEM and breccia comparison |
---|
| 201 | !! transition |
---|
| 202 | delta = depth_bedrock |
---|
| 203 | TI_PEM(ig,index_bedrock + 1,islope) = sqrt((layer_PEM(index_bedrock + 1) - layer_PEM(index_bedrock))/ & |
---|
| 204 | (((delta - layer_PEM(index_bedrock))/(TI_PEM(ig,index_bedrock,islope)**2)) + & |
---|
| 205 | ((layer_PEM(index_bedrock + 1) - delta)/(TI_bedrock**2)))) |
---|
| 206 | do iloop = index_bedrock + 2,nsoil_PEM |
---|
| 207 | TI_PEM(ig,iloop,islope) = TI_bedrock |
---|
[3076] | 208 | enddo |
---|
| 209 | enddo |
---|
[3149] | 210 | else ! found |
---|
| 211 | 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. |
---|
| 213 | enddo |
---|
| 214 | endif ! not found |
---|
| 215 | enddo ! islope |
---|
[2779] | 216 | |
---|
[3149] | 217 | write(*,*) 'PEMETAT0: THERMAL INERTIA done' |
---|
[2779] | 218 | |
---|
[2794] | 219 | ! b. Special case for inertiedat, inertiedat_PEM |
---|
[3149] | 220 | call get_field("inertiedat_PEM",inertiedat_PEM,found) |
---|
[3456] | 221 | if (.not. found) then |
---|
[3149] | 222 | do iloop = 1,nsoil_PCM |
---|
| 223 | inertiedat_PEM(:,iloop) = inertiedat(:,iloop) |
---|
| 224 | enddo |
---|
| 225 | !!! zone de transition |
---|
| 226 | delta = depth_breccia |
---|
| 227 | do ig = 1,ngrid |
---|
[3430] | 228 | if (inertiedat_PEM(ig,index_breccia) < TI_breccia) then |
---|
[3493] | 229 | inertiedat_PEM(ig,index_breccia + 1) = sqrt((layer_PEM(index_breccia+1)-layer_PEM(index_breccia))/ & |
---|
| 230 | (((delta-layer_PEM(index_breccia))/(inertiedat(ig,index_breccia)**2)) + & |
---|
[3149] | 231 | ((layer_PEM(index_breccia+1)-delta)/(TI_breccia**2)))) |
---|
[2779] | 232 | |
---|
[3430] | 233 | do iloop = index_breccia + 2,index_bedrock |
---|
[3149] | 234 | inertiedat_PEM(ig,iloop) = TI_breccia |
---|
| 235 | enddo |
---|
| 236 | else |
---|
[3430] | 237 | do iloop=index_breccia + 1,index_bedrock |
---|
[3149] | 238 | inertiedat_PEM(ig,iloop) = inertiedat_PEM(ig,nsoil_PCM) |
---|
| 239 | enddo |
---|
| 240 | endif ! comparison ti breccia |
---|
| 241 | enddo ! ig |
---|
[2779] | 242 | |
---|
[3149] | 243 | !!! zone de transition |
---|
| 244 | delta = depth_bedrock |
---|
| 245 | do ig = 1,ngrid |
---|
[3430] | 246 | inertiedat_PEM(ig,index_bedrock + 1) = sqrt((layer_PEM(index_bedrock+1)-layer_PEM(index_bedrock))/ & |
---|
| 247 | (((delta-layer_PEM(index_bedrock))/(inertiedat_PEM(ig,index_bedrock)**2))+ & |
---|
| 248 | ((layer_PEM(index_bedrock+1)-delta)/(TI_bedrock**2)))) |
---|
[3149] | 249 | enddo |
---|
[2779] | 250 | |
---|
[3149] | 251 | do iloop = index_bedrock + 2, nsoil_PEM |
---|
| 252 | do ig = 1,ngrid |
---|
| 253 | inertiedat_PEM(ig,iloop) = TI_bedrock |
---|
| 254 | enddo |
---|
| 255 | enddo |
---|
| 256 | endif ! not found |
---|
[2779] | 257 | |
---|
[3076] | 258 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
[2794] | 259 | !2. Soil Temperature |
---|
[3149] | 260 | do islope=1,nslope |
---|
| 261 | write(num,fmt='(i2.2)') islope |
---|
| 262 | call get_field("tsoil_PEM_slope"//num,tsoil_startPEM(:,:,islope),found) |
---|
[3456] | 263 | if (.not. found) then |
---|
[3149] | 264 | write(*,*)'PEM settings: failed loading <tsoil_PEM_slope'//num//'>' |
---|
| 265 | write(*,*)'will reconstruct the values of Tsoil' |
---|
| 266 | ! do ig = 1,ngrid |
---|
| 267 | ! kcond = (TI_PEM(ig,index_breccia+1,islope)*TI_PEM(ig,index_breccia+1,islope))/volcapa |
---|
| 268 | ! tsoil_PEM(ig,index_breccia+1,islope) = tsoil_PEM(ig,index_breccia,islope) + fluxgeo/kcond*(mlayer_PEM(index_breccia)-mlayer_PEM(index_breccia-1)) |
---|
| 269 | ! do iloop=index_breccia+2,index_bedrock |
---|
| 270 | ! kcond = (TI_PEM(ig,iloop,islope)*TI_PEM(ig,iloop,islope))/volcapa |
---|
| 271 | ! tsoil_PEM(ig,iloop,islope) = tsoil_PEM(ig,index_breccia+1,islope) + fluxgeo/kcond*(mlayer_PEM(iloop-1)-mlayer_PEM(index_breccia)) |
---|
| 272 | ! enddo |
---|
| 273 | ! kcond = (TI_PEM(ig,index_bedrock+1,islope)*TI_PEM(ig,index_bedrock+1,islope))/volcapa |
---|
| 274 | ! tsoil_PEM(ig,index_bedrock+1,islope) = tsoil_PEM(ig,index_bedrock,islope) + fluxgeo/kcond*(mlayer_PEM(index_bedrock)-mlayer_PEM(index_bedrock-1)) |
---|
[2895] | 275 | ! |
---|
[3149] | 276 | ! do iloop=index_bedrock+2,nsoil_PEM |
---|
| 277 | ! kcond = (TI_PEM(ig,iloop,islope)*TI_PEM(ig,iloop,islope))/volcapa |
---|
| 278 | ! tsoil_PEM(ig,iloop,islope) = tsoil_PEM(ig,index_bedrock+1,islope) + fluxgeo/kcond*(mlayer_PEM(iloop-1)-mlayer_PEM(index_bedrock)) |
---|
| 279 | ! enddo |
---|
| 280 | ! enddo |
---|
[3178] | 281 | call ini_tsoil_pem(ngrid,nsoil_PEM,TI_PEM(:,:,islope),tsurf_avg_yr2(:,islope),tsoil_PEM(:,:,islope)) |
---|
| 282 | call compute_tsoil_pem(ngrid,nsoil_PEM,.true.,TI_PEM(:,:,islope),timestep,tsurf_avg_yr2(:,islope),tsoil_PEM(:,:,islope)) |
---|
[3149] | 283 | else |
---|
[3532] | 284 | ! predictor corrector: restart from year 1 of the PCM and build the evolution of tsoil at depth |
---|
[3149] | 285 | tsoil_tmp_yr1(:,:,islope) = tsoil_startPEM(:,:,islope) |
---|
[3178] | 286 | call compute_tsoil_pem(ngrid,nsoil_PEM,.true.,TI_PEM(:,:,islope),timestep,tsurf_avg_yr1(:,islope),tsoil_tmp_yr1(:,:,islope)) |
---|
| 287 | call compute_tsoil_pem(ngrid,nsoil_PEM,.false.,TI_PEM(:,:,islope),timestep,tsurf_avg_yr1(:,islope),tsoil_tmp_yr1(:,:,islope)) |
---|
[3149] | 288 | tsoil_tmp_yr2(:,:,islope) = tsoil_tmp_yr1(:,:,islope) |
---|
[3178] | 289 | call compute_tsoil_pem(ngrid,nsoil_PEM,.false.,TI_PEM(:,:,islope),timestep,tsurf_avg_yr2(:,islope),tsoil_tmp_yr2(:,:,islope)) |
---|
[3203] | 290 | |
---|
[3532] | 291 | do iloop = nsoil_PCM + 1,nsoil_PEM |
---|
[3149] | 292 | tsoil_PEM(:,iloop,islope) = tsoil_tmp_yr2(:,iloop,islope) |
---|
| 293 | enddo |
---|
| 294 | endif !found |
---|
[2794] | 295 | |
---|
[3149] | 296 | do it = 1,timelen |
---|
[3532] | 297 | tsoil_inst(:,nsoil_PCM + 1:nsoil_PEM,islope,it) = tsoil_PEM(:,nsoil_PCM + 1:nsoil_PEM,islope) |
---|
[3149] | 298 | enddo |
---|
[3532] | 299 | do isoil = nsoil_PCM + 1,nsoil_PEM |
---|
| 300 | 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) |
---|
[3149] | 301 | enddo |
---|
| 302 | enddo ! islope |
---|
| 303 | write(*,*) 'PEMETAT0: SOIL TEMP done' |
---|
[2794] | 304 | |
---|
[3076] | 305 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
[2794] | 306 | !3. Ice Table |
---|
[3493] | 307 | if (icetable_equilibrium) then |
---|
[3537] | 308 | call get_field("icetable_depth",icetable_depth,found) |
---|
[3170] | 309 | if (.not. found) then |
---|
[3537] | 310 | write(*,*)'PEM settings: failed loading <icetable_depth>' |
---|
[3170] | 311 | write(*,*)'will reconstruct the values of the ice table given the current state' |
---|
[3537] | 312 | call computeice_table_equilibrium(ngrid,nslope,nsoil_PEM,watercaptag,watersurf_avg,watersoil_avg,TI_PEM(:,1,:),icetable_depth,icetable_thickness) |
---|
| 313 | 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) |
---|
[3170] | 314 | do islope = 1,nslope |
---|
[3178] | 315 | call ini_tsoil_pem(ngrid,nsoil_PEM,TI_PEM(:,:,islope),tsurf_avg_yr2(:,islope),tsoil_PEM(:,:,islope)) |
---|
[3170] | 316 | enddo |
---|
| 317 | endif |
---|
| 318 | write(*,*) 'PEMETAT0: ICE TABLE done' |
---|
[3493] | 319 | else if (icetable_dynamic) then |
---|
[3532] | 320 | call get_field("ice_porefilling",ice_porefilling,found) |
---|
[3537] | 321 | if (.not. found) write(*,*)'PEM settings: failed loading <ice_porefilling>' |
---|
| 322 | call get_field("icetable_depth",icetable_depth,found) |
---|
[3532] | 323 | if (.not. found) then |
---|
[3537] | 324 | write(*,*)'PEM settings: failed loading <icetable_depth>' |
---|
[3493] | 325 | write(*,*)'will reconstruct the values of the ice table given the current state' |
---|
[3537] | 326 | 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) |
---|
[3493] | 327 | do islope = 1,nslope |
---|
| 328 | call ini_tsoil_pem(ngrid,nsoil_PEM,TI_PEM(:,:,islope),tsurf_avg_yr2(:,islope),tsoil_PEM(:,:,islope)) |
---|
| 329 | enddo |
---|
| 330 | endif |
---|
| 331 | write(*,*) 'PEMETAT0: ICE TABLE done' |
---|
[3149] | 332 | endif |
---|
[2794] | 333 | |
---|
[3076] | 334 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
[2863] | 335 | !4. CO2 & H2O Adsorption |
---|
[3149] | 336 | if (adsorption_pem) then |
---|
| 337 | do islope = 1,nslope |
---|
| 338 | write(num,fmt='(i2.2)') islope |
---|
| 339 | call get_field("mco2_reg_ads_slope"//num,m_co2_regolith_phys(:,:,islope),found) |
---|
| 340 | if (.not. found) then |
---|
| 341 | m_co2_regolith_phys = 0. |
---|
| 342 | exit |
---|
| 343 | endif |
---|
| 344 | enddo |
---|
| 345 | do islope=1,nslope |
---|
| 346 | write(num,fmt='(i2.2)') islope |
---|
| 347 | call get_field("mh2o_reg_ads_slope"//num,m_h2o_regolith_phys(:,:,islope),found2) |
---|
| 348 | if (.not. found2) then |
---|
| 349 | m_h2o_regolith_phys = 0. |
---|
| 350 | exit |
---|
| 351 | endif |
---|
| 352 | enddo |
---|
[2794] | 353 | |
---|
[3498] | 354 | 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, & |
---|
[3149] | 355 | m_h2o_regolith_phys,deltam_h2o_regolith_phys, m_co2_regolith_phys,deltam_co2_regolith_phys) |
---|
[3076] | 356 | |
---|
[3149] | 357 | if (.not. found) deltam_co2_regolith_phys = 0. |
---|
[3456] | 358 | if (.not. found2) deltam_h2o_regolith_phys = 0. |
---|
[2849] | 359 | |
---|
[3149] | 360 | write(*,*) 'PEMETAT0: CO2 & H2O adsorption done' |
---|
| 361 | endif ! adsorption_pem |
---|
| 362 | endif ! soil_pem |
---|
[3076] | 363 | |
---|
[3149] | 364 | call close_startphy |
---|
[2779] | 365 | |
---|
[3493] | 366 | else !No startpem, let's build all by hand |
---|
[2794] | 367 | |
---|
[3297] | 368 | write(*,*)'There is no "startpem.nc"!' |
---|
| 369 | |
---|
[3149] | 370 | ! h2o ice |
---|
| 371 | h2o_ice = 0. |
---|
[3214] | 372 | write(*,*)'So ''h2o_ice'' is initialized with default value ''ini_huge_h2oice'' where ''watercaptag'' is true.' |
---|
| 373 | do ig = 1,ngrid |
---|
[3308] | 374 | if (watercaptag(ig)) h2o_ice(ig,:) = ini_huge_h2oice |
---|
[3214] | 375 | enddo |
---|
[2888] | 376 | |
---|
[3149] | 377 | ! co2 ice |
---|
[3214] | 378 | write(*,*)'So ''co2_ice'' is initialized with ''perennial_co2ice''.' |
---|
[3149] | 379 | co2_ice = perennial_co2ice |
---|
[2794] | 380 | |
---|
[3430] | 381 | ! Stratification (layerings) |
---|
| 382 | nb_str_max = 1 |
---|
| 383 | if (layering_algo) write(*,*)'So the stratification (layerings) is initialized with 1 sub-surface stratum.' |
---|
| 384 | |
---|
[3039] | 385 | if (soil_pem) then |
---|
[2794] | 386 | |
---|
| 387 | !a) Thermal inertia |
---|
[3149] | 388 | do islope = 1,nslope |
---|
| 389 | do ig = 1,ngrid |
---|
| 390 | if (TI_PEM(ig,index_breccia,islope) < TI_breccia) then |
---|
| 391 | !!! transition |
---|
| 392 | delta = depth_breccia |
---|
| 393 | TI_PEM(ig,index_breccia + 1,islope) = sqrt((layer_PEM(index_breccia+1)-layer_PEM(index_breccia))/ & |
---|
| 394 | (((delta-layer_PEM(index_breccia))/(TI_PEM(ig,index_breccia,islope)**2))+ & |
---|
| 395 | ((layer_PEM(index_breccia+1)-delta)/(TI_breccia**2)))) |
---|
| 396 | do iloop=index_breccia + 2,index_bedrock |
---|
| 397 | TI_PEM(ig,iloop,islope) = TI_breccia |
---|
| 398 | enddo |
---|
| 399 | else ! we keep the high ti values |
---|
| 400 | do iloop=index_breccia + 1,index_bedrock |
---|
| 401 | TI_PEM(ig,iloop,islope) = TI_PEM(ig,index_breccia,islope) |
---|
| 402 | enddo |
---|
| 403 | endif |
---|
| 404 | !! transition |
---|
| 405 | delta = depth_bedrock |
---|
| 406 | TI_PEM(ig,index_bedrock + 1,islope) = sqrt((layer_PEM(index_bedrock+1)-layer_PEM(index_bedrock))/ & |
---|
| 407 | (((delta-layer_PEM(index_bedrock))/(TI_PEM(ig,index_bedrock,islope)**2))+ & |
---|
| 408 | ((layer_PEM(index_bedrock+1)-delta)/(TI_breccia**2)))) |
---|
| 409 | do iloop = index_bedrock + 2,nsoil_PEM |
---|
| 410 | TI_PEM(ig,iloop,islope) = TI_bedrock |
---|
| 411 | enddo |
---|
| 412 | enddo |
---|
| 413 | enddo |
---|
[2794] | 414 | |
---|
[3149] | 415 | do iloop = 1,nsoil_PCM |
---|
| 416 | inertiedat_PEM(:,iloop) = inertiedat(:,iloop) |
---|
| 417 | enddo |
---|
| 418 | !!! zone de transition |
---|
| 419 | delta = depth_breccia |
---|
| 420 | do ig = 1,ngrid |
---|
| 421 | if (inertiedat_PEM(ig,index_breccia) < TI_breccia) then |
---|
| 422 | inertiedat_PEM(ig,index_breccia + 1) = sqrt((layer_PEM(index_breccia + 1) - layer_PEM(index_breccia))/ & |
---|
| 423 | (((delta - layer_PEM(index_breccia))/(inertiedat(ig,index_breccia)**2)) + & |
---|
| 424 | ((layer_PEM(index_breccia + 1)-delta)/(TI_breccia**2)))) |
---|
| 425 | do iloop = index_breccia + 2,index_bedrock |
---|
| 426 | inertiedat_PEM(ig,iloop) = TI_breccia |
---|
| 427 | enddo |
---|
| 428 | else |
---|
| 429 | do iloop = index_breccia + 1,index_bedrock |
---|
| 430 | inertiedat_PEM(ig,iloop) = inertiedat_PEM(ig,index_breccia) |
---|
| 431 | enddo |
---|
| 432 | endif |
---|
| 433 | enddo |
---|
[2794] | 434 | |
---|
[3149] | 435 | !!! zone de transition |
---|
| 436 | delta = depth_bedrock |
---|
| 437 | do ig = 1,ngrid |
---|
| 438 | inertiedat_PEM(ig,index_bedrock + 1) = sqrt((layer_PEM(index_bedrock + 1) - layer_PEM(index_bedrock))/ & |
---|
| 439 | (((delta - layer_PEM(index_bedrock))/(inertiedat_PEM(ig,index_bedrock)**2)) + & |
---|
| 440 | ((layer_PEM(index_bedrock + 1) - delta)/(TI_bedrock**2)))) |
---|
| 441 | enddo |
---|
[2779] | 442 | |
---|
[3149] | 443 | do iloop = index_bedrock + 2,nsoil_PEM |
---|
| 444 | do ig = 1,ngrid |
---|
| 445 | inertiedat_PEM(ig,iloop) = TI_bedrock |
---|
| 446 | enddo |
---|
| 447 | enddo |
---|
[2779] | 448 | |
---|
[3149] | 449 | write(*,*) 'PEMETAT0: TI done' |
---|
[2779] | 450 | |
---|
[3076] | 451 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 452 | !b) Soil temperature |
---|
[3149] | 453 | do islope = 1,nslope |
---|
| 454 | ! do ig = 1,ngrid |
---|
| 455 | ! kcond = (TI_PEM(ig,index_breccia+1,islope)*TI_PEM(ig,index_breccia+1,islope))/volcapa |
---|
| 456 | ! tsoil_PEM(ig,index_breccia+1,islope) = tsoil_PEM(ig,index_breccia,islope) + fluxgeo/kcond*(mlayer_PEM(index_breccia)-mlayer_PEM(index_breccia-1)) |
---|
[2895] | 457 | ! |
---|
[3149] | 458 | ! do iloop=index_breccia+2,index_bedrock |
---|
| 459 | ! kcond = (TI_PEM(ig,iloop,islope)*TI_PEM(ig,iloop,islope))/volcapa |
---|
| 460 | ! tsoil_PEM(ig,iloop,islope) = tsoil_PEM(ig,index_breccia+1,islope) + fluxgeo/kcond*(mlayer_PEM(iloop-1)-mlayer_PEM(index_breccia)) |
---|
| 461 | ! enddo |
---|
| 462 | ! kcond = (TI_PEM(ig,index_bedrock+1,islope)*TI_PEM(ig,index_bedrock+1,islope))/volcapa |
---|
| 463 | ! tsoil_PEM(ig,index_bedrock+1,islope) = tsoil_PEM(ig,index_bedrock,islope) + fluxgeo/kcond*(mlayer_PEM(index_bedrock)-mlayer_PEM(index_bedrock-1)) |
---|
| 464 | ! |
---|
| 465 | ! do iloop=index_bedrock+2,nsoil_PEM |
---|
| 466 | ! kcond = (TI_PEM(ig,iloop,islope)*TI_PEM(ig,iloop,islope))/volcapa |
---|
| 467 | ! tsoil_PEM(ig,iloop,islope) = tsoil_PEM(ig,index_bedrock+1,islope) + fluxgeo/kcond*(mlayer_PEM(iloop-1)-mlayer_PEM(index_bedrock)) |
---|
| 468 | ! enddo |
---|
| 469 | ! enddo |
---|
[3178] | 470 | call ini_tsoil_pem(ngrid,nsoil_PEM,TI_PEM(:,:,islope),tsurf_avg_yr2(:,islope),tsoil_PEM(:,:,islope)) |
---|
| 471 | call compute_tsoil_pem(ngrid,nsoil_PEM,.true.,TI_PEM(:,:,islope),timestep,tsurf_avg_yr2(:,islope),tsoil_PEM(:,:,islope)) |
---|
[2794] | 472 | |
---|
[3149] | 473 | ! First raw initialization |
---|
| 474 | do it = 1,timelen |
---|
| 475 | do isoil = nsoil_PCM + 1,nsoil_PEM |
---|
| 476 | tsoil_inst(:,isoil,islope,it) = tsoil_PEM(:,isoil,islope) |
---|
| 477 | enddo |
---|
| 478 | enddo |
---|
[3076] | 479 | |
---|
[3149] | 480 | do it = 1,timelen |
---|
| 481 | do isoil = nsoil_PCM + 1,nsoil_PEM |
---|
[3178] | 482 | call ini_tsoil_pem(ngrid,nsoil_PEM,TI_PEM(:,:,islope),tsurf_avg_yr2(:,islope),tsoil_inst(:,:,islope,it)) |
---|
[3149] | 483 | enddo |
---|
| 484 | enddo |
---|
[2794] | 485 | |
---|
[3149] | 486 | do isoil = nsoil_PCM + 1,nsoil_PEM |
---|
| 487 | do ig = 1,ngrid |
---|
| 488 | watersoil_avg(ig,isoil,islope) = exp(beta_clap_h2o/tsoil_PEM(ig,isoil,islope) + alpha_clap_h2o)/tsoil_PEM(ig,isoil,islope)*mmol(igcm_h2o_vap)/(mugaz*r) |
---|
| 489 | enddo |
---|
| 490 | enddo |
---|
| 491 | enddo !islope |
---|
| 492 | write(*,*) 'PEMETAT0: TSOIL done' |
---|
[3039] | 493 | |
---|
[3076] | 494 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
[3039] | 495 | !c) Ice table |
---|
[3493] | 496 | if (icetable_equilibrium) then |
---|
[3537] | 497 | call computeice_table_equilibrium(ngrid,nslope,nsoil_PEM,watercaptag,watersurf_avg,watersoil_avg,TI_PEM(:,1,:),icetable_depth,icetable_thickness) |
---|
| 498 | 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) |
---|
[3170] | 499 | do islope = 1,nslope |
---|
[3178] | 500 | call ini_tsoil_pem(ngrid,nsoil_PEM,TI_PEM(:,:,islope),tsurf_avg_yr2(:,islope),tsoil_PEM(:,:,islope)) |
---|
[3170] | 501 | enddo |
---|
| 502 | write(*,*) 'PEMETAT0: Ice table done' |
---|
[3493] | 503 | else if (icetable_dynamic) then |
---|
[3537] | 504 | 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) |
---|
[3493] | 505 | do islope = 1,nslope |
---|
| 506 | call ini_tsoil_pem(ngrid,nsoil_PEM,TI_PEM(:,:,islope),tsurf_avg_yr2(:,islope),tsoil_PEM(:,:,islope)) |
---|
| 507 | enddo |
---|
| 508 | write(*,*) 'PEMETAT0: Ice table done' |
---|
[3170] | 509 | endif |
---|
[3532] | 510 | |
---|
[3076] | 511 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
[2794] | 512 | !d) Regolith adsorbed |
---|
[3149] | 513 | if (adsorption_pem) then |
---|
| 514 | m_co2_regolith_phys = 0. |
---|
| 515 | m_h2o_regolith_phys = 0. |
---|
[3498] | 516 | 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, & |
---|
[3149] | 517 | m_h2o_regolith_phys,deltam_h2o_regolith_phys, m_co2_regolith_phys,deltam_co2_regolith_phys) |
---|
| 518 | deltam_co2_regolith_phys = 0. |
---|
| 519 | deltam_h2o_regolith_phys = 0. |
---|
| 520 | endif |
---|
[2863] | 521 | |
---|
[3149] | 522 | write(*,*) 'PEMETAT0: CO2 adsorption done' |
---|
| 523 | endif !soil_pem |
---|
[2893] | 524 | endif ! of if (startphy_file) |
---|
| 525 | |
---|
[3076] | 526 | if (soil_pem) then ! Sanity check |
---|
| 527 | do ig = 1,ngrid |
---|
| 528 | do islope = 1,nslope |
---|
| 529 | do iloop = 1,nsoil_PEM |
---|
| 530 | if (isnan(tsoil_PEM(ig,iloop,islope))) call abort_pem("PEM - pemetat0","NaN detected in Tsoil",1) |
---|
| 531 | enddo |
---|
| 532 | enddo |
---|
| 533 | enddo |
---|
| 534 | endif !soil_pem |
---|
[2794] | 535 | |
---|
[3076] | 536 | END SUBROUTINE pemetat0 |
---|
| 537 | |
---|
| 538 | END MODULE pemetat0_mod |
---|