Skip to content

Commit

Permalink
Merge pull request #2 from swat-model/main
Browse files Browse the repository at this point in the history
Merging in swatplus main changes
  • Loading branch information
fgeter authored Dec 12, 2024
2 parents 363e471 + 7d0c639 commit b064c02
Show file tree
Hide file tree
Showing 10 changed files with 295 additions and 174 deletions.
10 changes: 4 additions & 6 deletions src/mgt_killop.f90
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,20 @@ subroutine mgt_killop (jj, iplant)
!! add above ground biomass to surface residue pools
soil1(j)%rsd(1) = soil1(j)%rsd(1) + pl_mass(j)%ab_gr(ipl)
if (bsn_cc%cswat == 2) then
soil1(j)%meta(1) = soil1(j)%meta(1) + 0.85 * soil(j)%ly(1)%rtfr * pl_mass(j)%ab_gr(ipl)
soil1(j)%str(1) = soil1(j)%str(1) + 0.15 * soil(j)%ly(1)%rtfr * pl_mass(j)%ab_gr(ipl)
soil1(j)%lig(1) = soil1(j)%lig(1) + 0.12 * soil(j)%ly(1)%rtfr * pl_mass(j)%ab_gr(ipl)
soil1(j)%meta(1) = soil1(j)%meta(1) + 0.85 * pl_mass(j)%ab_gr(ipl)
soil1(j)%str(1) = soil1(j)%str(1) + 0.15 * pl_mass(j)%ab_gr(ipl)
soil1(j)%lig(1) = soil1(j)%lig(1) + 0.12 * pl_mass(j)%ab_gr(ipl)
end if

!! add dead roots to soil residue pools
if (bsn_cc%cswat == 2) then
do ly = 1, soil(j)%nly
do ly = 2, soil(j)%nly
soil1(j)%rsd(ly) = soil1(j)%rsd(ly) + soil(j)%ly(ly)%rtfr * pl_mass(j)%root(ipl)
if (bsn_cc%cswat == 2) then
soil1(j)%meta(ly) = soil1(j)%meta(ly) + 0.85 * soil(j)%ly(ly)%rtfr * pl_mass(j)%root(ipl)
soil1(j)%str(ly) = soil1(j)%str(ly) + 0.15 * soil(j)%ly(ly)%rtfr * pl_mass(j)%root(ipl)
soil1(j)%lig(ly) = soil1(j)%lig(ly) + 0.12 * soil(j)%ly(ly)%rtfr * pl_mass(j)%root(ipl) ! 0.12 = 0.8 * 0.15 -> lig = 80%str
end if
end do
end if

!! sum total community masses
pl_mass(j)%tot_com = pl_mass(j)%tot_com - pl_mass(j)%tot(ipl)
Expand Down
4 changes: 4 additions & 0 deletions src/mgt_newtillmix.f90
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ subroutine mgt_newtillmix (jj, bmix, idtill)
frac_non_mixed = 0.
emix = 0.
dtil = 0.
mix_clay = 0.
mix_silt = 0.
mix_sand = 0.

if (bmix > 1.e-6) then
!! biological mixing
emix = bmix !bmix MJW (rev 412)
Expand Down
26 changes: 6 additions & 20 deletions src/organic_mineral_mass_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ module organic_mineral_mass_module
implicit none

type organic_mass
real :: m = 0. !kg or kg/ha |total object mass
real :: c = 0. !kg or kg/ha |carbon mass
real :: n = 0. !kg or kg/ha |organic nitrogen mass
real :: p = 0. !kg or kg/ha |organic phosphorus mass
real :: m = 0. !kg/ha |total object mass
real :: c = 0. !kg/ha |carbon mass
real :: n = 0. !kg/ha |organic nitrogen mass
real :: p = 0. !kg/ha |organic phosphorus mass
end type organic_mass
type (organic_mass) :: orgz

Expand Down Expand Up @@ -127,22 +127,6 @@ module organic_mineral_mass_module
type (organic_mass) :: rsd_meta ! |temporary storage for initial metabolic litter
type (organic_mass) :: rsd_str ! |temporary storage for initial structural litter

type residue_mass1 !surface residue
character (len=16) :: name = ""
type (organic_mass), dimension(:), allocatable :: tot ! |total mass surface residue litter pool-dimensioned by plant
type (organic_mass), dimension(:), allocatable :: meta ! |metabolic litter pool-dimensioned by plant
type (organic_mass), dimension(:), allocatable :: str ! |structural litter pool-dimensioned by plant
type (organic_mass), dimension(:), allocatable :: lignin ! |lignin pool-dimensioned by plant
type (organic_mass) :: tot_com !kg/ha |total
type (organic_mass) :: tot_meta ! |
type (organic_mass) :: tot_str ! |
type (organic_mass) :: tot_lignin ! |
type (organic_mass) :: man ! |
end type residue_mass1
!soil profile object - dimensioned to number of hrus, using the hru pointer
type (residue_mass1), dimension(:), allocatable :: rsd1
type (residue_mass1), dimension(:), allocatable :: rsd1_init

type plant_community_mass
character(len=4) :: name = ""
type (organic_mass), dimension(:), allocatable :: tot !kg/ha |total biomass for individual plant in community
Expand Down Expand Up @@ -170,6 +154,8 @@ module organic_mineral_mass_module
type (organic_mass) :: graz_plant, graz_seed, graz_leaf, graz_stem
type (organic_mass) :: leaf_drop !kg/ha |organic mass of falling leaves
type (organic_mass) :: abgr_drop !kg/ha |above ground that dies at dormancy
type (organic_mass) :: stem_drop !kg/ha |stem that dies at dormancy
type (organic_mass) :: seed_drop !kg/ha |seed that dies at dormancy
type (organic_mass) :: plt_mass_z

type mineral_mass
Expand Down
18 changes: 8 additions & 10 deletions src/output_landscape_init.f90
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,6 @@ subroutine output_landscape_init
end if
endif

if (bsn_cc%cswat == 2) then
if (pco%nb_hru%a == "y") then
open (4553,file="hru_scf_aa.txt", recl = 1500)
write (4553,*) bsn%name, prog
Expand All @@ -451,7 +450,6 @@ subroutine output_landscape_init
write (9000,*) "HRU hru_scf_aa.csv"
end if
endif
end if

!!!NEW SOIL TRANSFORMATIONS CARBON OUTPUT

Expand Down Expand Up @@ -479,18 +477,18 @@ subroutine output_landscape_init
end if
endif

open (4561,file = "hru_resc_stat.txt", recl = 1500)
if (pco%nb_hru%a == "y") then
open (4561,file = "hru_rsdc_stat.txt", recl = 1500)
write (4561,*) bsn%name, prog
write (4561,*) resc_hdr
write (4561,*) resc_hdr_units
write (9000,*) "HRU hru_resc_stat.txt"
write (4561,*) rsdc_hdr
write (4561,*) rsdc_hdr_units
write (9000,*) "HRU hru_rsdc_stat.txt"
if (pco%csvout == "y") then
open (4564,file="hru_resc_stat.csv", recl = 1500)
open (4564,file="hru_rsdc_stat.csv", recl = 1500)
write (4564,*) bsn%name, prog
write (4564,'(*(G0.3,:,","))') resc_hdr
write (4564,'(*(G0.3,:,","))') resc_hdr_units
write (9000,*) "HRU hru_resc_stat.csv"
write (4564,'(*(G0.3,:,","))') rsdc_hdr
write (4564,'(*(G0.3,:,","))') rsdc_hdr_units
write (9000,*) "HRU hru_rsdc_stat.csv"
end if
endif

Expand Down
28 changes: 18 additions & 10 deletions src/output_landscape_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -815,23 +815,27 @@ module output_landscape_module

!! NEW RESIDUE CARBON STAT OUTPUT

type output_resc_header
type output_rsdc_header
character (len=11) :: day = " jday"
character (len=11) :: mo = " mon"
character (len=11) :: day_mo = " day"
character (len=11) :: yrc = " yr"
character (len=16) :: isd = " unit"
character (len=21) :: id = " gis_id "
character (len=16) :: name = " name "
character(len=15) :: tot_c = " tot_c"
character(len=15) :: meta_c = " meta_c"
character(len=15) :: str_c = " str_c"
character(len=15) :: lig_c = " lig_c"
character(len=15) :: tot_surf_c = " tot_surf_c"
character(len=15) :: meta_surf_c = " meta_surf_c"
character(len=15) :: str_surf_c = " str_surf_c"
character(len=15) :: lig_surf_c = " lig_surf_c"
character(len=15) :: tot_soil_c = " tot_soil_c"
character(len=15) :: meta_soil_c = " meta_soil_c"
character(len=15) :: str_soil_c = " str_soil_c"
character(len=15) :: lig_soil_c = " lig_soil_c"

end type output_resc_header
type (output_resc_header) :: resc_hdr
end type output_rsdc_header
type (output_rsdc_header) :: rsdc_hdr

type output_resc_header_units
type output_rsdc_header_units
character (len=11) :: day = " "
character (len=11) :: mo = " "
character (len=11) :: day_mo = " "
Expand All @@ -843,8 +847,12 @@ module output_landscape_module
character(len=15) :: meta_c = " kg/ha"
character(len=15) :: str_c = " kg/ha"
character(len=15) :: lig_c = " kg/ha"
end type output_resc_header_units
type (output_resc_header_units) :: resc_hdr_units
character(len=15) :: tot_soil_c = " kg/ha"
character(len=15) :: meta_soil_c = " kg/ha"
character(len=15) :: str_soil_c = " kg/ha"
character(len=15) :: lig_soil_c = " kg/ha"
end type output_rsdc_header_units
type (output_rsdc_header_units) :: rsdc_hdr_units

!!! NEW RESIDUE CARBON STAT OUTPUT

Expand Down
23 changes: 15 additions & 8 deletions src/pl_dormant.f90
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ subroutine pl_dormant
integer :: idp = 0 ! |
integer :: iob = 0 ! |
integer :: iwgn = 0 ! |
integer :: ly = 0 ! |soil layer number
real :: rto = 0. ! |
real :: lai_init = 0. !
real :: lai_drop = 0.
Expand All @@ -34,7 +35,7 @@ subroutine pl_dormant
pcom(j)%plcur(ipl)%idorm = "y"
!! add dead stem mass to residue pool
rto = pldb(idp)%bm_dieoff
abgr_drop = rto * pl_mass(j)%stem(ipl)
stem_drop = rto * pl_mass(j)%stem(ipl)
!! drop lai to minimum if not already
lai_init = pcom(j)%plg(ipl)%lai
pcom(j)%plg(ipl)%lai = pldb(idp)%alai_min
Expand All @@ -51,18 +52,24 @@ subroutine pl_dormant
leaf_drop%n = max (0., leaf_drop%n)
leaf_drop%p = leaf_drop%m * pcom(j)%plm(ipl)%p_fr
leaf_drop%p = max (0., leaf_drop%p)
!! add all seed/fruit mass to residue pool
seed_drop = pl_mass(j)%seed(ipl)
abgr_drop = stem_drop + leaf_drop + seed_drop

pl_mass(j)%tot(ipl) = pl_mass(j)%tot(ipl) - abgr_drop - leaf_drop
pl_mass(j)%ab_gr(ipl) = pl_mass(j)%ab_gr(ipl) - abgr_drop - leaf_drop
pl_mass(j)%stem(ipl) = pl_mass(j)%stem(ipl) - abgr_drop
pl_mass(j)%leaf(ipl) = pl_mass(j)%leaf(ipl) - leaf_drop
soil1(j)%rsd(1) = soil1(j)%rsd(1) + abgr_drop + leaf_drop
!! add all seed/fruit mass to residue poolpool
abgr_drop = pl_mass(j)%seed(ipl)
!! add all seed/fruit mass to residue pool
pl_mass(j)%tot(ipl) = pl_mass(j)%tot(ipl) - abgr_drop
pl_mass(j)%ab_gr(ipl) = pl_mass(j)%ab_gr(ipl) - abgr_drop
pl_mass(j)%stem(ipl) = pl_mass(j)%stem(ipl) - stem_drop
pl_mass(j)%leaf(ipl) = pl_mass(j)%leaf(ipl) - leaf_drop
pl_mass(j)%seed(ipl) = plt_mass_z

soil1(j)%rsd(1) = soil1(j)%rsd(1) + abgr_drop
if (bsn_cc%cswat == 2) then
soil1(j)%meta(ly) = soil1(j)%meta(ly) + 0.85 * abgr_drop
soil1(j)%str(ly) = soil1(j)%str(ly) + 0.15 * abgr_drop
soil1(j)%lig(ly) = soil1(j)%lig(ly) + 0.12 * abgr_drop ! 0.12 = 0.8 * 0.15 -> lig = 80%str
end if

end if

!! beginning of cool season annual dormant period
Expand Down
Loading

0 comments on commit b064c02

Please sign in to comment.