Changeset 4157 for trunk/LMDZ.COMMON/libf/evolution
- Timestamp:
- Mar 26, 2026, 4:29:10 PM (2 weeks ago)
- Location:
- trunk/LMDZ.COMMON/libf/evolution
- Files:
-
- 11 edited
-
allocation.F90 (modified) (3 diffs)
-
atmosphere.F90 (modified) (4 diffs)
-
backup.F90 (modified) (3 diffs)
-
changelog.txt (modified) (1 diff)
-
clim_state_init.F90 (modified) (5 diffs)
-
clim_state_rec.F90 (modified) (5 diffs)
-
pem.F90 (modified) (16 diffs)
-
planet.F90 (modified) (1 diff)
-
tracers.F90 (modified) (1 diff)
-
workflow_status.F90 (modified) (1 diff)
-
xios_data.F90 (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.COMMON/libf/evolution/allocation.F90
r4138 r4157 28 28 use orbit, only: ini_orbit, end_orbit 29 29 use output, only: ini_output, end_output 30 use planet, only: ini_planet, end_planet 30 31 31 32 ! DECLARATION … … 67 68 68 69 ! Initialize everything else 70 call ini_planet() 69 71 call ini_atmosphere() 70 72 call ini_tracers() … … 115 117 call end_tracers() 116 118 call end_atmosphere() 119 call end_planet() 117 120 call end_geometry() 118 121 -
trunk/LMDZ.COMMON/libf/evolution/atmosphere.F90
r4147 r4157 267 267 ! DEPENDENCIES 268 268 ! ------------ 269 use geometry, only: dyngrd2vect , nlon, nlat, ngrid269 use geometry, only: dyngrd2vect 270 270 271 271 ! DECLARATION … … 302 302 ! DEPENDENCIES 303 303 ! ------------ 304 use geometry, only: dyngrd2vect, nl on, nlat, ngrid, nlayer304 use geometry, only: dyngrd2vect, nlayer 305 305 306 306 ! DECLARATION … … 343 343 ! DEPENDENCIES 344 344 ! ------------ 345 use geometry, only: dyngrd2vect, nl on, nlat, ngrid, nlayer345 use geometry, only: dyngrd2vect, nlayer 346 346 347 347 ! DECLARATION … … 384 384 ! DEPENDENCIES 385 385 ! ------------ 386 use geometry, only: dyngrd2vect, nl on, nlat, ngrid, nlayer386 use geometry, only: dyngrd2vect, nlayer 387 387 388 388 ! DECLARATION -
trunk/LMDZ.COMMON/libf/evolution/backup.F90
r4135 r4157 95 95 use atmosphere, only: build4PCM_atmosphere 96 96 use tracers, only: build4PCM_tracers, nq 97 use clim_state_rec, only: write_restart, write_restartfi, write_restart pem97 use clim_state_rec, only: write_restart, write_restartfi, write_restartevo 98 98 use layered_deposits, only: layering 99 99 … … 143 143 144 144 ! Write restart files 145 call write_restart pem(h2o_ice,co2_ice,tsoil_avg,TI,icetable_depth,icetable_thickness,ice_porefilling,h2o_ads_reg,co2_ads_reg,layerings_map)145 call write_restartevo(h2o_ice,co2_ice,tsoil_avg,TI,icetable_depth,icetable_thickness,ice_porefilling,h2o_ads_reg,co2_ads_reg,layerings_map) 146 146 call write_restartfi(is_h2o_perice,h2o_ice4PCM,co2_ice4PCM,tsurf4PCM,tsoil4PCM,inertiesoil4PCM,albedo4PCM,emissivity4PCM,flux_geo4PCM) 147 147 call write_restart(ps4PCM,pa4PCM,preff4PCM,q4PCM,teta4PCM,air_mass4PCM) … … 191 191 ! CODE 192 192 ! ---- 193 suffix = '_ts'//int2str(backup_idt) 193 suffix = '' 194 suffix = suffix//'_ts'//int2str(backup_idt) 194 195 195 196 call print_msg('> Backup of "restart" files at dt = '//int2str(backup_idt),LVL_NFO) -
trunk/LMDZ.COMMON/libf/evolution/changelog.txt
r4152 r4157 945 945 - Fix sign in computing exchanges due to adsorption/ice table and in balancing H2O flux from/into atmosphere. 946 946 - Few cleanings. 947 948 == 26/03/2026 == JBC 949 - Separate variables ownership between the module "planet" for persistent climate state and the program "pem" for transient workflow logic. It provides a meaningful structure. 950 - Add lifecycle helpers for clear allocation/deallocation logic. 951 - Simplify string suffix for slopes variables. -
trunk/LMDZ.COMMON/libf/evolution/clim_state_init.F90
r4152 r4157 296 296 297 297 !======================================================================= 298 SUBROUTINE read_start pem(tsurf_avg_yr1,tsurf_avg_yr2,ps_avg_glob,ps_ts,q_co2_ts,q_h2o_ts,h2o_surfdensity_avg,h2o_ice,co2_ice, &298 SUBROUTINE read_startevo(tsurf_avg_yr1,tsurf_avg_yr2,ps_avg_glob,ps_ts,q_co2_ts,q_h2o_ts,h2o_surfdensity_avg,h2o_ice,co2_ice, & 299 299 tsoil_avg,h2o_soildensity_avg,icetable_depth,icetable_thickness,ice_porefilling,layerings_map, & 300 300 h2o_ads_reg,co2_ads_reg,delta_h2o_ads,delta_co2_ads) 301 301 !----------------------------------------------------------------------- 302 302 ! NAME 303 ! read_start pem303 ! read_startevo 304 304 ! 305 305 ! DESCRIPTION … … 359 359 ! --------------- 360 360 logical(k4) :: here 361 integer(di) :: i, islope, k, nb_str_max, nsoil_start pem361 integer(di) :: i, islope, k, nb_str_max, nsoil_startevo 362 362 real(dp) :: delta ! Depth of the interface regolith/breccia, breccia/bedrock [m] 363 real(dp), dimension(ngrid,nsoil,nslope) :: TI_start pem! Soil thermal inertia saved in the startevo [SI]364 real(dp), dimension(ngrid,nsoil,nslope) :: tsoil_start pem! Soil temperature saved in the startevo [K]363 real(dp), dimension(ngrid,nsoil,nslope) :: TI_startevo ! Soil thermal inertia saved in the startevo [SI] 364 real(dp), dimension(ngrid,nsoil,nslope) :: tsoil_startevo ! Soil temperature saved in the startevo [K] 365 365 real(dp), dimension(:,:,:,:), allocatable :: layerings_array ! Array for layerings 366 366 … … 521 521 if (do_soil) then 522 522 ! Check if the number of soil layers is compatible 523 call get_dim_nc('subsurface_layers',nsoil_start pem)524 if (nsoil_start pem/= nsoil) then525 call print_msg('nsoil (PEM) = '//int2str(nsoil)//' | nsoil ("'//startevo_name//'") = '//int2str(nsoil_start pem),LVL_ERR)523 call get_dim_nc('subsurface_layers',nsoil_startevo) 524 if (nsoil_startevo /= nsoil) then 525 call print_msg('nsoil (PEM) = '//int2str(nsoil)//' | nsoil ("'//startevo_name//'") = '//int2str(nsoil_startevo),LVL_ERR) 526 526 call stop_clean(__FILE__,__LINE__,'nsoil defined in the PEM is different from the one read in "'//startevo_name//'"!',1) 527 527 end if … … 529 529 do islope = 1,nslope 530 530 ! Soil temperature 531 call get_var_nc('tsoil',tsoil_start pem(:,:,islope))532 ! Predictor-corrector: due to changes of surface temperature in the PCM, the tsoil_start pemis adapted firstly531 call get_var_nc('tsoil',tsoil_startevo(:,:,islope)) 532 ! Predictor-corrector: due to changes of surface temperature in the PCM, the tsoil_startevo is adapted firstly 533 533 ! for PCM year 1 and then for PCM year 2 in order to build the evolution of the profile at depth 534 call compute_tsoil(ngrid,nsoil,.true.,TI(:,:,islope),dt,tsurf_avg_yr1(:,islope),tsoil_start pem(:,:,islope))535 call compute_tsoil(ngrid,nsoil,.false.,TI(:,:,islope),dt,tsurf_avg_yr1(:,islope),tsoil_start pem(:,:,islope))536 call compute_tsoil(ngrid,nsoil,.false.,TI(:,:,islope),dt,tsurf_avg_yr2(:,islope),tsoil_start pem(:,:,islope))534 call compute_tsoil(ngrid,nsoil,.true.,TI(:,:,islope),dt,tsurf_avg_yr1(:,islope),tsoil_startevo(:,:,islope)) 535 call compute_tsoil(ngrid,nsoil,.false.,TI(:,:,islope),dt,tsurf_avg_yr1(:,islope),tsoil_startevo(:,:,islope)) 536 call compute_tsoil(ngrid,nsoil,.false.,TI(:,:,islope),dt,tsurf_avg_yr2(:,islope),tsoil_startevo(:,:,islope)) 537 537 end do 538 tsoil_avg(:,nsoil_PCM + 1:nsoil,:) = tsoil_start pem(:,nsoil_PCM + 1:nsoil,:)538 tsoil_avg(:,nsoil_PCM + 1:nsoil,:) = tsoil_startevo(:,nsoil_PCM + 1:nsoil,:) 539 539 if (any(isnan(tsoil_avg(:,:,:)))) call stop_clean(__FILE__,__LINE__,"NaN detected in 'tsoil_avg'",1) 540 540 541 541 ! Thermal inertia 542 call get_var_nc('TI',TI_start pem(:,:,:))543 TI(:,nsoil_PCM + 1:nsoil,:) = TI_start pem(:,nsoil_PCM + 1:nsoil,:) ! 1st layers can change because of the presence of ice at the surface, so we don't change it here542 call get_var_nc('TI',TI_startevo(:,:,:)) 543 TI(:,nsoil_PCM + 1:nsoil,:) = TI_startevo(:,nsoil_PCM + 1:nsoil,:) ! 1st layers can change because of the presence of ice at the surface, so we don't change it here 544 544 call get_var_nc('inertiedat',inertiedat(:,:)) 545 545 … … 579 579 call close_nc(startevo_name) 580 580 581 END SUBROUTINE read_start pem581 END SUBROUTINE read_startevo 582 582 !======================================================================= 583 583 -
trunk/LMDZ.COMMON/libf/evolution/clim_state_rec.F90
r4147 r4157 25 25 ! VARIABLES 26 26 ! --------- 27 logical(k4), protected, private :: is_restart pem= .false. ! Flag to know if "restartevo.nc" exists27 logical(k4), protected, private :: is_restartevo = .false. ! Flag to know if "restartevo.nc" exists 28 28 29 29 contains … … 271 271 272 272 !======================================================================= 273 SUBROUTINE create_ nc_pem(nb_str_max)273 SUBROUTINE create_startevo(nb_str_max) 274 274 !----------------------------------------------------------------------- 275 275 ! NAME 276 ! create_ nc_pem276 ! create_startevo 277 277 ! 278 278 ! DESCRIPTION … … 414 414 415 415 ! File creation done 416 is_restart pem= .true.417 418 END SUBROUTINE create_ nc_pem419 !======================================================================= 420 421 !======================================================================= 422 SUBROUTINE write_restart pem(h2o_ice,co2_ice,tsoil,TI,icetable_depth,icetable_thickness,ice_porefilling,h2o_ads_reg,co2_ads_reg,layerings_map)416 is_restartevo = .true. 417 418 END SUBROUTINE create_startevo 419 !======================================================================= 420 421 !======================================================================= 422 SUBROUTINE write_restartevo(h2o_ice,co2_ice,tsoil,TI,icetable_depth,icetable_thickness,ice_porefilling,h2o_ads_reg,co2_ads_reg,layerings_map) 423 423 !----------------------------------------------------------------------- 424 424 ! NAME 425 ! write_restart pem425 ! write_restartevo 426 426 ! 427 427 ! DESCRIPTION … … 466 466 ! Create the file 467 467 nb_str_max = get_nb_str_max(layerings_map) 468 call create_ nc_pem(nb_str_max)468 call create_startevo(nb_str_max) 469 469 470 470 call print_msg('> Writing "re'//startevo_name//'"',LVL_NFO) 471 if (.not. is_restart pem) call stop_clean(__FILE__,__LINE__,'The file"'//startevo_name//'" has not been created',1)471 if (.not. is_restartevo) call stop_clean(__FILE__,__LINE__,'The file"'//startevo_name//'" has not been created',1) 472 472 473 473 ! Writing time counter … … 510 510 call close_nc('re'//startevo_name) 511 511 512 END SUBROUTINE write_restart pem512 END SUBROUTINE write_restartevo 513 513 !======================================================================= 514 514 -
trunk/LMDZ.COMMON/libf/evolution/pem.F90
r4152 r4157 8 8 ! 9 9 ! AUTHORS & DATE 10 ! R. Vandemeulebrouck, 22/07/2022 10 ! R. Vandemeulebrouck, 22/07/2022 with r2778 & r2779 11 11 ! L. Lange, 22/07/2022 12 12 ! JB Clement, 2023-2025 13 13 ! 14 14 ! NOTES 15 ! 15 ! Ownership criterion for declarations: 16 ! - Declare in module "planet" variables that are persistent climate 17 ! state or persistent references used across multiple time steps. 18 ! - Declare in program "pem.F90" transient workflow/control varaibles, 19 ! one-shot initialization buffers and per-iteration working buffers. 16 20 !----------------------------------------------------------------------- 17 21 … … 25 29 use atmosphere, only: ps_PCM, evolve_pressure, CO2cond_ps_PCM 26 30 use backup, only: save_clim_state, backup_rate 27 use clim_state_init, only: read_start, read_startfi, read_start pem31 use clim_state_init, only: read_start, read_startfi, read_startevo 28 32 use config, only: read_rundef, read_display_config 29 33 use display, only: print_ini, print_end, print_msg, LVL_NFO, LVL_WRN … … 32 36 use glaciers, only: h2oice_flow, co2ice_flow, flow_co2glaciers, flow_h2oglaciers 33 37 use ice_table, only: icetable_equilibrium, icetable_dynamic, evolve_ice_table 34 use layered_deposits, only: layering,do_layering, del_layering, evolve_layering, ptrarray, layering2surfice, surfice2layering, print_layering38 use layered_deposits, only: do_layering, del_layering, evolve_layering, ptrarray, layering2surfice, surfice2layering, print_layering 35 39 use maths, only: pi 36 40 use numerics, only: dp, qp, di, li, k4, minieps, minieps_qp 37 41 use orbit, only: evo_orbit, read_orbitpm, compute_maxyr_orbit, update_orbit 38 42 use output, only: write_diagevo, dim_ngrid, dim_nsoil 43 use planet 39 44 use physics, only: g 40 45 use slopes, only: subslope_dist, def_slope_mean … … 60 65 ! --------------- 61 66 ! Utility-related: 62 integer(li) :: cr ! Number of clock ticks per second (count rate) 63 integer(li) :: c1, c2 ! Counts of processor clock 64 character(:), allocatable :: num ! To write slope variables 65 integer(di) :: i, islope 66 ! Pressure-related: 67 real(dp), dimension(:), allocatable :: ps_avg ! Average surface pressure [Pa] 68 real(dp), dimension(:), allocatable :: ps_dev ! Deviation of surface pressure [Pa] 69 real(dp), dimension(:,:), allocatable :: ps_ts ! Surface pressure timeseries [Pa] 70 real(dp) :: ps_avg_glob_ini ! Global average pressure at initialization [Pa] 71 real(dp) :: ps_avg_glob_old ! Global average pressure of previous time step [Pa] 72 real(dp) :: ps_avg_glob ! Global average pressure of current time step [Pa] 67 integer(li) :: cr ! Number of clock ticks per second (count rate) 68 integer(li) :: c1, c2 ! Counts of processor clock 69 character(8) :: num ! Slope suffix to ouput variables 70 integer(di) :: i, islope 73 71 ! Ice-related: 74 real(dp), dimension(:,:), allocatable :: h2o_ice ! H2O ice [kg.m-2] 75 real(dp), dimension(:,:), allocatable :: co2_ice ! CO2 ice [kg.m-2] 76 real(dp) :: h2oice_sublim_coverage_ini ! Initial surface area of sublimating H2O ice [m2] 77 real(dp) :: co2ice_sublim_coverage_ini ! Initial surface area of sublimating CO2 ice [m2] 78 logical(k4), dimension(:,:), allocatable :: is_h2oice_ini ! Initial location of H2O ice 79 logical(k4), dimension(:,:), allocatable :: is_co2ice_ini ! Initial location of CO2 ice 80 logical(k4), dimension(:,:), allocatable :: is_co2ice_flow ! Flag for location of CO2 glacier flow 81 logical(k4), dimension(:,:), allocatable :: is_h2oice_flow ! Flag for location of H2O glacier flow 82 real(dp), dimension(:,:,:), allocatable :: minPCM_h2operice ! Minimum of H2O perennial ice over the last PCM year [kg.m-2] 83 real(dp), dimension(:,:,:), allocatable :: minPCM_co2perice ! Minimum of CO2 perennial ice over the last PCM year [kg.m-2] 84 real(dp), dimension(:,:,:), allocatable :: minPCM_h2ofrost ! Minimum of H2O frost over the last PCM year [kg.m-2] 85 real(dp), dimension(:,:,:), allocatable :: minPCM_co2frost ! Minimum of CO2 frost over the last PCM year [kg.m-2] 86 logical(k4), dimension(:,:), allocatable :: is_co2ice_disappeared ! Flag to check if CO2 ice disappeared at the previous timestep 72 logical(k4), dimension(:,:), allocatable :: is_co2ice_flow ! Flag for location of CO2 glacier flow 73 logical(k4), dimension(:,:), allocatable :: is_h2oice_flow ! Flag for location of H2O glacier flow 74 real(dp), dimension(:,:,:), allocatable :: minPCM_h2operice ! Minimum of H2O perennial ice over the last PCM year [kg.m-2] 75 real(dp), dimension(:,:,:), allocatable :: minPCM_co2perice ! Minimum of CO2 perennial ice over the last PCM year [kg.m-2] 76 real(dp), dimension(:,:,:), allocatable :: minPCM_h2ofrost ! Minimum of H2O frost over the last PCM year [kg.m-2] 77 real(dp), dimension(:,:,:), allocatable :: minPCM_co2frost ! Minimum of CO2 frost over the last PCM year [kg.m-2] 87 78 ! Surface-related: 88 real(dp), dimension(:,:), allocatable :: tsurf_avg ! Average surface temperature [K] 89 real(dp), dimension(:,:), allocatable :: tsurf_avg_yr1 ! Average surface temperature of the second to last PCM run [K] 90 real(dp), dimension(:,:), allocatable :: tsurf_dev ! Deviation of surface temperature [K] 91 real(dp), dimension(:,:), allocatable :: h2o_surfdensity_avg ! Average water surface density [kg/m^3] 92 real(dp), dimension(:,:), allocatable :: zshift_surf ! Elevation shift for the surface [m] 93 real(dp), dimension(:,:), allocatable :: zlag ! Newly built lag thickness [m] 94 ! Soil-related: 95 real(dp), dimension(:,:,:), allocatable :: tsoil_avg ! Average soil temperature [K] 96 real(dp), dimension(:,:,:), allocatable :: tsoil_dev ! Deviation pf soil temperature [K] 97 real(dp), dimension(:,:,:,:), allocatable :: tsoil_ts ! Soil temperature timeseries [K] 98 real(dp), dimension(:,:,:,:), allocatable :: tsoil_ts_old ! Soil temperature timeseries at the previous time step [K] 99 real(dp), dimension(:,:,:), allocatable :: h2o_soildensity_avg ! Average of soil water soil density [kg/m^3] 100 real(dp), dimension(:), allocatable :: delta_co2_ads ! Quantity of CO2 exchanged due to adsorption/desorption [kg/m^2] 101 real(dp), dimension(:), allocatable :: delta_h2o_ads ! Quantity of H2O exchanged due to adsorption/desorption [kg/m^2] 102 real(qp) :: totmass_adsh2o ! Total mass of H2O exchanged because of adsorption/desorption [kg] 103 real(dp), dimension(:,:,:), allocatable :: h2o_ads_reg ! H2O adsorbed in the regolith [kg/m^2] 104 real(dp), dimension(:,:,:), allocatable :: co2_ads_reg ! CO2 adsorbed in the regolith [kg/m^2] 105 real(dp), dimension(:,:), allocatable :: icetable_depth ! Depth of the ice table [m] 106 real(dp), dimension(:,:), allocatable :: icetable_thickness ! Thickness of the ice table [m] 107 real(dp), dimension(:,:,:), allocatable :: ice_porefilling ! Amount of porefilling [m^3/m^3] 108 real(dp), dimension(:,:), allocatable :: icetable_depth_old ! Old depth of the ice table [m] 109 real(dp), dimension(:), allocatable :: delta_icetable ! Total mass of the H2O that has sublimated / condenses from the ice table [kg] 110 ! Tracer-related: 111 real(dp), dimension(:,:), allocatable :: q_co2_ts ! CO2 mass mixing ratio in the first layer [kg/kg] 112 real(dp), dimension(:,:), allocatable :: q_co2_ts_ini ! Initial CO2 mass mixing ratio in the first layer [kg/kg] 113 real(dp), dimension(:,:), allocatable :: q_h2o_ts ! H2O mass mixing ratio in the first layer [kg/kg] 79 real(dp), dimension(:,:), allocatable :: tsurf_avg_yr1 ! Average surface temperature of the second to last PCM run [K] 80 real(dp), dimension(:,:), allocatable :: zshift_surf ! Elevation shift for the surface [m] 81 real(dp), dimension(:,:), allocatable :: zlag ! Newly built lag thickness [m] 114 82 ! Tendency-related: 115 real(dp), dimension(:,:), allocatable :: d_co2ice ! Tendency of perennial CO2 ice [kg/m2/y]116 real(dp), dimension(:,:), allocatable :: d_co2ice_ini ! Tendency of perennial CO2 ice at the beginning [kg/m2/y]117 real(dp), dimension(:,:), allocatable :: d_h2oice ! Tendency of perennial H2O ice [kg/m2/y]118 83 real(dp), dimension(:,:), allocatable :: d_h2oice_new ! Adjusted tendency of perennial H2O ice to keep balance between donor and recipient [kg/m2/y] 119 84 ! Layering-related: 120 type(layering), dimension(:,:), allocatable :: layerings_map ! Layering for each grid point and slope121 85 type(ptrarray), dimension(:,:), allocatable :: current ! Current active stratum in the layering 122 86 real(dp), dimension(:,:), allocatable :: h2oice_depth ! Depth of subsurface ice layer … … 130 94 real(qp) :: totmass_co2ice_ini, totmass_atmco2_ini, totmass_adsco2_ini ! Initial total CO2 masses (surface ice|atmospheric|adsorbed) 131 95 real(qp) :: totmass_ini ! Initial total CO2 mass [kg] 96 real(qp) :: totmass_adsh2o ! Current total adsorbed H2O mass [kg] 132 97 real(qp) :: S_atm_2_h2o, S_h2o_2_atm, S_atm_2_h2oice, S_h2oice_2_atm ! Variables to balance H2O ice reservoirs 133 98 … … 168 133 169 134 ! Read the PCM data given by XIOS 170 allocate(ps_avg(ngrid),ps_ts(ngrid,nday)) 171 allocate(tsurf_avg(ngrid,nslope),tsurf_avg_yr1(ngrid,nslope),h2o_surfdensity_avg(ngrid,nslope)) 172 allocate(tsoil_avg(ngrid,nsoil,nslope),tsoil_ts(ngrid,nsoil,nslope,nday),h2o_soildensity_avg(ngrid,nsoil,nslope)) 173 allocate(q_h2o_ts(ngrid,nday),q_co2_ts(ngrid,nday)) 174 allocate(minPCM_h2operice(ngrid,nslope,2),minPCM_co2perice(ngrid,nslope,2),minPCM_h2ofrost(ngrid,nslope,2),minPCM_co2frost(ngrid,nslope,2)) 135 call allocate_xios_state() 136 allocate(tsurf_avg_yr1(ngrid,nslope)) 137 allocate(minPCM_h2operice(ngrid,nslope,2)) 138 allocate(minPCM_co2perice(ngrid,nslope,2)) 139 allocate(minPCM_h2ofrost(ngrid,nslope,2)) 140 allocate(minPCM_co2frost(ngrid,nslope,2)) 175 141 176 142 call load_xios_data(ps_avg,ps_ts,tsurf_avg,tsurf_avg_yr1,tsoil_avg,tsoil_ts,h2o_surfdensity_avg,h2o_soildensity_avg, & … … 181 147 182 148 ! Compute the deviation from the average 183 allocate(ps_dev(ngrid),tsurf_dev(ngrid,nslope),tsoil_dev(ngrid,nsoil_PCM,nslope))149 call allocate_deviation_state() 184 150 ps_dev(:) = ps_PCM(:) - ps_avg(:) 185 151 tsurf_dev(:,:) = tsurf_PCM(:,:) - tsurf_avg(:,:) … … 193 159 194 160 ! Read the "startevo.nc" 195 allocate(h2o_ice(ngrid,nslope),co2_ice(ngrid,nslope)) 196 allocate(icetable_depth(ngrid,nslope),icetable_thickness(ngrid,nslope),ice_porefilling(ngrid,nsoil,nslope)) 197 allocate(h2o_ads_reg(ngrid,nsoil,nslope),co2_ads_reg(ngrid,nsoil,nslope),delta_h2o_ads(ngrid),delta_co2_ads(ngrid)) 198 allocate(layerings_map(ngrid,nslope)) 199 icetable_depth(:,:) = 0._dp 200 icetable_thickness(:,:) = 0._dp 201 ice_porefilling(:,:,:) = 0._dp 202 delta_h2o_ads(:) = 0._dp 203 delta_co2_ads(:) = 0._dp 204 call read_startpem(tsurf_avg_yr1,tsurf_avg,ps_avg_glob_ini,ps_ts,q_co2_ts,q_h2o_ts,h2o_surfdensity_avg,h2o_ice,co2_ice, & 161 call allocate_startevo_state() 162 call read_startevo(tsurf_avg_yr1,tsurf_avg,ps_avg_glob_ini,ps_ts,q_co2_ts,q_h2o_ts,h2o_surfdensity_avg,h2o_ice,co2_ice, & 205 163 tsoil_avg,h2o_soildensity_avg,icetable_depth,icetable_thickness,ice_porefilling,layerings_map, & 206 164 h2o_ads_reg,co2_ads_reg,delta_h2o_ads,delta_co2_ads) … … 208 166 209 167 ! Compute ice tendencies from yearly minima 210 allocate(d_h2oice(ngrid,nslope),d_co2ice(ngrid,nslope))168 call allocate_tendencies() 211 169 call print_msg('> Computing surface ice tendencies',LVL_NFO) 212 170 call compute_tendice(minPCM_h2operice,minPCM_h2ofrost,h2o_ice,d_h2oice) … … 218 176 ! Save initial set-up useful for the next computations 219 177 call print_msg('> Saving some initial climate state variables',LVL_NFO) 220 allocate(d_co2ice_ini(ngrid,nslope),q_co2_ts_ini(ngrid,nday)) 221 allocate(is_h2oice_ini(ngrid,nslope),is_co2ice_ini(ngrid,nslope)) 178 call allocate_initial_snapshots() 222 179 ps_avg_glob_ini = ps_avg_glob 223 180 d_co2ice_ini(:,:) = d_co2ice(:,:) … … 225 182 h2oice_sublim_coverage_ini = 0._dp 226 183 co2ice_sublim_coverage_ini = 0._dp 227 is_h2oice_ini(:,:) = .false.228 is_co2ice_ini(:,:) = .false.229 184 totmass_co2ice_ini = 0._qp 230 185 totmass_atmco2_ini = 0._qp … … 268 223 !where (h2oice_depth > 0. .and. zdqsdif_ssi_tot < -minieps) d_h2oice = zdqsdif_ssi_tot 269 224 end if 270 if (nslope == 1) then ! No slope 271 allocate(character(0) :: num) 272 else ! Using slopes 273 allocate(character(8) :: num) 274 end if 275 allocate(delta_icetable(ngrid),icetable_depth_old(ngrid,nslope),is_co2ice_disappeared(ngrid,nslope),tsoil_ts_old(ngrid,nsoil,nslope,nday)) 276 is_co2ice_disappeared(:,:) = .false. 277 delta_icetable(:) = 0._dp 225 call allocate_loop_state() 278 226 n_yr_run = 0 279 227 idt = 0 … … 353 301 call write_diagevo('ps_avg_glob','Global average pressure','Pa',ps_avg_glob) 354 302 do islope = 1,nslope 355 if (nslope /= 1) then356 num = ' '357 write(num,'(i2.2)') islope358 num = '_slope'//num359 end if 360 call write_diagevo('h2oice'// num,'H2O ice','kg.m-2',h2o_ice(:,islope),(/dim_ngrid/))361 call write_diagevo('co2ice'// num,'CO2 ice','kg.m-2',co2_ice(:,islope),(/dim_ngrid/))362 call write_diagevo('d_h2oice'// num,'H2O ice tendency','kg.m-2.yr-1',d_h2oice(:,islope),(/dim_ngrid/))363 call write_diagevo('d_co2ice'// num,'CO2 ice tendency','kg.m-2.yr-1',d_co2ice(:,islope),(/dim_ngrid/))303 if (nslope == 1) then 304 num = '' 305 else 306 write(num,'("_slope",i2.2)') islope 307 end if 308 call write_diagevo('h2oice'//trim(num),'H2O ice','kg.m-2',h2o_ice(:,islope),(/dim_ngrid/)) 309 call write_diagevo('co2ice'//trim(num),'CO2 ice','kg.m-2',co2_ice(:,islope),(/dim_ngrid/)) 310 call write_diagevo('d_h2oice'//trim(num),'H2O ice tendency','kg.m-2.yr-1',d_h2oice(:,islope),(/dim_ngrid/)) 311 call write_diagevo('d_co2ice'//trim(num),'CO2 ice tendency','kg.m-2.yr-1',d_co2ice(:,islope),(/dim_ngrid/)) 364 312 if (co2ice_flow) then 365 call write_diagevo('Flow_co2ice'//num,'CO2 ice flow location','T/F',merge(1._dp,0._dp,is_co2ice_flow(:,islope)),(/dim_ngrid/)) 366 deallocate(is_co2ice_flow) 313 call write_diagevo('Flow_co2ice'//trim(num),'CO2 ice flow location','T/F',merge(1._dp,0._dp,is_co2ice_flow(:,islope)),(/dim_ngrid/)) 367 314 end if 368 315 if (h2oice_flow) then 369 call write_diagevo('Flow_h2oice'//num,'H2O ice flow location','T/F',merge(1._dp,0._dp,is_h2oice_flow(:,islope)),(/dim_ngrid/)) 370 deallocate(is_h2oice_flow) 371 end if 372 call write_diagevo('tsurf'//num,'Surface temperature','K',tsurf_avg(:,islope),(/dim_ngrid/)) 316 call write_diagevo('Flow_h2oice'//trim(num),'H2O ice flow location','T/F',merge(1._dp,0._dp,is_h2oice_flow(:,islope)),(/dim_ngrid/)) 317 end if 318 call write_diagevo('tsurf'//trim(num),'Surface temperature','K',tsurf_avg(:,islope),(/dim_ngrid/)) 373 319 if (do_soil) then 374 320 if (icetable_equilibrium) then 375 call write_diagevo('icetable_depth'// num,'Ice table depth','m',icetable_depth(:,islope),(/dim_ngrid/))376 call write_diagevo('icetable_thick'// num,'Ice table thickness','m',icetable_thickness(:,islope),(/dim_ngrid/))321 call write_diagevo('icetable_depth'//trim(num),'Ice table depth','m',icetable_depth(:,islope),(/dim_ngrid/)) 322 call write_diagevo('icetable_thick'//trim(num),'Ice table thickness','m',icetable_thickness(:,islope),(/dim_ngrid/)) 377 323 else if (icetable_dynamic) then 378 call write_diagevo('icetable_depth'// num,'Ice table depth','m',icetable_depth(:,islope),(/dim_ngrid/))379 call write_diagevo('ice_porefilling'// num,'Ice pore filling','-',ice_porefilling(:,:,islope),(/dim_ngrid,dim_nsoil/))324 call write_diagevo('icetable_depth'//trim(num),'Ice table depth','m',icetable_depth(:,islope),(/dim_ngrid/)) 325 call write_diagevo('ice_porefilling'//trim(num),'Ice pore filling','-',ice_porefilling(:,:,islope),(/dim_ngrid,dim_nsoil/)) 380 326 end if 381 call write_diagevo('tsoil_avg'// num,'Soil temperature','K',tsoil_avg(:,:,islope),(/dim_ngrid,dim_nsoil/))382 call write_diagevo('inertiesoil'// num,'Thermal inertia','SI',TI(:,:,islope),(/dim_ngrid,dim_nsoil/))327 call write_diagevo('tsoil_avg'//trim(num),'Soil temperature','K',tsoil_avg(:,:,islope),(/dim_ngrid,dim_nsoil/)) 328 call write_diagevo('inertiesoil'//trim(num),'Thermal inertia','SI',TI(:,:,islope),(/dim_ngrid,dim_nsoil/)) 383 329 if (do_sorption) then 384 call write_diagevo('co2_ads_reg'// num,'CO2 adsorbed in regolith','kg.m-2',co2_ads_reg(:,:,islope),(/dim_ngrid,dim_nsoil/))385 call write_diagevo('h2o_ads_reg'// num,'H2O adsorbed in regolith','kg.m-2',h2o_ads_reg(:,:,islope),(/dim_ngrid,dim_nsoil/))330 call write_diagevo('co2_ads_reg'//trim(num),'CO2 adsorbed in regolith','kg.m-2',co2_ads_reg(:,:,islope),(/dim_ngrid,dim_nsoil/)) 331 call write_diagevo('h2o_ads_reg'//trim(num),'H2O adsorbed in regolith','kg.m-2',h2o_ads_reg(:,:,islope),(/dim_ngrid,dim_nsoil/)) 386 332 end if 387 333 end if 388 334 end do 335 if (co2ice_flow .and. allocated(is_co2ice_flow)) deallocate(is_co2ice_flow) 336 if (h2oice_flow .and. allocated(is_h2oice_flow)) deallocate(is_h2oice_flow) 389 337 390 338 ! Checking mass balance for CO2 … … 458 406 end if 459 407 end do ! End of the evolution loop 460 deallocate(is_co2ice_disappeared)461 408 462 409 ! Finalization … … 474 421 475 422 ! Deallocation 476 deallocate(num)477 423 if (do_layering) then 478 424 deallocate(h2oice_depth,h2oice_depth_old,new_str,new_lag,current) … … 483 429 end do 484 430 end if 485 deallocate(layerings_map)486 deallocate(h2o_ads_reg,co2_ads_reg)487 deallocate(h2o_ice,co2_ice,is_h2oice_ini,is_co2ice_ini)488 deallocate(ps_avg,ps_dev,ps_ts)489 deallocate(tsurf_avg,tsurf_dev,h2o_surfdensity_avg)490 deallocate(tsoil_avg,tsoil_dev,tsoil_ts,tsoil_ts_old,h2o_soildensity_avg)491 deallocate(q_h2o_ts,q_co2_ts,q_co2_ts_ini)492 deallocate(d_h2oice,d_co2ice,d_co2ice_ini)493 deallocate(delta_h2o_ads,delta_co2_ads,delta_icetable,icetable_depth_old)494 deallocate(icetable_depth,icetable_thickness,ice_porefilling)495 431 call end_allocation() 496 432 -
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 -
trunk/LMDZ.COMMON/libf/evolution/tracers.F90
r4147 r4157 152 152 ! DEPENDENCIES 153 153 ! ------------ 154 use geometry, only: dyngrd2vect , nlon, nlat, ngrid154 use geometry, only: dyngrd2vect 155 155 156 156 ! DECLARATION -
trunk/LMDZ.COMMON/libf/evolution/workflow_status.F90
r4117 r4157 152 152 n_id_PCM = n_pcm_runs 153 153 end if 154 headline = 'cycle=PCM('//int2str(id_PCM_1) 154 headline = '' 155 headline = headline//'cycle=PCM('//int2str(id_PCM_1) 155 156 do i = 1,n_id_PCM - 1 156 157 headline = headline//'+'//int2str(id_PCM_1 + i) -
trunk/LMDZ.COMMON/libf/evolution/xios_data.F90
r4147 r4157 72 72 real(dp), dimension(:,:,:), allocatable :: var_read_3d 73 73 real(dp), dimension(:,:,:,:), allocatable :: var_read_4d 74 character( :), allocatable :: num ! To read slopevariables74 character(8) :: num ! Slope suffix to read variables 75 75 76 76 ! CODE … … 81 81 minPCM_h2ofrost(:,:,:) = 0._dp 82 82 minPCM_co2frost(:,:,:) = 0._dp 83 if (nslope == 1) then ! No slope 84 allocate(character(0) :: num) 85 else ! Using slopes 86 allocate(character(8) :: num) 87 end if 83 num = '' 88 84 89 85 !~~~~~~~~~~~~~~~~~~~~~~~~ Year 1 - Yearly data ~~~~~~~~~~~~~~~~~~~~~~~~~ … … 98 94 allocate(var_read_2d(nlon,nlat),var_read_3d(nlon,nlat,nsoil_PCM)) 99 95 do islope = 1,nslope 100 if (nslope /= 1) then101 num = ' '102 write(num,'(i2.2)') islope103 num = '_slope'//num96 if (nslope == 1) then 97 num = '' 98 else 99 write(num,'("_slope",i2.2)') islope 104 100 end if 105 call get_var_nc('co2ice'// num,var_read_2d) ; call lonlat2vect(var_read_2d,minPCM_co2frost(:,islope,1))106 call get_var_nc('h2o_ice_s'// num,var_read_2d) ; call lonlat2vect(var_read_2d,minPCM_h2ofrost(:,islope,1))107 call get_var_nc('watercap'// num,var_read_2d) ; call lonlat2vect(var_read_2d,minPCM_h2operice(:,islope,1))108 call get_var_nc('perennial_co2ice'// num,var_read_2d); call lonlat2vect(var_read_2d,minPCM_co2perice(:,islope,1))109 call get_var_nc('tsurf'// num,var_read_2d) ; call lonlat2vect(var_read_2d,tsurf_avg_yr1(:,islope))101 call get_var_nc('co2ice'//trim(num),var_read_2d) ; call lonlat2vect(var_read_2d,minPCM_co2frost(:,islope,1)) 102 call get_var_nc('h2o_ice_s'//trim(num),var_read_2d) ; call lonlat2vect(var_read_2d,minPCM_h2ofrost(:,islope,1)) 103 call get_var_nc('watercap'//trim(num),var_read_2d) ; call lonlat2vect(var_read_2d,minPCM_h2operice(:,islope,1)) 104 call get_var_nc('perennial_co2ice'//trim(num),var_read_2d); call lonlat2vect(var_read_2d,minPCM_co2perice(:,islope,1)) 105 call get_var_nc('tsurf'//trim(num),var_read_2d) ; call lonlat2vect(var_read_2d,tsurf_avg_yr1(:,islope)) 110 106 end do 111 107 … … 123 119 call get_var_nc('ps',var_read_2d); call lonlat2vect(var_read_2d,ps_avg) 124 120 do islope = 1,nslope 125 if (nslope /= 1) then126 num =''127 write(num,'(i2.2)') islope128 num = '_slope'//num121 if (nslope == 1) then 122 num = '' 123 else 124 write(num,'("_slope",i2.2)') islope 129 125 end if 130 call get_var_nc('tsurf'// num,var_read_2d) ; call lonlat2vect(var_read_2d,tsurf_avg(:,islope))131 call get_var_nc('co2ice'// num,var_read_2d) ; call lonlat2vect(var_read_2d,minPCM_co2frost(:,islope,2))132 call get_var_nc('h2o_ice_s'// num,var_read_2d) ; call lonlat2vect(var_read_2d,minPCM_h2ofrost(:,islope,2))133 call get_var_nc('watercap'// num,var_read_2d) ; call lonlat2vect(var_read_2d,minPCM_h2operice(:,islope,2))134 call get_var_nc('perennial_co2ice'// num,var_read_2d); call lonlat2vect(var_read_2d,minPCM_co2perice(:,islope,2))126 call get_var_nc('tsurf'//trim(num),var_read_2d) ; call lonlat2vect(var_read_2d,tsurf_avg(:,islope)) 127 call get_var_nc('co2ice'//trim(num),var_read_2d) ; call lonlat2vect(var_read_2d,minPCM_co2frost(:,islope,2)) 128 call get_var_nc('h2o_ice_s'//trim(num),var_read_2d) ; call lonlat2vect(var_read_2d,minPCM_h2ofrost(:,islope,2)) 129 call get_var_nc('watercap'//trim(num),var_read_2d) ; call lonlat2vect(var_read_2d,minPCM_h2operice(:,islope,2)) 130 call get_var_nc('perennial_co2ice'//trim(num),var_read_2d); call lonlat2vect(var_read_2d,minPCM_co2perice(:,islope,2)) 135 131 if (do_soil) then 136 call get_var_nc('soiltemp'// num,var_read_3d)132 call get_var_nc('soiltemp'//trim(num),var_read_3d) 137 133 do isoil = 1,nsoil_PCM 138 134 call lonlat2vect(var_read_3d(:,:,isoil),tsoil_avg(:,isoil,islope)) … … 141 137 tsoil_avg(:,isoil,islope) = tsoil_avg(:,nsoil_PCM,islope) ! Explicit initialization because dimension with size nsoil > nsoil_PCM 142 138 end do 143 call get_var_nc('waterdensity_surface'// num,var_read_2d); call lonlat2vect(var_read_2d,h2o_surfdensity_avg(:,islope))139 call get_var_nc('waterdensity_surface'//trim(num),var_read_2d); call lonlat2vect(var_read_2d,h2o_surfdensity_avg(:,islope)) 144 140 end if 145 141 end do … … 173 169 h2o_soildensity_avg(:,:,:) = 0._dp 174 170 do islope = 1,nslope 175 if (nslope /= 1) then176 num =''177 write(num,'(i2.2)') islope178 num = '_slope'//num171 if (nslope == 1) then 172 num = '' 173 else 174 write(num,'("_slope",i2.2)') islope 179 175 end if 180 call get_var_nc('soiltemp'// num,var_read_4d)176 call get_var_nc('soiltemp'//trim(num),var_read_4d) 181 177 do iday = 1,nday 182 178 do isoil = 1,nsoil_PCM … … 187 183 end do 188 184 end do 189 call get_var_nc('waterdensity_soil'// num,var_read_4d)185 call get_var_nc('waterdensity_soil'//trim(num),var_read_4d) 190 186 do iday = 1,nday 191 187 do isoil = 1,nsoil_PCM … … 200 196 h2o_soildensity_avg(:,:,:) = h2o_soildensity_avg(:,:,:)/real(nday,dp) 201 197 end if 202 deallocate(var_read_1d,var_read_3d,var_read_4d ,num)198 deallocate(var_read_1d,var_read_3d,var_read_4d) 203 199 204 200 ! Close the NetCDF file of XIOS outputs
Note: See TracChangeset
for help on using the changeset viewer.
