Ignore:
Timestamp:
Dec 16, 2025, 4:39:24 PM (4 weeks ago)
Author:
jbclement
Message:

PEM:
Apply documentation template everywhere: standardized headers format with short description, separators between functions/subroutines, normalized code sections, aligned dependencies/arguments/variables declaration.
JBC

File:
1 edited

Legend:

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

    r3989 r3991  
    11MODULE sorption
    2 
    3 implicit none
    4 
     2!-----------------------------------------------------------------------
     3! NAME
     4!     sorption
     5!
     6! DESCRIPTION
     7!     CO2 and H2O adsorption/desorption in regolith following Zent & Quinn
     8!     (1995) and Jackosky et al. (1997).
     9!
     10! AUTHORS & DATE
     11!     L. Lange, 2023
     12!     JB Clement, 2025
     13!
     14! NOTES
     15!
     16!-----------------------------------------------------------------------
     17
     18! DECLARATION
     19! -----------
     20implicit none
     21
     22! MODULE VARIABLES
     23! ----------------
    524logical                             :: do_sorption       ! Flag to compute adsorption/desorption
    625real, allocatable, dimension(:,:,:) :: co2_adsorbed_phys ! co2 that is in the regolith [kg/m^2]
    726real, allocatable, dimension(:,:,:) :: h2o_adsorbed_phys ! h2o that is in the regolith [kg/m^2]
    827
    9 !=======================================================================
    1028contains
    11 !=======================================================================
    12 
    13 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    14 !!!
    15 !!! Purpose: Compute CO2 and H2O adsorption, following the methods from Zent & Quinn 1995, Jackosky et al., 1997
    16 !!!
    17 !!! Author: LL, 01/2023
    18 !!!
    19 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     29!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     30
     31!=======================================================================
    2032SUBROUTINE ini_adsorption_h_PEM(ngrid,nslope,nsoilmx_PEM)
    21 
    22 implicit none
    23 
     33!-----------------------------------------------------------------------
     34! NAME
     35!     ini_adsorption_h_PEM
     36!
     37! DESCRIPTION
     38!     Allocate CO2 and H2O adsorption arrays.
     39!
     40! AUTHORS & DATE
     41!     L. Lange, 2023
     42!     JB Clement, 2025
     43!
     44! NOTES
     45!
     46!-----------------------------------------------------------------------
     47
     48! DECLARATION
     49! -----------
     50implicit none
     51
     52! ARGUMENTS
     53! ---------
    2454integer, intent(in) :: ngrid       ! number of atmospheric columns
    2555integer, intent(in) :: nslope      ! number of slope within a mesh
    2656integer, intent(in) :: nsoilmx_PEM ! number of soil layer in the PEM
    2757
     58! CODE
     59! ----
    2860allocate(co2_adsorbed_phys(ngrid,nsoilmx_PEM,nslope))
    2961allocate(h2o_adsorbed_phys(ngrid,nsoilmx_PEM,nslope))
    3062
    3163END SUBROUTINE ini_adsorption_h_PEM
     64!=======================================================================
    3265
    3366!=======================================================================
    3467SUBROUTINE end_adsorption_h_PEM
    35 
     68!-----------------------------------------------------------------------
     69! NAME
     70!     end_adsorption_h_PEM
     71!
     72! DESCRIPTION
     73!     Deallocate adsorption arrays.
     74!
     75! AUTHORS & DATE
     76!     L. Lange, 2023
     77!     JB Clement, 2025
     78!
     79! NOTES
     80!
     81!-----------------------------------------------------------------------
     82
     83! DECLARATION
     84! -----------
     85implicit none
     86
     87! CODE
     88! ----
    3689if (allocated(co2_adsorbed_phys)) deallocate(co2_adsorbed_phys)
    3790if (allocated(h2o_adsorbed_phys)) deallocate(h2o_adsorbed_phys)
    3891
    3992END SUBROUTINE end_adsorption_h_PEM
     93!=======================================================================
    4094
    4195!=======================================================================
    4296SUBROUTINE regolith_adsorption(ngrid,nslope,nsoil_PEM,timelen,d_h2oglaciers,d_co2glaciers,waterice,co2ice,tsoil_PEM,TI_PEM,ps,q_co2,q_h2o, &
    4397                               m_h2o_completesoil,delta_mh2oreg, m_co2_completesoil,delta_mco2reg)
    44 
    45 implicit none
    46 
    47 ! Inputs
    48 integer,                                    intent(in) :: ngrid, nslope, nsoil_PEM, timelen  ! size dimension: physics x subslope x soil x timeseries
    49 real,    dimension(ngrid,nslope),           intent(in) :: d_h2oglaciers, d_co2glaciers ! tendancies on the glaciers [1]
    50 real,    dimension(ngrid,nslope),           intent(in) :: waterice                           ! water ice at the surface [kg/m^2]
    51 real,    dimension(ngrid,nslope),           intent(in) :: co2ice                             ! co2 ice at the surface [kg/m^2]
    52 real,    dimension(ngrid,nsoil_PEM,nslope), intent(in) :: TI_PEM                             ! Soil Thermal inertia (J/K/^2/s^1/2)
    53 real,    dimension(ngrid,nsoil_PEM,nslope), intent(in) :: tsoil_PEM                          ! Soil temperature (K)
    54 real,    dimension(ngrid,timelen),          intent(in) :: ps                                 ! Average surface pressure [Pa]
    55 real,    dimension(ngrid,timelen),          intent(in) :: q_co2                              ! Mass mixing ratio of co2 in the first layer (kg/kg)
    56 real,    dimension(ngrid,timelen),          intent(in) :: q_h2o                              ! Mass mixing ratio of H2o in the first layer (kg/kg)
    57 
    58 ! Outputs
    59 real, dimension(ngrid), intent(out) :: delta_mh2oreg ! Difference density of h2o adsorbed (kg/m^3)
    60 real, dimension(ngrid), intent(out) :: delta_mco2reg ! Difference density of co2 adsorbed (kg/m^3)
    61 real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: m_co2_completesoil ! Density of co2 adsorbed (kg/m^3)
    62 real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: m_h2o_completesoil ! Density of h2o adsorbed (kg/m^3)
    63 
    64 ! Local variables
     98!-----------------------------------------------------------------------
     99! NAME
     100!     regolith_adsorption
     101!
     102! DESCRIPTION
     103!     Compute both H2O and CO2 adsorption in regolith.
     104!
     105! AUTHORS & DATE
     106!     L. Lange, 2023
     107!     JB Clement, 2025
     108!
     109! NOTES
     110!
     111!-----------------------------------------------------------------------
     112
     113! DECLARATION
     114! -----------
     115implicit none
     116
     117! ARGUMENTS
     118! ---------
     119integer,                                    intent(in)    :: ngrid, nslope, nsoil_PEM, timelen  ! size dimension: physics x subslope x soil x timeseries
     120real,    dimension(ngrid,nslope),           intent(in)    :: d_h2oglaciers, d_co2glaciers ! tendancies on the glaciers [1]
     121real,    dimension(ngrid,nslope),           intent(in)    :: waterice                           ! water ice at the surface [kg/m^2]
     122real,    dimension(ngrid,nslope),           intent(in)    :: co2ice                             ! co2 ice at the surface [kg/m^2]
     123real,    dimension(ngrid,nsoil_PEM,nslope), intent(in)    :: TI_PEM                             ! Soil Thermal inertia (J/K/^2/s^1/2)
     124real,    dimension(ngrid,nsoil_PEM,nslope), intent(in)    :: tsoil_PEM                          ! Soil temperature (K)
     125real,    dimension(ngrid,timelen),          intent(in)    :: ps                                 ! Average surface pressure [Pa]
     126real,    dimension(ngrid,timelen),          intent(in)    :: q_co2                              ! Mass mixing ratio of co2 in the first layer (kg/kg)
     127real,    dimension(ngrid,timelen),          intent(in)    :: q_h2o                              ! Mass mixing ratio of H2o in the first layer (kg/kg)
     128real,    dimension(ngrid),                  intent(out)   :: delta_mh2oreg                      ! Difference density of h2o adsorbed (kg/m^3)
     129real,    dimension(ngrid),                  intent(out)   :: delta_mco2reg                      ! Difference density of co2 adsorbed (kg/m^3)
     130real,    dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: m_co2_completesoil                 ! Density of co2 adsorbed (kg/m^3)
     131real,    dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: m_h2o_completesoil                 ! Density of h2o adsorbed (kg/m^3)
     132
     133! LOCAL VARIABLES
     134! ---------------
    65135real, dimension(ngrid,nsoil_PEM,nslope) :: theta_h2o_adsorbed ! Fraction of the pores occupied by H2O molecules
    66 ! -------------
    67 ! Compute H2O adsorption, then CO2 adsorption
     136
     137! CODE
     138! ----
    68139call regolith_h2oadsorption(ngrid,nslope,nsoil_PEM,timelen,d_h2oglaciers,d_co2glaciers,waterice,co2ice,ps,q_co2,q_h2o,tsoil_PEM,TI_PEM, &
    69140                            theta_h2o_adsorbed,m_h2o_completesoil,delta_mh2oreg)
     
    72143
    73144END SUBROUTINE regolith_adsorption
     145!=======================================================================
    74146
    75147!=======================================================================
    76148SUBROUTINE regolith_h2oadsorption(ngrid,nslope,nsoil_PEM,timelen,d_h2oglaciers,d_co2glaciers,waterice,co2ice,ps,q_co2,q_h2o,tsoil_PEM,TI_PEM, &
    77149                                  theta_h2o_adsorbed,m_h2o_completesoil,delta_mreg)
    78 
    79 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    80 !!!
    81 !!! Purpose: Compute H2O adsorption, following the methods from Jackosky et al., 1997
    82 !!!
    83 !!! Author: LL, 01/2023
    84 !!!
    85 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    86 
    87 use soil,         only: layer_PEM, index_breccia
     150!-----------------------------------------------------------------------
     151! NAME
     152!     regolith_h2oadsorption
     153!
     154! DESCRIPTION
     155!     Compute H2O adsorption in regolith following Jackosky et al. (1997).
     156!
     157! AUTHORS & DATE
     158!     L. Lange, 2023
     159!     JB Clement, 2025
     160!
     161! NOTES
     162!
     163!-----------------------------------------------------------------------
     164
     165! DEPENDENCIES
     166! ------------
     167use soil,                  only: layer_PEM, index_breccia
    88168use comslope_mod,          only: subslope_dist, def_slope_mean
    89169use vertical_layers_mod,   only: ap, bp
     
    91171use phys_constants,        only: pi
    92172
    93 implicit none
    94 
    95 ! Inputs
    96 integer,                                    intent(in) :: ngrid, nslope, nsoil_PEM,timelen   ! Size dimension
    97 real,    dimension(ngrid,nslope),           intent(in) :: d_h2oglaciers, d_co2glaciers ! Tendencies on the glaciers ()
    98 real,    dimension(ngrid,nslope),           intent(in) :: waterice                           ! Water ice at the surface [kg/m^2]
    99 real,    dimension(ngrid,nslope),           intent(in) :: co2ice                             ! CO2 ice at the surface [kg/m^2]
    100 real,    dimension(ngrid,timelen),          intent(in) :: ps                                 ! Surface pressure (Pa)
    101 real,    dimension(ngrid,timelen),          intent(in) :: q_co2                              ! Mass mixing ratio of co2 in the first layer (kg/kg)
    102 real,    dimension(ngrid,timelen),          intent(in) :: q_h2o                              ! Mass mixing ratio of H2o in the first layer (kg/kg)
    103 real,    dimension(ngrid,nsoil_PEM,nslope), intent(in) :: TI_PEM                             ! Soil Thermal inertia (J/K/^2/s^1/2)
    104 real,    dimension(ngrid,nsoil_PEM,nslope), intent(in) :: tsoil_PEM                          ! Soil temperature (K)
    105 
    106 ! Outputs
    107 real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: m_h2o_completesoil ! Density of h2o adsorbed (kg/m^3)(ngrid,nsoil_PEM,nslope)
    108 real, dimension(ngrid,nsoil_PEM,nslope), intent(out) :: theta_h2o_adsorbed ! Fraction of the pores occupied by H2O molecules
    109 real, dimension(ngrid),                  intent(out) :: delta_mreg          ! Difference density of h2o adsorbed (kg/m^3)
    110 
    111 ! Constants
     173! DECLARATION
     174! -----------
     175implicit none
     176
     177! ARGUMENTS
     178! ---------
     179integer,                                    intent(in)    :: ngrid, nslope, nsoil_PEM,timelen ! Size dimension
     180real,    dimension(ngrid,nslope),           intent(in)    :: d_h2oglaciers, d_co2glaciers     ! Tendencies on the glaciers ()
     181real,    dimension(ngrid,nslope),           intent(in)    :: waterice                         ! Water ice at the surface [kg/m^2]
     182real,    dimension(ngrid,nslope),           intent(in)    :: co2ice                           ! CO2 ice at the surface [kg/m^2]
     183real,    dimension(ngrid,timelen),          intent(in)    :: ps                               ! Surface pressure (Pa)
     184real,    dimension(ngrid,timelen),          intent(in)    :: q_co2                            ! Mass mixing ratio of co2 in the first layer (kg/kg)
     185real,    dimension(ngrid,timelen),          intent(in)    :: q_h2o                            ! Mass mixing ratio of H2o in the first layer (kg/kg)
     186real,    dimension(ngrid,nsoil_PEM,nslope), intent(in)    :: TI_PEM                           ! Soil Thermal inertia (J/K/^2/s^1/2)
     187real,    dimension(ngrid,nsoil_PEM,nslope), intent(in)    :: tsoil_PEM                        ! Soil temperature (K)
     188real,    dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: m_h2o_completesoil               ! Density of h2o adsorbed (kg/m^3)(ngrid,nsoil_PEM,nslope)
     189real,    dimension(ngrid,nsoil_PEM,nslope), intent(out)   :: theta_h2o_adsorbed               ! Fraction of the pores occupied by H2O molecules
     190real,    dimension(ngrid),                  intent(out)   :: delta_mreg                       ! Difference density of h2o adsorbed (kg/m^3)
     191
     192! LOCAL VARIABLES
     193! ---------------
     194! Constants:
    112195real :: Ko =  1.57e-8            ! Jackosky et al. 1997
    113196real :: e = 2573.9               ! Jackosky et al. 1997
     
    117200real :: as = 9.48e4              ! Specific area, Zent
    118201real ::  inertie_thresold = 800. ! TI > 800 means cementation
    119 
    120 ! Local variables
    121202real,    dimension(ngrid,index_breccia,nslope) :: deltam_reg_complete     ! Difference in the mass per slope and soil layer (kg/m^3)
    122203real                                           :: K                       ! Used to compute theta
     
    133214real,    dimension(:)  , allocatable           :: pvapor_avg              ! Yearly averaged
    134215
     216! CODE
     217! ----
    135218! 0. Some initializations
    136219allocate(mass_mean(ngrid,timelen),zplev_mean(ngrid,timelen),pvapor(ngrid,timelen),pvapor_avg(ngrid))
     
    207290
    208291END SUBROUTINE regolith_h2oadsorption
    209 
    210 !=======================================================================
    211 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    212 !!!
    213 !!! Purpose: Compute CO2  following the methods from Zent & Quinn 1995
    214 !!!
    215 !!! Author: LL, 01/2023
    216 !!!
    217 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     292!=======================================================================
     293
     294!=======================================================================
    218295SUBROUTINE regolith_co2adsorption(ngrid,nslope,nsoil_PEM,timelen,d_h2oglaciers,d_co2glaciers,waterice,co2ice,ps,q_co2,q_h2o,tsoil_PEM,TI_PEM,m_co2_completesoil,delta_mreg)
    219296
    220 use soil,                  only: layer_PEM, index_breccia, index_breccia
     297!-----------------------------------------------------------------------
     298! NAME
     299!     regolith_co2adsorption
     300!
     301! DESCRIPTION
     302!     Compute CO2 adsorption in regolith following Zent & Quinn (1995).
     303!
     304! AUTHORS & DATE
     305!     L. Lange, 2023
     306!     JB Clement, 2025
     307!
     308! NOTES
     309!
     310!-----------------------------------------------------------------------
     311
     312! DEPENDENCIES
     313! ------------
     314use soil,                  only: layer_PEM, index_breccia
    221315use comslope_mod,          only: subslope_dist, def_slope_mean
    222316use vertical_layers_mod,   only: ap, bp
     
    224318use phys_constants,        only: pi
    225319
    226 implicit none
    227 
    228 ! Inputs:
    229 integer,                                    intent(in) :: ngrid, nslope, nsoil_PEM,timelen   ! Size dimension
    230 real,    dimension(ngrid,timelen),          intent(in) :: ps                                 ! Average surface pressure [Pa]
    231 real,    dimension(ngrid,nsoil_PEM,nslope), intent(in) :: tsoil_PEM                          ! Mean Soil Temperature [K]
    232 real,    dimension(ngrid,nsoil_PEM,nslope), intent(in) :: TI_PEM                             ! Mean Thermal Inertia [USI]
    233 real,    dimension(ngrid,nslope),           intent(in) :: d_h2oglaciers, d_co2glaciers ! Tendencies on the glaciers ()
    234 real,    dimension(ngrid,timelen),          intent(in) :: q_co2, q_h2o                       ! Mass mixing ratio of co2 and h2o in the first layer (kg/kg)
    235 real,    dimension(ngrid,nslope),           intent(in) :: waterice                           ! Water ice at the surface [kg/m^2]
    236 real,    dimension(ngrid,nslope),           intent(in) :: co2ice                             ! CO2 ice at the surface [kg/m^2]
    237 
    238 ! Outputs:
    239 real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: m_co2_completesoil ! Density of co2 adsorbed (kg/m^3)
    240 real, dimension(ngrid), intent(out) :: delta_mreg ! Difference density of co2 adsorbed (kg/m^3)
    241 
     320! DECLARATION
     321! -----------
     322implicit none
     323
     324! ARGUMENTS
     325! ---------
     326integer,                                    intent(in)    :: ngrid, nslope, nsoil_PEM,timelen ! Size dimension
     327real,    dimension(ngrid,timelen),          intent(in)    :: ps                               ! Average surface pressure [Pa]
     328real,    dimension(ngrid,nsoil_PEM,nslope), intent(in)    :: tsoil_PEM                        ! Mean Soil Temperature [K]
     329real,    dimension(ngrid,nsoil_PEM,nslope), intent(in)    :: TI_PEM                           ! Mean Thermal Inertia [USI]
     330real,    dimension(ngrid,nslope),           intent(in)    :: d_h2oglaciers, d_co2glaciers     ! Tendencies on the glaciers ()
     331real,    dimension(ngrid,timelen),          intent(in)    :: q_co2, q_h2o                     ! Mass mixing ratio of co2 and h2o in the first layer (kg/kg)
     332real,    dimension(ngrid,nslope),           intent(in)    :: waterice                         ! Water ice at the surface [kg/m^2]
     333real,    dimension(ngrid,nslope),           intent(in)    :: co2ice                           ! CO2 ice at the surface [kg/m^2]
     334real,    dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: m_co2_completesoil               ! Density of co2 adsorbed (kg/m^3)
     335real,    dimension(ngrid),                  intent(out)   :: delta_mreg                       ! Difference density of co2 adsorbed (kg/m^3)
     336
     337! LOCAL VARIABLES
     338! ---------------
    242339! Constants:
    243340real :: alpha = 7.512e-6        ! Zent & Quinn 1995
     
    247344! real :: as = 18.9e3             ! Specific area, Buhler & Piqueux 2021
    248345real :: as = 9.48e4             ! Same as previous but from zent
    249 
    250 ! Local
    251346real                                           :: A, B                    ! Used to compute the mean mass above the surface
    252347integer                                        :: ig, islope, iloop, it   ! For loops
     
    265360real,    dimension(:),   allocatable           :: pco2_avg                ! Yearly averaged
    266361
     362! CODE
     363! ----
    267364! 0. Some initializations
    268365allocate(mass_mean(ngrid,timelen),zplev_mean(ngrid,timelen),pco2(ngrid,timelen),pco2_avg(ngrid))
     
    348445
    349446END SUBROUTINE regolith_co2adsorption
     447!=======================================================================
    350448
    351449END MODULE sorption
Note: See TracChangeset for help on using the changeset viewer.