Ignore:
Timestamp:
Dec 11, 2025, 12:56:05 PM (6 weeks ago)
Author:
jbclement
Message:

PEM:
Massive structural refactor of the PEM codebase for improved readability, consistency and maintainability. The goal is to modernize, standardize and consolidate the code while removing legacy complexity. In detail, this change:

  • Performs large-scale cleanup removing unused code, obsolete routines, duplicated functionality and deprecated initialization logic;
  • Removes "*_mod" wrappers;
  • Replaces mixed naming conventions with clearer variable names, domain-based file/module names and purpose-based routine names;
  • Adds native reading/writing capabilities to the PEM removing the cumbersome dependency on Mars PCM subroutines;
  • Centralizes soil/ice/orbital/PEM configuration logic into dedicated modules;
  • Simplifies routines and updates calls/interfaces to match the new structure.

This refactor significantly clarifies the codebase and provides a cleaner foundation for forthcoming developments.
JBC

File:
1 moved

Legend:

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

    r3988 r3989  
    1 MODULE glaciers_mod
    2 
    3 implicit none
    4 
    5 ! Different types of ice
    6 type :: ice
    7     real :: h2o
    8     real :: co2
    9 end type ice
    10 
    11 ! Perennial ice manage by the PEM
    12 type(ice), dimension(:,:), allocatable :: perice
     1MODULE glaciers
     2
     3implicit none
    134
    145! Flags for ice flow
    15 logical :: h2oice_flow  ! True by default, to compute H2O ice flow. Read in "run_PEM.def"
    16 logical :: co2ice_flow  ! True by default, to compute CO2 ice flow. Read in "run_PEM.def"
    17 
    18 ! Threshold to consider H2O ice as watercap
    19 real :: inf_h2oice_threshold   ! To consider the amount of H2O ice as an infinite reservoir [kg.m-2]
    20 
    21 ! Ice properties
    22 real, parameter :: rho_co2ice = 1650. ! Density of CO2 ice [kg.m-3]
    23 real, parameter :: rho_h2oice = 920.  ! Density of H2O ice [kg.m-3]
     6logical :: h2oice_flow  ! True by default, flag to compute H2O ice flow
     7logical :: co2ice_flow  ! True by default, flag to compute CO2 ice flow
    248
    259!=======================================================================
    2610contains
    27 !=======================================================================
    28 
    29 SUBROUTINE set_perice4PCM(ngrid,nslope,PCMfrost,is_perh2oice,PCMh2oice,PCMco2ice)
    30 
    31 use metamorphism,   only: iPCM_h2ofrost
    32 use comslope_mod,   only: subslope_dist, def_slope_mean
    33 use phys_constants, only: pi
    34 
    35 
    36 implicit none
    37 
    38 ! Arguments
    39 !----------
    40 integer, intent(in) :: ngrid, nslope
    41 real, dimension(:,:,:), intent(inout) :: PCMfrost
    42 logical, dimension(ngrid),        intent(out) :: is_perh2oice
    43 real,    dimension(ngrid,nslope), intent(out) :: PCMco2ice, PCMh2oice
    44 
    45 ! Local variables
    46 !----------------
    47 integer :: i
    48 
    49 ! Code
    50 !-----
    51 write(*,*) '> Reconstructing perennial ic for the PCM'
    52 PCMco2ice(:,:) = perice(:,:)%co2
    53 PCMh2oice(:,:) = 0. ! Because in the Mars PCM, only the variation of perennial H2O ice is monitored, not the absolute quantity
    54 do i = 1,ngrid
    55     ! Is H2O ice still considered as an infinite reservoir for the PCM?
    56     if (sum(perice(i,:)%h2o*subslope_dist(i,:)/cos(pi*def_slope_mean(:)/180.)) > inf_h2oice_threshold) then
    57         ! There is enough ice to be considered as an infinite reservoir
    58         is_perh2oice(i) = .true.
    59     else
    60         ! Too little ice to be considered as an infinite reservoir so ice is transferred to the frost
    61         is_perh2oice(i) = .false.
    62         PCMfrost(i,iPCM_h2ofrost,:) = PCMfrost(i,iPCM_h2ofrost,:) + perice(i,:)%h2o
    63         perice(i,:)%h2o = 0.
    64     endif
    65 enddo
    66 
    67 END SUBROUTINE set_perice4PCM
    68 !=======================================================================
    69 
    70 SUBROUTINE ini_ice(ngrid,nslope)
    71 
    72 implicit none
    73 
    74 ! Arguments
    75 !----------
    76 integer, intent(in) :: ngrid, nslope
    77 
    78 ! Local variables
    79 !----------------
    80 
    81 ! Code
    82 !-----
    83 if (.not. allocated(perice)) allocate(perice(ngrid,nslope))
    84 
    85 END SUBROUTINE ini_ice
    86 !=======================================================================
    87 
    88 SUBROUTINE end_ice()
    89 
    90 implicit none
    91 
    92 ! Arguments
    93 !----------
    94 
    95 ! Local variables
    96 !----------------
    97 
    98 ! Code
    99 !-----
    100 if (allocated(perice)) deallocate(perice)
    101 
    102 END SUBROUTINE end_ice
    103 
    10411!=======================================================================
    10512
     
    18693SUBROUTINE compute_hmaxglaciers(ngrid,nslope,iflat,def_slope_mean,Tice,name_ice,hmax)
    18794
    188 use ice_table_mod,  only: rho_ice
    189 use abort_pem_mod,  only: abort_pem
     95use ice_table,  only: rho_ice
     96use stop_pem,  only: stop_clean
    19097use phys_constants, only: pi, g
    19198
     
    222129        tau_d = 5.e3
    223130    case default
    224         call abort_pem("compute_hmaxglaciers","Type of ice not known!",1)
     131        call stop_clean("compute_hmaxglaciers","Type of ice not known!",1)
    225132end select
    226133
     
    249156!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    250157
    251 use ice_table_mod,  only: rho_ice
    252 use abort_pem_mod,  only: abort_pem
     158use ice_table,      only: rho_ice
     159use stop_pem,       only: stop_clean
    253160use phys_constants, only: pi
    254161
     
    345252END SUBROUTINE computeTcondCO2
    346253
    347 END MODULE glaciers_mod
     254END MODULE glaciers
Note: See TracChangeset for help on using the changeset viewer.