-
Notifications
You must be signed in to change notification settings - Fork 1
/
filter.f
352 lines (296 loc) · 15.1 KB
/
filter.f
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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
subroutine filter
!! ~ ~ ~ PURPOSE ~ ~ ~
!! this subroutine calculates the reduction of pollutants in surface runoff
!! due to an edge of field filter or buffer strip
!! ~ ~ ~ INCOMING VARIABLES ~ ~ ~
!! name |units |definition
!! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
!! bactrolp |# colonies/ha |less persistent bacteria transported to main
!! |channel with surface runoff
!! bactrop |# colonies/ha |persistent bacteria transported to main
!! |channel with surface runoff
!! bactsedlp |# colonies/ha |less persistent bacteria transported with
!! |sediment in surface runoff
!! bactsedp |# colonies/ha |persistent bacteria transported with
!! |sediment in surface runoff
!! curyr |none |current year of simulation
!! fsred(:) |none |reduction in bacteria loading from filter
!! |strip
!! hru_dafr(:) |none |fraction of watershed area in HRU
!! hrupest(:) |none |pesticide use flag:
!! | 0: no pesticides used in HRU
!! | 1: pesticides used in HRU
!! ihru |none |HRU number
!! npmx |none |number of different pesticides used in
!! |the simulation
!! nyskip |none |number of years to skip output summarization
!! |and printing
!! pst_sed(:,:)|kg/ha |pesticide loading from HRU sorbed onto
!! |sediment
!! pst_surq(:,:)|kg/ha |amount of pesticide type lost in surface
!! |runoff on current day in HRU
!! sbactrolp |# colonies/ha |average annual number of less persistent
!! |bacteria transported to main channel
!! |with surface runoff in solution
!! sbactrop |# colonies/ha |average annual number of persistent bacteria
!! |transported to main channel with surface
!! |runoff in solution
!! sbactsedlp |# colonies/ha |average annual number of less persistent
!! |bacteria transported with sediment in
!! |surface runoff
!! sbactsedp |# colonies/ha |average annual number of persistent bacteria
!! |transported with sediment in surface runoff
!! sedminpa(:) |kg P/ha |amount of active mineral phosphorus sorbed to
!! |sediment in surface runoff in HRU for day
!! sedminps(:) |kg P/ha |amount of stable mineral phosphorus sorbed to
!! |sediment in surface runoff in HRU for day
!! sedorgn(:) |kg N/ha |amount of organic nitrogen in surface runoff
!! |in HRU for the day
!! sedorgp(:) |kg P/ha |amount of organic phosphorus in surface runoff
!! |in HRU for the day
!! sedyld(:) |metric tons |daily soil loss caused by water erosion
!! surqno3(:) |kg N/ha |amount of NO3-N in surface runoff in HRU for
!! |the day
!! surqsolp(:) |kg P/ha |amount of soluble phosphorus in surface runoff
!! |in HRU for the day
!! surfq(:) |mm H2O |surface runoff generated on day in HRU
!! hru_ha(:) |ha |area of HRU in hectares
!! vfscon(:) |none |Fraction of the total runoff from the entire field
!! |entering the most concentrated 10% of the VFS.
!! vfsratio(:) |none |Field area/VFS area ratio
!! hru_slp(:) |m/m |average slope steepness
!! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
!! ~ ~ ~ OUTGOING VARIABLES ~ ~ ~
!! name |units |definition
!! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
!! bactrolp |# colonies/ha |less persistent bacteria transported to main
!! |channel with surface runoff
!! bactrop |# colonies/ha |persistent bacteria transported to main
!! |channel with surface runoff
!! bactsedlp |# colonies/ha |less persistent bacteria transported with
!! |sediment in surface runoff
!! bactsedp |# colonies/ha |persistent bacteria transported with
!! |sediment in surface runoff
!! pst_sed(:,:)|kg/ha |pesticide loading from HRU sorbed onto
!! |sediment
!! pst_surq(:,:)|kg/ha |amount of pesticide type lost in surface
!! |runoff on current day in HRU
!! sbactrolp |# colonies/ha |average annual number of less persistent
!! |bacteria transported to main channel
!! |with surface runoff in solution
!! sbactrop |# colonies/ha |average annual number of persistent bacteria
!! |transported to main channel with surface
!! |runoff in solution
!! sbactsedlp |# colonies/ha |average annual number of less persistent
!! |bacteria transported with sediment in
!! |surface runoff
!! sbactsedp |# colonies/ha |average annual number of persistent bacteria
!! |transported with sediment in surface runoff
!! sedminpa(:) |kg P/ha |amount of active mineral phosphorus sorbed to
!! |sediment in surface runoff in HRU for day
!! sedminps(:) |kg P/ha |amount of stable mineral phosphorus sorbed to
!! |sediment in surface runoff in HRU for day
!! sedorgn(:) |kg N/ha |amount of organic nitrogen in surface runoff
!! |in HRU for the day
!! sedorgp(:) |kg P/ha |amount of organic phosphorus in surface runoff
!! |in HRU for the day
!! sedyld(:) |metric tons |daily soil loss caused by water erosion
!! surqno3(:) |kg N/ha |amount of NO3-N in surface runoff in HRU for
!! |the day
!! surqsolp(:) |kg P/ha |amount of soluble phosphorus in surface runoff
!! |in HRU for the day
!! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
!! ~ ~ ~ LOCAL DEFINITIONS ~ ~ ~
!! name |units |definition
!! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
!! j |none |HRU number
!! k |none |counter
!! drain_vfs1 |ha |drainage area of vfs section 1
!! drain_vfs2 |ha |drainage area of vfs section 2
!! area_vfs1 |ha |Area of vfs section 1
!! area_vfs2 |ha |Area of vfs section 2
!! vfs_depth1 |mm |Runoff Loading for vfs section 1
!! vfs_depth2 |mm |Runoff Loading for vfs section 2
!! vfs_sed1 |kg/m^2 |sediment loading for vfs section 1
!! vfs_sed2 |kg/m^2 |sediment loading for vfs section 2
!! surq_remove1|% |Surface runoff removal for for vfs section 1
!! surq_remove2|% |Surface runoff removal for for vfs section 2
!! surq_remove |% |Average surface runoff removal for for entire vfs
!! sed_remove1 |% |sediment removal for for vfs section 1
!! sed_remove2 |% |sediment removal for for vfs section 2
!! sed_remove |% |Average sediment removal for for entire vfs
!! remove1 |% |Generic removal for for vfs section 1
!! |(recycled for constituants)
!! remove2 |% |Generic removal for for vfs section 2
!! |(recycled for constituants)
!! orgn_remove |% |Average organic N removal from surface
!! |runoff for for entire vfs
!! surqno3_remove |% |Average nitrate removal from surface
!! |runoff for for entire vfs
!! partp_remove |% |Average particulate P removal from surface
!! | runoff for for entire vfs
!! solP_remove |% |Average soluble P removal from surface
!! |runoff for for entire vfs
!! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
!! ~ ~ ~ ~ ~ ~ END SPECIFICATIONS ~ ~ ~ ~ ~ ~
use parm
integer :: j, k
real :: sdrain_vfs1, drain_vfs2, area_vfs1, area_vfs2, vfs_depth1,
& vfs_depth2, vfs_sed1, vfs_sed2, surq_remove1, surq_remove2,
& surq_remove, sed_remove1, sed_remove2, sed_remove, remove1,
& remove2, orgn_remove, surqno3_remove, partp_remove, solP_remove,
& sedtrap, xrem
j = 0
j = ihru
if (i == 100) then
remove2=0
end if
!! Filter only if there is some surface runoff
if (surfq(j) > .0001) then
!! vfs comnposed of two sections one with more concentrated flow than the other
!! Calculate drainage area of vfs 1 2 3 in ha
drain_vfs1 = (1-vfscon(j))* hru_ha(j)
drain_vfs2 = ((1-vfsch(j)) * vfscon(j))* hru_ha(j)
drain_vfs3 = vfscon(j) * vfsch(j) * hru_ha(j)
!! Calculate area of vfs 1 and 2 in ha
area_vfs1 = hru_ha(j) * 0.9 / vfsratio(j)
area_vfs2 = hru_ha(j) * 0.1 / vfsratio(j)
!! Calculate drainage area to vfs area ratio (unitless)
vfs_ratio1 = drain_vfs1/area_vfs1
vfs_ratio2 = drain_vfs2/area_vfs2
!! calculate runoff depth over buffer area in mm
vfs_depth1 = vfs_ratio1 * surfq(j)
vfs_depth2 = vfs_ratio2 * surfq(j)
!! calculate sediment loading over buffer area in kg/m^2
vfs_sed1 = (sedyld(j) / hru_ha(j) * 1000 * drain_vfs1) /
& (area_vfs1 * 10000)
vfs_sed2 = (sedyld(j) / hru_ha(j) * 1000 * drain_vfs2) /
& (area_vfs2 * 10000)
!! calculate Runoff Removal by vfs (used for nutrient removal estimation only) based on runoff depth and ksat
!! Based on vfsmod simulations
surq_remove1 = 75.8 - 10.8 * Log(vfs_depth1)+25.9*Log(sol_k(1,j))
if (surq_remove1 > 100.) surq_remove1 = 100.
if (surq_remove1 < 0.) surq_remove1 = 0.
surq_remove2 = 75.8 - 10.8 * Log(vfs_depth2)+25.9*Log(sol_k(1,j))
if (surq_remove2 > 100.) surq_remove2 = 100.
if (surq_remove2 < 0.) surq_remove2 = 0.
surq_remove = (surq_remove1 * drain_vfs1 + surq_remove2
& * drain_vfs2)/hru_ha(j)
!! calculate sediment Removal
!! Based on measured data from literature
sed_remove1 = 79.0 - 1.04 * vfs_sed1 + 0.213 * surq_remove1
if (sed_remove1 > 100.) sed_remove1 = 100.
if (sed_remove1 < 0.) sed_remove1 = 0.
sed_remove2 = 79.0 - 1.04 * vfs_sed2 + 0.213 * surq_remove1
if (sed_remove2 > 100.) sed_remove2 = 100.
if (sed_remove2 < 0.) sed_remove2 = 0.
sed_remove = (sed_remove1 * drain_vfs1 + sed_remove2
& * drain_vfs2)/hru_ha(j)
sedyld(j) = sedyld(j) * (1. - sed_remove / 100.)
sedyld(j) = Max(0., sedyld(j))
sedtrap = sedyld(j) * sed_remove / 100.
xrem = 0.
if (sedtrap <= lagyld(j)) then
lagyld(j) = lagyld(j) - sedtrap
else
xrem = sedtrap - lagyld(j)
lagyld(j) = 0.
if (xrem <= sanyld(j)) then
sanyld(j) = sanyld(j) - xrem
else
xrem = xrem - sanyld(j)
sanyld(j) = 0.
if (xrem <= sagyld(j)) then
sagyld(j) = sagyld(j) - xrem
else
xrem = xrem - sagyld(j)
sagyld(j) = 0.
if (xrem <= silyld(j)) then
silyld(j) = silyld(j) - xrem
else
xrem = xrem - silyld(j)
silyld(j) = 0.
if (xrem <= clayld(j)) then
clayld(j) = clayld(j) - xrem
else
xrem = xrem - clayld(j)
clayld(j) = 0.
end if
end if
end if
end if
end if
sanyld(j) = Max(0., sanyld(j))
silyld(j) = Max(0., silyld(j))
clayld(j) = Max(0., clayld(j))
sagyld(j) = Max(0., sagyld(j))
lagyld(j) = Max(0., lagyld(j))
!! Calculate Organic Nitrogen Removal
!! Based on measured data from literature
remove1 = 0.036 * sed_remove1 ** 1.69
if (remove1 > 100.) remove1 = 100.
if (remove1 < 0.) remove1 = 0.
remove2 = 0.036 * sed_remove2 ** 1.69
if (remove2 > 100.) remove2 = 100.
if (remove2 < 0.) remove2 = 0.
orgn_remove = (remove1 * drain_vfs1 + remove2
& * drain_vfs2)/hru_ha(j)
sedorgn(j) = sedorgn(j) * (1. - orgn_remove / 100.)
!! calculate Nitrate removal from surface runoff
!! Based on measured data from literature
remove1 = 39.4 + 0.584 * surq_remove1
if (remove1 > 100.) remove1 = 100.
if (remove1 < 0.) remove1 = 0.
remove2 = 39.4 + 0.584 * surq_remove2
if (remove2 > 100.) remove2 = 100.
if (remove2 < 0.) remove2 = 0.
surqno3_remove = (remove1 * drain_vfs1 + remove2
& * drain_vfs2)/hru_ha(j)
surqno3(j) = surqno3(j) * (1. - surqno3_remove / 100.)
!! calculate Particulate P removal from surface runoff
!!Based on measured data from literature
remove1 = 0.903 * sed_remove1
if (remove1 > 100.) remove1 = 100.
if (remove1 < 0.) remove1 = 0.
remove2 = 0.903 * sed_remove2
if (remove2 > 100.) remove2 = 100.
if (remove2 < 0.) remove2 = 0.
partP_remove = (remove1 * drain_vfs1 + remove2
& * drain_vfs2)/hru_ha(j)
sedminpa(j) = sedminpa(j) * (1. - partP_remove / 100.)
sedminps(j) = sedminps(j) * (1. - partP_remove / 100.)
sedorgp(j) = sedorgp(j) * (1. - partP_remove / 100.)
!! Calculate Soluble P removal from surface runoff
!! DP% = - 6.14 + 1.13 Runoff%
remove1 = 29.3 + 0.51 * surq_remove1
if (remove1 > 100.) remove1 = 100.
if (remove1 < 0.) remove1 = 0.
remove21 = 29.3 + 0.51 * surq_remove2
if (remove2 > 100.) remove2 = 100.
if (remove2 < 0.) remove2 = 0.
solp_remove = (remove1 * drain_vfs1 + remove2
& * drain_vfs2)/hru_ha(j)
surqsolp(j) = surqsolp(j) * (1. - solp_remove / 100.)
!! Calculate pesticide removal
!! based on the sediment and runoff removal only
if (hrupest(j) == 1) then
do k = 1, npmx
pst_surq(k,j) = pst_surq(k,j) * (1. - surq_remove / 100.)
pst_sed(k,j) = pst_sed(k,j) * (1. - sed_remove / 100.)
end do
end if
!! compute filter strip reduction
bactrop = bactrop * (1. - surq_remove / 100.)
bactrolp = bactrolp * (1. - surq_remove / 100.)
bactsedp = bactsedp * (1. - sed_remove / 100.)
bactsedlp = bactsedlp * (1. - sed_remove / 100.)
!! summary calculations
if (curyr > nyskip) then
sbactrop = sbactrop + bactrop * hru_dafr(j)
sbactrolp = sbactrolp + bactrolp * hru_dafr(j)
sbactsedp = sbactsedp + bactsedp * hru_dafr(j)
sbactsedlp = sbactsedlp + bactsedlp * hru_dafr(j)
end if
end if
return
end