| 1 | MODULE soil |
|---|
| 2 | !----------------------------------------------------------------------- |
|---|
| 3 | ! NAME |
|---|
| 4 | ! soil |
|---|
| 5 | ! |
|---|
| 6 | ! DESCRIPTION |
|---|
| 7 | ! Soil state and properties for PEM. |
|---|
| 8 | ! |
|---|
| 9 | ! AUTHORS & DATE |
|---|
| 10 | ! L. Lange, 04/2023 |
|---|
| 11 | ! JB Clement, 2023-2025 |
|---|
| 12 | ! |
|---|
| 13 | ! NOTES |
|---|
| 14 | ! |
|---|
| 15 | !----------------------------------------------------------------------- |
|---|
| 16 | |
|---|
| 17 | ! DECLARATION |
|---|
| 18 | ! ----------- |
|---|
| 19 | implicit none |
|---|
| 20 | |
|---|
| 21 | ! MODULE PARAMETERS |
|---|
| 22 | ! ----------------- |
|---|
| 23 | integer, parameter :: nsoilmx_PEM = 68 ! number of layers in the PEM |
|---|
| 24 | |
|---|
| 25 | ! MODULE VARIABLES |
|---|
| 26 | ! ----------------- |
|---|
| 27 | real, allocatable, dimension(:) :: layer_PEM ! soil layer depths [m] |
|---|
| 28 | real, allocatable, dimension(:) :: mlayer_PEM ! soil mid-layer depths [m] |
|---|
| 29 | real, allocatable, dimension(:,:,:) :: TI_PEM ! soil thermal inertia [SI] |
|---|
| 30 | real, allocatable, dimension(:,:) :: inertiedat_PEM ! soil thermal inertia saved as reference for current climate [SI] |
|---|
| 31 | real, allocatable, dimension(:,:,:) :: tsoil_PEM ! sub-surface temperatures [K] |
|---|
| 32 | real, allocatable, dimension(:,:) :: mthermdiff_PEM ! mid-layer thermal diffusivity [SI] |
|---|
| 33 | real, allocatable, dimension(:,:) :: thermdiff_PEM ! inter-layer thermal diffusivity [SI] |
|---|
| 34 | real, allocatable, dimension(:) :: coefq_PEM ! q_{k+1/2} coefficients [SI] |
|---|
| 35 | real, allocatable, dimension(:,:) :: coefd_PEM ! d_k coefficients [SI] |
|---|
| 36 | real, allocatable, dimension(:,:) :: alph_PEM ! alpha_k coefficients [SI] |
|---|
| 37 | real, allocatable, dimension(:,:) :: beta_PEM ! beta_k coefficients [SI] |
|---|
| 38 | real :: mu_PEM ! mu coefficient [SI] |
|---|
| 39 | real :: fluxgeo ! Geothermal flux [W/m^2] |
|---|
| 40 | real :: depth_breccia ! Depth at which we have breccia [m] |
|---|
| 41 | real :: depth_bedrock ! Depth at which we have bedrock [m] |
|---|
| 42 | integer :: index_breccia ! last index of the depth grid before having breccia |
|---|
| 43 | integer :: index_bedrock ! last index of the depth grid before having bedrock |
|---|
| 44 | logical :: do_soil ! True by default, to run with the subsurface physic. Read in run_PEM.def |
|---|
| 45 | real :: h2oice_huge_ini ! Initial value for huge reservoirs of H2O ice [kg/m^2] |
|---|
| 46 | logical :: reg_thprop_dependp ! thermal properites of the regolith vary with the surface pressure |
|---|
| 47 | |
|---|
| 48 | contains |
|---|
| 49 | !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|---|
| 50 | |
|---|
| 51 | !======================================================================= |
|---|
| 52 | SUBROUTINE ini_soil(ngrid,nslope) |
|---|
| 53 | !----------------------------------------------------------------------- |
|---|
| 54 | ! NAME |
|---|
| 55 | ! ini_soil |
|---|
| 56 | ! |
|---|
| 57 | ! DESCRIPTION |
|---|
| 58 | ! Allocate soil arrays based on grid dimensions. |
|---|
| 59 | ! |
|---|
| 60 | ! AUTHORS & DATE |
|---|
| 61 | ! L. Lange, 2023 |
|---|
| 62 | ! JB Clement, 2023-2025 |
|---|
| 63 | ! |
|---|
| 64 | ! NOTES |
|---|
| 65 | ! |
|---|
| 66 | !----------------------------------------------------------------------- |
|---|
| 67 | |
|---|
| 68 | ! DECLARATION |
|---|
| 69 | ! ----------- |
|---|
| 70 | implicit none |
|---|
| 71 | |
|---|
| 72 | ! ARGUMENTS |
|---|
| 73 | ! --------- |
|---|
| 74 | integer, intent(in) :: ngrid ! number of atmospheric columns |
|---|
| 75 | integer, intent(in) :: nslope ! number of slope within a mesh |
|---|
| 76 | |
|---|
| 77 | ! CODE |
|---|
| 78 | ! ---- |
|---|
| 79 | allocate(layer_PEM(nsoilmx_PEM)) |
|---|
| 80 | allocate(mlayer_PEM(0:nsoilmx_PEM - 1)) |
|---|
| 81 | allocate(TI_PEM(ngrid,nsoilmx_PEM,nslope)) |
|---|
| 82 | allocate(tsoil_PEM(ngrid,nsoilmx_PEM,nslope)) |
|---|
| 83 | allocate(mthermdiff_PEM(ngrid,0:nsoilmx_PEM - 1)) |
|---|
| 84 | allocate(thermdiff_PEM(ngrid,nsoilmx_PEM - 1)) |
|---|
| 85 | allocate(coefq_PEM(0:nsoilmx_PEM - 1)) |
|---|
| 86 | allocate(coefd_PEM(ngrid,nsoilmx_PEM - 1)) |
|---|
| 87 | allocate(alph_PEM(ngrid,nsoilmx_PEM - 1)) |
|---|
| 88 | allocate(beta_PEM(ngrid,nsoilmx_PEM - 1)) |
|---|
| 89 | allocate(inertiedat_PEM(ngrid,nsoilmx_PEM)) |
|---|
| 90 | |
|---|
| 91 | END SUBROUTINE ini_soil |
|---|
| 92 | !======================================================================= |
|---|
| 93 | |
|---|
| 94 | !======================================================================= |
|---|
| 95 | SUBROUTINE end_soil |
|---|
| 96 | !----------------------------------------------------------------------- |
|---|
| 97 | ! NAME |
|---|
| 98 | ! end_soil |
|---|
| 99 | ! |
|---|
| 100 | ! DESCRIPTION |
|---|
| 101 | ! Deallocate all soil arrays. |
|---|
| 102 | ! |
|---|
| 103 | ! AUTHORS & DATE |
|---|
| 104 | ! L. Lange, 2023 |
|---|
| 105 | ! JB Clement, 2023-2025 |
|---|
| 106 | ! |
|---|
| 107 | ! NOTES |
|---|
| 108 | ! |
|---|
| 109 | !----------------------------------------------------------------------- |
|---|
| 110 | |
|---|
| 111 | ! DECLARATION |
|---|
| 112 | ! ----------- |
|---|
| 113 | implicit none |
|---|
| 114 | |
|---|
| 115 | ! CODE |
|---|
| 116 | ! ---- |
|---|
| 117 | if (allocated(layer_PEM)) deallocate(layer_PEM) |
|---|
| 118 | if (allocated(mlayer_PEM)) deallocate(mlayer_PEM) |
|---|
| 119 | if (allocated(TI_PEM)) deallocate(TI_PEM) |
|---|
| 120 | if (allocated(tsoil_PEM)) deallocate(tsoil_PEM) |
|---|
| 121 | if (allocated(mthermdiff_PEM)) deallocate(mthermdiff_PEM) |
|---|
| 122 | if (allocated(thermdiff_PEM)) deallocate(thermdiff_PEM) |
|---|
| 123 | if (allocated(coefq_PEM)) deallocate(coefq_PEM) |
|---|
| 124 | if (allocated(coefd_PEM)) deallocate(coefd_PEM) |
|---|
| 125 | if (allocated(alph_PEM)) deallocate(alph_PEM) |
|---|
| 126 | if (allocated(beta_PEM)) deallocate(beta_PEM) |
|---|
| 127 | if (allocated(inertiedat_PEM)) deallocate(inertiedat_PEM) |
|---|
| 128 | |
|---|
| 129 | END SUBROUTINE end_soil |
|---|
| 130 | !======================================================================= |
|---|
| 131 | |
|---|
| 132 | !======================================================================= |
|---|
| 133 | SUBROUTINE set_soil(ngrid,nslope,nsoil_PEM,nsoil_PCM,TI_PCM,TI_PEM) |
|---|
| 134 | !----------------------------------------------------------------------- |
|---|
| 135 | ! NAME |
|---|
| 136 | ! set_soil |
|---|
| 137 | ! |
|---|
| 138 | ! DESCRIPTION |
|---|
| 139 | ! Initialize soil depths and properties. Builds layer depths using |
|---|
| 140 | ! exponential then power-law distribution; interpolates thermal inertia |
|---|
| 141 | ! from PCM to PEM grid. |
|---|
| 142 | ! |
|---|
| 143 | ! AUTHORS & DATE |
|---|
| 144 | ! E. Millour, 07/2006 |
|---|
| 145 | ! L. Lange, 2023 |
|---|
| 146 | ! JB Clement, 2023-2025 |
|---|
| 147 | ! |
|---|
| 148 | ! NOTES |
|---|
| 149 | ! Modifications: |
|---|
| 150 | ! Aug.2010 EM: use NetCDF90 to load variables (enables using |
|---|
| 151 | ! r4 or r8 restarts independently of having compiled |
|---|
| 152 | ! the GCM in r4 or r8) |
|---|
| 153 | ! June 2013 TN: Possibility to read files with a time axis |
|---|
| 154 | ! The various actions and variable read/initialized are: |
|---|
| 155 | ! 1. Read/build layer (and midlayer) depth |
|---|
| 156 | ! 2. Interpolate thermal inertia and temperature on the new grid, if necessary |
|---|
| 157 | !----------------------------------------------------------------------- |
|---|
| 158 | |
|---|
| 159 | ! DEPENDENCIES |
|---|
| 160 | ! ------------ |
|---|
| 161 | use iostart, only: inquire_field_ndims, get_var, get_field, inquire_field, inquire_dimension_length |
|---|
| 162 | |
|---|
| 163 | ! DECLARATION |
|---|
| 164 | ! ----------- |
|---|
| 165 | implicit none |
|---|
| 166 | |
|---|
| 167 | ! ARGUMENTS |
|---|
| 168 | ! --------- |
|---|
| 169 | integer, intent(in) :: ngrid ! # of horizontal grid points |
|---|
| 170 | integer, intent(in) :: nslope ! # of subslope wihtin the mesh |
|---|
| 171 | integer, intent(in) :: nsoil_PEM ! # of soil layers in the PEM |
|---|
| 172 | integer, intent(in) :: nsoil_PCM ! # of soil layers in the PCM |
|---|
| 173 | real, dimension(ngrid,nsoil_PCM,nslope), intent(in) :: TI_PCM ! Thermal inertia in the PCM [SI] |
|---|
| 174 | real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: TI_PEM ! Thermal inertia in the PEM [SI] |
|---|
| 175 | |
|---|
| 176 | ! LOCAL VARIABLES |
|---|
| 177 | ! --------------- |
|---|
| 178 | integer :: ig, iloop, islope ! loop counters |
|---|
| 179 | real :: alpha, lay1 ! coefficients for building layers |
|---|
| 180 | real :: index_powerlaw ! coefficient to match the power low grid with the exponential one |
|---|
| 181 | |
|---|
| 182 | ! CODE |
|---|
| 183 | ! ---- |
|---|
| 184 | ! 1. Depth coordinate |
|---|
| 185 | ! ------------------- |
|---|
| 186 | ! mlayer_PEM distribution: For the grid in common with the PCM: lay1*(1+k^(2.9)*(1-exp(-k/20)) |
|---|
| 187 | ! Then we use a power low : lay1*alpha**(k-1/2) |
|---|
| 188 | lay1 = 2.e-4 |
|---|
| 189 | alpha = 2 |
|---|
| 190 | do iloop = 0,nsoil_PCM - 1 |
|---|
| 191 | mlayer_PEM(iloop) = lay1*(1 + iloop**2.9*(1 - exp(-real(iloop)/20.))) |
|---|
| 192 | enddo |
|---|
| 193 | |
|---|
| 194 | do iloop = 0,nsoil_PEM - 1 |
|---|
| 195 | if (lay1*(alpha**(iloop-0.5)) > mlayer_PEM(nsoil_PCM - 1)) then |
|---|
| 196 | index_powerlaw = iloop |
|---|
| 197 | exit |
|---|
| 198 | endif |
|---|
| 199 | enddo |
|---|
| 200 | |
|---|
| 201 | do iloop = nsoil_PCM,nsoil_PEM - 1 |
|---|
| 202 | mlayer_PEM(iloop) = lay1*(alpha**(index_powerlaw + (iloop - nsoil_PCM) - 0.5)) |
|---|
| 203 | enddo |
|---|
| 204 | |
|---|
| 205 | ! Build layer_PEM() |
|---|
| 206 | do iloop = 1,nsoil_PEM - 1 |
|---|
| 207 | layer_PEM(iloop) = (mlayer_PEM(iloop) + mlayer_PEM(iloop - 1))/2. |
|---|
| 208 | enddo |
|---|
| 209 | layer_PEM(nsoil_PEM) = 2*mlayer_PEM(nsoil_PEM - 1) - mlayer_PEM(nsoil_PEM - 2) |
|---|
| 210 | |
|---|
| 211 | |
|---|
| 212 | ! 2. Thermal inertia (note: it is declared in comsoil_h) |
|---|
| 213 | ! ------------------ |
|---|
| 214 | do ig = 1,ngrid |
|---|
| 215 | do islope = 1,nslope |
|---|
| 216 | do iloop = 1,nsoil_PCM |
|---|
| 217 | TI_PEM(ig,iloop,islope) = TI_PCM(ig,iloop,islope) |
|---|
| 218 | enddo |
|---|
| 219 | if (nsoil_PEM > nsoil_PCM) then |
|---|
| 220 | do iloop = nsoil_PCM + 1,nsoil_PEM |
|---|
| 221 | TI_PEM(ig,iloop,islope) = TI_PCM(ig,nsoil_PCM,islope) |
|---|
| 222 | enddo |
|---|
| 223 | endif |
|---|
| 224 | enddo |
|---|
| 225 | enddo |
|---|
| 226 | |
|---|
| 227 | ! 3. Index for subsurface layering |
|---|
| 228 | ! ------------------ |
|---|
| 229 | index_breccia = 1 |
|---|
| 230 | do iloop = 1,nsoil_PEM - 1 |
|---|
| 231 | if (depth_breccia >= layer_PEM(iloop)) then |
|---|
| 232 | index_breccia = iloop |
|---|
| 233 | else |
|---|
| 234 | exit |
|---|
| 235 | endif |
|---|
| 236 | enddo |
|---|
| 237 | |
|---|
| 238 | index_bedrock = 1 |
|---|
| 239 | do iloop = 1,nsoil_PEM - 1 |
|---|
| 240 | if (depth_bedrock >= layer_PEM(iloop)) then |
|---|
| 241 | index_bedrock = iloop |
|---|
| 242 | else |
|---|
| 243 | exit |
|---|
| 244 | endif |
|---|
| 245 | enddo |
|---|
| 246 | |
|---|
| 247 | END SUBROUTINE set_soil |
|---|
| 248 | !======================================================================= |
|---|
| 249 | |
|---|
| 250 | END MODULE soil |
|---|