1 | MODULE soil_pem_ini_mod |
---|
2 | |
---|
3 | implicit none |
---|
4 | |
---|
5 | !======================================================================= |
---|
6 | contains |
---|
7 | !======================================================================= |
---|
8 | |
---|
9 | SUBROUTINE soil_pem_ini(ngrid,nsoil,therm_i,tsurf,tsoil) |
---|
10 | |
---|
11 | use comsoil_h_PEM, only: layer_PEM, mlayer_PEM, mthermdiff_PEM, thermdiff_PEM, coefq_PEM, coefd_PEM, mu_PEM, alph_PEM, beta_PEM, fluxgeo |
---|
12 | use comsoil_h, only: volcapa |
---|
13 | |
---|
14 | implicit none |
---|
15 | |
---|
16 | !----------------------------------------------------------------------- |
---|
17 | ! Author: LL |
---|
18 | ! Purpose: Compute soil temperature using an implict 1st order scheme, stationnary solution |
---|
19 | ! |
---|
20 | ! Note: depths of layers and mid-layers, soil thermal inertia and |
---|
21 | ! heat capacity are commons in comsoil_PEM.h |
---|
22 | !----------------------------------------------------------------------- |
---|
23 | |
---|
24 | #include "dimensions.h" |
---|
25 | |
---|
26 | !----------------------------------------------------------------------- |
---|
27 | ! arguments |
---|
28 | ! --------- |
---|
29 | ! inputs: |
---|
30 | integer, intent(in) :: ngrid ! number of (horizontal) grid-points |
---|
31 | integer, intent(in) :: nsoil ! number of soil layers |
---|
32 | real, dimension(ngrid,nsoil), intent(in) :: therm_i ! thermal inertia [SI] |
---|
33 | real, dimension(ngrid), intent(in) :: tsurf ! surface temperature [K] |
---|
34 | |
---|
35 | ! outputs: |
---|
36 | real, dimension(ngrid,nsoil), intent(inout) :: tsoil ! soil (mid-layer) temperature [K] |
---|
37 | ! local variables: |
---|
38 | integer :: ig, ik, iloop |
---|
39 | |
---|
40 | ! 0. Initialisations and preprocessing step |
---|
41 | ! 0.1 Build mthermdiff_PEM(:), the mid-layer thermal diffusivities |
---|
42 | do ig = 1,ngrid |
---|
43 | do ik = 0,nsoil - 1 |
---|
44 | mthermdiff_PEM(ig,ik) = therm_i(ig,ik + 1)*therm_i(ig,ik + 1)/volcapa |
---|
45 | enddo |
---|
46 | enddo |
---|
47 | |
---|
48 | ! 0.2 Build thermdiff(:), the "interlayer" thermal diffusivities |
---|
49 | do ig = 1,ngrid |
---|
50 | do ik = 1,nsoil - 1 |
---|
51 | thermdiff_PEM(ig,ik) = ((layer_PEM(ik) - mlayer_PEM(ik - 1))*mthermdiff_PEM(ig,ik) & |
---|
52 | + (mlayer_PEM(ik) - layer_PEM(ik))*mthermdiff_PEM(ig,ik - 1))/(mlayer_PEM(ik) - mlayer_PEM(ik - 1)) |
---|
53 | enddo |
---|
54 | enddo |
---|
55 | |
---|
56 | ! 0.3 Build coefficients mu_PEM, q_{k+1/2}, d_k, alph_PEMa_k and capcal |
---|
57 | ! mu_PEM |
---|
58 | mu_PEM = mlayer_PEM(0)/(mlayer_PEM(1) - mlayer_PEM(0)) |
---|
59 | |
---|
60 | ! q_{1/2} |
---|
61 | coefq_PEM(:) = 0. |
---|
62 | ! q_{k+1/2} |
---|
63 | |
---|
64 | do ig = 1,ngrid |
---|
65 | ! d_k |
---|
66 | do ik = 1,nsoil-1 |
---|
67 | coefd_PEM(ig,ik) = thermdiff_PEM(ig,ik)/(mlayer_PEM(ik) - mlayer_PEM(ik - 1)) |
---|
68 | enddo |
---|
69 | |
---|
70 | ! alph_PEM_{N-1} |
---|
71 | alph_PEM(ig,nsoil - 1) = coefd_PEM(ig,nsoil - 1)/(coefq_PEM(nsoil - 1) + coefd_PEM(ig,nsoil - 1)) |
---|
72 | ! alph_PEM_k |
---|
73 | do ik = nsoil - 2,1,-1 |
---|
74 | alph_PEM(ig,ik) = coefd_PEM(ig,ik)/(coefq_PEM(ik) + coefd_PEM(ig,ik + 1)*(1. - alph_PEM(ig,ik + 1)) + coefd_PEM(ig,ik)) |
---|
75 | enddo |
---|
76 | enddo ! of do ig=1,ngrid |
---|
77 | |
---|
78 | ! 1. Compute beta_PEM coefficients |
---|
79 | ! Bottom layer, beta_PEM_{N-1} |
---|
80 | do ig = 1,ngrid |
---|
81 | beta_PEM(ig,nsoil - 1) = coefq_PEM(nsoil - 1)*tsoil(ig,nsoil)/(coefq_PEM(nsoil - 1) + coefd_PEM(ig,nsoil - 1)) & |
---|
82 | + fluxgeo/(coefq_PEM(nsoil - 1) + coefd_PEM(ig,nsoil - 1)) |
---|
83 | enddo |
---|
84 | ! Other layers |
---|
85 | do ik = nsoil - 2,1,-1 |
---|
86 | do ig = 1,ngrid |
---|
87 | beta_PEM(ig,ik) = (coefq_PEM(ik)*tsoil(ig,ik + 1) + coefd_PEM(ig,ik+1)*beta_PEM(ig,ik + 1))/ & |
---|
88 | (coefq_PEM(ik) + coefd_PEM(ig,ik + 1)*(1. - alph_PEM(ig,ik + 1)) + coefd_PEM(ig,ik)) |
---|
89 | enddo |
---|
90 | enddo |
---|
91 | |
---|
92 | ! 2. Compute soil temperatures |
---|
93 | do iloop = 1,10 !just convergence |
---|
94 | ! First layer: |
---|
95 | do ig = 1,ngrid |
---|
96 | tsoil(ig,1)=(tsurf(ig) + mu_PEM*beta_PEM(ig,1)*thermdiff_PEM(ig,1)/mthermdiff_PEM(ig,0))/ & |
---|
97 | (1. + mu_PEM*(1. - alph_PEM(ig,1))*thermdiff_PEM(ig,1)/mthermdiff_PEM(ig,0)) |
---|
98 | ! Other layers: |
---|
99 | do ik = 1,nsoil - 1 |
---|
100 | tsoil(ig,ik + 1) = alph_PEM(ig,ik)*tsoil(ig,ik) + beta_PEM(ig,ik) |
---|
101 | enddo |
---|
102 | enddo |
---|
103 | |
---|
104 | enddo ! iloop |
---|
105 | |
---|
106 | END SUBROUTINE soil_pem_ini |
---|
107 | |
---|
108 | END MODULE soil_pem_ini_mod |
---|