-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsibslv.F90
305 lines (229 loc) · 10.6 KB
/
sibslv.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
!======================SUBROUTINE SIBSLV=================================
subroutine sibslv(sib,sib_loc)
!========================================================================
!
! Calculation of time increments in Tc, Tgs, Theta-m and Qm using an
! implicit backwards method with explicit coefficients.
!pl Similar to equations (10-15), SA-92B.
!
! Longwave feedbacks are now really included
!
!========================================================================
!++++++++++++++++++++++++++++++OUTPUT+++++++++++++++++++++++++++++++++++
!
! DTC CANOPY TEMPERATURE INCREMENT (K)
! DTG GROUND SURFACE TEMPERATURE INCREMENT (K)
! DTH MIXED LAYER POTENTIAL TEMPERATURE INCREMENT (K)
! DQM MIXED LAYER MIXING RATIO INCREMENT (KG KG-1)
! ETMASS (FWS) EVAPOTRANSPIRATION (MM)
! HFLUX (FSS) SENSIBLE HEAT FLUX (W M-2)
!
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
use kinds
use sibtype
!itb...used for diagnostic print...
use sib_const_module, only: &
nsoil, &
dtt, &
dti
use physical_parameters, only: &
grav, &
cp => spec_heat_cp, &
hltm
IMPLICIT none
!----------------------------------------------------------------------
type(sib_t), intent(inout) :: sib
type(sib_local_vars) ,intent(inout) :: sib_loc
! variables local to SiB
!----------------------------------------------------------------------
real(kind=dbl_kind),parameter :: grav2 = grav * 0.01_dbl_kind
integer(kind=int_kind) :: error_flag,i,j,k
!...matrix arrays - variable, due to potential snow layers
real(kind=dbl_kind),dimension(15-sib%prog%nsl,15-sib%prog%nsl) :: avec
real(kind=dbl_kind),dimension(15-sib%prog%nsl) :: bvec
integer(kind=int_kind),dimension(15-sib%prog%nsl) :: cvec
!...this routine sets up the coupled system of partial
!...differential equations described in Sato et al.,
!...with the exception that now Ta and ea are prognostic
!...variables, and so we have two more equations, reflected
!...in two more lines and two more columns as compared
!...to the old sibslv.F (used for no prognistic CAS calculations)
!...this matrix is expandable, size determined by the number of
!...snow layers (0 to 5). All energy is passed through the snow layer
!...if snow exists. Partial snowcover is not dealt with. We know
!...that this is physically incorrect, it is an issue that we hope
!...to deal with in the future...
!itb...VARIABLES
!...1 : TREF (lowest model layer/driver data temperature)
!...2 : EREF (lowest model layer/driver data water vapor)
!...3 : TA (CAS temperature)
!...4 : EA (CAS water vapor)
!...5 : TC (vegetation temperature)
!...6 : TG (Ground or snow surface temperature)
!...7-14 to 19 : TD (interior soil layers temperature)
!...last member: TD (bottom soil level)
!*****************************************************
!
! THESE FIRST TWO EQUATIONS (TREF AND EREF) ARE
! FOR THE 'OFFLINE SiB' SITUATION, WHERE SiB IS
! DRIVEN BY TOWER DATA. FOR COUPLING TO A MODEL
! (GCM OR MESOSCALE MODEL), USE THE SECOND SET
! OF EQUATIONS. REFERENCE IS TO KALNAY AND KANAMITSU
! (1988) RIGHT NOW, BUT I'LL WRITE IT UP LATER...
!
!*****************************************************
!itb...set up a_areas
sib%diag%a_areas = sib%diag%areas
! if(sib%diag%areas > 0.0) then
! sib%diag%a_areas = 1.0
! else
! sib%diag%a_areas = 0.0
! endif
!1 TREF EQUATION
avec(1,1) = 1.0
avec(1,2:15-sib%prog%nsl) = 0.0
bvec(1) = 0.0
!2 EREF EQUATION
avec(2,1) = 0.0
avec(2,2) = 1.0
avec(2,3:15-sib%prog%nsl) = 0.0
bvec(2) = 0.0
!********************************************************************
! TREF EQUATION - COUPLED
! avec(1,1) = (sib%cp * sib%prog%psb)/(grav* &
! (0.5_dbl_kind * dtt)) + sib_loc%hadta
! avec(1,2) = 0.0
! avec(1,3) = -sib_loc%hadta
! avec(1,4:15-sib%prog%nsl) = 0.0
! bvec(2) = sib%diag%fss * dti
!
! EREF EQUATION - COUPLED
! avec(2,1) = 0.0
! avec(2,2) = (sib%cp * sib%prog%psb)/ &
! (grav * (0.5_dbl_kind * dtt) &
! * sib%diag%psy) + sib_loc%eadea
! avec(2,3) = sib_loc%eadem
! avec(2,4:15-sib%prog%nsl) = 0.0
! bvec(3) = sib%diag%fws * dti
!*********************************************************************
!3 TA EQUATION
!itb...start with the 2delta_t stuff here...
!itb...zero all of 'em out first, then fill 'em in...
avec(3,:) = 0.0
avec(3,1) = sib_loc%hadth
avec(3,2) = 0.0
avec(3,3) = sib%diag%cas_cap_heat * (0.5_dbl_kind *dti ) &
+ sib_loc%hadta - sib_loc%hcdta &
- (1.-sib%diag%areas)*sib_loc%hgdta - sib%diag%areas*sib_loc%hsdta
avec(3,4) = 0.0
avec(3,5) = - sib_loc%hcdtc
!itb...my latest crack at this...(15 august)
if(sib%diag%areas > 0.0 )then
avec(3,6) = - sib_loc%hsdts * sib%diag%areas
avec(3,6-sib%prog%nsl) = -sib_loc%hgdtg * (1.0 - sib%diag%areas)
else
avec(3,6) = - sib_loc%hgdtg
endif
avec(3,7:15-sib%prog%nsl) = 0.0
bvec(3) = sib%diag%hc * dti - sib%diag%fss * dti &
+ (1.-sib%diag%a_areas)*sib%diag%hg * dti &
+ sib%diag%a_areas *sib%diag%hs * dti
!4 EA EQUATION
avec(4,:) = 0.0
avec(4,1) = 0.0
avec(4,2) = sib_loc%eadem
avec(4,3) = 0.0
avec(4,4) = sib%diag%cas_cap_vap * (0.5_dbl_kind * dti) &
+ sib_loc%eadea - sib_loc%ecdea &
- (1.-sib%diag%areas)*sib_loc%egdea &
- sib%diag%areas *sib_loc%esdea
avec(4,5) = - sib_loc%ecdtc
avec(4,6) = - sib_loc%egdtg * (1.-sib%diag%areas)
avec(4,7:15-sib%prog%nsl) = 0.0
bvec(4) = (sib%diag%ec * dti - sib%diag%fws * dti &
+ (1.-sib%diag%a_areas)*sib%diag%eg * dti &
+ sib%diag%a_areas *sib%diag%es * dti)
!5 TC EQUATION
avec(5,1) = 0.0
avec(5,2) = 0.0
avec(5,3) = sib_loc%hcdta
avec(5,4) = sib_loc%ecdea
avec(5,5) = sib%param%czc * (0.5_dbl_kind * dti) + sib_loc%hcdtc &
+ sib_loc%ecdtc + sib_loc%lcdtc
avec(5,6) = sib_loc%lcdtg
avec(5,7:15-sib%prog%nsl) = 0.0
bvec(5) = sib%diag%radt(1) - sib%diag%hc * dti - sib%diag%ec * dti
!6 TOP SOIL LAYER (TD1 OR TG) EQUATION
!itb...will need an 'if' statement here for snow/no snow case
if(sib%prog%nsl == 0) then !NO SNOW CASE
avec(6,1) = 0.0
avec(6,2) = 0.0
avec(6,3) = sib_loc%hgdta
avec(6,4) = sib_loc%egdea
avec(6,5) = sib_loc%lgdtc
avec(6,6) = sib%param%slamda(1) + sib%param%shcap(1) * &
(0.5_dbl_kind * dti) &
+ sib_loc%hgdtg + sib_loc%egdtg + sib_loc%lgdtg
avec(6,7) = sib%param%slamda(1)
avec(6,8:15-sib%prog%nsl) = 0.0
bvec(6) = sib%diag%radt(2) - sib%diag%hg * dti - sib%diag%eg * dti &
+ sib%param%slamda(1) * (sib%prog%td(2) - sib%prog%td(1))
else ! SNOW CASE
avec(6,1) = 0.0
avec(6,2) = 0.0
avec(6,3) = sib_loc%hsdta*sib%diag%areas
avec(6,4) = sib_loc%esdea *sib%diag%areas
avec(6,5) = sib_loc%lsdtc
avec(6,6) = sib%param%slamda(sib%prog%nsl+1)*sib%diag%areas + &
sib%param%shcap(sib%prog%nsl+1) * (0.5_dbl_kind * dti) + &
sib_loc%hsdts + sib_loc%esdts + sib_loc%lsdts
avec(6,7) = sib%param%slamda(sib%prog%nsl+1)
avec(6,8:15-sib%prog%nsl) = 0.0
bvec(6) = sib%diag%radt(3) - sib%diag%hs * dti*sib%diag%areas - &
sib%diag%es * dti*sib%diag%areas + &
sib%param%slamda(sib%prog%nsl+1) * (sib%prog%td(sib%prog%nsl+2) - &
sib%prog%td(sib%prog%nsl+1))*sib%diag%areas
endif
!7-?? INTERIOR SOIL LAYERS
!itb...need to scale this for snow/no snow (sib%prog%nsl)
do i = 7, 14 - sib%prog%nsl ! matrix indices
k = i - 5 + sib%prog%nsl ! soil layer indices
!itb...fill all matrix components with zero, re-fill the 3 necessary
! ...positions
do j=1, 15 - sib%prog%nsl
avec(i,j) = 0.0
enddo
avec(i,i-1) = -sib%param%slamda(k-1)
avec(i,i) = sib%param%shcap(k)*dti + sib%param%slamda(k) &
+ sib%param%slamda(k-1)
avec(i,i+1) = -sib%param%slamda(k)
bvec(i) = sib%param%slamda(k)*(sib%prog%td(k+1) - sib%prog%td(k)) &
- sib%param%slamda(k-1) * (sib%prog%td(k) - sib%prog%td(k-1))
enddo
! BOTTOM SOIL LAYER
i = 15-sib%prog%nsl
do j=1,i-2
avec(i,j) = 0.0
enddo
avec(i,i-1) = sib%param%slamda(9) * (sib%prog%td(10) - sib%prog%td(9))
avec(i,i) = sib%param%shcap(10) * dti &
+ sib%param%slamda(9)
bvec(i) = - sib%param%slamda(9) * (sib%prog%td(10) - sib%prog%td(9))
! SOLVE MATRIX EQUATION
!call dsimul(avec,bvec,cvec,1,15-sib%prog%nsl,15-sib%prog%nsl,error_flag)
!jlc...use the lapack version of this call, instead of our home-brewed
!FIXME: cvec is temporarily in the place of IPIV (the pivot array)
call dgesv( 15-sib%prog%nsl, 1, avec, 15-sib%prog%nsl, cvec, bvec, &
15-sib%prog%nsl, error_flag )
sib_loc%dth = bvec(1)
sib_loc%dqm = bvec(2)
sib_loc%dta = bvec(3)
sib_loc%dea = bvec(4)
sib_loc%dtc = bvec(5)
sib_loc%dtg = bvec(6)
sib_loc%dts = 0.0
sib_loc%dtd(sib%prog%nsl+1) = sib_loc%dtg
do i=7,15-sib%prog%nsl
sib_loc%dtd(i-5+sib%prog%nsl) = bvec(i)
enddo
end subroutine sibslv