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