Skip to content

Commit b13dcd7

Browse files
authored
Merge pull request swat-model#171 from tugraskan/change_snow
Snow change (#149)
2 parents 47ac207 + 57f3eea commit b13dcd7

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

src/actions.f90

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ subroutine actions (ob_cur, ob_num, idtbl)
44
use time_module
55
use aquifer_module
66
use hru_module, only : hru, cn2, fertno3, fertnh3, fertorgn, fertorgp, fertsolp, &
7-
ihru, ipl, isol, phubase, sol_sumno3, sol_sumsolp, qtile
7+
ihru, ipl, isol, phubase, sol_sumno3, sol_sumsolp, qtile, snodb
88
use soil_module
99
use plant_module
1010
use plant_data_module
@@ -91,6 +91,7 @@ subroutine actions (ob_cur, ob_num, idtbl)
9191
real :: stor_m3 = 0.
9292
character(len=1) :: action = "" ! |
9393
character(len=40) :: lu_prev = "" ! |
94+
character(len=40) :: snow_prev = "" ! |
9495

9596
do iac = 1, d_tbl%acts
9697
action = "n"
@@ -944,6 +945,22 @@ subroutine actions (ob_cur, ob_num, idtbl)
944945
end do
945946
!pcom(j)%dtbl(idtbl)%num_actions(iac) = pcom(j)%dtbl(idtbl)%num_actions(iac) + 1
946947
!end if
948+
949+
!snow change - change snow parameters for HRU
950+
case ("snow_change")
951+
j = d_tbl%act(iac)%ob_num
952+
if (j == 0) j = ob_cur
953+
d_tbl%snow_chg_mx(iac) = d_tbl%snow_chg_mx(iac) + 1
954+
ilu = d_tbl%act_typ(iac)
955+
hru(j)%dbs%snow = ilu
956+
957+
snow_prev = hru(j)%dbsc%snow
958+
hru(j)%dbsc%snow = d_tbl%act(iac)%file_pointer
959+
hru(j)%sno = snodb(ilu)
960+
!! write to lu_change output file
961+
write (3612,*) j, time%yrc, time%mo, time%day_mo, " SNOW_CHANGE ", &
962+
snow_prev, hru(j)%dbsc%snow, " 0 0"
963+
947964
!land use change - contouring
948965
case ("p_factor")
949966
j = d_tbl%act(iac)%ob_num

src/conditional_module.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ module conditional_module
3434
character(len=25), dimension(:,:), allocatable :: alt ! condition alternatives
3535
type (actions_var), dimension(:), allocatable :: act ! actions
3636
integer, dimension(:), allocatable :: lu_chg_mx ! max times lu change can occur
37+
integer, dimension(:), allocatable :: snow_chg_mx ! max times snow change can occur
3738
character(len=1), dimension(:,:), allocatable :: act_outcomes ! action outcomes ("y" to perform action; "n" to not perform)
3839
character(len=1), dimension(:), allocatable :: act_hit ! "y" if all condition alternatives (rules) are met; "n" if not
3940
integer, dimension(:), allocatable :: act_typ ! pointer to action type (ie plant, fert type, tillage implement, release type, etc)

src/dtbl_lum_read.f90

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ subroutine dtbl_lum_read
1212
use plant_data_module
1313
use constituent_mass_module
1414
use hydrograph_module, only : sp_ob
15-
use hru_module, only : hru
15+
use hru_module, only : hru, snodb
1616

1717
implicit none
1818

@@ -59,6 +59,8 @@ subroutine dtbl_lum_read
5959
allocate (dtbl_lum(i)%act_hit(dtbl_lum(i)%alts))
6060
allocate (dtbl_lum(i)%act_typ(dtbl_lum(i)%acts), source = 0)
6161
allocate (dtbl_lum(i)%act_app(dtbl_lum(i)%acts), source = 0)
62+
allocate (dtbl_lum(i)%lu_chg_mx(dtbl_lum(i)%acts), source = 0)
63+
allocate (dtbl_lum(i)%snow_chg_mx(dtbl_lum(i)%acts), source = 0)
6264
allocate (dtbl_lum(i)%act_outcomes(dtbl_lum(i)%acts,dtbl_lum(i)%alts))
6365

6466
!read conditions and condition alternatives
@@ -230,6 +232,22 @@ subroutine dtbl_lum_read
230232
exit
231233
end if
232234
end do
235+
236+
case ("lu_change")
237+
do idb = 1, db_mx%landuse
238+
if (dtbl_lum(i)%act(iac)%file_pointer == lum(idb)%name) then
239+
dtbl_lum(i)%act_typ(iac) = idb
240+
exit
241+
end if
242+
end do
243+
244+
case ("snow_change")
245+
do idb = 1, db_mx%sno
246+
if (dtbl_lum(i)%act(iac)%file_pointer == snodb(idb)%name) then
247+
dtbl_lum(i)%act_typ(iac) = idb
248+
exit
249+
end if
250+
end do
233251
end select
234252

235253
!xwalk conditions and actions for days since last action

src/dtbl_scen_read.f90

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ subroutine dtbl_scen_read
88
use fertilizer_data_module
99
use input_file_module
1010
use conditional_module
11+
use hru_module, only : snodb
1112

1213
implicit none
1314

@@ -52,6 +53,7 @@ subroutine dtbl_scen_read
5253
allocate (dtbl_scen(i)%act_typ(dtbl_scen(i)%acts), source = 0)
5354
allocate (dtbl_scen(i)%act_app(dtbl_scen(i)%acts), source = 0)
5455
allocate (dtbl_scen(i)%lu_chg_mx(dtbl_scen(i)%acts), source = 0)
56+
allocate (dtbl_scen(i)%snow_chg_mx(dtbl_scen(i)%acts), source = 0)
5557

5658
allocate (dtbl_scen(i)%act_outcomes(dtbl_scen(i)%acts,dtbl_scen(i)%alts))
5759

@@ -83,6 +85,13 @@ subroutine dtbl_scen_read
8385
exit
8486
end if
8587
end do
88+
case ("snow_change")
89+
do ilum = 1, db_mx%sno
90+
if (dtbl_scen(i)%act(iac)%file_pointer == snodb(ilum)%name) then
91+
dtbl_scen(i)%act_typ(iac) = ilum
92+
exit
93+
end if
94+
end do
8695
end select
8796

8897
end do

0 commit comments

Comments
 (0)