-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwallo_demand.f90
79 lines (68 loc) · 3.37 KB
/
wallo_demand.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
subroutine wallo_demand (iwallo, idmd)
use water_allocation_module
use hru_module
use hydrograph_module
use conditional_module
implicit none
integer, intent (in) :: iwallo !water allocation object number
integer, intent (in) :: idmd !water demand object number
integer :: j !none |hru number
integer :: id !none |flo_con decision table number
integer :: isrc !none |source object number
integer :: irec !none |recall database number
!! zero total demand for each object
wallod_out(iwallo)%dmd(idmd)%dmd_tot = 0.
!! compute total demand from each demand object
select case (wallo(iwallo)%dmd(idmd)%ob_typ)
!! minicipal demand
case ("muni")
if (wallo(iwallo)%dmd(idmd)%withdr == "ave_day") then
wallod_out(iwallo)%dmd(idmd)%dmd_tot = wallo(iwallo)%dmd(idmd)%amount
else
!! use recall object for demand
irec = wallo(iwallo)%dmd(idmd)%rec_num
select case (recall(irec)%typ)
case (1) !daily
wallod_out(iwallo)%dmd(idmd)%dmd_tot = recall(irec)%hd(time%day,time%yrs)%flo
case (2) !monthly
wallod_out(iwallo)%dmd(idmd)%dmd_tot = recall(irec)%hd(time%mo,time%yrs)%flo
case (3) !annual
wallod_out(iwallo)%dmd(idmd)%dmd_tot = recall(irec)%hd(1,time%yrs)%flo
end select
end if
!! diversion demand
case ("divert")
!! use average daily or a flow control decision table
if (wallo(iwallo)%dmd(idmd)%withdr == "ave_day") then
wallod_out(iwallo)%dmd(idmd)%dmd_tot = wallo(iwallo)%dmd(idmd)%amount
else
!! use decision table for flow control - water allocation
id = wallo(iwallo)%dmd(idmd)%rec_num !dtbl_flo(i)%act_typ(iac)
ich = 0 !use number in decision table for divert
!icmd is source channel object number
icmd = sp_ob1%chandeg + wallo(iwallo)%cha - 1
d_tbl => dtbl_flo(id)
call conditions (ich, id)
call actions (ich, icmd, id)
wallod_out(iwallo)%dmd(idmd)%dmd_tot = trans_m3
end if
!! irrigation demand
case ("hru")
j = wallo(iwallo)%dmd(idmd)%ob_num
!! if there is demand, use amount from water allocation file
if (irrig(j)%demand > 0.) then
!wallod_out(iwallo)%dmd(idmd)%dmd_tot = wallo(iwallo)%dmd(idmd)%amount * hru(j)%area_ha * 10. !m3 = mm * ha * 10.
wallod_out(iwallo)%dmd(idmd)%dmd_tot = irrig(j)%demand !LEstrada
else
wallod_out(iwallo)%dmd(idmd)%dmd_tot = 0.
end if
end select
!! initialize unmet to total demand and subtract as water is withdrawn
wallo(iwallo)%dmd(idmd)%unmet_m3 = wallod_out(iwallo)%dmd(idmd)%dmd_tot
!! compute demand from each source object
do isrc = 1, wallo(iwallo)%dmd(idmd)%dmd_src_obs
wallod_out(iwallo)%dmd(idmd)%src(isrc)%demand = wallo(iwallo)%dmd(idmd)%src(isrc)%frac * &
wallod_out(iwallo)%dmd(idmd)%dmd_tot
end do
return
end subroutine wallo_demand