Ignore:
Timestamp:
Feb 12, 2026, 9:09:12 AM (2 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 edited

Legend:

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

    r3991 r4065  
    55!
    66! DESCRIPTION
    7 !     Contains global parameters used for the evolution flags.
     7!     Time parameters for the evolution of the simulation.
    88!
    99! AUTHORS & DATE
    10 !     R. Vandemeulebrouck
    11 !     JB Clement, 2023-2025
     10!     JB Clement, 12/2025
     11!
     12! NOTES
     13!
     14!-----------------------------------------------------------------------
     15
     16! DEPENDENCIES
     17! ------------
     18use numerics, only: dp, di
     19
     20! DECLARATION
     21! -----------
     22implicit none
     23
     24! PARAMETERS
     25! ----------
     26real(dp), protected :: r_plnt2earth_yr ! Conversion ratio from Planetary years to Earth years
     27real(dp), protected :: pem_ini_date    ! Initial year (in Planetary years) of the simulation of the PEM defined in "run.def"
     28real(dp), protected :: dt              ! Time step in Planetary years
     29real(dp), protected :: nmax_yr_run     ! Maximum number of Planetary years of a PEM run if no stopping criterion is reached
     30
     31! VARIABLES
     32! ---------
     33real(dp)    :: n_yr_run    ! Number of simulated Planetary years of the PEM run
     34real(dp)    :: n_yr_sim    ! Number of simulated Planetary years of the chained simulations
     35real(dp)    :: nmax_yr_sim ! Maximum number of Planetary years of the chained simulations
     36integer(di) :: idt         ! Number of timesteps of the PEM run
     37
     38contains
     39!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     40
     41!=======================================================================
     42SUBROUTINE set_r_plnt2earth_yr(r_plnt2earth_yr_in)
     43!-----------------------------------------------------------------------
     44! NAME
     45!     set_r_plnt2earth_yr
     46!
     47! DESCRIPTION
     48!     Setter for 'r_plnt2earth_yr'.
     49!
     50! AUTHORS & DATE
     51!     JB Clement, 12/2025
    1252!
    1353! NOTES
     
    1959implicit none
    2060
    21 ! PARAMETERS
    22 ! ----------
    23 real    :: year_bp_ini   ! Initial year (in Planetary years) of the simulation of the PEM defined in run.def (in Earth years)
    24 real    :: dt            ! Time step used by the PEM in Planetary years
    25 real    :: convert_years ! Conversion ratio from Planetary years to Earth years
    26 real    :: nyears_max    ! Maximal number of iterations when converging to a steady state, read in evol.def
    27 logical :: evol_orbit    ! True if we want to follow the orbital parameters of obl_ecc_lsp.asc, read in evol.def
    28 logical :: var_obl       ! True if we want the PEM to follow obl_ecc_lsp.asc parameters for obliquity
    29 logical :: var_ecc       ! True if we want the PEM to follow obl_ecc_lsp.asc parameters for eccenticity
    30 logical :: var_lsp       ! True if we want the PEM to follow obl_ecc_lsp.asc parameters for ls perihelie
     61! ARGUMENTS
     62! ---------
     63real(dp), intent(in) :: r_plnt2earth_yr_in
     64
     65! CODE
     66! ----
     67r_plnt2earth_yr = r_plnt2earth_yr_in
     68
     69END SUBROUTINE set_r_plnt2earth_yr
     70!=======================================================================
     71
     72!=======================================================================
     73SUBROUTINE set_evolution_config(pem_ini_earth_date,dt_in,nmax_yr_run_in)
     74!-----------------------------------------------------------------------
     75! NAME
     76!     set_evolution_config
     77!
     78! DESCRIPTION
     79!     Setter for 'evolution' configuration parameters.
     80!
     81! AUTHORS & DATE
     82!     JB Clement, 02/2026
     83!
     84! NOTES
     85!
     86!-----------------------------------------------------------------------
     87
     88! DEPENDENCIES
     89! ------------
     90use utility, only: real2str, int2str
     91use display, only: print_msg
     92
     93! DECLARATION
     94! -----------
     95implicit none
     96
     97! ARGUMENTS
     98! ---------
     99integer(di), intent(in) :: pem_ini_earth_date
     100real(dp),    intent(in) :: dt_in, nmax_yr_run_in
     101
     102! CODE
     103! ----
     104pem_ini_date = real(pem_ini_earth_date,dp)/r_plnt2earth_yr
     105dt = dt_in
     106nmax_yr_run = nmax_yr_run_in
     107call print_msg('pem_ini_earth_date = '//int2str(pem_ini_earth_date)//' | pem_ini_date = '//real2str(pem_ini_date))
     108call print_msg('dt                 = '//real2str(dt))
     109call print_msg('nmax_yr_run        = '//real2str(nmax_yr_run))
     110
     111END SUBROUTINE set_evolution_config
     112!=======================================================================
    31113
    32114END MODULE evolution
Note: See TracChangeset for help on using the changeset viewer.