source: trunk/LMDZ.COMMON/libf/evolution/planet.F90 @ 4065

Last change on this file since 4065 was 4065, checked in by jbclement, 2 weeks ago

PEM:
Major refactor following the previous ones (r3989 and r3991) completing the large structural reorganization and cleanup of the PEM codebase. This revision introduces newly designed modules, standardizes interfaces with explicit ini/end APIs and adds native NetCDF I/O together with explicit PCM/PEM adapters. In detail:

  • Some PEM models were corrected or improved:
    • Frost/perennial ice semantics are clarified via renaming;
    • Soil temperature remapping clarified, notably by removing the rescaling of temperature deviation;
    • Geothermal flux for the PCM is computed based on the PEM state;
  • New explicit PEM/PCM adapters ("set_*"/"build4PCM_*") to decouple PEM internal representation from PCM file layouts and reconstruct consistent fields returned to the PCM;
  • New explicit build/teardown routines that centralize allocation and initialization ordering, reducing accidental use of uninitialized data and making the model lifecycle explicit;
  • Add native read/write helpers for NetCDF that centralize all low-level NetCDF interactions with major improvements (and more simplicity) compared to legacy PEM/PCM I/O (see the modules "io_netcdf" and "output"). They support reading, creation and writing of "diagevol.nc" (renamed from "diagpem.nc") and start/restart files;
  • Provide well-focused modules ("numerics"/"maths"/"utility"/"display") to host commonly-used primitives:
    • "numerics" defines numerical types and constants for reproducibility, portability across compilers and future transitions (e.g. quadruple precision experiments);
    • "display" provides a single controlled interface for runtime messages, status output and diagnostics, avoiding direct 'print'/'write' to enable silent mode, log redirection, and MPI-safe output in the future.
    • "utility" (new module) hosts generic helpers used throughout the code (e.g. "int2str" or "real2str");
  • Add modules "clim_state_init"/"clim_state_rec" which provide robust read/write logic for "start/startfi/startpem", including 1D fallbacks, mesh conversions and dimension checks. NetCDF file creation is centralized and explicit. Restart files are now self-consistent and future-proof, requiring changes only to affected variables;
  • Add module "atmosphere" which computes pressure fields, reconstructs potential temperature and air mass. It also holds the whole logic to define sigma or hybrid coordinates for altitudes;
  • Add module "geometry" to centrilize dimensions logic and grid conversions routines (including 2 new ones "dyngrd2vect"/"vect2dyngrd");
  • Add module "slopes" to isolate slopes handling;
  • Add module "surface" to isolate surface management. Notably, albedo and emissivity are now fully reconstructed following the PCM settings;
  • Add module "allocation" to check the dimension initialization and centrilize allocation/deallocation;
  • Finalize module decomposition and renaming to consolidate domain-based modules, purpose-based routines and physics/process-based variables;
  • The main program now drives a clearer sequence of conceptual steps (initialization / reading / evolution / update / build / writing) and fails explicitly instead of silently defaulting;
  • Ice table logic is made restart-safe;
  • 'Open'/'read' intrinsic logic is made safe and automatic;
  • Improve discoverability and standardize the data handling (private vs protected vs public);
  • Apply consistent documentation/header style already introduced;
  • Update deftank scripts to reflect new names and launch wrappers;

This revision is a structural milestone aiming to be behavior-preserving where possible. It has been tested via compilation and short integration runs. However, due to extensive renames, moves, and API changes, full validation is still ongoing.
Note: the revision includes one (possibly two) easter egg hidden in the code for future archaeologists of the PEM. No physics were harmed.
JBC

File size: 2.7 KB
Line 
1MODULE planet
2!-----------------------------------------------------------------------
3! NAME
4!     planet
5!
6! DESCRIPTION
7!     Mars-specific constants kept hard-coded for the PEM.
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! DEPENDENCIES
18! ------------
19use numerics, only: dp
20
21! DECLARATION
22! -----------
23implicit none
24
25! PARAMETERS
26! ----------
27! Molecular masses for CO2, H2O and non condensible gaz, following Franz et al. 2017
28real(dp), parameter :: m_co2 = 44.01e-3_dp               ! CO2 molecular mass [kg/mol]
29real(dp), parameter :: m_noco2 = 33.37e-3_dp             ! Non condensible mol mass [kg/mol]
30real(dp), parameter :: m_h2o = 18.01528e-3_dp            ! Molecular weight of h2o [kg/mol]
31real(dp), parameter :: A = (1._dp/m_co2 - 1._dp/m_noco2) ! Intermediate parameter for computation
32real(dp), parameter :: B = 1._dp/m_noco2                 ! Intermediate parameter for computation
33
34! Thermal inertia for breccia and bedrock following Mellon et al. 2000; Wood et al. 2008
35real(dp), parameter :: TI_breccia = 750._dp  ! Thermal inertia of Breccia following Wood 2009 [SI]
36real(dp), parameter :: TI_bedrock = 2300._dp ! Thermal inertia of Bedrock following Wood 2009 [SI]
37
38! Coefficient for Clapeyron law for psat (psat = exp(beta/Th2o + alpha)), following Murphy and Koop 2005
39real(dp), parameter :: alpha_clap_h2o = 28.9074_dp ! Uniteless, Murphy and Koop 2005
40real(dp), parameter :: beta_clap_h2o = -6143.7_dp  ! Kelvin, Murphy and Koop 2005
41
42! Coefficient for Clapeyron law for CO2 condensation temperature (Tco2 = beta/(alpha-log(vmr)),following James et al. 1992
43real(dp), parameter :: alpha_clap_co2 = 23.3494_dp ! Unitless, James et al. 1992
44real(dp), parameter :: beta_clap_co2 = 3182.48_dp  ! Kelvin, James et al. 1992
45
46! Density of the regolith (Zent et al., 1995; Buhler and Piqueux 2021)
47real(dp), parameter :: rho_regolith = 2000._dp ! kg/m^3
48
49! Average thermal inertia of the surface, breccia, bedrock, following Mellon et al., 2000., Wood et al., 2008
50real(dp), parameter :: TI_regolith_avg = 250._dp ! Averaged of the observed thermal inertia for regolith following Mellon et al., 2000[SI]
51
52! Porosity of the soil
53real(dp), parameter :: porosity = 0.4_dp ! porosity of the martian soil, correspond to the value for a random loose packing of monodiperse sphere (Scott, 1960)
54
55! Stefan Boltzmann constant
56real(dp), parameter :: sigmaB = 5.678e-8_dp
57
58! Latent heat of CO2
59real(dp), parameter :: Lco2 =  5.71e5_dp ! Pilorget and Forget 2016
60
61! Current average pressure [Pa]
62real(dp), parameter :: P610 = 610._dp
63
64contains
65!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
66
67END MODULE planet
Note: See TracBrowser for help on using the repository browser.