-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGetMeteorologicalData.f90
312 lines (287 loc) · 17.6 KB
/
GetMeteorologicalData.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
306
307
308
309
310
311
312
!> This subroutine reads the hydrodynamic parameters.
Subroutine GetMeteorologicalData(MeshParam,MeteoParam,time,AirtempRef)
Use Meteorological
Use MeshVars
Implicit none
Integer:: i,iElem,iEdge
Real:: t_interp(1)
Real:: p_interp(1,1)
Real:: weit
Real:: t_interp_double
Real:: NearZero = 1e-10
Real:: AirtempRef
Real:: time
type(MeshGridParam) :: MeshParam
type(MeteorologicalParam) :: MeteoParam
Integer:: leftt(MeteoParam%NStation),rightt(MeteoParam%NStation)
Real :: staint(MeteoParam%NStation)
t_interp = time
t_interp_double = time
!1. Atmosferic pressure data
If (MeteoParam%NStation == 0) Then
MeteoParam%AtmPressure = 1.01325e5
ElseIf (MeteoParam%Nstation==1) Then
call r8vec_bracket ( MeteoParam%AtmPressurenTime(1), MeteoParam%AtmPressureTime(1,1:MeteoParam%AtmPressurenTime(1)), t_interp_double, leftt(1),rightt(1) )
Do iElem=1,MeshParam%nElem
!Atmosferic pressure for each cell
MeteoParam%AtmPressure(iElem) = &
( ( MeteoParam%AtmPressureTime(1,rightt(1)) - time ) * MeteoParam%AtmPressureValue(1,leftt(1)) &
+ ( time - MeteoParam%AtmPressureTime(1,leftt(1)) ) * MeteoParam%AtmPressureValue(1,rightt(1)) ) &
/ ( MeteoParam%AtmPressureTime(1,rightt(1)) - MeteoParam%AtmPressureTime(1,leftt(1)) )
!Call interp_linear( 1, AtmPressurenTime(1), AtmPressureTime(1,1:AtmPressurenTime(1)), AtmPressureValue(1,1:AtmPressurenTime(1)), 1, t_interp, p_interp )
!AtmPressure(iElem) = p_interp(1,1)
EndDo
Else
Do i=1,MeteoParam%Nstation
call r8vec_bracket ( MeteoParam%AtmPressurenTime(i), MeteoParam%AtmPressureTime(i,1:MeteoParam%AtmPressurenTime(i)), t_interp_double, leftt(i),rightt(i) )
EndDo
Do iElem=1,MeshParam%nElem
!IDW interpolation for each cell
weit = 0.
Do i=1,MeteoParam%Nstation
staint(i) = 1./(dsqrt((MeteoParam%CoordMetStations(1,i)-MeshParam%xb(iElem))**2.+(MeteoParam%CoordMetStations(2,i)-MeshParam%yb(iElem))**2.)+NearZero)
weit = weit + staint(i)
EndDo
MeteoParam%AtmPressure(iElem) = 0.
Do i=1,MeteoParam%Nstation
MeteoParam%AtmPressure(iElem) = &
( ( MeteoParam%AtmPressureTime(i,rightt(i)) - time ) * MeteoParam%AtmPressureValue(i,leftt(i)) &
+ ( time - MeteoParam%AtmPressureTime(i,leftt(i)) ) * MeteoParam%AtmPressureValue(i,rightt(i)) ) &
/ ( MeteoParam%AtmPressureTime(i,rightt(i)) - MeteoParam%AtmPressureTime(i,leftt(i)) )
!Call interp_linear( 1, AtmPressurenTime(i), AtmPressureTime(i,1:AtmPressurenTime(i)), AtmPressureValue(i,1:AtmPressurenTime(i)), 1, t_interp, p_interp )
!AtmPressure(iElem) = AtmPressure(iElem) + p_interp(1,1)*staint(i)/weit
EndDo
EndDo
EndIf
!2. Reading Air Temperature
If (MeteoParam%NStation == 0) Then
MeteoParam%AirTemp = AirtempRef
ElseIf (MeteoParam%Nstation==1) Then
call r8vec_bracket ( MeteoParam%AirTempnTime(1), MeteoParam%AirTempTime(1,1:MeteoParam%AirTempnTime(1)), t_interp_double, leftt(1),rightt(1) )
Do iElem=1,MeshParam%nElem
!Value for each cell
MeteoParam%AirTemp(iElem) = &
( ( MeteoParam%AirTempTime(1,rightt(1)) - time ) * MeteoParam%AirTempValue(1,leftt(1)) &
+ ( time - MeteoParam%AirTempTime(1,leftt(1)) ) * MeteoParam%AirTempValue(1,rightt(1)) ) &
/ ( MeteoParam%AirTempTime(1,rightt(1)) - MeteoParam%AirTempTime(1,leftt(1)) )
!Call interp_linear( 1, AirTempnTime(1), AirTempTime(1,1:AirTempnTime(1)), AirTempValue(1,1:AirTempnTime(1)), 1, t_interp, p_interp )
!AirTemp(iElem) = p_interp(1,1)
EndDo
Else
Do i=1,MeteoParam%Nstation
call r8vec_bracket ( MeteoParam%AirTempnTime(i), MeteoParam%AirTempTime(i,1:MeteoParam%AirTempnTime(i)), t_interp_double, leftt(i),rightt(i) )
EndDo
Do iElem=1,MeshParam%nElem
!IDW interpolation for each cell
weit = 0.
Do i=1,MeteoParam%Nstation
staint(i) = 1./(dsqrt((MeteoParam%CoordMetStations(1,i)-MeshParam%xb(iElem))**2.+(MeteoParam%CoordMetStations(2,i)-MeshParam%yb(iElem))**2.)+NearZero)
weit = weit + staint(i)
EndDo
MeteoParam%AirTemp(iElem) = 0.
Do i=1,MeteoParam%Nstation
MeteoParam%AirTemp(iElem) = &
( ( MeteoParam%AirTempTime(i,rightt(i)) - time ) * MeteoParam%AirTempValue(i,leftt(i)) &
+ ( time - MeteoParam%AirTempTime(i,leftt(i)) ) * MeteoParam%AirTempValue(i,rightt(i)) ) &
/ ( MeteoParam%AirTempTime(i,rightt(i)) - MeteoParam%AirTempTime(i,leftt(i)) )
!Call interp_linear( 1, AirTempnTime(i), AirTempTime(i,1:AirTempnTime(i)), AirTempValue(i,1:AirTempnTime(i)), 1, t_interp, p_interp )
!AirTemp(iElem) = AirTemp(iElem) + p_interp(1,1)*staint(i)/weit
EndDo
EndDo
EndIf
!3. Reading Relative Humidity
If (MeteoParam%NStation == 0) Then
MeteoParam%RelHum = 100.
ElseIf (MeteoParam%Nstation==1) Then
call r8vec_bracket ( MeteoParam%RelHumnTime(1), MeteoParam%RelHumTime(1,1:MeteoParam%RelHumnTime(1)), t_interp_double, leftt(1),rightt(1) )
Do iElem=1,MeshParam%nElem
!Value for each cell
MeteoParam%RelHum(iElem) = &
( ( MeteoParam%RelHumTime(1,rightt(1)) - time ) * MeteoParam%RelHumValue(1,leftt(1)) &
+ ( time - MeteoParam%RelHumTime(1,leftt(1)) ) * MeteoParam%RelHumValue(1,rightt(1)) ) &
/ ( MeteoParam%RelHumTime(1,rightt(1)) - MeteoParam%RelHumTime(1,leftt(1)) )
!Call interp_linear( 1, RelHumnTime(1), RelHumTime(1,1:RelHumnTime(1)), RelHumValue(1,1:RelHumnTime(1)), 1, t_interp, p_interp )
!RelHum(iElem) = p_interp(1,1)
EndDo
Else
Do i=1,MeteoParam%Nstation
call r8vec_bracket ( MeteoParam%RelHumnTime(i), MeteoParam%RelHumTime(i,1:MeteoParam%RelHumnTime(i)), t_interp_double, leftt(i),rightt(i) )
EndDo
Do iElem=1,MeshParam%nElem
!IDW interpolation for each cell
weit = 0.
Do i=1,MeteoParam%Nstation
staint(i) = 1./(dsqrt((MeteoParam%CoordMetStations(1,i)-MeshParam%xb(iElem))**2.+(MeteoParam%CoordMetStations(2,i)-MeshParam%yb(iElem))**2.)+NearZero)
weit = weit + staint(i)
EndDo
MeteoParam%RelHum(iElem) = 0.
Do i=1,MeteoParam%Nstation
MeteoParam%RelHum(iElem) = &
( ( MeteoParam%RelHumTime(i,rightt(i)) - time ) * MeteoParam%RelHumValue(i,leftt(i)) &
+ ( time - MeteoParam%RelHumTime(i,leftt(i)) ) * MeteoParam%RelHumValue(i,rightt(i)) ) &
/ ( MeteoParam%RelHumTime(i,rightt(i)) - MeteoParam%RelHumTime(i,leftt(i)) )
!Call interp_linear( 1, RelHumnTime(i), RelHumTime(i,1:RelHumnTime(i)), RelHumValue(i,1:RelHumnTime(i)), 1, t_interp, p_interp )
!RelHum(iElem) = RelHum(iElem) + p_interp(1,1)*staint(i)/weit
EndDo
EndDo
EndIf
!4. Reading solar radiation data
If (MeteoParam%NStation == 0) Then
MeteoParam%SolarRad = 0.
ElseIf (MeteoParam%Nstation==1) Then
call r8vec_bracket ( MeteoParam%SolarRadnTime(1), MeteoParam%SolarRadTime(1,1:MeteoParam%SolarRadnTime(1)), t_interp_double, leftt(1),rightt(1) )
Do iElem=1,MeshParam%nElem
!Atmosferic pressure for each cell
MeteoParam%SolarRad(iElem) = &
( ( MeteoParam%SolarRadTime(1,rightt(1)) - time ) * MeteoParam%SolarRadValue(1,leftt(1)) &
+ ( time - MeteoParam%SolarRadTime(1,leftt(1)) ) * MeteoParam%SolarRadValue(1,rightt(1)) ) &
/ ( MeteoParam%SolarRadTime(1,rightt(1)) - MeteoParam%SolarRadTime(1,leftt(1)) )
!Call interp_linear( 1, SolarRadnTime(1), SolarRadTime(1,1:SolarRadnTime(1)), SolarRadValue(1,1:SolarRadnTime(1)), 1, t_interp, p_interp )
!SolarRad(iElem) = p_interp(1,1)
EndDo
Else
Do i=1,MeteoParam%Nstation
call r8vec_bracket ( MeteoParam%SolarRadnTime(i), MeteoParam%SolarRadTime(i,1:MeteoParam%SolarRadnTime(i)), t_interp_double, leftt(i),rightt(i) )
EndDo
Do iElem=1,MeshParam%nElem
!IDW interpolation for each cell
weit = 0.
Do i=1,MeteoParam%Nstation
staint(i) = 1./(dsqrt((MeteoParam%CoordMetStations(1,i)-MeshParam%xb(iElem))**2.+(MeteoParam%CoordMetStations(2,i)-MeshParam%yb(iElem))**2.)+NearZero)
weit = weit + staint(i)
EndDo
MeteoParam%SolarRad(iElem) = 0.
Do i=1,MeteoParam%Nstation
MeteoParam%SolarRad(iElem) = &
( ( MeteoParam%SolarRadTime(i,rightt(i)) - time ) * MeteoParam%SolarRadValue(i,leftt(i)) &
+ ( time - MeteoParam%SolarRadTime(i,leftt(i)) ) * MeteoParam%SolarRadValue(i,rightt(i)) ) &
/ ( MeteoParam%SolarRadTime(i,rightt(i)) - MeteoParam%SolarRadTime(i,leftt(i)) )
!Call interp_linear( 1, SolarRadnTime(i), SolarRadTime(i,1:SolarRadnTime(i)), SolarRadValue(i,1:SolarRadnTime(i)), 1, t_interp, p_interp )
!SolarRad(iElem) = SolarRad(iElem) + p_interp(1,1)*staint(i)/weit
EndDo
EndDo
EndIf
!5. Reading wind data
If (MeteoParam%NStation == 0) Then
MeteoParam%WindX = 0.
MeteoParam%WindY = 0.
ElseIf (MeteoParam%Nstation==1) Then
call r8vec_bracket ( MeteoParam%WindnTime(1), MeteoParam%WindTime(1,1:MeteoParam%WindnTime(1)), t_interp_double, leftt(1),rightt(1) )
Do iEdge=1,MeshParam%nEdge
!Value for each cell
MeteoParam%WindX(iEdge) = &
( ( MeteoParam%WindTime(1,rightt(1)) - time ) * MeteoParam%WindValuex(1,leftt(1)) &
+ ( time - MeteoParam%WindTime(1,leftt(1)) ) * MeteoParam%WindValuex(1,rightt(1)) ) &
/ ( MeteoParam%WindTime(1,rightt(1)) - MeteoParam%WindTime(1,leftt(1)) )
!Call interp_linear( 1, WindnTime(1), WindTime(1,1:WindnTime(1)), WindValuex(1,1:WindnTime(1)), 1, t_interp, p_interp )
!WindX(iEdge) = p_interp(1,1)
!Call interp_linear( 1, WindnTime(1), WindTime(1,1:WindnTime(1)), WindValuey(1,1:WindnTime(1)), 1, t_interp, p_interp )
!WindY(iEdge) = p_interp(1,1)
MeteoParam%WindY(iEdge) = &
( ( MeteoParam%WindTime(1,rightt(1)) - time ) * MeteoParam%WindValuey(1,leftt(1)) &
+ ( time - MeteoParam%WindTime(1,leftt(1)) ) * MeteoParam%WindValuey(1,rightt(1)) ) &
/ ( MeteoParam%WindTime(1,rightt(1)) - MeteoParam%WindTime(1,leftt(1)) )
EndDo
Else
Do i=1,MeteoParam%Nstation
call r8vec_bracket ( MeteoParam%WindnTime(i), MeteoParam%WindTime(i,1:MeteoParam%WindnTime(i)), t_interp_double, leftt(i),rightt(i) )
EndDo
Do iEdge=1,MeshParam%nEdge
!IDW interpolation for each cell
weit = 0.
Do i=1,MeteoParam%Nstation
staint(i) = 1./(dsqrt((MeteoParam%CoordMetStations(1,i)-MeshParam%EdgeBary(1,iEdge))**2.+(MeteoParam%CoordMetStations(2,i)-MeshParam%EdgeBary(2,iEdge))**2.)+NearZero)
weit = weit + staint(i)
EndDo
MeteoParam%WindX(iEdge) = 0.
MeteoParam%WindY(iEdge) = 0.
Do i=1,MeteoParam%Nstation
MeteoParam%WindX(iEdge) = &
( ( MeteoParam%WindTime(i,rightt(i)) - time ) * MeteoParam%WindValuex(i,leftt(i)) &
+ ( time - MeteoParam%WindTime(i,leftt(i)) ) * MeteoParam%WindValuex(i,rightt(i)) ) &
/ ( MeteoParam%WindTime(i,rightt(i)) - MeteoParam%WindTime(i,leftt(i)) )
!Call interp_linear( 1, WindnTime(i), WindTime(i,1:WindnTime(i)), WindValuex(i,1:WindnTime(i)), 1, t_interp, p_interp )
!WindX(iEdge) = WindX(iEdge) + p_interp(1,1)*staint(i)/weit
MeteoParam%WindY(iEdge) = &
( ( MeteoParam%WindTime(i,rightt(i)) - time ) * MeteoParam%WindValuey(i,leftt(i)) &
+ ( time - MeteoParam%WindTime(i,leftt(i)) ) * MeteoParam%WindValuey(i,rightt(i)) ) &
/ ( MeteoParam%WindTime(i,rightt(i)) - MeteoParam%WindTime(i,leftt(i)) )
!Call interp_linear( 1, WindnTime(i), WindTime(i,1:WindnTime(i)), WindValuex(i,1:WindnTime(i)), 1, t_interp, p_interp )
!WindY(iEdge) = WindY(iEdge) + p_interp(1,1)*staint(i)/weit
EndDo
EndDo
EndIf
!6. Reading precipitation data
If (MeteoParam%NStation == 0) Then
MeteoParam%Precip = 0.
ElseIf (MeteoParam%Nstation==1) Then
call r8vec_bracket ( MeteoParam%PrecipnTime(1), MeteoParam%PrecipTime(1,1:MeteoParam%PrecipnTime(1)), t_interp_double, leftt(1),rightt(1) )
Do iElem=1,MeshParam%nElem
!Precipitation for each cell
MeteoParam%Precip(iElem) = &
( ( MeteoParam%PrecipTime(1,rightt(1)) - time ) * MeteoParam%PrecipValue(1,leftt(1)) &
+ ( time - MeteoParam%PrecipTime(1,leftt(1)) ) * MeteoParam%PrecipValue(1,rightt(1)) ) &
/ ( MeteoParam%PrecipTime(1,rightt(1)) - MeteoParam%PrecipTime(1,leftt(1)) )
!Call interp_linear( 1, PrecipnTime(1), PrecipTime(1,1:PrecipnTime(1)), PrecipValue(1,1:PrecipnTime(1)), 1, t_interp, p_interp )
!Precip(iElem) = p_interp(1,1)
EndDo
Else
Do i=1,MeteoParam%Nstation
call r8vec_bracket ( MeteoParam%PrecipnTime(i), MeteoParam%PrecipTime(i,1:MeteoParam%PrecipnTime(i)), t_interp_double, leftt(i),rightt(i) )
EndDo
Do iElem=1,MeshParam%nElem
!IDW interpolation for each cell
weit = 0.
Do i=1,MeteoParam%Nstation
staint(i) = 1./(dsqrt((MeteoParam%CoordMetStations(1,i)-MeshParam%xb(iElem))**2.+(MeteoParam%CoordMetStations(2,i)-MeshParam%yb(iElem))**2.)+NearZero)
weit = weit + staint(i)
EndDo
MeteoParam%Precip(iElem) = 0.
Do i=1,MeteoParam%Nstation
MeteoParam%Precip(iElem) = &
( ( MeteoParam%PrecipTime(i,rightt(i)) - time ) * MeteoParam%PrecipValue(i,leftt(i)) &
+ ( time - MeteoParam%PrecipTime(i,leftt(i)) ) * MeteoParam%PrecipValue(i,rightt(i)) ) &
/ ( MeteoParam%PrecipTime(i,rightt(i)) - MeteoParam%PrecipTime(i,leftt(i)) )
!Call interp_linear( 1, PrecipnTime(i), PrecipTime(i,1:PrecipnTime(i)), PrecipValue(i,1:PrecipnTime(i)), 1, t_interp, p_interp )
!Precip(iElem) = Precip(iElem) + p_interp(1,1)*staint(i)/weit
EndDo
EndDo
EndIf
!7. Reading evaporation data
If (MeteoParam%NStation == 0) Then
MeteoParam%Evap = 0.
ElseIf (MeteoParam%Nstation==1) Then
call r8vec_bracket ( MeteoParam%EvapnTime(1), MeteoParam%EvapTime(1,1:MeteoParam%EvapnTime(1)), t_interp_double, leftt(1),rightt(1) )
Do iElem=1,MeshParam%nElem
!Value for each cell
MeteoParam%Evap(iElem) = &
( ( MeteoParam%EvapTime(1,rightt(1)) - time ) * MeteoParam%EvapValue(1,leftt(1)) &
+ ( time - MeteoParam%EvapTime(1,leftt(1)) ) * MeteoParam%EvapValue(1,rightt(1)) ) &
/ ( MeteoParam%EvapTime(1,rightt(1)) - MeteoParam%EvapTime(1,leftt(1)) )
!Call interp_linear( 1, EvapnTime(1), EvapTime(1,1:EvapnTime(1)), EvapValue(1,1:EvapnTime(1)), 1, t_interp, p_interp )
!Evap(iElem) = p_interp(1,1)
EndDo
Else
Do i=1,MeteoParam%Nstation
call r8vec_bracket ( MeteoParam%EvapnTime(i), MeteoParam%EvapTime(i,1:MeteoParam%EvapnTime(i)), t_interp_double, leftt(i),rightt(i) )
EndDo
Do iElem=1,MeshParam%nElem
!IDW interpolation for each cell
weit = 0.
Do i=1,MeteoParam%Nstation
staint(i) = 1./(dsqrt((MeteoParam%CoordMetStations(1,i)-MeshParam%xb(iElem))**2.+(MeteoParam%CoordMetStations(2,i)-MeshParam%yb(iElem))**2.)+NearZero)
weit = weit + staint(i)
EndDo
MeteoParam%Evap(iElem) = 0.
Do i=1,MeteoParam%Nstation
MeteoParam%Evap(iElem) = &
( ( MeteoParam%EvapTime(i,rightt(i)) - time ) * MeteoParam%EvapValue(i,leftt(i)) &
+ ( time - MeteoParam%EvapTime(i,leftt(i)) ) * MeteoParam%EvapValue(i,rightt(i)) ) &
/ ( MeteoParam%EvapTime(i,rightt(i)) - MeteoParam%EvapTime(i,leftt(i)) )
!Call interp_linear( 1, EvapnTime(i), EvapTime(i,1:EvapnTime(i)), EvapValue(i,1:EvapnTime(i)), 1, t_interp, p_interp )
!Evap(iElem) = Evap(iElem) + p_interp(1,1)*staint(i)/weit
EndDo
EndDo
EndIf
Return
End Subroutine GetMeteorologicalData