[3286] | 1 | MODULE layering_mod |
---|
| 2 | |
---|
| 3 | !======================================================================= |
---|
| 4 | ! Purpose: Manage layered deposits in the PEM with a linked list data structure |
---|
| 5 | ! |
---|
| 6 | ! Author: JBC |
---|
| 7 | ! Date: 08/03/2024 |
---|
| 8 | !======================================================================= |
---|
| 9 | |
---|
[3553] | 10 | use glaciers_mod, only: rho_co2ice, rho_h2oice |
---|
[3286] | 11 | |
---|
| 12 | implicit none |
---|
| 13 | |
---|
| 14 | !---- Declarations |
---|
| 15 | ! Numerical parameter |
---|
| 16 | real, parameter :: eps = epsilon(1.), tol = 1.e2*eps |
---|
[3297] | 17 | integer :: nb_str_max |
---|
[3319] | 18 | logical :: layering_algo |
---|
[3286] | 19 | |
---|
| 20 | ! Physical parameters |
---|
[3498] | 21 | real, parameter :: d_dust = 5.78e-2 ! Tendency of dust [kg.m-2.y-1] |
---|
[3286] | 22 | real, parameter :: dry_lag_porosity = 0.5 ! Porosity of dust lag |
---|
| 23 | real, parameter :: dry_regolith_porosity = 0.45 ! Porosity of regolith |
---|
| 24 | real, parameter :: co2ice_porosity = 0.3 ! Porosity of CO2 ice |
---|
| 25 | real, parameter :: h2oice_porosity = 0.3 ! Porosity of H2O ice |
---|
| 26 | real, parameter :: rho_dust = 2500. ! Density of dust [kg.m-3] |
---|
| 27 | real, parameter :: rho_rock = 3200. ! Density of rock [kg.m-3] |
---|
| 28 | |
---|
[3424] | 29 | ! Lag layer parameters -> see Levrard et al. 2007 |
---|
| 30 | real, parameter :: hmin_lag = 0.5 ! Minimal height of the lag deposit to reduce the sblimation rate |
---|
| 31 | real, parameter :: fred_subl = 0.1 ! Reduction factor of sublimation rate |
---|
| 32 | |
---|
[3286] | 33 | ! Stratum = node of the linked list |
---|
| 34 | type :: stratum |
---|
[3320] | 35 | real :: thickness ! Layer thickness [m] |
---|
| 36 | real :: top_elevation ! Layer top_elevation (top height from the surface) [m] |
---|
| 37 | real :: co2ice_volfrac ! CO2 ice volumetric fraction |
---|
| 38 | real :: h2oice_volfrac ! H2O ice volumetric fraction |
---|
| 39 | real :: dust_volfrac ! Dust volumetric fraction |
---|
| 40 | real :: air_volfrac ! Air volumetric fraction inside pores |
---|
[3286] | 41 | type(stratum), pointer :: up => null() ! Upper stratum (next node) |
---|
| 42 | type(stratum), pointer :: down => null() ! Lower stratum (previous node) |
---|
| 43 | end type stratum |
---|
| 44 | |
---|
| 45 | ! Layering = linked list |
---|
| 46 | type layering |
---|
| 47 | integer :: nb_str = 0 ! Number of strata |
---|
| 48 | type(stratum), pointer :: bottom => null() ! First stratum (head of the list) |
---|
| 49 | type(stratum), pointer :: top => null() ! Last stratum (tail of the list) |
---|
| 50 | end type layering |
---|
| 51 | |
---|
[3297] | 52 | ! Array of pointers to "stratum" |
---|
| 53 | type ptrarray |
---|
| 54 | type(stratum), pointer :: p |
---|
| 55 | end type ptrarray |
---|
| 56 | |
---|
[3286] | 57 | !======================================================================= |
---|
| 58 | contains |
---|
[3297] | 59 | ! Procedures to manipulate the data structure: |
---|
| 60 | ! > print_stratum |
---|
| 61 | ! > add_stratum |
---|
| 62 | ! > insert_stratum |
---|
| 63 | ! > rm_stratum |
---|
| 64 | ! > get_stratum |
---|
| 65 | ! > ini_layering |
---|
| 66 | ! > del_layering |
---|
| 67 | ! > print_layering |
---|
| 68 | ! > get_nb_str_max |
---|
| 69 | ! > stratif2array |
---|
| 70 | ! > array2stratif |
---|
| 71 | ! > print_stratif |
---|
| 72 | ! Procedures for the algorithm to evolve the layering: |
---|
| 73 | ! > make_layering |
---|
| 74 | ! > subl_co2ice_layering |
---|
| 75 | ! > subl_h2oice_layering |
---|
| 76 | ! > lift_dust_lags |
---|
[3286] | 77 | !======================================================================= |
---|
| 78 | ! To display a stratum |
---|
| 79 | SUBROUTINE print_stratum(this) |
---|
| 80 | |
---|
| 81 | implicit none |
---|
| 82 | |
---|
| 83 | !---- Arguments |
---|
| 84 | type(stratum), intent(in) :: this |
---|
| 85 | |
---|
| 86 | !---- Code |
---|
| 87 | write(*,'(a20,es13.6)') 'Thickness : ', this%thickness |
---|
[3297] | 88 | write(*,'(a20,es13.6)') 'Top elevation : ', this%top_elevation |
---|
| 89 | write(*,'(a20,es13.6)') 'CO2 ice (m3/m3): ', this%co2ice_volfrac |
---|
| 90 | write(*,'(a20,es13.6)') 'H2O ice (m3/m3): ', this%h2oice_volfrac |
---|
| 91 | write(*,'(a20,es13.6)') 'Dust (m3/m3) : ', this%dust_volfrac |
---|
| 92 | write(*,'(a20,es13.6)') 'Air (m3/m3) : ', this%air_volfrac |
---|
[3286] | 93 | |
---|
| 94 | END SUBROUTINE print_stratum |
---|
| 95 | |
---|
| 96 | !======================================================================= |
---|
| 97 | ! To add a stratum to the top of a layering |
---|
[3297] | 98 | SUBROUTINE add_stratum(this,thickness,top_elevation,co2ice,h2oice,dust,air) |
---|
[3286] | 99 | |
---|
| 100 | implicit none |
---|
| 101 | |
---|
| 102 | !---- Arguments |
---|
| 103 | type(layering), intent(inout) :: this |
---|
[3297] | 104 | real, intent(in), optional :: thickness, top_elevation, co2ice, h2oice, dust, air |
---|
[3286] | 105 | |
---|
| 106 | !---- Local variables |
---|
| 107 | type(stratum), pointer :: str |
---|
| 108 | |
---|
| 109 | !---- Code |
---|
| 110 | ! Creation of the stratum |
---|
| 111 | allocate(str) |
---|
| 112 | nullify(str%up,str%down) |
---|
| 113 | str%thickness = 1. |
---|
[3297] | 114 | str%top_elevation = 1. |
---|
[3286] | 115 | str%co2ice_volfrac = 0. |
---|
| 116 | str%h2oice_volfrac = 0. |
---|
| 117 | str%dust_volfrac = 0. |
---|
| 118 | str%air_volfrac = 1. |
---|
| 119 | if (present(thickness)) str%thickness = thickness |
---|
[3297] | 120 | if (present(top_elevation)) str%top_elevation = top_elevation |
---|
[3286] | 121 | if (present(co2ice)) str%co2ice_volfrac = co2ice |
---|
| 122 | if (present(h2oice)) str%h2oice_volfrac = h2oice |
---|
| 123 | if (present(dust)) str%dust_volfrac = dust |
---|
| 124 | if (present(air)) str%air_volfrac = air |
---|
| 125 | |
---|
| 126 | ! Verification of volume fraction |
---|
| 127 | if (abs(1. - (str%co2ice_volfrac + str%h2oice_volfrac + str%dust_volfrac + str%air_volfrac)) > tol) & |
---|
[3317] | 128 | error stop 'add_stratum: properties for the new stratum are not possible (sum of volumetric fraction /= 1)!' |
---|
[3286] | 129 | |
---|
| 130 | ! Increment the number of strata |
---|
| 131 | this%nb_str = this%nb_str + 1 |
---|
| 132 | |
---|
| 133 | ! Add the stratum to the layering |
---|
| 134 | if (.not. associated(this%bottom)) then ! If it is the very first one |
---|
| 135 | this%bottom => str |
---|
| 136 | this%top => str |
---|
| 137 | else |
---|
| 138 | str%down => this%top |
---|
| 139 | this%top%up => str |
---|
| 140 | this%top => str |
---|
| 141 | endif |
---|
| 142 | |
---|
| 143 | END SUBROUTINE add_stratum |
---|
| 144 | |
---|
| 145 | !======================================================================= |
---|
| 146 | ! To insert a stratum after another one in a layering |
---|
[3297] | 147 | SUBROUTINE insert_stratum(this,str_prev,thickness,top_elevation,co2ice,h2oice,dust,air) |
---|
[3286] | 148 | |
---|
| 149 | implicit none |
---|
| 150 | |
---|
| 151 | !---- Arguments |
---|
| 152 | type(layering), intent(inout) :: this |
---|
| 153 | type(stratum), pointer, intent(inout) :: str_prev |
---|
[3297] | 154 | real, intent(in), optional :: thickness, top_elevation, co2ice, h2oice, dust, air |
---|
[3286] | 155 | |
---|
| 156 | !---- Local variables |
---|
| 157 | type(stratum), pointer :: str, current |
---|
| 158 | |
---|
| 159 | !---- Code |
---|
| 160 | if (.not. associated(str_prev%up)) then ! If str_prev is the top stratum of the layering |
---|
[3297] | 161 | call add_stratum(this,thickness,top_elevation,co2ice,h2oice,dust,air) |
---|
[3286] | 162 | else |
---|
| 163 | ! Creation of the stratum |
---|
| 164 | allocate(str) |
---|
| 165 | nullify(str%up,str%down) |
---|
| 166 | str%thickness = 1. |
---|
[3297] | 167 | str%top_elevation = 1. |
---|
[3286] | 168 | str%co2ice_volfrac = 0. |
---|
| 169 | str%h2oice_volfrac = 0. |
---|
| 170 | str%dust_volfrac = 0. |
---|
| 171 | str%air_volfrac = 1. |
---|
| 172 | if (present(thickness)) str%thickness = thickness |
---|
[3297] | 173 | if (present(top_elevation)) str%top_elevation = top_elevation |
---|
[3286] | 174 | if (present(co2ice)) str%co2ice_volfrac = co2ice |
---|
| 175 | if (present(h2oice)) str%h2oice_volfrac = h2oice |
---|
| 176 | if (present(dust)) str%dust_volfrac = dust |
---|
| 177 | if (present(air)) str%air_volfrac = air |
---|
| 178 | |
---|
| 179 | ! Verification of volume fraction |
---|
| 180 | if (abs(1. - (str%co2ice_volfrac + str%h2oice_volfrac + str%dust_volfrac + str%air_volfrac)) > tol) & |
---|
[3317] | 181 | error stop 'insert_stratum: properties for the new stratum are not possible (sum of volumetric fraction /= 1)!' |
---|
[3286] | 182 | |
---|
| 183 | ! Increment the number of strata |
---|
| 184 | this%nb_str = this%nb_str + 1 |
---|
| 185 | |
---|
| 186 | ! Insert the stratum into the layering at the right place |
---|
| 187 | str%down => str_prev |
---|
| 188 | str%up => str_prev%up |
---|
| 189 | str_prev%up => str |
---|
| 190 | str%up%down => str |
---|
| 191 | |
---|
[3297] | 192 | ! Correct the value of top_elevation for the upper strata |
---|
[3286] | 193 | current => str%up |
---|
| 194 | do while (associated(current)) |
---|
[3297] | 195 | current%top_elevation = current%down%top_elevation + current%thickness |
---|
[3286] | 196 | current => current%up |
---|
| 197 | enddo |
---|
| 198 | endif |
---|
| 199 | |
---|
| 200 | END SUBROUTINE insert_stratum |
---|
| 201 | |
---|
| 202 | !======================================================================= |
---|
| 203 | ! To remove a stratum in a layering |
---|
| 204 | SUBROUTINE rm_stratum(this,str) |
---|
| 205 | |
---|
| 206 | implicit none |
---|
| 207 | |
---|
| 208 | !---- Arguments |
---|
| 209 | type(layering), intent(inout) :: this |
---|
| 210 | type(stratum), pointer, intent(inout) :: str |
---|
| 211 | |
---|
| 212 | !---- Local variables |
---|
| 213 | type(stratum), pointer :: new_str |
---|
| 214 | |
---|
| 215 | !---- Code |
---|
| 216 | ! Protect the 3 sub-surface strata from removing |
---|
[3297] | 217 | if (str%top_elevation <= 0.) return |
---|
[3286] | 218 | |
---|
| 219 | ! Decrement the number of strata |
---|
| 220 | this%nb_str = this%nb_str - 1 |
---|
| 221 | |
---|
[3297] | 222 | ! Remove the stratum from the layering |
---|
[3286] | 223 | str%down%up => str%up |
---|
| 224 | if (associated(str%up)) then ! If it is not the last one at the top of the layering |
---|
| 225 | str%up%down => str%down |
---|
| 226 | else |
---|
| 227 | this%top => str%down |
---|
| 228 | endif |
---|
| 229 | new_str => str%down |
---|
| 230 | nullify(str%up,str%down) |
---|
| 231 | deallocate(str) |
---|
| 232 | nullify(str) |
---|
| 233 | str => new_str |
---|
| 234 | |
---|
| 235 | END SUBROUTINE rm_stratum |
---|
| 236 | |
---|
| 237 | !======================================================================= |
---|
[3297] | 238 | ! To get a specific stratum in a layering |
---|
| 239 | FUNCTION get_stratum(lay,i) RESULT(str) |
---|
| 240 | |
---|
| 241 | implicit none |
---|
| 242 | |
---|
| 243 | !---- Arguments |
---|
| 244 | type(layering), intent(in) :: lay |
---|
| 245 | integer, intent(in) :: i |
---|
| 246 | type(stratum), pointer :: str |
---|
| 247 | |
---|
| 248 | !---- Local variables |
---|
| 249 | integer :: k |
---|
| 250 | |
---|
| 251 | !---- Code |
---|
| 252 | if (i < 1 .or. i > lay%nb_str) error stop 'get_stratum: requested number is beyond the number of strata of the layering!' |
---|
| 253 | k = 1 |
---|
| 254 | str => lay%bottom |
---|
| 255 | do while (k /= i) |
---|
| 256 | str => str%up |
---|
| 257 | k = k + 1 |
---|
| 258 | enddo |
---|
| 259 | |
---|
| 260 | END FUNCTION get_stratum |
---|
| 261 | |
---|
| 262 | !======================================================================= |
---|
[3286] | 263 | ! To initialize the layering |
---|
| 264 | SUBROUTINE ini_layering(this) |
---|
| 265 | |
---|
| 266 | implicit none |
---|
| 267 | |
---|
| 268 | !---- Arguments |
---|
| 269 | type(layering), intent(inout) :: this |
---|
| 270 | |
---|
| 271 | !---- Code |
---|
| 272 | ! Creation of three strata at the bottom of the layering |
---|
| 273 | ! 1) Dry porous deep regolith |
---|
[3430] | 274 | !call add_stratum(this,18.,-12.,0.,0.,dry_regolith_porosity,1. - dry_regolith_porosity) |
---|
[3286] | 275 | ! 2) Ice-cemented regolith (ice table) |
---|
[3430] | 276 | !call add_stratum(this,10.,-2.,0.,1. - dry_regolith_porosity,dry_regolith_porosity,0.) |
---|
[3286] | 277 | ! 3) Dry porous regolith |
---|
| 278 | call add_stratum(this,2.,0.,0.,0.,dry_regolith_porosity,1. - dry_regolith_porosity) |
---|
| 279 | |
---|
| 280 | END SUBROUTINE ini_layering |
---|
| 281 | |
---|
| 282 | !======================================================================= |
---|
| 283 | ! To delete the entire layering |
---|
| 284 | SUBROUTINE del_layering(this) |
---|
| 285 | |
---|
| 286 | implicit none |
---|
| 287 | |
---|
| 288 | !---- Arguments |
---|
| 289 | type(layering), intent(inout) :: this |
---|
| 290 | |
---|
| 291 | !---- Local variables |
---|
| 292 | type(stratum), pointer :: current, next |
---|
| 293 | |
---|
| 294 | !---- Code |
---|
| 295 | current => this%bottom |
---|
| 296 | do while (associated(current)) |
---|
| 297 | next => current%up |
---|
| 298 | deallocate(current) |
---|
| 299 | nullify(current) |
---|
| 300 | current => next |
---|
| 301 | enddo |
---|
| 302 | this%nb_str = 0 |
---|
| 303 | |
---|
| 304 | END SUBROUTINE del_layering |
---|
| 305 | |
---|
| 306 | !======================================================================= |
---|
[3297] | 307 | ! To display a layering |
---|
| 308 | SUBROUTINE print_layering(this) |
---|
[3286] | 309 | |
---|
| 310 | implicit none |
---|
| 311 | |
---|
| 312 | !---- Arguments |
---|
[3297] | 313 | type(layering), intent(in) :: this |
---|
[3286] | 314 | |
---|
| 315 | !---- Local variables |
---|
[3297] | 316 | type(stratum), pointer :: current |
---|
| 317 | integer :: i |
---|
[3286] | 318 | |
---|
| 319 | !---- Code |
---|
[3297] | 320 | current => this%top |
---|
| 321 | |
---|
| 322 | i = this%nb_str |
---|
| 323 | do while (associated(current)) |
---|
| 324 | write(*,'(a8,i4)') 'Stratum ', i |
---|
| 325 | call print_stratum(current) |
---|
| 326 | write(*,*) |
---|
| 327 | current => current%down |
---|
| 328 | i = i - 1 |
---|
[3286] | 329 | enddo |
---|
| 330 | |
---|
[3297] | 331 | END SUBROUTINE print_layering |
---|
[3286] | 332 | |
---|
| 333 | !======================================================================= |
---|
[3297] | 334 | ! To get the maximum number of "stratum" in the stratification (layerings) |
---|
| 335 | FUNCTION get_nb_str_max(stratif,ngrid,nslope) RESULT(nb_str_max) |
---|
[3286] | 336 | |
---|
| 337 | implicit none |
---|
| 338 | |
---|
| 339 | !---- Arguments |
---|
[3297] | 340 | type(layering), dimension(ngrid,nslope), intent(in) :: stratif |
---|
| 341 | integer, intent(in) :: ngrid, nslope |
---|
| 342 | integer :: nb_str_max |
---|
[3286] | 343 | |
---|
| 344 | !---- Local variables |
---|
[3297] | 345 | integer :: ig, islope |
---|
| 346 | |
---|
| 347 | !---- Code |
---|
| 348 | nb_str_max = 0 |
---|
| 349 | do islope = 1,nslope |
---|
| 350 | do ig = 1,ngrid |
---|
| 351 | nb_str_max = max(stratif(ig,islope)%nb_str,nb_str_max) |
---|
| 352 | enddo |
---|
| 353 | enddo |
---|
| 354 | |
---|
| 355 | END FUNCTION get_nb_str_max |
---|
| 356 | |
---|
| 357 | !======================================================================= |
---|
| 358 | ! To convert the stratification data structure (layerings) into an array able to be outputted |
---|
| 359 | SUBROUTINE stratif2array(stratif,ngrid,nslope,stratif_array) |
---|
| 360 | |
---|
| 361 | implicit none |
---|
| 362 | |
---|
| 363 | !---- Arguments |
---|
| 364 | integer, intent(in) :: ngrid, nslope |
---|
| 365 | type(layering), dimension(ngrid,nslope), intent(in) :: stratif |
---|
| 366 | real, dimension(:,:,:,:), allocatable, intent(inout) :: stratif_array |
---|
| 367 | |
---|
| 368 | !---- Local variables |
---|
[3286] | 369 | type(stratum), pointer :: current |
---|
[3297] | 370 | integer :: ig, islope, k |
---|
[3286] | 371 | |
---|
| 372 | !---- Code |
---|
[3297] | 373 | stratif_array = 0. |
---|
| 374 | do islope = 1,nslope |
---|
| 375 | do ig = 1,ngrid |
---|
| 376 | current => stratif(ig,islope)%bottom |
---|
| 377 | k = 1 |
---|
| 378 | do while (associated(current)) |
---|
| 379 | stratif_array(ig,islope,k,1) = current%thickness |
---|
| 380 | stratif_array(ig,islope,k,2) = current%top_elevation |
---|
| 381 | stratif_array(ig,islope,k,3) = current%co2ice_volfrac |
---|
| 382 | stratif_array(ig,islope,k,4) = current%h2oice_volfrac |
---|
| 383 | stratif_array(ig,islope,k,5) = current%dust_volfrac |
---|
| 384 | stratif_array(ig,islope,k,6) = current%air_volfrac |
---|
| 385 | current => current%up |
---|
| 386 | k = k + 1 |
---|
| 387 | enddo |
---|
| 388 | enddo |
---|
[3286] | 389 | enddo |
---|
| 390 | |
---|
[3297] | 391 | END SUBROUTINE stratif2array |
---|
[3286] | 392 | |
---|
| 393 | !======================================================================= |
---|
[3297] | 394 | ! To convert the stratification array into the stratification data structure (layerings) |
---|
| 395 | SUBROUTINE array2stratif(stratif_array,ngrid,nslope,stratif) |
---|
[3286] | 396 | |
---|
| 397 | implicit none |
---|
| 398 | |
---|
| 399 | !---- Arguments |
---|
[3297] | 400 | integer, intent(in) :: ngrid, nslope |
---|
| 401 | real, dimension(:,:,:,:), allocatable, intent(in) :: stratif_array |
---|
| 402 | type(layering), dimension(ngrid,nslope), intent(inout) :: stratif |
---|
[3286] | 403 | |
---|
| 404 | !---- Local variables |
---|
[3430] | 405 | integer :: ig, islope, k |
---|
[3286] | 406 | |
---|
| 407 | !---- Code |
---|
[3297] | 408 | do islope = 1,nslope |
---|
| 409 | do ig = 1,ngrid |
---|
[3430] | 410 | stratif(ig,islope)%bottom%thickness = stratif_array(ig,islope,1,1) |
---|
| 411 | stratif(ig,islope)%bottom%top_elevation = stratif_array(ig,islope,1,2) |
---|
| 412 | stratif(ig,islope)%bottom%co2ice_volfrac = stratif_array(ig,islope,1,3) |
---|
| 413 | stratif(ig,islope)%bottom%h2oice_volfrac = stratif_array(ig,islope,1,4) |
---|
| 414 | stratif(ig,islope)%bottom%dust_volfrac = stratif_array(ig,islope,1,5) |
---|
| 415 | stratif(ig,islope)%bottom%air_volfrac = stratif_array(ig,islope,1,6) |
---|
| 416 | do k = 2,size(stratif_array,3) |
---|
[3297] | 417 | if (all(abs(stratif_array(ig,islope,k,:)) < eps)) exit |
---|
| 418 | call add_stratum(stratif(ig,islope),stratif_array(ig,islope,k,1),stratif_array(ig,islope,k,2),stratif_array(ig,islope,k,3),stratif_array(ig,islope,k,4),stratif_array(ig,islope,k,5),stratif_array(ig,islope,k,6)) |
---|
| 419 | enddo |
---|
| 420 | enddo |
---|
[3286] | 421 | enddo |
---|
| 422 | |
---|
[3297] | 423 | END SUBROUTINE array2stratif |
---|
[3286] | 424 | |
---|
| 425 | !======================================================================= |
---|
[3297] | 426 | ! To display a stratification (layerings) |
---|
| 427 | SUBROUTINE print_stratif(this,ngrid,nslope) |
---|
[3286] | 428 | |
---|
| 429 | implicit none |
---|
| 430 | |
---|
| 431 | !---- Arguments |
---|
[3297] | 432 | integer, intent(in) :: ngrid, nslope |
---|
| 433 | type(layering), dimension(ngrid,nslope), intent(in) :: this |
---|
[3286] | 434 | |
---|
[3297] | 435 | !---- Local variables |
---|
| 436 | integer :: ig, islope |
---|
| 437 | |
---|
[3286] | 438 | !---- Code |
---|
[3297] | 439 | do ig = 1,ngrid |
---|
| 440 | write(*,'(a10,i4)') 'Grid cell ', ig |
---|
| 441 | do islope = 1,nslope |
---|
| 442 | write(*,'(a13,i1)') 'Slope number ', islope |
---|
| 443 | call print_layering(this(ig,islope)) |
---|
| 444 | write(*,*) '~~~~~~~~~~' |
---|
| 445 | enddo |
---|
| 446 | write(*,*) '--------------------' |
---|
| 447 | enddo |
---|
[3286] | 448 | |
---|
[3297] | 449 | END SUBROUTINE print_stratif |
---|
[3286] | 450 | |
---|
| 451 | !======================================================================= |
---|
| 452 | ! Layering algorithm |
---|
[3553] | 453 | SUBROUTINE make_layering(this,d_co2ice,d_h2oice,d_dust,new_str,zshift_surf,new_lag1,new_lag2,zlag,stopPEM,current1,current2) |
---|
[3286] | 454 | |
---|
| 455 | implicit none |
---|
| 456 | |
---|
| 457 | !---- Arguments |
---|
[3553] | 458 | ! Inputs |
---|
| 459 | real, intent(in) :: d_co2ice, d_h2oice, d_dust |
---|
| 460 | |
---|
| 461 | ! Outputs |
---|
[3286] | 462 | type(layering), intent(inout) :: this |
---|
| 463 | type(stratum), pointer, intent(inout) :: current1, current2 |
---|
[3297] | 464 | logical, intent(inout) :: new_str, new_lag1, new_lag2 |
---|
| 465 | integer, intent(inout) :: stopPEM |
---|
[3553] | 466 | real, intent(out) :: zshift_surf, zlag |
---|
[3286] | 467 | |
---|
| 468 | !---- Local variables |
---|
[3498] | 469 | real :: dh_co2ice, dh_h2oice, dh_dust |
---|
[3424] | 470 | real :: h_co2ice_old, h_h2oice_old, h_dust_old |
---|
| 471 | real :: thickness, h2subl, h2subl_tot, h2lift, h2lift_tot |
---|
| 472 | real :: h_toplag |
---|
| 473 | type(stratum), pointer :: currentloc |
---|
[3286] | 474 | |
---|
| 475 | !---- Code |
---|
[3498] | 476 | dh_co2ice = d_co2ice/rho_co2ice |
---|
| 477 | dh_h2oice = d_h2oice/rho_h2oice |
---|
| 478 | dh_dust = d_dust/rho_dust |
---|
[3553] | 479 | zshift_surf = 0. |
---|
| 480 | zlag = 0. |
---|
[3297] | 481 | |
---|
[3498] | 482 | if (dh_dust < 0.) then ! Dust lifting only |
---|
| 483 | if (abs(dh_co2ice) > eps .or. abs(dh_h2oice) > eps) error stop 'Situation not managed: dust lifting + CO2/H2O ice condensation/sublimation!' |
---|
[3297] | 484 | write(*,'(a)') ' Stratification -> Dust lifting' |
---|
[3498] | 485 | h2lift_tot = abs(dh_dust) |
---|
[3286] | 486 | do while (h2lift_tot > 0. .and. associated(current1)) |
---|
| 487 | ! Is the considered stratum a dust lag? |
---|
| 488 | if (abs(1. - (current1%dust_volfrac + current1%air_volfrac)) < tol) then ! Yes, we can lift dust |
---|
| 489 | h_dust_old = current1%dust_volfrac*current1%thickness |
---|
| 490 | ! How much dust can be lifted in the considered dust lag? |
---|
| 491 | if (h2lift_tot - h_dust_old <= eps) then ! There is enough to lift |
---|
| 492 | h2lift = h2lift_tot |
---|
| 493 | h2lift_tot = 0. |
---|
| 494 | call lift_dust_lags(this,current1,h2lift) |
---|
| 495 | else ! Only a fraction can be lifted and so we move to the underlying stratum |
---|
| 496 | h2lift = h_dust_old |
---|
| 497 | h2lift_tot = h2lift_tot - h2lift |
---|
| 498 | call lift_dust_lags(this,current1,h2lift) |
---|
| 499 | current1 => current1%down |
---|
| 500 | endif |
---|
| 501 | else ! No, we stop |
---|
[3297] | 502 | write(*,'(a)') ' Stratification -> Dust lifting: no dust lag!' |
---|
[3430] | 503 | stopPEM = 8 |
---|
[3286] | 504 | exit |
---|
| 505 | endif |
---|
| 506 | enddo |
---|
| 507 | if (h2lift_tot > 0.) then |
---|
[3297] | 508 | write(*,'(a)') ' Stratification -> Not enough dust in the lag layers to complete the lifting!' |
---|
[3430] | 509 | stopPEM = 8 |
---|
[3286] | 510 | endif |
---|
[3553] | 511 | zshift_surf = dh_dust + h2lift_tot |
---|
[3286] | 512 | |
---|
| 513 | else |
---|
| 514 | |
---|
[3331] | 515 | !------ Dust sedimentation only |
---|
[3498] | 516 | if (abs(dh_co2ice) < eps .and. abs(dh_h2oice) < eps) then |
---|
[3297] | 517 | write(*,'(a)') ' Stratification -> Dust sedimentation' |
---|
[3286] | 518 | ! New stratum at the layering top by sedimentation of dust |
---|
[3498] | 519 | thickness = dh_dust/(1. - dry_regolith_porosity) |
---|
[3331] | 520 | if (thickness > 0.) then ! Only if the stratum is building up |
---|
[3286] | 521 | if (new_str) then |
---|
[3498] | 522 | call add_stratum(this,thickness,this%top%top_elevation + thickness,0.,0.,dh_dust/thickness,dry_regolith_porosity) |
---|
[3286] | 523 | new_str = .false. |
---|
| 524 | else |
---|
| 525 | this%top%thickness = this%top%thickness + thickness |
---|
[3297] | 526 | this%top%top_elevation = this%top%top_elevation + thickness |
---|
[3286] | 527 | endif |
---|
| 528 | endif |
---|
[3553] | 529 | zshift_surf = thickness |
---|
[3286] | 530 | |
---|
| 531 | !------ Condensation of CO2 ice + H2O ice |
---|
[3498] | 532 | else if ((dh_co2ice >= 0. .and. dh_h2oice > 0.) .or. (dh_co2ice > 0. .and. dh_h2oice >= 0.)) then |
---|
[3297] | 533 | write(*,'(a)') ' Stratification -> CO2 and H2O ice condensation' |
---|
[3286] | 534 | ! New stratum at the layering top by condensation of CO2 and H2O ice |
---|
[3498] | 535 | thickness = dh_co2ice/(1. - co2ice_porosity) + dh_h2oice/(1. - h2oice_porosity) + dh_dust |
---|
[3331] | 536 | if (thickness > 0.) then ! Only if the stratum is building up |
---|
[3286] | 537 | if (new_str) then |
---|
[3498] | 538 | call add_stratum(this,thickness,this%top%top_elevation + thickness,dh_co2ice/thickness,dh_h2oice/thickness,dh_dust/thickness,1. - (dh_co2ice/thickness + dh_h2oice/thickness + dh_dust/thickness)) |
---|
[3286] | 539 | new_str = .false. |
---|
| 540 | else |
---|
| 541 | this%top%thickness = this%top%thickness + thickness |
---|
[3297] | 542 | this%top%top_elevation = this%top%top_elevation + thickness |
---|
[3286] | 543 | endif |
---|
| 544 | endif |
---|
[3553] | 545 | zshift_surf = thickness |
---|
[3286] | 546 | |
---|
| 547 | !------ Sublimation of CO2 ice + Condensation of H2O ice |
---|
[3498] | 548 | else if (dh_co2ice < 0. .and. dh_h2oice > 0.) then |
---|
[3297] | 549 | write(*,'(a)') ' Stratification -> Sublimation of CO2 ice + Condensation of H2O ice' |
---|
[3286] | 550 | ! CO2 ice sublimation in the considered stratum + New stratum for dust lag |
---|
[3498] | 551 | h2subl_tot = abs(dh_co2ice) |
---|
[3286] | 552 | do while (h2subl_tot > 0. .and. associated(current1)) |
---|
| 553 | h_co2ice_old = current1%co2ice_volfrac*current1%thickness |
---|
| 554 | h_h2oice_old = current1%h2oice_volfrac*current1%thickness |
---|
| 555 | h_dust_old = current1%dust_volfrac*current1%thickness |
---|
[3424] | 556 | |
---|
| 557 | ! How much is CO2 ice sublimation inhibited by the top dust lag? |
---|
| 558 | h_toplag = 0. |
---|
[3430] | 559 | if (associated(current1%up)) then ! If there is an upper stratum |
---|
| 560 | currentloc => current1%up |
---|
| 561 | do while (abs(1. - (currentloc%dust_volfrac + currentloc%air_volfrac)) < tol) |
---|
| 562 | h_toplag = h_toplag + currentloc%thickness |
---|
| 563 | if (.not. associated(currentloc%up)) exit |
---|
| 564 | currentloc => currentloc%up |
---|
| 565 | enddo |
---|
| 566 | endif |
---|
[3424] | 567 | h2subl_tot = h2subl_tot*fred_subl**(h_toplag/hmin_lag) |
---|
| 568 | |
---|
[3286] | 569 | ! How much CO2 ice can sublimate in the considered stratum? |
---|
| 570 | if (h2subl_tot - h_co2ice_old <= eps) then ! There is enough to sublimate |
---|
| 571 | h2subl = h2subl_tot |
---|
| 572 | h2subl_tot = 0. |
---|
[3553] | 573 | call subl_co2ice_layering(this,current1,h2subl,h_co2ice_old,h_h2oice_old,h_dust_old,zshift_surf,new_lag1,zlag) |
---|
[3424] | 574 | else if (h_co2ice_old < eps) then ! There is nothing to sublimate |
---|
| 575 | ! Is the considered stratum a dust lag? |
---|
| 576 | if (abs(1. - (current1%dust_volfrac + current1%air_volfrac)) < tol) then ! Yes, we move to the underlying stratum |
---|
| 577 | current1 => current1%down |
---|
| 578 | new_lag1 = .true. |
---|
| 579 | else ! No, so we stop here |
---|
| 580 | exit |
---|
| 581 | endif |
---|
[3286] | 582 | else ! Only a fraction can sublimate and so we move to the underlying stratum |
---|
| 583 | h2subl = h_co2ice_old |
---|
| 584 | h2subl_tot = h2subl_tot - h2subl |
---|
[3553] | 585 | call subl_co2ice_layering(this,current1,h2subl,h_co2ice_old,h_h2oice_old,h_dust_old,zshift_surf,new_lag1,zlag) |
---|
[3286] | 586 | current1 => current1%down |
---|
| 587 | new_lag1 = .true. |
---|
| 588 | endif |
---|
| 589 | enddo |
---|
| 590 | if (h2subl_tot > 0.) then |
---|
[3297] | 591 | write(*,'(a)') ' Stratification -> Not enough CO2 ice in the layering to complete the sublimation!' |
---|
[3430] | 592 | stopPEM = 8 |
---|
[3286] | 593 | endif |
---|
| 594 | ! New stratum at the layering top by condensation of H2O ice |
---|
[3498] | 595 | thickness = dh_h2oice/(1. - h2oice_porosity) + dh_dust |
---|
[3331] | 596 | if (thickness > 0.) then ! Only if the stratum is building up |
---|
[3286] | 597 | if (new_str) then |
---|
[3498] | 598 | call add_stratum(this,thickness,this%top%top_elevation + thickness,0.,dh_h2oice/thickness,dh_dust/thickness,1. - (dh_h2oice/thickness + dh_dust/thickness)) |
---|
[3286] | 599 | new_str = .false. |
---|
| 600 | else |
---|
| 601 | this%top%thickness = this%top%thickness + thickness |
---|
[3297] | 602 | this%top%top_elevation = this%top%top_elevation + thickness |
---|
[3286] | 603 | endif |
---|
| 604 | endif |
---|
[3553] | 605 | zshift_surf = zshift_surf + thickness |
---|
[3286] | 606 | |
---|
| 607 | !------ Sublimation of CO2 ice + H2O ice |
---|
[3498] | 608 | else if ((dh_co2ice <= 0. .and. dh_h2oice < 0.) .or. (dh_co2ice < 0. .and. dh_h2oice <= 0.)) then |
---|
[3297] | 609 | write(*,'(a)') ' Stratification -> Sublimation of CO2 and H2O ice' |
---|
[3286] | 610 | ! CO2 ice sublimation in the considered stratum + New stratum for dust lag |
---|
[3498] | 611 | h2subl_tot = abs(dh_co2ice) |
---|
[3286] | 612 | do while (h2subl_tot > 0. .and. associated(current1)) |
---|
| 613 | h_co2ice_old = current1%co2ice_volfrac*current1%thickness |
---|
| 614 | h_h2oice_old = current1%h2oice_volfrac*current1%thickness |
---|
| 615 | h_dust_old = current1%dust_volfrac*current1%thickness |
---|
[3424] | 616 | |
---|
| 617 | ! How much is CO2 ice sublimation inhibited by the top dust lag? |
---|
| 618 | h_toplag = 0. |
---|
[3430] | 619 | if (associated(current1%up)) then ! If there is an upper stratum |
---|
| 620 | currentloc => current1%up |
---|
| 621 | do while (abs(1. - (currentloc%dust_volfrac + currentloc%air_volfrac)) < tol) |
---|
| 622 | h_toplag = h_toplag + currentloc%thickness |
---|
| 623 | if (.not. associated(currentloc%up)) exit |
---|
| 624 | currentloc => currentloc%up |
---|
| 625 | enddo |
---|
| 626 | endif |
---|
[3424] | 627 | h2subl_tot = h2subl_tot*fred_subl**(h_toplag/hmin_lag) |
---|
| 628 | |
---|
[3286] | 629 | ! How much CO2 ice can sublimate in the considered stratum? |
---|
| 630 | if (h2subl_tot - h_co2ice_old <= eps) then ! There is enough to sublimate |
---|
| 631 | h2subl = h2subl_tot |
---|
| 632 | h2subl_tot = 0. |
---|
[3553] | 633 | call subl_co2ice_layering(this,current1,h2subl,h_co2ice_old,h_h2oice_old,h_dust_old,zshift_surf,new_lag1,zlag) |
---|
[3424] | 634 | else if (h_co2ice_old < eps) then ! There is nothing to sublimate |
---|
| 635 | ! Is the considered stratum a dust lag? |
---|
| 636 | if (abs(1. - (current1%dust_volfrac + current1%air_volfrac)) < tol) then ! Yes, we move to the underlying stratum |
---|
| 637 | current1 => current1%down |
---|
| 638 | new_lag1 = .true. |
---|
| 639 | else ! No, so we stop here |
---|
| 640 | exit |
---|
| 641 | endif |
---|
[3286] | 642 | else ! Only a fraction can sublimate and so we move to the underlying stratum |
---|
| 643 | h2subl = h_co2ice_old |
---|
| 644 | h2subl_tot = h2subl_tot - h2subl |
---|
[3553] | 645 | call subl_co2ice_layering(this,current1,h2subl,h_co2ice_old,h_h2oice_old,h_dust_old,zshift_surf,new_lag1,zlag) |
---|
[3286] | 646 | current1 => current1%down |
---|
| 647 | new_lag1 = .true. |
---|
| 648 | endif |
---|
| 649 | enddo |
---|
| 650 | if (h2subl_tot > 0.) then |
---|
[3297] | 651 | write(*,'(a)') ' Stratification -> Not enough CO2 ice in the layering to complete the sublimation!' |
---|
[3430] | 652 | stopPEM = 8 |
---|
[3286] | 653 | endif |
---|
| 654 | ! H2O ice sublimation in the considered stratum + New stratum for dust lag |
---|
[3498] | 655 | h2subl_tot = abs(dh_h2oice) |
---|
[3286] | 656 | do while (h2subl_tot > 0. .and. associated(current2)) |
---|
| 657 | h_co2ice_old = current2%co2ice_volfrac*current2%thickness |
---|
| 658 | h_h2oice_old = current2%h2oice_volfrac*current2%thickness |
---|
| 659 | h_dust_old = current2%dust_volfrac*current2%thickness |
---|
[3424] | 660 | |
---|
[3430] | 661 | ! How much is H2O ice sublimation inhibited by the top dust lag? |
---|
[3424] | 662 | h_toplag = 0. |
---|
[3430] | 663 | if (associated(current2%up)) then ! If there is an upper stratum |
---|
| 664 | currentloc => current2%up |
---|
| 665 | do while (abs(1. - (currentloc%dust_volfrac + currentloc%air_volfrac)) < tol) |
---|
| 666 | h_toplag = h_toplag + currentloc%thickness |
---|
| 667 | if (.not. associated(currentloc%up)) exit |
---|
| 668 | currentloc => currentloc%up |
---|
| 669 | enddo |
---|
| 670 | endif |
---|
[3424] | 671 | h2subl_tot = h2subl_tot*fred_subl**(h_toplag/hmin_lag) |
---|
| 672 | |
---|
[3286] | 673 | ! How much H2O ice can sublimate in the considered stratum? |
---|
| 674 | if (h2subl_tot - h_h2oice_old <= eps) then ! There is enough to sublimate |
---|
| 675 | h2subl = h2subl_tot |
---|
| 676 | h2subl_tot = 0. |
---|
[3553] | 677 | call subl_h2oice_layering(this,current2,h2subl,h_co2ice_old,h_h2oice_old,h_dust_old,zshift_surf,new_lag2,zlag) |
---|
[3424] | 678 | else if (h_h2oice_old < eps) then ! There is nothing to sublimate |
---|
| 679 | ! Is the considered stratum a dust lag? |
---|
| 680 | if (abs(1. - (current1%dust_volfrac + current1%air_volfrac)) < tol) then ! Yes, we move to the underlying stratum |
---|
| 681 | current1 => current1%down |
---|
| 682 | new_lag1 = .true. |
---|
| 683 | else ! No, so we stop here |
---|
| 684 | exit |
---|
| 685 | endif |
---|
[3286] | 686 | else ! Only a fraction can sublimate and so we move to the underlying stratum |
---|
| 687 | h2subl = h_h2oice_old |
---|
| 688 | h2subl_tot = h2subl_tot - h2subl |
---|
[3553] | 689 | call subl_h2oice_layering(this,current2,h2subl,h_co2ice_old,h_h2oice_old,h_dust_old,zshift_surf,new_lag2,zlag) |
---|
[3286] | 690 | current2 => current2%down |
---|
| 691 | new_lag2 = .true. |
---|
| 692 | endif |
---|
| 693 | enddo |
---|
| 694 | if (h2subl_tot > 0.) then |
---|
[3297] | 695 | write(*,'(a)') ' Stratification -> Not enough H2O ice in the layering to complete the sublimation!' |
---|
[3430] | 696 | stopPEM = 8 |
---|
[3286] | 697 | endif |
---|
| 698 | |
---|
| 699 | !------ Condensation of CO2 ice + Sublimation of H2O ice |
---|
[3498] | 700 | else if (dh_co2ice > 0. .and. dh_h2oice < 0.) then |
---|
[3286] | 701 | error stop 'Impossible situation: CO2 ice condensation + H2O ice sublimation!' |
---|
| 702 | endif |
---|
| 703 | endif |
---|
| 704 | |
---|
| 705 | END SUBROUTINE make_layering |
---|
| 706 | |
---|
[3297] | 707 | !======================================================================= |
---|
| 708 | ! To sublimate CO2 ice in the layering |
---|
[3553] | 709 | SUBROUTINE subl_co2ice_layering(this,str,h2subl,h_co2ice_old,h_h2oice_old,h_dust_old,zshift_surf,new_lag,zlag) |
---|
[3297] | 710 | |
---|
| 711 | implicit none |
---|
| 712 | |
---|
| 713 | !---- Arguments |
---|
| 714 | type(layering), intent(inout) :: this |
---|
| 715 | type(stratum), pointer, intent(inout) :: str |
---|
| 716 | logical, intent(inout) :: new_lag |
---|
[3553] | 717 | real, intent(inout) :: zshift_surf, zlag |
---|
[3297] | 718 | real, intent(in) :: h2subl, h_co2ice_old, h_h2oice_old, h_dust_old |
---|
| 719 | |
---|
| 720 | !---- Local variables |
---|
| 721 | real :: r_subl, hsubl_dust, h_lag |
---|
| 722 | type(stratum), pointer :: current |
---|
| 723 | |
---|
| 724 | !---- Code |
---|
| 725 | ! How much dust does CO2 ice sublimation involve to create the lag? |
---|
| 726 | r_subl = h2subl/(1. - co2ice_porosity) & |
---|
| 727 | /(str%thickness*(str%co2ice_volfrac/(1. - co2ice_porosity) + str%h2oice_volfrac/(1. - h2oice_porosity))) |
---|
| 728 | hsubl_dust = r_subl*str%dust_volfrac*str%thickness |
---|
[3321] | 729 | |
---|
[3297] | 730 | str%thickness = str%thickness - h2subl/(1. - co2ice_porosity) - hsubl_dust |
---|
[3553] | 731 | zshift_surf = zshift_surf - h2subl/(1. - co2ice_porosity) - hsubl_dust |
---|
[3321] | 732 | if (str%thickness < tol) then |
---|
| 733 | ! Remove the sublimating stratum if there is no ice anymore |
---|
| 734 | call rm_stratum(this,str) |
---|
| 735 | else |
---|
| 736 | ! Update of properties in the sublimating stratum |
---|
| 737 | str%top_elevation = str%top_elevation - h2subl/(1. - co2ice_porosity) - hsubl_dust |
---|
| 738 | str%co2ice_volfrac = (h_co2ice_old - h2subl)/str%thickness |
---|
| 739 | str%h2oice_volfrac = h_h2oice_old/str%thickness |
---|
| 740 | str%dust_volfrac = (h_dust_old - hsubl_dust)/str%thickness |
---|
| 741 | str%air_volfrac = 1. - (str%co2ice_volfrac + str%h2oice_volfrac + str%dust_volfrac) |
---|
| 742 | ! Correct the value of top_elevation for the upper strata |
---|
| 743 | current => str%up |
---|
| 744 | do while (associated(current)) |
---|
| 745 | current%top_elevation = current%down%top_elevation + current%thickness |
---|
| 746 | current => current%up |
---|
| 747 | enddo |
---|
| 748 | endif |
---|
| 749 | |
---|
[3297] | 750 | ! New stratum = dust lag |
---|
| 751 | h_lag = hsubl_dust/(1. - dry_lag_porosity) |
---|
| 752 | if (h_lag > 0.) then ! Only if the dust lag is building up |
---|
| 753 | if (new_lag) then |
---|
| 754 | call insert_stratum(this,str,h_lag,str%top_elevation + h_lag,0.,0.,1. - dry_lag_porosity,dry_lag_porosity) |
---|
| 755 | new_lag = .false. |
---|
| 756 | else |
---|
| 757 | str%up%thickness = str%up%thickness + h_lag |
---|
| 758 | str%up%top_elevation = str%up%top_elevation + h_lag |
---|
| 759 | endif |
---|
| 760 | endif |
---|
[3553] | 761 | zlag = zlag + h_lag |
---|
[3297] | 762 | |
---|
| 763 | END SUBROUTINE subl_co2ice_layering |
---|
| 764 | |
---|
| 765 | !======================================================================= |
---|
| 766 | ! To sublimate H2O ice in the layering |
---|
[3553] | 767 | SUBROUTINE subl_h2oice_layering(this,str,h2subl,h_co2ice_old,h_h2oice_old,h_dust_old,zshift_surf,new_lag,zlag) |
---|
[3297] | 768 | |
---|
| 769 | implicit none |
---|
| 770 | |
---|
| 771 | !---- Arguments |
---|
| 772 | type(layering), intent(inout) :: this |
---|
| 773 | type(stratum), pointer, intent(inout) :: str |
---|
| 774 | logical, intent(inout) :: new_lag |
---|
[3553] | 775 | real, intent(inout) :: zshift_surf, zlag |
---|
[3297] | 776 | real, intent(in) :: h2subl, h_co2ice_old, h_h2oice_old, h_dust_old |
---|
| 777 | |
---|
| 778 | !---- Local variables |
---|
| 779 | real :: r_subl, hsubl_dust, h_lag |
---|
| 780 | type(stratum), pointer :: current |
---|
| 781 | |
---|
| 782 | !---- Code |
---|
| 783 | ! How much dust does CO2 ice sublimation involve to create the lag? |
---|
| 784 | r_subl = h2subl/(1. - h2oice_porosity) & |
---|
| 785 | /(str%thickness*(str%co2ice_volfrac/(1. - co2ice_porosity) + str%h2oice_volfrac/(1. - h2oice_porosity))) |
---|
| 786 | hsubl_dust = r_subl*str%dust_volfrac*str%thickness |
---|
[3321] | 787 | |
---|
[3297] | 788 | str%thickness = str%thickness - h2subl/(1. - h2oice_porosity) - hsubl_dust |
---|
[3553] | 789 | zshift_surf = zshift_surf - h2subl/(1. - h2oice_porosity) - hsubl_dust |
---|
[3321] | 790 | if (str%thickness < tol) then |
---|
| 791 | ! Remove the sublimating stratum if there is no ice anymore |
---|
| 792 | call rm_stratum(this,str) |
---|
| 793 | else |
---|
| 794 | ! Update of properties in the sublimating stratum |
---|
| 795 | str%top_elevation = str%top_elevation - h2subl/(1. - h2oice_porosity) - hsubl_dust |
---|
| 796 | str%co2ice_volfrac = h_co2ice_old/str%thickness |
---|
| 797 | str%h2oice_volfrac = (h_h2oice_old - h2subl)/str%thickness |
---|
| 798 | str%dust_volfrac = (h_dust_old - hsubl_dust)/str%thickness |
---|
| 799 | str%air_volfrac = 1. - (str%co2ice_volfrac + str%h2oice_volfrac + str%dust_volfrac) |
---|
| 800 | ! Correct the value of top_elevation for the upper strata |
---|
| 801 | current => str%up |
---|
| 802 | do while (associated(current)) |
---|
| 803 | current%top_elevation = current%down%top_elevation + current%thickness |
---|
| 804 | current => current%up |
---|
| 805 | enddo |
---|
| 806 | endif |
---|
| 807 | |
---|
[3297] | 808 | ! New stratum = dust lag |
---|
| 809 | h_lag = hsubl_dust/(1. - dry_lag_porosity) |
---|
| 810 | if (h_lag > 0.) then ! Only if the dust lag is building up |
---|
| 811 | if (new_lag) then |
---|
| 812 | call insert_stratum(this,str,h_lag,str%top_elevation + h_lag,0.,0.,1. - dry_lag_porosity,dry_lag_porosity) |
---|
| 813 | new_lag = .false. |
---|
| 814 | else |
---|
| 815 | str%up%thickness = str%up%thickness + h_lag |
---|
| 816 | str%up%top_elevation = str%up%top_elevation + h_lag |
---|
| 817 | endif |
---|
| 818 | endif |
---|
[3553] | 819 | zlag = zlag + h_lag |
---|
[3297] | 820 | |
---|
| 821 | END SUBROUTINE subl_h2oice_layering |
---|
| 822 | |
---|
| 823 | !======================================================================= |
---|
| 824 | ! To lift dust in the layering |
---|
| 825 | SUBROUTINE lift_dust_lags(this,str,h2lift) |
---|
| 826 | |
---|
| 827 | implicit none |
---|
| 828 | |
---|
| 829 | !---- Arguments |
---|
| 830 | type(layering), intent(inout) :: this |
---|
| 831 | type(stratum), pointer, intent(inout) :: str |
---|
| 832 | real, intent(in) :: h2lift |
---|
| 833 | |
---|
| 834 | !---- Code |
---|
| 835 | ! Update of properties in the eroding dust lag |
---|
| 836 | str%thickness = str%thickness - h2lift/(1. - str%air_volfrac) |
---|
| 837 | str%top_elevation = str%top_elevation - h2lift/(1. - str%air_volfrac) |
---|
| 838 | ! Remove the eroding dust lag if there is no dust anymore |
---|
| 839 | if (str%thickness < tol) call rm_stratum(this,str) |
---|
| 840 | |
---|
| 841 | END SUBROUTINE lift_dust_lags |
---|
| 842 | |
---|
[3286] | 843 | END MODULE layering_mod |
---|