Ignore:
Timestamp:
Feb 12, 2026, 9:09:12 AM (3 weeks ago)
Author:
jbclement
Message:

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:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.COMMON/libf/evolution/planet.F90

    r4064 r4065  
    1 MODULE constants_marspem_mod
     1MODULE planet
    22!-----------------------------------------------------------------------
    33! NAME
    4 !     constants_marspem_mod
     4!     planet
    55!
    66! DESCRIPTION
    7 !     Physical constants for PEM simulations on Mars
     7!     Mars-specific constants kept hard-coded for the PEM.
    88!
    99! AUTHORS & DATE
     
    1212!
    1313! NOTES
    14 !
     14!     Only valid for the Mars planet.
    1515!-----------------------------------------------------------------------
     16
     17! DEPENDENCIES
     18! ------------
     19use numerics, only: dp
    1620
    1721! DECLARATION
     
    2125! PARAMETERS
    2226! ----------
    23 ! Duration of a year and day
    24 integer, parameter :: sols_per_my = 669    ! Number of sols per year
    25 real,    parameter :: sec_per_sol = 88775. ! Duration of a sol, in seconds
     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
    2633
    27 ! Molecular masses for CO2,H2O and non condensible gaz, following Franz et al. 2017
    28 real, parameter :: m_co2 = 44.01e-3    ! CO2 molecular mass (kg/mol)
    29 real, parameter :: m_noco2 = 33.37e-3  ! Non condensible mol mass (kg/mol)
    30 real, parameter :: m_h2o = 18.01528e-3 ! Molecular weight of h2o (kg/mol)
     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
    3141
    3242! Coefficient for Clapeyron law for CO2 condensation temperature (Tco2 = beta/(alpha-log(vmr)),following James et al. 1992
    33 real, parameter :: alpha_clap_co2 = 23.3494 ! Uniteless, James et al. 1992
    34 real, parameter :: beta_clap_co2 = 3182.48  ! Kelvin, 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
    3545
    36 ! Coefficient for Clapeyron law for psat (psat = exp(beta/Th2o+alpha)),following Murphy and Koop 2005
    37 real, parameter :: alpha_clap_h2o = 28.9074 ! Uniteless, Murphy and Koop 2005
    38 real, parameter :: beta_clap_h2o = -6143.7  ! Kelvin, Murphy and Koop 2005
    39 
    40 ! Density of the regolith (Zent et al., 1995, Buhler and Piqueux 2021)
    41 real, parameter :: rho_regolith = 2000. ! kg/m^3
     46! Density of the regolith (Zent et al., 1995; Buhler and Piqueux 2021)
     47real(dp), parameter :: rho_regolith = 2000._dp ! kg/m^3
    4248
    4349! Average thermal inertia of the surface, breccia, bedrock, following Mellon et al., 2000., Wood et al., 2008
    44 real, parameter :: TI_regolith_avg = 250. ! Averaged of the observed thermal inertia for regolith following Mellon et al., 2000[SI]
    45 real, parameter :: TI_breccia = 750.      ! Thermal inertia of Breccia following Wood 2009 [SI]
    46 real, parameter :: TI_bedrock = 2300.     ! Thermal inertia of Bedrock following Wood 2009 [SI]
     50real(dp), parameter :: TI_regolith_avg = 250._dp ! Averaged of the observed thermal inertia for regolith following Mellon et al., 2000[SI]
    4751
    4852! Porosity of the soil
    49 real, parameter :: porosity = 0.4 ! porosity of the martian soil, correspond to the value for a random loose packing of monodiperse sphere (Scott, 1960)
     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)
    5054
    5155! Stefan Boltzmann constant
    52 real, parameter :: sigmaB = 5.678e-8
     56real(dp), parameter :: sigmaB = 5.678e-8_dp
    5357
    5458! Latent heat of CO2
    55 real, parameter :: Lco2 =  5.71e5 ! Pilorget and Forget 2016
     59real(dp), parameter :: Lco2 =  5.71e5_dp ! Pilorget and Forget 2016
    5660
    57 END MODULE constants_marspem_mod
     61! Current average pressure [Pa]
     62real(dp), parameter :: P610 = 610._dp
     63
     64contains
     65!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     66
     67END MODULE planet
Note: See TracChangeset for help on using the changeset viewer.