1 | subroutine soil(ngrid,nsoil,firstcall, |
---|
2 | & therm_i, |
---|
3 | & timestep,tsurf,tsoil, |
---|
4 | & capcal,fluxgrd) |
---|
5 | |
---|
6 | use comsoil_h, only: layer, mlayer, volcapa, |
---|
7 | & mthermdiff, thermdiff, coefq, |
---|
8 | & coefd, alph, beta, mu |
---|
9 | use surfdat_h, only: watercaptag, inert_h2o_ice |
---|
10 | |
---|
11 | implicit none |
---|
12 | |
---|
13 | !----------------------------------------------------------------------- |
---|
14 | ! Author: Ehouarn Millour |
---|
15 | ! |
---|
16 | ! Purpose: Compute soil temperature using an implict 1st order scheme |
---|
17 | ! |
---|
18 | ! Note: depths of layers and mid-layers, soil thermal inertia and |
---|
19 | ! heat capacity are commons in comsoil_h |
---|
20 | !----------------------------------------------------------------------- |
---|
21 | |
---|
22 | #include "dimensions.h" |
---|
23 | #include "dimphys.h" |
---|
24 | |
---|
25 | !#include"comsoil.h" |
---|
26 | |
---|
27 | !#include"surfdat.h" |
---|
28 | #include"callkeys.h" |
---|
29 | |
---|
30 | c----------------------------------------------------------------------- |
---|
31 | ! arguments |
---|
32 | ! --------- |
---|
33 | ! inputs: |
---|
34 | integer ngrid ! number of (horizontal) grid-points |
---|
35 | integer nsoil ! number of soil layers |
---|
36 | logical firstcall ! identifier for initialization call |
---|
37 | real therm_i(ngrid,nsoil) ! thermal inertia |
---|
38 | real timestep ! time step |
---|
39 | real tsurf(ngrid) ! surface temperature |
---|
40 | ! outputs: |
---|
41 | real tsoil(ngrid,nsoil) ! soil (mid-layer) temperature |
---|
42 | real capcal(ngrid) ! surface specific heat |
---|
43 | real fluxgrd(ngrid) ! surface diffusive heat flux |
---|
44 | |
---|
45 | ! local variables: |
---|
46 | integer ig,ik |
---|
47 | |
---|
48 | ! 0. Initialisations and preprocessing step |
---|
49 | if (firstcall.or.tifeedback) then |
---|
50 | ! note: firstcall is set to .true. or .false. by the caller |
---|
51 | ! and not changed by soil.F |
---|
52 | ! 0.1 Build mthermdiff(:), the mid-layer thermal diffusivities |
---|
53 | do ig=1,ngrid |
---|
54 | if (watercaptag(ig)) then |
---|
55 | do ik=0,nsoil-1 |
---|
56 | ! If we have permanent ice, we use the water ice thermal inertia from ground to last layer. |
---|
57 | mthermdiff(ig,ik)=inert_h2o_ice*inert_h2o_ice/volcapa |
---|
58 | enddo |
---|
59 | else |
---|
60 | do ik=0,nsoil-1 |
---|
61 | mthermdiff(ig,ik)=therm_i(ig,ik+1)*therm_i(ig,ik+1)/volcapa |
---|
62 | enddo |
---|
63 | endif |
---|
64 | enddo |
---|
65 | |
---|
66 | #ifdef MESOSCALE |
---|
67 | do ig=1,ngrid |
---|
68 | if ( therm_i(ig,1) .ge. inert_h2o_ice ) then |
---|
69 | print *, "limit max TI ", therm_i(ig,1), inert_h2o_ice |
---|
70 | do ik=0,nsoil-1 |
---|
71 | mthermdiff(ig,ik)=inert_h2o_ice*inert_h2o_ice/volcapa |
---|
72 | enddo |
---|
73 | endif |
---|
74 | enddo |
---|
75 | #endif |
---|
76 | |
---|
77 | ! 0.2 Build thermdiff(:), the "interlayer" thermal diffusivities |
---|
78 | do ig=1,ngrid |
---|
79 | do ik=1,nsoil-1 |
---|
80 | thermdiff(ig,ik)=((layer(ik)-mlayer(ik-1))*mthermdiff(ig,ik) |
---|
81 | & +(mlayer(ik)-layer(ik))*mthermdiff(ig,ik-1)) |
---|
82 | & /(mlayer(ik)-mlayer(ik-1)) |
---|
83 | ! write(*,*),'soil: ik: ',ik,' thermdiff:',thermdiff(ig,ik) |
---|
84 | enddo |
---|
85 | enddo |
---|
86 | |
---|
87 | ! 0.3 Build coefficients mu, q_{k+1/2}, d_k, alpha_k and capcal |
---|
88 | ! mu |
---|
89 | mu=mlayer(0)/(mlayer(1)-mlayer(0)) |
---|
90 | |
---|
91 | ! q_{1/2} |
---|
92 | coefq(0)=volcapa*layer(1)/timestep |
---|
93 | ! q_{k+1/2} |
---|
94 | do ik=1,nsoil-1 |
---|
95 | coefq(ik)=volcapa*(layer(ik+1)-layer(ik)) |
---|
96 | & /timestep |
---|
97 | enddo |
---|
98 | |
---|
99 | do ig=1,ngrid |
---|
100 | ! d_k |
---|
101 | do ik=1,nsoil-1 |
---|
102 | coefd(ig,ik)=thermdiff(ig,ik)/(mlayer(ik)-mlayer(ik-1)) |
---|
103 | enddo |
---|
104 | |
---|
105 | ! alph_{N-1} |
---|
106 | alph(ig,nsoil-1)=coefd(ig,nsoil-1)/ |
---|
107 | & (coefq(nsoil-1)+coefd(ig,nsoil-1)) |
---|
108 | ! alph_k |
---|
109 | do ik=nsoil-2,1,-1 |
---|
110 | alph(ig,ik)=coefd(ig,ik)/(coefq(ik)+coefd(ig,ik+1)* |
---|
111 | & (1.-alph(ig,ik+1))+coefd(ig,ik)) |
---|
112 | enddo |
---|
113 | |
---|
114 | ! capcal |
---|
115 | ! Cstar |
---|
116 | capcal(ig)=volcapa*layer(1)+ |
---|
117 | & (thermdiff(ig,1)/(mlayer(1)-mlayer(0)))* |
---|
118 | & (timestep*(1.-alph(ig,1))) |
---|
119 | ! Cs |
---|
120 | capcal(ig)=capcal(ig)/(1.+mu*(1.0-alph(ig,1))* |
---|
121 | & thermdiff(ig,1)/mthermdiff(ig,0)) |
---|
122 | ! write(*,*)'soil: ig=',ig,' capcal(ig)=',capcal(ig) |
---|
123 | enddo ! of do ig=1,ngrid |
---|
124 | |
---|
125 | endif ! of if (firstcall.or.tifeedback) |
---|
126 | |
---|
127 | ! 1. Compute soil temperatures |
---|
128 | IF (.not.firstcall) THEN |
---|
129 | ! First layer: |
---|
130 | do ig=1,ngrid |
---|
131 | tsoil(ig,1)=(tsurf(ig)+mu*beta(ig,1)* |
---|
132 | & thermdiff(ig,1)/mthermdiff(ig,0))/ |
---|
133 | & (1.+mu*(1.0-alph(ig,1))* |
---|
134 | & thermdiff(ig,1)/mthermdiff(ig,0)) |
---|
135 | enddo |
---|
136 | ! Other layers: |
---|
137 | do ik=1,nsoil-1 |
---|
138 | do ig=1,ngrid |
---|
139 | tsoil(ig,ik+1)=alph(ig,ik)*tsoil(ig,ik)+beta(ig,ik) |
---|
140 | enddo |
---|
141 | enddo |
---|
142 | |
---|
143 | ENDIF! of if (.not.firstcall) |
---|
144 | |
---|
145 | ! 2. Compute beta coefficients (preprocessing for next time step) |
---|
146 | ! Bottom layer, beta_{N-1} |
---|
147 | do ig=1,ngrid |
---|
148 | beta(ig,nsoil-1)=coefq(nsoil-1)*tsoil(ig,nsoil) |
---|
149 | & /(coefq(nsoil-1)+coefd(ig,nsoil-1)) |
---|
150 | enddo |
---|
151 | ! Other layers |
---|
152 | do ik=nsoil-2,1,-1 |
---|
153 | do ig=1,ngrid |
---|
154 | beta(ig,ik)=(coefq(ik)*tsoil(ig,ik+1)+ |
---|
155 | & coefd(ig,ik+1)*beta(ig,ik+1))/ |
---|
156 | & (coefq(ik)+coefd(ig,ik+1)*(1.0-alph(ig,ik+1)) |
---|
157 | & +coefd(ig,ik)) |
---|
158 | enddo |
---|
159 | enddo |
---|
160 | |
---|
161 | ! 3. Compute surface diffusive flux & calorific capacity |
---|
162 | do ig=1,ngrid |
---|
163 | ! Cstar |
---|
164 | ! capcal(ig)=volcapa(ig,1)*layer(ig,1)+ |
---|
165 | ! & (thermdiff(ig,1)/(mlayer(ig,1)-mlayer(ig,0)))* |
---|
166 | ! & (timestep*(1.-alph(ig,1))) |
---|
167 | ! Fstar |
---|
168 | fluxgrd(ig)=(thermdiff(ig,1)/(mlayer(1)-mlayer(0)))* |
---|
169 | & (beta(ig,1)+(alph(ig,1)-1.0)*tsoil(ig,1)) |
---|
170 | |
---|
171 | ! mu=mlayer(ig,0)/(mlayer(ig,1)-mlayer(ig,0)) |
---|
172 | ! capcal(ig)=capcal(ig)/(1.+mu*(1.0-alph(ig,1))* |
---|
173 | ! & thermdiff(ig,1)/mthermdiff(ig,0)) |
---|
174 | ! Fs |
---|
175 | fluxgrd(ig)=fluxgrd(ig)+(capcal(ig)/timestep)* |
---|
176 | & (tsoil(ig,1)*(1.+mu*(1.0-alph(ig,1))* |
---|
177 | & thermdiff(ig,1)/mthermdiff(ig,0)) |
---|
178 | & -tsurf(ig)-mu*beta(ig,1)* |
---|
179 | & thermdiff(ig,1)/mthermdiff(ig,0)) |
---|
180 | enddo |
---|
181 | |
---|
182 | end |
---|
183 | |
---|