Changeset 4157 for trunk/LMDZ.COMMON/libf/evolution/planet.F90
- Timestamp:
- Mar 26, 2026, 4:29:10 PM (11 days ago)
- File:
-
- 1 edited
-
trunk/LMDZ.COMMON/libf/evolution/planet.F90 (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.COMMON/libf/evolution/planet.F90
r4135 r4157 5 5 ! 6 6 ! DESCRIPTION 7 ! Legacy compatibility module for planet-specific definitions. 8 ! 9 ! AUTHORS & DATE 10 ! R. Vandemeulebrouck 11 ! JB Clement, 2023-2025 12 ! 13 ! NOTES 14 ! Only valid for the Mars planet. 15 !----------------------------------------------------------------------- 16 17 ! DECLARATION 18 ! ----------- 19 implicit none 20 21 ! NOTE 22 ! ---- 7 ! Centralized climate-state storage and lifecycle helpers for PEM. 8 ! 9 ! AUTHORS & DATE 10 ! JB Clement, 03/2026 11 ! 12 ! NOTES 13 ! Ownership criterion for declarations: 14 ! - Declare in module "planet" variables that are persistent climate 15 ! state or persistent references used across multiple time steps. 16 ! - Declare in program "pem.F90" transient workflow/control varaibles, 17 ! one-shot initialization buffers and per-iteration working buffers. 18 !----------------------------------------------------------------------- 19 20 ! DEPENDENCIES 21 ! ------------ 22 use numerics, only: dp, qp, k4 23 use layered_deposits, only: layering 24 25 ! DECLARATION 26 ! ----------- 27 implicit none 28 29 ! PARAMETERS 30 ! ---------- 31 ! Pressure-related: 32 real(dp), dimension(:), allocatable :: ps_avg ! Average surface pressure [Pa] 33 real(dp), dimension(:,:), allocatable :: ps_ts ! Surface pressure timeseries [Pa] 34 real(dp), dimension(:), allocatable :: ps_dev ! Deviation of surface pressure [Pa] 35 real(dp) :: ps_avg_glob_ini ! Global average pressure at initialization [Pa] 36 real(dp) :: ps_avg_glob_old ! Global average pressure of previous time step [Pa] 37 real(dp) :: ps_avg_glob ! Global average pressure of current time step [Pa] 38 39 ! Ice-related: 40 real(dp), dimension(:,:), allocatable :: h2o_ice ! H2O ice [kg.m-2] 41 real(dp), dimension(:,:), allocatable :: co2_ice ! CO2 ice [kg.m-2] 42 real(dp) :: h2oice_sublim_coverage_ini ! Initial surface area of sublimating H2O ice [m2] 43 real(dp) :: co2ice_sublim_coverage_ini ! Initial surface area of sublimating CO2 ice [m2] 44 logical(k4), dimension(:,:), allocatable :: is_h2oice_ini ! Initial location of H2O ice 45 logical(k4), dimension(:,:), allocatable :: is_co2ice_ini ! Initial location of CO2 ice 46 logical(k4), dimension(:,:), allocatable :: is_co2ice_disappeared ! Flag to check if CO2 ice disappeared at the previous timestep 47 48 ! Surface-related: 49 real(dp), dimension(:,:), allocatable :: tsurf_avg ! Average surface temperature [K] 50 real(dp), dimension(:,:), allocatable :: tsurf_dev ! Deviation of surface temperature [K] 51 real(dp), dimension(:,:), allocatable :: h2o_surfdensity_avg ! Average water surface density [kg/m^3] 52 53 ! Soil-related: 54 real(dp), dimension(:,:,:), allocatable :: tsoil_avg ! Average soil temperature [K] 55 real(dp), dimension(:,:,:), allocatable :: tsoil_dev ! Deviation of soil temperature [K] 56 real(dp), dimension(:,:,:,:), allocatable :: tsoil_ts ! Soil temperature timeseries [K] 57 real(dp), dimension(:,:,:,:), allocatable :: tsoil_ts_old ! Soil temperature timeseries at the previous time step [K] 58 59 ! Layering-related: 60 type(layering), dimension(:,:), allocatable :: layerings_map ! Layering for each grid point and slope 61 62 ! Sorption-related: 63 real(dp), dimension(:,:,:), allocatable :: h2o_soildensity_avg ! Average of soil water soil density [kg/m^3] 64 real(dp), dimension(:), allocatable :: delta_co2_ads ! Quantity of CO2 exchanged due to adsorption/desorption [kg/m^2] 65 real(dp), dimension(:), allocatable :: delta_h2o_ads ! Quantity of H2O exchanged due to adsorption/desorption [kg/m^2] 66 real(dp), dimension(:,:,:), allocatable :: h2o_ads_reg ! H2O adsorbed in the regolith [kg/m^2] 67 real(dp), dimension(:,:,:), allocatable :: co2_ads_reg ! CO2 adsorbed in the regolith [kg/m^2] 68 69 ! Ice table-related: 70 real(dp), dimension(:,:), allocatable :: icetable_depth ! Depth of the ice table [m] 71 real(dp), dimension(:,:), allocatable :: icetable_thickness ! Thickness of the ice table [m] 72 real(dp), dimension(:,:,:), allocatable :: ice_porefilling ! Amount of porefilling [m^3/m^3] 73 real(dp), dimension(:,:), allocatable :: icetable_depth_old ! Old depth of the ice table [m] 74 real(dp), dimension(:), allocatable :: delta_icetable ! Total mass of the H2O exchanged with the ice table [kg] 75 76 ! Tracer-related: 77 real(dp), dimension(:,:), allocatable :: q_co2_ts ! CO2 mass mixing ratio in the first layer [kg/kg] 78 real(dp), dimension(:,:), allocatable :: q_co2_ts_ini ! Initial CO2 mass mixing ratio in the first layer [kg/kg] 79 real(dp), dimension(:,:), allocatable :: q_h2o_ts ! H2O mass mixing ratio in the first layer [kg/kg] 80 81 ! Tendency-related: 82 real(dp), dimension(:,:), allocatable :: d_co2ice ! Tendency of perennial CO2 ice [kg/m2/y] 83 real(dp), dimension(:,:), allocatable :: d_co2ice_ini ! Tendency of perennial CO2 ice at the beginning [kg/m2/y] 84 real(dp), dimension(:,:), allocatable :: d_h2oice ! Tendency of perennial H2O ice [kg/m2/y] 23 85 24 86 contains 25 87 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 26 88 89 !======================================================================= 90 SUBROUTINE ini_planet() 91 !----------------------------------------------------------------------- 92 ! NAME 93 ! ini_planet 94 ! 95 ! DESCRIPTION 96 ! Initialize scalar state values of module planet. 97 ! 98 ! AUTHORS & DATE 99 ! JB Clement, 03/2026 100 ! 101 ! NOTES 102 ! 103 !----------------------------------------------------------------------- 104 105 ! DECLARATION 106 ! ----------- 107 implicit none 108 109 ! CODE 110 ! ---- 111 ps_avg_glob_ini = 0._dp 112 ps_avg_glob_old = 0._dp 113 ps_avg_glob = 0._dp 114 h2oice_sublim_coverage_ini = 0._dp 115 co2ice_sublim_coverage_ini = 0._dp 116 117 END SUBROUTINE ini_planet 118 !======================================================================= 119 120 !======================================================================= 121 SUBROUTINE allocate_xios_state() 122 !----------------------------------------------------------------------- 123 ! NAME 124 ! allocate_xios_state 125 ! 126 ! DESCRIPTION 127 ! Allocate arrays needed before loading PCM/XIOS data. 128 ! 129 ! AUTHORS & DATE 130 ! JB Clement, 03/2026 131 ! 132 ! NOTES 133 ! 134 !----------------------------------------------------------------------- 135 136 ! DEPENDENCIES 137 ! ------------ 138 use geometry, only: ngrid, nslope, nday, nsoil 139 140 ! DECLARATION 141 ! ----------- 142 implicit none 143 144 ! CODE 145 ! ---- 146 allocate(ps_avg(ngrid)) 147 allocate(ps_ts(ngrid,nday)) 148 allocate(tsurf_avg(ngrid,nslope)) 149 allocate(h2o_surfdensity_avg(ngrid,nslope)) 150 allocate(tsoil_avg(ngrid,nsoil,nslope)) 151 allocate(tsoil_ts(ngrid,nsoil,nslope,nday)) 152 allocate(h2o_soildensity_avg(ngrid,nsoil,nslope)) 153 allocate(q_h2o_ts(ngrid,nday)) 154 allocate(q_co2_ts(ngrid,nday)) 155 156 ps_avg(:) = 0._dp 157 ps_ts(:,:) = 0._dp 158 tsurf_avg(:,:) = 0._dp 159 h2o_surfdensity_avg(:,:) = 0._dp 160 tsoil_avg(:,:,:) = 0._dp 161 tsoil_ts(:,:,:,:) = 0._dp 162 h2o_soildensity_avg(:,:,:) = 0._dp 163 q_h2o_ts(:,:) = 0._dp 164 q_co2_ts(:,:) = 0._dp 165 166 END SUBROUTINE allocate_xios_state 167 !======================================================================= 168 169 !======================================================================= 170 SUBROUTINE allocate_deviation_state() 171 !----------------------------------------------------------------------- 172 ! NAME 173 ! allocate_deviation_state 174 ! 175 ! DESCRIPTION 176 ! Allocate persistent deviation fields derived from PCM averages. 177 ! 178 ! AUTHORS & DATE 179 ! JB Clement, 03/2026 180 ! 181 ! NOTES 182 ! 183 !----------------------------------------------------------------------- 184 185 ! DEPENDENCIES 186 ! ------------ 187 use geometry, only: ngrid, nslope, nsoil_PCM 188 189 ! DECLARATION 190 ! ----------- 191 implicit none 192 193 ! CODE 194 ! ---- 195 allocate(ps_dev(ngrid)) 196 allocate(tsurf_dev(ngrid,nslope)) 197 allocate(tsoil_dev(ngrid,nsoil_PCM,nslope)) 198 199 ps_dev(:) = 0._dp 200 tsurf_dev(:,:) = 0._dp 201 tsoil_dev(:,:,:) = 0._dp 202 203 END SUBROUTINE allocate_deviation_state 204 !======================================================================= 205 206 !======================================================================= 207 SUBROUTINE allocate_startevo_state() 208 !----------------------------------------------------------------------- 209 ! NAME 210 ! allocate_startevo_state 211 ! 212 ! DESCRIPTION 213 ! Allocate arrays loaded from startevo or evolving afterward. 214 ! 215 ! AUTHORS & DATE 216 ! JB Clement, 03/2026 217 ! 218 ! NOTES 219 ! 220 !----------------------------------------------------------------------- 221 222 ! DEPENDENCIES 223 ! ------------ 224 use geometry, only: ngrid, nslope, nsoil 225 226 ! DECLARATION 227 ! ----------- 228 implicit none 229 230 ! CODE 231 ! ---- 232 allocate(h2o_ice(ngrid,nslope)) 233 allocate(co2_ice(ngrid,nslope)) 234 allocate(icetable_depth(ngrid,nslope)) 235 allocate(icetable_thickness(ngrid,nslope)) 236 allocate(ice_porefilling(ngrid,nsoil,nslope)) 237 allocate(h2o_ads_reg(ngrid,nsoil,nslope)) 238 allocate(co2_ads_reg(ngrid,nsoil,nslope)) 239 allocate(delta_h2o_ads(ngrid)) 240 allocate(delta_co2_ads(ngrid)) 241 allocate(layerings_map(ngrid,nslope)) 242 243 h2o_ice(:,:) = 0._dp 244 co2_ice(:,:) = 0._dp 245 icetable_depth(:,:) = 0._dp 246 icetable_thickness(:,:) = 0._dp 247 ice_porefilling(:,:,:) = 0._dp 248 h2o_ads_reg(:,:,:) = 0._dp 249 co2_ads_reg(:,:,:) = 0._dp 250 delta_h2o_ads(:) = 0._dp 251 delta_co2_ads(:) = 0._dp 252 253 END SUBROUTINE allocate_startevo_state 254 !======================================================================= 255 256 !======================================================================= 257 SUBROUTINE allocate_tendencies() 258 !----------------------------------------------------------------------- 259 ! NAME 260 ! allocate_tendencies 261 ! 262 ! DESCRIPTION 263 ! Allocate perennial ice tendency arrays. 264 ! 265 ! AUTHORS & DATE 266 ! JB Clement, 03/2026 267 ! 268 ! NOTES 269 ! 270 !----------------------------------------------------------------------- 271 272 ! DEPENDENCIES 273 ! ------------ 274 use geometry, only: ngrid, nslope 275 276 ! DECLARATION 277 ! ----------- 278 implicit none 279 280 ! CODE 281 ! ---- 282 allocate(d_h2oice(ngrid,nslope)) 283 allocate(d_co2ice(ngrid,nslope)) 284 285 d_h2oice(:,:) = 0._dp 286 d_co2ice(:,:) = 0._dp 287 288 END SUBROUTINE allocate_tendencies 289 !======================================================================= 290 291 !======================================================================= 292 SUBROUTINE allocate_initial_snapshots() 293 !----------------------------------------------------------------------- 294 ! NAME 295 ! allocate_initial_snapshots 296 ! 297 ! DESCRIPTION 298 ! Allocate arrays storing initial-state snapshots. 299 ! 300 ! AUTHORS & DATE 301 ! JB Clement, 03/2026 302 ! 303 ! NOTES 304 ! 305 !----------------------------------------------------------------------- 306 307 ! DEPENDENCIES 308 ! ------------ 309 use geometry, only: ngrid, nslope, nday 310 311 ! DECLARATION 312 ! ----------- 313 implicit none 314 315 ! CODE 316 ! ---- 317 allocate(d_co2ice_ini(ngrid,nslope)) 318 allocate(q_co2_ts_ini(ngrid,nday)) 319 allocate(is_h2oice_ini(ngrid,nslope)) 320 allocate(is_co2ice_ini(ngrid,nslope)) 321 322 d_co2ice_ini(:,:) = 0._dp 323 q_co2_ts_ini(:,:) = 0._dp 324 is_h2oice_ini(:,:) = .false. 325 is_co2ice_ini(:,:) = .false. 326 327 END SUBROUTINE allocate_initial_snapshots 328 !======================================================================= 329 330 !======================================================================= 331 SUBROUTINE allocate_loop_state() 332 !----------------------------------------------------------------------- 333 ! NAME 334 ! allocate_loop_state 335 ! 336 ! DESCRIPTION 337 ! Allocate arrays that start being used during the main PEM loop. 338 ! 339 ! AUTHORS & DATE 340 ! JB Clement, 03/2026 341 ! 342 ! NOTES 343 ! 344 !----------------------------------------------------------------------- 345 346 ! DEPENDENCIES 347 ! ------------ 348 use geometry, only: ngrid, nslope, nsoil, nday 349 350 ! DECLARATION 351 ! ----------- 352 implicit none 353 354 ! CODE 355 ! ---- 356 allocate(delta_icetable(ngrid)) 357 allocate(icetable_depth_old(ngrid,nslope)) 358 allocate(is_co2ice_disappeared(ngrid,nslope)) 359 allocate(tsoil_ts_old(ngrid,nsoil,nslope,nday)) 360 361 delta_icetable(:) = 0._dp 362 icetable_depth_old(:,:) = 0._dp 363 is_co2ice_disappeared(:,:) = .false. 364 tsoil_ts_old(:,:,:,:) = 0._dp 365 366 END SUBROUTINE allocate_loop_state 367 !======================================================================= 368 369 !======================================================================= 370 SUBROUTINE end_planet() 371 !----------------------------------------------------------------------- 372 ! NAME 373 ! end_planet 374 ! 375 ! DESCRIPTION 376 ! Finalize module planet. 377 ! 378 ! AUTHORS & DATE 379 ! JB Clement, 03/2026 380 ! 381 ! NOTES 382 ! Deallocate all allocatable state arrays of module planet. 383 !----------------------------------------------------------------------- 384 385 ! DECLARATION 386 ! ----------- 387 implicit none 388 389 ! CODE 390 ! ---- 391 if (allocated(ps_avg)) deallocate(ps_avg) 392 if (allocated(ps_ts)) deallocate(ps_ts) 393 if (allocated(ps_dev)) deallocate(ps_dev) 394 if (allocated(h2o_ice)) deallocate(h2o_ice) 395 if (allocated(co2_ice)) deallocate(co2_ice) 396 if (allocated(is_h2oice_ini)) deallocate(is_h2oice_ini) 397 if (allocated(is_co2ice_ini)) deallocate(is_co2ice_ini) 398 if (allocated(is_co2ice_disappeared)) deallocate(is_co2ice_disappeared) 399 if (allocated(tsurf_avg)) deallocate(tsurf_avg) 400 if (allocated(tsurf_dev)) deallocate(tsurf_dev) 401 if (allocated(h2o_surfdensity_avg)) deallocate(h2o_surfdensity_avg) 402 if (allocated(tsoil_avg)) deallocate(tsoil_avg) 403 if (allocated(tsoil_dev)) deallocate(tsoil_dev) 404 if (allocated(tsoil_ts)) deallocate(tsoil_ts) 405 if (allocated(tsoil_ts_old)) deallocate(tsoil_ts_old) 406 if (allocated(layerings_map)) deallocate(layerings_map) 407 if (allocated(h2o_soildensity_avg)) deallocate(h2o_soildensity_avg) 408 if (allocated(delta_co2_ads)) deallocate(delta_co2_ads) 409 if (allocated(delta_h2o_ads)) deallocate(delta_h2o_ads) 410 if (allocated(h2o_ads_reg)) deallocate(h2o_ads_reg) 411 if (allocated(co2_ads_reg)) deallocate(co2_ads_reg) 412 if (allocated(icetable_depth)) deallocate(icetable_depth) 413 if (allocated(icetable_thickness)) deallocate(icetable_thickness) 414 if (allocated(ice_porefilling)) deallocate(ice_porefilling) 415 if (allocated(icetable_depth_old)) deallocate(icetable_depth_old) 416 if (allocated(delta_icetable)) deallocate(delta_icetable) 417 if (allocated(q_co2_ts)) deallocate(q_co2_ts) 418 if (allocated(q_co2_ts_ini)) deallocate(q_co2_ts_ini) 419 if (allocated(q_h2o_ts)) deallocate(q_h2o_ts) 420 if (allocated(d_co2ice)) deallocate(d_co2ice) 421 if (allocated(d_co2ice_ini)) deallocate(d_co2ice_ini) 422 if (allocated(d_h2oice)) deallocate(d_h2oice) 423 if (allocated(layerings_map)) deallocate(layerings_map) 424 425 END SUBROUTINE end_planet 426 !======================================================================= 427 27 428 END MODULE planet
Note: See TracChangeset
for help on using the changeset viewer.
