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/soil_temp.F90

    r3989 r3991  
    11MODULE soil_temp
    2 
     2!-----------------------------------------------------------------------
     3! NAME
     4!     soil_temp
     5!
     6! DESCRIPTION
     7!     Routines to compute soil temperature evolution and initialization.
     8!
     9! AUTHORS & DATE
     10!     L. Lange, 2023
     11!     JB Clement, 2023-2025
     12!
     13! NOTES
     14!
     15!-----------------------------------------------------------------------
     16
     17! DECLARATION
     18! -----------
    319implicit none
    4 !-----------------------------------------------------------------------
    5 !  Author: LL
    6 !  Purpose: This module gathers the different routines used in the PEM to compute the soil temperature evolution and initialisation.
    7 !
    8 !  Note: depths of layers and mid-layers, soil thermal inertia and
    9 !        heat capacity are commons in comsoil_PEM.h
    10 !-----------------------------------------------------------------------
     20
    1121contains
    12 !=======================================================================
     22!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    1323
    1424!=======================================================================
    1525SUBROUTINE compute_tsoil(ngrid,nsoil,firstcall,therm_i,timestep,tsurf,tsoil)
    16 
    17 use soil, only: layer_PEM, mlayer_PEM, mthermdiff_PEM, thermdiff_PEM, coefq_PEM, coefd_PEM, mu_PEM, alph_PEM, beta_PEM, fluxgeo
    18 use comsoil_h,     only: volcapa
    19 
     26!-----------------------------------------------------------------------
     27! NAME
     28!     compute_tsoil
     29!
     30! DESCRIPTION
     31!     Compute soil temperature using an implicit 1st order scheme.
     32!
     33! AUTHORS & DATE
     34!     L. Lange, 2023
     35!     JB Clement, 2023-2025
     36!
     37! NOTES
     38!
     39!-----------------------------------------------------------------------
     40
     41! DEPENDENCIES
     42! ------------
     43use soil,      only: layer_PEM, mlayer_PEM, mthermdiff_PEM, thermdiff_PEM, coefq_PEM, coefd_PEM, mu_PEM, alph_PEM, beta_PEM, fluxgeo
     44use comsoil_h, only: volcapa
     45
     46! DECLARATION
     47! -----------
    2048implicit none
    2149
    22 !-----------------------------------------------------------------------
    23 !  Author: LL
    24 !  Purpose: Compute soil temperature using an implict 1st order scheme
    25 !
    26 !  Note: depths of layers and mid-layers, soil thermal inertia and
    27 !        heat capacity are commons in comsoil_PEM.h
    28 !-----------------------------------------------------------------------
    29 
    3050#include "dimensions.h"
    3151
    32 ! Inputs:
    33 ! -------
    34 integer,                      intent(in) :: ngrid     ! number of (horizontal) grid-points
    35 integer,                      intent(in) :: nsoil     ! number of soil layers
    36 logical,                      intent(in) :: firstcall ! identifier for initialization call
    37 real, dimension(ngrid,nsoil), intent(in) :: therm_i   ! thermal inertia [SI]
    38 real,                         intent(in) :: timestep  ! time step [s]
    39 real, dimension(ngrid),       intent(in) :: tsurf     ! surface temperature [K]
    40 ! Outputs:
    41 !---------
    42 real, dimension(ngrid,nsoil), intent(inout) :: tsoil ! soil (mid-layer) temperature [K]
    43 ! Local:
    44 !-------
     52! ARGUMENTS
     53! ---------
     54integer,                      intent(in)    :: ngrid     ! number of (horizontal) grid-points
     55integer,                      intent(in)    :: nsoil     ! number of soil layers
     56logical,                      intent(in)    :: firstcall ! identifier for initialization call
     57real, dimension(ngrid,nsoil), intent(in)    :: therm_i   ! thermal inertia [SI]
     58real,                         intent(in)    :: timestep  ! time step [s]
     59real, dimension(ngrid),       intent(in)    :: tsurf     ! surface temperature [K]
     60real, dimension(ngrid,nsoil), intent(inout) :: tsoil     ! soil (mid-layer) temperature [K]
     61
     62! LOCAL VARIABLES
     63! ---------------
    4564integer :: ig, ik
    4665
     66! CODE
     67! ----
    4768! 0. Initialisations and preprocessing step
    4869 if (firstcall) then
     
    121142!=======================================================================
    122143SUBROUTINE ini_tsoil_pem(ngrid,nsoil,therm_i,tsurf,tsoil)
    123 
    124 use soil, only: layer_PEM, mlayer_PEM, mthermdiff_PEM, thermdiff_PEM, coefq_PEM, coefd_PEM, mu_PEM, alph_PEM, beta_PEM, fluxgeo
    125 use comsoil_h,     only: volcapa
    126 
     144!-----------------------------------------------------------------------
     145! NAME
     146!     ini_tsoil_pem
     147!
     148! DESCRIPTION
     149!     Initialize soil with the solution of the stationary heat conduction problem.
     150!     Boundary conditions: Tsurf averaged from PCM; geothermal flux at bottom.
     151!
     152! AUTHORS & DATE
     153!     L. Lang, 2023
     154!     JB Clement, 2023-2025
     155!
     156! NOTES
     157!
     158!-----------------------------------------------------------------------
     159
     160! DEPENDENCIES
     161! ------------
     162use soil,      only: layer_PEM, mlayer_PEM, mthermdiff_PEM, thermdiff_PEM, coefq_PEM, coefd_PEM, mu_PEM, alph_PEM, beta_PEM, fluxgeo
     163use comsoil_h, only: volcapa
     164
     165! DECLARATION
     166! -----------
    127167implicit none
    128168
    129 !-----------------------------------------------------------------------
    130 !  Author: LL
    131 !  Purpose: Initialize the soil with the solution of the stationnary problem of Heat Conduction. Boundarry conditions: Tsurf averaged from the PCM; Geothermal flux at the bottom layer
    132 !
    133 !  Note: depths of layers and mid-layers, soil thermal inertia and
    134 !        heat capacity are commons in comsoil_PEM.h
    135 !-----------------------------------------------------------------------
    136 
    137169#include "dimensions.h"
    138170
    139 ! Inputs:
    140 !--------
    141 integer,                      intent(in) :: ngrid   ! number of (horizontal) grid-points
    142 integer,                      intent(in) :: nsoil   ! number of soil layers
    143 real, dimension(ngrid,nsoil), intent(in) :: therm_i ! thermal inertia [SI]
    144 real, dimension(ngrid),       intent(in) :: tsurf   ! surface temperature [K]
    145 ! Outputs:
    146 !---------
    147 real, dimension(ngrid,nsoil), intent(inout) :: tsoil ! soil (mid-layer) temperature [K]
    148 ! Local:
    149 !-------
     171! ARGUMENTS
     172! ---------
     173integer,                      intent(in)    :: ngrid   ! number of (horizontal) grid-points
     174integer,                      intent(in)    :: nsoil   ! number of soil layers
     175real, dimension(ngrid,nsoil), intent(in)    :: therm_i ! thermal inertia [SI]
     176real, dimension(ngrid),       intent(in)    :: tsurf   ! surface temperature [K]
     177real, dimension(ngrid,nsoil), intent(inout) :: tsoil   ! soil (mid-layer) temperature [K]
     178
     179! LOCAL VARIABLES
     180! ---------------
    150181integer :: ig, ik, iloop
    151182
     183! CODE
     184! ----
    152185! 0. Initialisations and preprocessing step
    153186! 0.1 Build mthermdiff_PEM(:), the mid-layer thermal diffusivities
     
    220253!=======================================================================
    221254SUBROUTINE shift_tsoil2surf(ngrid,nsoil,nslope,zshift_surf,zlag,tsurf,tsoil)
    222 
    223 use soil, only: layer_PEM, mlayer_PEM, fluxgeo, thermdiff_PEM, mthermdiff_PEM
    224 use math_toolkit,  only: solve_steady_heat
    225 
     255!-----------------------------------------------------------------------
     256! NAME
     257!     shift_tsoil2surf
     258!
     259! DESCRIPTION
     260!     Shift soil temperature profile to follow surface evolution due to ice
     261!     condensation/sublimation.
     262!
     263! AUTHORS & DATE
     264!     JB Clement, 2025
     265!
     266! NOTES
     267!
     268!-----------------------------------------------------------------------
     269
     270! DEPENDENCIES
     271! ------------
     272use soil,         only: layer_PEM, mlayer_PEM, fluxgeo, thermdiff_PEM, mthermdiff_PEM
     273use math_toolkit, only: solve_steady_heat
     274
     275! DECLARATION
     276! -----------
    226277implicit none
    227278
    228 !-----------------------------------------------------------------------
    229 !  Author: JBC
    230 !  Purpose: Shifting the soil temperature profile to follow the surface evolution due to ice condensation/sublimation
    231 !-----------------------------------------------------------------------
    232 ! Inputs:
    233 ! -------
    234 integer,                       intent(in) :: ngrid       ! number of (horizontal) grid-points
    235 integer,                       intent(in) :: nsoil       ! number of soil layers
    236 integer,                       intent(in) :: nslope      ! number of sub-slopes
    237 real, dimension(ngrid,nslope), intent(in) :: zshift_surf ! elevation shift for the surface [m]
    238 real, dimension(ngrid,nslope), intent(in) :: zlag        ! newly built lag thickness [m]
    239 real, dimension(ngrid,nslope), intent(in) :: tsurf       ! surface temperature [K]
    240 ! Outputs:
    241 ! --------
    242 real, dimension(ngrid,nsoil,nslope), intent(inout) :: tsoil ! soil (mid-layer) temperature [K]
    243 ! Local:
    244 ! ------
     279! ARGUMENTS
     280! ---------
     281integer,                             intent(in)    :: ngrid       ! number of (horizontal) grid-points
     282integer,                             intent(in)    :: nsoil       ! number of soil layers
     283integer,                             intent(in)    :: nslope      ! number of sub-slopes
     284real, dimension(ngrid,nslope),       intent(in)    :: zshift_surf ! elevation shift for the surface [m]
     285real, dimension(ngrid,nslope),       intent(in)    :: zlag        ! newly built lag thickness [m]
     286real, dimension(ngrid,nslope),       intent(in)    :: tsurf       ! surface temperature [K]
     287real, dimension(ngrid,nsoil,nslope), intent(inout) :: tsoil       ! soil (mid-layer) temperature [K]
     288
     289! LOCAL VARIABLES
     290! ---------------
    245291integer                             :: ig, isoil, islope, ishift, ilag, iz
    246292real                                :: a, z, zshift_surfloc, tsoil_minus, mlayer_minus
    247293real, dimension(ngrid,nsoil,nslope) :: tsoil_old
    248294
     295! CODE
     296! ----
    249297write(*,*) "> Shifting soil temperature profile to match surface evolution"
    250298tsoil_old = tsoil
     
    317365!=======================================================================
    318366FUNCTION itp_tsoil(tsoil,tsurf,z) RESULT(tsoil_z)
    319 
     367!-----------------------------------------------------------------------
     368! NAME
     369!     itp_tsoil
     370!
     371! DESCRIPTION
     372!     Interpolate soil temperature profile.
     373!
     374! AUTHORS & DATE
     375!     JB Clement, 2025
     376!
     377! NOTES
     378!
     379!-----------------------------------------------------------------------
     380
     381! DEPENDENCIES
     382! ------------
    320383use soil, only: mlayer_PEM
    321384
     385! DECLARATION
     386! -----------
    322387implicit none
    323388
     389! ARGUMENTS
     390! ---------
    324391real, dimension(:), intent(in) :: tsoil
    325392real,               intent(in) :: z, tsurf
    326393
     394! LOCAL VARIABLES
     395! ---------------
    327396real    :: tsoil_z, tsoil_minus, mlayer_minus, a
    328397integer :: iz
    329398
     399! CODE
     400! ----
    330401! Find the interval [mlayer_PEM(iz - 1),mlayer_PEM(iz)[ where the position z belongs
    331402iz = 0
Note: See TracChangeset for help on using the changeset viewer.