Ignore:
Timestamp:
Dec 11, 2025, 12:56:05 PM (3 months 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/config_pem.F90

    r3988 r3989  
    1 MODULE conf_pem_mod
     1MODULE config_pem
    22
    33!=======================================================================
     
    1414!=======================================================================
    1515
    16 SUBROUTINE conf_pem(i_myear,n_myears)
     16SUBROUTINE read_rundef(i_myear,nyears_tots)
    1717
    1818#ifdef CPP_IOIPSL
     
    2323#endif
    2424
    25 use time_evol_mod,         only: year_bp_ini, dt, h2o_ice_crit, co2_ice_crit, ps_criterion, Max_iter_pem, &
    26                                  evol_orbit_pem, var_obl, var_ecc, var_lsp, convert_years, ecritpem
    27 use comsoil_h_pem,         only: soil_pem, fluxgeo, ini_huge_h2oice, depth_breccia, depth_bedrock, reg_thprop_dependp
    28 use adsorption_mod,        only: adsorption_pem
    29 use glaciers_mod,          only: h2oice_flow, co2ice_flow, inf_h2oice_threshold
    30 use ice_table_mod,         only: icetable_equilibrium, icetable_dynamic
    31 use layering_mod,          only: layering_algo, d_dust, impose_dust_ratio, dust2ice_ratio
    32 use info_PEM_mod,          only: iPCM, iPEM, nPCM, nPCM_ini
     25use evolution,        only: year_bp_ini, dt, nyears_max, evol_orbit, var_obl, var_ecc, var_lsp, convert_years
     26use stopping_crit,    only: h2oice_crit, co2ice_crit, ps_crit
     27use soil,             only: do_soil, fluxgeo, h2oice_huge_ini, depth_breccia, depth_bedrock, reg_thprop_dependp
     28use sorption,         only: do_sorption
     29use glaciers,         only: h2oice_flow, co2ice_flow
     30use surf_ice,         only: h2oice_cap_threshold
     31use ice_table,        only: icetable_equilibrium, icetable_dynamic
     32use layered_deposits, only: layering_algo, d_dust, impose_dust_ratio, dust2ice_ratio
     33use info_pem,         only: iPCM, iPEM, nPCM, nPCM_ini
     34use outputs,          only: output_rate
    3335
    3436implicit none
    3537
    36 real, intent(out) :: i_myear, n_myears ! Current simulated Martian year and maximum number of Martian years to be simulated
     38real, intent(out) :: i_myear, nyears_tots ! Current simulated Martian year and maximum number of Martian years to be simulated
    3739
    38 character(20), parameter :: modname ='conf_pem'
     40character(20), parameter :: modname ='read_rundef'
    3941integer                  :: ierr
    4042integer                  :: year_earth_bp_ini ! Initial year (in Earth years) of the simulation of the PEM defined in run.def
     
    4951    stop
    5052else
    51     read(100,*) i_myear, n_myears, convert_years, iPCM, iPEM, nPCM, nPCM_ini
     53    read(100,*) i_myear, nyears_tots, convert_years, iPCM, iPEM, nPCM, nPCM_ini
    5254endif
    5355close(100)
     
    5557!#---------- Output parameters ----------#
    5658! Frequency of outputs for the PEM
    57 ecritpem = 1 ! Default value: every year
    58 call getin('ecritpem',ecritpem)
     59output_rate = 1 ! Default value: every year
     60call getin('output_rate',output_rate)
    5961
    6062!#---------- Orbital parameters ----------#
    61 evol_orbit_pem = .false.
    62 call getin('evol_orbit_pem',evol_orbit_pem)
     63evol_orbit = .false.
     64call getin('evol_orbit',evol_orbit)
    6365
    6466year_earth_bp_ini = 0.
     
    7981
    8082!#---------- Stopping criteria parameters ----------#
    81 Max_iter_pem = 100000000
    82 call getin('Max_iter_pem',Max_iter_pem)
    83 write(*,*) 'Max_iter_pem =',Max_iter_pem
     83nyears_max = 100000000.
     84call getin('nyears_max',nyears_max)
     85write(*,*) 'nyears_max =',nyears_max
    8486
    85 h2o_ice_crit = 0.2
    86 call getin('h2o_ice_crit',h2o_ice_crit)
    87 write(*,*) 'h2o_ice_crit =',h2o_ice_crit
     87h2oice_crit = 0.2
     88call getin('h2oice_crit',h2oice_crit)
     89write(*,*) 'h2oice_crit =',h2oice_crit
    8890
    89 co2_ice_crit = 0.2
    90 call getin('co2_ice_crit',co2_ice_crit)
    91 write(*,*) 'co2_ice_crit =',co2_ice_crit
     91co2ice_crit = 0.2
     92call getin('co2ice_crit',co2ice_crit)
     93write(*,*) 'co2ice_crit =',co2ice_crit
    9294
    93 ps_criterion = 0.15
    94 call getin('ps_criterion',ps_criterion)
    95 write(*,*) 'ps_criterion =',ps_criterion
     95ps_crit = 0.15
     96call getin('ps_crit',ps_crit)
     97write(*,*) 'ps_crit =',ps_crit
    9698
    9799dt = 1.
     
    99101
    100102!#---------- Subsurface parameters ----------#
    101 soil_pem = .true.
    102 call getin('soil_pem',soil_pem)
     103do_soil = .true.
     104call getin('do_soil',do_soil)
    103105
    104 adsorption_pem = .false.
    105 call getin('adsorption_pem',adsorption_pem)
     106do_sorption = .false.
     107call getin('do_sorption',do_sorption)
    106108
    107109reg_thprop_dependp = .false.
     
    128130call getin('icetable_dynamic',icetable_dynamic)
    129131write(*,*) 'Is the ice table computed with the dynamic method?', icetable_dynamic
    130 if ((.not. soil_pem) .and. (icetable_equilibrium .or. icetable_dynamic)) then
    131     write(*,*) 'Ice table (equilibrium or dynamic method) must be used when soil_pem = T'
    132     call abort_physic(modname,"Ice table must be used when soil_pem = T",1)
     132if ((.not. do_soil) .and. (icetable_equilibrium .or. icetable_dynamic)) then
     133    write(*,*) 'Ice table (equilibrium or dynamic method) must be used when do_soil = T'
     134    call abort_physic(modname,"Ice table must be used when do_soil = T",1)
    133135endif
    134136if (icetable_equilibrium .and. icetable_dynamic) then
     
    138140endif
    139141
    140 if ((.not. soil_pem) .and. adsorption_pem) then
    141     write(*,*) 'Adsorption must be used when soil_pem = T'
    142     call abort_physic(modname,"Adsorption must be used when soil_pem = T",1)
     142if ((.not. do_soil) .and. do_sorption) then
     143    write(*,*) 'Adsorption must be used when do_soil = T'
     144    call abort_physic(modname,"Adsorption must be used when do_soil = T",1)
    143145endif
    144146
    145 if ((.not. soil_pem) .and. (fluxgeo > 0.)) then
     147if ((.not. do_soil) .and. (fluxgeo > 0.)) then
    146148    write(*,*) 'Soil is not activated but Flux Geo > 0.'
    147149    call abort_physic(modname,"Soil is not activated but Flux Geo > 0.",1)
    148150endif
    149151
    150 if ((.not. soil_pem) .and. reg_thprop_dependp) then
     152if ((.not. do_soil) .and. reg_thprop_dependp) then
    151153    write(*,*) 'Regolith properties vary with Ps only when soil is set to true'
    152154    call abort_physic(modname,'Regolith properties vary with Ps only when soil is set to true',1)
    153155endif
    154156
    155 if (evol_orbit_pem .and. abs(year_bp_ini) < 1.e-10) then
     157if (evol_orbit .and. abs(year_bp_ini) < 1.e-10) then
    156158    write(*,*) 'You want to follow the file "obl_ecc_lsp.asc" for changing orbital parameters,'
    157159    write(*,*) 'but you did not specify from which year to start.'
    158     call abort_physic(modname,"evol_orbit_pem=.true. but year_bp_ini = 0",1)
     160    call abort_physic(modname,"evol_orbit=.true. but year_bp_ini = 0",1)
    159161endif
    160162
    161163!#---------- Ice management parameters ----------#
    162 ini_huge_h2oice = 9200. ! kg.m-2 (= 10 m)
    163 call getin('ini_huge_h2oice',ini_huge_h2oice)
     164h2oice_huge_ini = 9200. ! kg.m-2 (= 10 m)
     165call getin('h2oice_huge_ini',h2oice_huge_ini)
    164166
    165 inf_h2oice_threshold = 460. ! kg.m-2 (= 0.5 m)
    166 call getin('inf_h2oice_threshold',inf_h2oice_threshold)
     167h2oice_cap_threshold = 460. ! kg.m-2 (= 0.5 m)
     168call getin('h2oice_cap_threshold',h2oice_cap_threshold)
    167169
    168170h2oice_flow = .true.
     
    185187call getin('dust2ice_ratio',dust2ice_ratio)
    186188
    187 END SUBROUTINE conf_pem
     189END SUBROUTINE read_rundef
    188190
    189 END MODULE conf_pem_mod
     191END MODULE config_pem
Note: See TracChangeset for help on using the changeset viewer.