Skip to content

Commit 0937104

Browse files
authored
Merge pull request #36 from tugraskan/jeffs
Refactor modules for plant class handling, erosion, sediment, & biomass.
2 parents b5c414e + 76efbf1 commit 0937104

13 files changed

+210
-177
lines changed

src/basin_module.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ module basin_module
111111
real :: tlaps = 6.5 !! deg C/km |temperature lapse rate: deg C per km of elevation difference
112112
real :: nfixmx = 20.0 !! max daily n-fixation (kg/ha)
113113
real :: decr_min = 0.01 !! minimum daily residue decay
114-
real :: rsd_covco = 0.30 !! residue cover factor for computing frac of cover
114+
real :: rsd_covco = 0.75 !! residue cover factor for computing frac of cover
115115
real :: urb_init_abst = 1. !! maximum initial abstraction for urban areas when using Green and Ampt
116116
real :: petco_pmpt = 100.0 !! PET adjustment (%) for Penman-Montieth and Preiestly-Taylor methods
117117
real :: uhalpha = 1.0 !! alpha coeff for est unit hydrograph using gamma func

src/basin_prm_default.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ subroutine basin_prm_default
3737
!if (bsn_prm%dorm_hr < 1.e-6) bsn_prm%dorm_hr = -1. !! time threshold used to define dormant (hrs)
3838
if (bsn_prm%nfixmx < 1.e-6) bsn_prm%nfixmx = 20.0 !! max daily n-fixation (kg/ha)
3939
if (bsn_prm%decr_min < 1.e-6) bsn_prm%decr_min = 0.01 !!
40-
if (bsn_prm%rsd_covco < 1.e-6) bsn_prm%rsd_covco = 0.30 !! residue cover factor for computing frac of cover
40+
if (bsn_prm%rsd_covco < 1.e-6) bsn_prm%rsd_covco = 0.75 !! residue cover factor for computing C factor equation
4141
if (bsn_prm%urb_init_abst < 1.e-6) bsn_prm%urb_init_abst = 0. !! PET adjustment (%) for Penman-Montieth and Preiestly-Taylor methods
4242
if (bsn_prm%petco_pmpt < 0.5 .and. bsn_prm%petco_pmpt > 0.) bsn_prm%petco_pmpt = 0.0 !! reservoir sediment settling coeff
4343
bsn_prm%petco_pmpt = (100. + bsn_prm%petco_pmpt) / 100. !! convert to fraction

src/cal_conditions.f90

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ subroutine cal_conditions
77
use hru_module, only : hru
88
use soil_module
99
use plant_module
10+
use plant_data_module
1011
use time_module
1112
use climate_module, only : pcp, tmp
1213

@@ -74,6 +75,10 @@ subroutine cal_conditions
7475
if (pl_find == "n") cond_met = "n"
7576
exit
7677
end do
78+
case ("pl_class")
79+
if (cal_upd(ichg_par)%cond(ic)%targc /= pl_class(ielem)) then
80+
cond_met = "n"
81+
end if
7782
case ("landuse") !for hru
7883
if (cal_upd(ichg_par)%cond(ic)%targc /= hru(ielem)%land_use_mgt_c) then
7984
cond_met = "n"

src/cal_parm_select.f90

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ subroutine cal_parm_select (ielem, ly, chg_parm, chg_typ, chg_val, absmin, absma
3434
use hydrograph_module
3535
use pesticide_data_module
3636
use plant_module
37-
use gwflow_module
37+
use plant_data_module
38+
use gwflow_module
3839

3940
implicit none
4041

@@ -80,12 +81,16 @@ subroutine cal_parm_select (ielem, ly, chg_parm, chg_typ, chg_val, absmin, absma
8081
hru(ielem)%lumv%usle_p = chg_par (hru(ielem)%lumv%usle_p, &
8182
chg_typ, chg_val, absmin, absmax)
8283

84+
case ("usle_c")
85+
pldb(ielem)%usle_c = chg_par (pldb(ielem)%usle_c, &
86+
chg_typ, chg_val, absmin, absmax)
87+
8388
case ("ovn")
8489
hru(ielem)%luse%ovn = chg_par (hru(ielem)%luse%ovn, &
8590
chg_typ, chg_val, absmin, absmax)
8691

8792
case ("elev")
88-
hru(ielem)%topo%elev = chg_par (hru(ielem)%topo%elev, &
93+
hru(ielem)%topo%elev = chg_par (hru(ielem)%topo%elev, &
8994
chg_typ, chg_val, absmin, absmax)
9095

9196
case ("slope")
@@ -429,8 +434,8 @@ subroutine cal_parm_select (ielem, ly, chg_parm, chg_typ, chg_val, absmin, absma
429434
bsn_prm%n_updis = chg_par(bsn_prm%n_updis, &
430435
chg_typ, chg_val, absmin, absmax)
431436

432-
case ("p_updis")
433-
bsn_prm%p_updis = chg_par(bsn_prm%p_updis, &
437+
case ("rsd_covco")
438+
bsn_prm%rsd_covco = chg_par(bsn_prm%rsd_covco, &
434439
chg_typ, chg_val, absmin, absmax)
435440

436441
case ("dorm_hr")

src/cal_parmchg_read.f90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ subroutine cal_parmchg_read
102102
cal_upd(i)%num_elem = db_mx%dtbl_res
103103
case ("plt")
104104
cal_upd(i)%num_elem = sp_ob%hru
105+
case ("pl_class")
106+
cal_upd(i)%num_elem = db_mx%plantparm
105107
case ("lyr")
106108
cal_upd(i)%num_elem = sp_ob%hru
107109
case ("sol")

src/ero_cfactor.f90

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,23 +103,24 @@ subroutine ero_cfactor
103103

104104
!! newer method using residue and biomass cover
105105
rsd_sumfac = (soil1(j)%rsd(1)%m +1.) / 1000.
106-
grnd_covfact = 0.
106+
grnd_sumfac = 0.
107107
can_covfact = 10000.
108108
do ipl = 1, pcom(j)%npl
109109
idp = pcom(j)%plcur(ipl)%idplt
110110
ab_gr_t = pl_mass(j)%ab_gr(ipl)%m / 1000.
111-
!grnd_sumfac = grnd_sumfac + ab_gr_t
112-
grnd_covfact = grnd_covfact + pldb(idp)%usle_c * ab_gr_t / (ab_gr_t + exp(1.175 - 1.748 * ab_gr_t))
111+
grnd_sumfac = grnd_sumfac + ab_gr_t
112+
!! grnd_covfact = grnd_covfact + pldb(idp)%usle_c * ab_gr_t / (ab_gr_t + exp(1.175 - 1.748 * ab_gr_t))
113113
can_covfact = amin1 (can_covfact, pcom(j)%plg(ipl)%cht)
114114
end do
115115
!grnd_covfact = grnd_sumfac / (grnd_sumfac + exp(1.175 - 1.748 * grnd_sumfac))
116-
rsd_covfact = exp(-0.75 * rsd_sumfac)
116+
rsd_covfact = exp(-bsn_prm%rsd_covco * rsd_sumfac)
117117

118118
can_frcov = amin1 (1., pcom(j)%lai_sum / 3.)
119119
can_covfact = 1. - can_frcov * Exp(-.328 * pcom(j)%cht_mx)
120120

121-
bio_covfac = 1. - grnd_covfact * exp(-0.1 * can_covfact)
122-
c = Max(1.e-10, rsd_covfact * grnd_covfact * bio_covfac)
121+
grnd_covfact = exp(-pldb(idp)%usle_c * grnd_sumfac)
122+
!! bio_covfac = 1. - grnd_covfact * exp(-0.1 * can_covfact)
123+
c = Max(1.e-10, rsd_covfact * grnd_covfact) ! * can_covfact)
123124

124125
!! erosion output variables
125126
ero_output(j)%ero_d%c = c

src/mgt_harvbiomass.f90

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,10 @@ subroutine mgt_harvbiomass (jj, iplant, iharvop)
4040
harv_seed = hi_tot * pl_mass(j)%seed(ipl)
4141
harv_leaf = hi_tot * pl_mass(j)%leaf(ipl)
4242
harv_stem = hi_tot * pl_mass(j)%stem(ipl)
43-
pl_yield = harv_seed + harv_leaf
44-
pl_yield = pl_yield + harv_stem
43+
pl_yield = harv_seed + harv_leaf + harv_stem
4544

4645
!! apply pest stress to harvest index - mass lost due to pests - don't add to residue
47-
pl_yield = (1. - pcom(j)%plcur(ipl)%pest_stress) * (1. - harveff) * pl_yield
46+
pl_yield = (1. - pcom(j)%plcur(ipl)%pest_stress) * pl_yield
4847
!! add plant carbon for printing
4948
hrc_d(j)%plant_surf_c = hrc_d(j)%plant_surf_c + pl_yield%c
5049
hpc_d(j)%harv_abgr_c = hpc_d(j)%harv_abgr_c + pl_yield%c

src/nut_nminrl.f90

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ subroutine nut_nminrl
3232
use septic_data_module
3333
use basin_module
3434
use organic_mineral_mass_module
35-
use hru_module, only : rsdco_plcom, i_sep, ihru, ipl, isep
35+
use hru_module, only : rsdco_plcom, i_sep, ihru, isep
3636
use soil_module
3737
use plant_module
3838
use output_landscape_module, only : hnb_d
@@ -43,7 +43,7 @@ subroutine nut_nminrl
4343
integer :: k = 0 !none |counter (soil layer)
4444
integer :: kk = 0 !none |soil layer used to compute soil water and
4545
! |soil temperature factors
46-
integer :: idp = 0
46+
!integer :: idp = 0
4747
real :: rmn1 = 0. !kg N/ha |amount of nitrogen moving from fresh organic
4848
! |to nitrate(80%) and active organic(20%)
4949
! |pools in layer
@@ -62,7 +62,7 @@ subroutine nut_nminrl
6262
real :: cprf = 0. ! |carbon phosphorus ratio factor
6363
real :: ca = 0. ! |
6464
real :: decr = 0. ! |
65-
real :: rdc = 0. ! |
65+
!real :: rdc = 0. ! |
6666
real :: wdn = 0. !kg N/ha |amount of nitrogen lost from nitrate pool in
6767
! |layer due to denitrification
6868
real :: cdg = 0. !none |soil temperature factor
@@ -77,6 +77,8 @@ subroutine nut_nminrl
7777
hnb_d(j)%org_lab_p = 0.
7878
hnb_d(j)%act_sta_n = 0.
7979
hnb_d(j)%denit = 0.
80+
hnb_d(j)%rsd_nitorg_n = 0.
81+
hnb_d(j)%rsd_laborg_p = 0.
8082

8183
!! compute humus mineralization of organic soil pools
8284
do k = 1, soil(j)%nly
@@ -147,33 +149,36 @@ subroutine nut_nminrl
147149
cnrf = 1.
148150
end if
149151

150-
if (soil1(j)%rsd(k)%p > 1.e-4) then
151-
cpr = soil1(j)%rsd(k)%c / soil1(j)%rsd(k)%p
152-
if (cpr > 5000.) cpr = 5000.
153-
cprf = Exp(-.693 * (cpr - 200.) / 200.)
154-
else
155-
cprf = 1.
156-
end if
152+
if (soil1(j)%rsd(k)%p > 1.e-4) then
153+
cpr = soil1(j)%rsd(k)%c / soil1(j)%rsd(k)%p
154+
if (cpr > 5000.) cpr = 5000.
155+
cprf = Exp(-.693 * (cpr - 200.) / 200.)
156+
else
157+
cprf = 1.
158+
end if
157159

158-
ca = Min(cnrf, cprf, 1.)
160+
ca = Min(cnrf, cprf, 1.)
159161

160-
!! compute root and incorporated residue decomposition
161-
!! all plant residue in soil is mixed - don't track individual plant residue in soil
162+
!! compute root and incorporated residue decomposition
163+
!! all plant residue in soil is mixed - don't track individual plant residue in soil
162164

163-
if (pcom(j)%npl > 0) then
164-
decr = rsdco_plcom(j) / pcom(j)%npl * ca * csf
165-
else
166-
decr = 0.05
167-
end if
168-
decr = Max(bsn_prm%decr_min, decr)
169-
decr = Min(decr, 1.)
170-
decomp = decr * soil1(j)%rsd(k)
171-
soil1(j)%rsd(k) = soil1(j)%rsd(k) - decomp
172-
soil1(j)%mn(k)%no3 = soil1(j)%mn(k)%no3 + .8 * decomp%n
173-
soil1(j)%hact(k)%n = soil1(j)%hact(k)%n + .2 * decomp%n
174-
soil1(j)%mp(k)%lab = soil1(j)%mp(k)%lab + .8 * decomp%p
175-
soil1(j)%hsta(k)%p = soil1(j)%hsta(k)%p + .2 * decomp%p
176-
165+
if (pcom(j)%npl > 0) then
166+
decr = rsdco_plcom(j) / pcom(j)%npl * ca * csf
167+
else
168+
decr = 0.05
169+
end if
170+
decr = Max(bsn_prm%decr_min, decr)
171+
decr = Min(decr, 1.)
172+
decomp = decr * soil1(j)%rsd(k)
173+
soil1(j)%rsd(k) = soil1(j)%rsd(k) - decomp
174+
soil1(j)%mn(k)%no3 = soil1(j)%mn(k)%no3 + .8 * decomp%n
175+
soil1(j)%hact(k)%n = soil1(j)%hact(k)%n + .2 * decomp%n
176+
soil1(j)%mp(k)%lab = soil1(j)%mp(k)%lab + .8 * decomp%p
177+
soil1(j)%hsta(k)%p = soil1(j)%hsta(k)%p + .2 * decomp%p
178+
179+
hnb_d(j)%rsd_nitorg_n = hnb_d(j)%rsd_nitorg_n + .8 * decomp%n
180+
hnb_d(j)%rsd_laborg_p = hnb_d(j)%rsd_laborg_p + .8 * decomp%p
181+
177182
!! compute denitrification
178183
wdn = 0.
179184
if (i_sep(j) /= k .or. sep(isep)%opt /= 1) then

src/pl_dormant.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ subroutine pl_dormant
4747
end if
4848
lai_drop = max (0., lai_drop)
4949
lai_drop = amin1 (1., lai_drop)
50-
leaf_drop%m = lai_drop * pl_mass(j)%leaf(ipl)%m
50+
leaf_drop%m = rto * lai_drop * pl_mass(j)%leaf(ipl)%m
5151
leaf_drop%n = leaf_drop%m * pcom(j)%plm(ipl)%n_fr
5252
leaf_drop%n = max (0., leaf_drop%n)
5353
leaf_drop%p = leaf_drop%m * pcom(j)%plm(ipl)%p_fr

src/pl_fert.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ subroutine pl_fert (ifrt, frt_kg, fertop)
1919

2020
implicit none
2121

22-
real, parameter :: rtof=0.5 !none |weighting factor used to partition the
22+
real :: rtof !none |weighting factor used to partition the
2323
! |organic N & P concentration of septic effluent
2424
! |between the fresh organic and the stable organic pools
2525
integer :: j = 0 !none |hru counter
@@ -36,6 +36,7 @@ subroutine pl_fert (ifrt, frt_kg, fertop)
3636

3737
j = ihru
3838

39+
rtof = 0.5
3940
!! calculate c:n ratio for manure applications for SWAT-C
4041
if (bsn_cc%cswat == 2) then
4142
org_frt%m = frt_kg

0 commit comments

Comments
 (0)