From aa3db21bcc6f53cafdbfa218c9a0a06c92ac1e63 Mon Sep 17 00:00:00 2001 From: Taci Ugraskan <143652012+tugraskan@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:08:48 -0600 Subject: [PATCH 01/11] Refactor biomass and residue pool handling in mgt_killop.f90 - Removed dependency on soil(j)%ly(1)%rtfr for calculating meta(1), str(1), and lig(1) when bsn_cc%cswat == 2, using pl_mass(j)%ab_gr(ipl) instead. - Modified loop for adding dead roots to soil residue pools to start from ly = 2. --- src/mgt_killop.f90 | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/mgt_killop.f90 b/src/mgt_killop.f90 index 9cdc5a6..9290e13 100644 --- a/src/mgt_killop.f90 +++ b/src/mgt_killop.f90 @@ -28,14 +28,13 @@ 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) @@ -43,7 +42,6 @@ subroutine mgt_killop (jj, iplant) 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) From dbed7f8ab1287eb1db67de4ad3f981fb87876c6a Mon Sep 17 00:00:00 2001 From: Taci Ugraskan <143652012+tugraskan@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:11:18 -0600 Subject: [PATCH 02/11] Refactor soil nutrient allocation and update comments in pl_fert.f90 - Removed initialization of unused variables and allocation of organic fertilizer to soil pools. - Added N and P addition to active humus, manure, and slow humus pools. - Updated summary calculations with a return statement. --- src/pl_fert.f90 | 151 +++++++++++------------------------------------- 1 file changed, 33 insertions(+), 118 deletions(-) diff --git a/src/pl_fert.f90 b/src/pl_fert.f90 index f349305..b3607b0 100644 --- a/src/pl_fert.f90 +++ b/src/pl_fert.f90 @@ -30,35 +30,7 @@ subroutine pl_fert (ifrt, frt_kg, fertop) real, intent (in) :: frt_kg !kg/ha |amount of fertilizer applied real :: xx = 0. ! | - !!added by zhang - !!====================== - real :: X1 = 0. - real :: X8 = 0. - real :: X10 = 0. - real :: XXX = 0. - real :: YY = 0. - real :: ZZ = 0. - real :: XZ = 0. - real :: YZ = 0. - real :: RLN = 0. - real :: orgc_f = 0. - j = ihru - - X1 = 0. - X8 = 0. - X10 = 0. - XXX = 0. - YY = 0. - ZZ = 0. - XZ = 0. - YZ = 0. - RLN = 0. - orgc_f = 0. - !!added by zhang - !!====================== - - !j = jj do l = 1, 2 xx = 0. @@ -68,109 +40,51 @@ subroutine pl_fert (ifrt, frt_kg, fertop) xx = 1. - chemapp_db(fertop)%surf_frac endif + !! add mineral n and p for all methods soil1(j)%mn(l)%no3 = soil1(j)%mn(l)%no3 + xx * frt_kg * & - (1. - fertdb(ifrt)%fnh3n) * fertdb(ifrt)%fminn + (1. - fertdb(ifrt)%fnh3n) * fertdb(ifrt)%fminn + soil1(j)%mn(l)%nh4 = soil1(j)%mn(l)%nh4 + xx * frt_kg * & + fertdb(ifrt)%fnh3n * fertdb(ifrt)%fminn + soil1(j)%mp(l)%lab = soil1(j)%mp(l)%lab + xx * frt_kg * & + fertdb(ifrt)%fminp - if (bsn_cc%cswat == 0) then + !! add total organic n and p for all methods soil1(j)%tot(l)%n = soil1(j)%tot(l)%n + rtof * xx * frt_kg * & fertdb(ifrt)%forgn - soil1(j)%hact(l)%n = soil1(j)%hact(l)%n + (1. - rtof) * xx * & - frt_kg * fertdb(ifrt)%forgn soil1(j)%tot(l)%p = soil1(j)%tot(l)%p + rtof * xx * frt_kg * & fertdb(ifrt)%forgp - soil1(j)%hsta(l)%p = soil1(j)%hsta(l)%p + (1. - rtof)*xx*frt_kg * & + + !! for stable carbon - add n and p to active humus pool + if (bsn_cc%cswat == 0) then + soil1(j)%hact(l)%n = soil1(j)%hact(l)%n + (1. - rtof) * xx * & + frt_kg * fertdb(ifrt)%forgn + soil1(j)%hact(l)%p = soil1(j)%hsta(l)%p + (1. - rtof)*xx*frt_kg * & fertdb(ifrt)%forgp end if - if (bsn_cc%cswat == 1) then - soil1(j)%man(l)%c = soil1(j)%man(l)%c + xx * frt_kg * & - fertdb(ifrt)%forgn * 10. - soil1(j)%man(l)%n = soil1(j)%man(l)%n + xx * frt_kg * & - fertdb(ifrt)%forgn - soil1(j)%man(l)%p = soil1(j)%man(l)%p + xx * frt_kg * & - fertdb(ifrt)%forgp - end if - - !!By Zhang for C/N cycling - !!=========================== - if (bsn_cc%cswat == 2) then - soil1(j)%tot(l)%p = soil1(j)%tot(l)%p + rtof * xx * & - frt_kg * fertdb(ifrt)%forgp - soil1(j)%hsta(l)%p = soil1(j)%hsta(l)%p + (1. - rtof) * xx * & - frt_kg * fertdb(ifrt)%forgp - !!Allocate organic fertilizer to Slow (SWAT_active) N pool; - soil1(j)%hact(l)%n = soil1(j)%hact(l)%n + (1. - rtof) * xx * & - frt_kg * fertdb(ifrt)%forgn - - !orgc_f is the fraction of organic carbon in fertilizer - !for most fertilziers this value is set to 0. - orgc_f = 0.0 - !X1 is fertlizer applied to layer (kg/ha) - !xx is fraction of fertilizer applied to layer - X1 = xx * frt_kg - !X8: organic carbon applied (kg C/ha) - X8 = X1 * orgc_f - !RLN is calculated as a function of C:N ration in fertilizer - RLN = .175 *(orgc_f)/(fertdb(ifrt)%fminn + fertdb(ifrt)%forgn & - + 1.e-5) - - !X10 is the fraction of carbon in fertilizer that is allocated to metabolic litter C pool - X10 = .85-.018*RLN - if (X10<0.01) then - X10 = 0.01 - else - if (X10 > .7) then - X10 = .7 - end if - end if - - !XXX is the amount of organic carbon allocated to metabolic litter C pool - XXX = X8 * X10 - soil1(j)%meta(l)%c = soil1(j)%meta(l)%c + XXX - !YY is the amount of fertilizer (including C and N) allocated into metabolic litter SOM pool - YY = X1 * X10 - soil1(j)%meta(l)%m = soil1(j)%meta(l)%m + YY - - !ZZ is amount of organic N allocated to metabolic litter N pool - ZZ = X1 *rtof * fertdb(ifrt)%forgn * X10 - - - soil1(j)%meta(l)%n = soil1(j)%meta(l)%n + ZZ - - !!remaining organic N is llocated to structural litter N pool - soil1(j)%str(l)%n = soil1(j)%str(l)%n + X1 * fertdb(ifrt)%forgn - ZZ - !XZ is the amount of organic carbon allocated to structural litter C pool - XZ = X1 *orgc_f-XXX - soil1(j)%str(l)%c = soil1(j)%str(l)%c + XZ - - !assuming lignin C fraction of organic carbon to be 0.175; updating lignin amount in strucutral litter pool - soil1(j)%lig(l)%c = soil1(j)%lig(l)%c + XZ * .175 - !non-lignin part of the structural litter C is also updated; - soil1(j)%lig(l)%n = soil1(j)%lig(l)%n + XZ * (1.-.175) - - !YZ is the amount of fertilizer (including C and N) allocated into strucutre litter SOM pool - YZ = X1 - YY - soil1(j)%str(l)%m = soil1(j)%str(l)%m + YZ - !assuming lignin fraction of the organic fertilizer allocated into structure litter SOM pool to be 0.175; - !update lignin weight in structural litter. - soil1(j)%lig(l)%m = soil1(j)%lig(l)%m + YZ*.175 - soil1(j)%tot(l)%n = soil1(j)%meta(l)%n + soil1(j)%str(l)%n - - !end if - - end if - !!By Zhang for C/N cycling - !!=========================== - - soil1(j)%mn(l)%nh4 = soil1(j)%mn(l)%nh4 + xx * frt_kg * & - fertdb(ifrt)%fnh3n * fertdb(ifrt)%fminn + !! for C-FARM add to manure pool - assume C:N ratio = 10 + if (bsn_cc%cswat == 1) then + soil1(j)%man(l)%c = soil1(j)%man(l)%c + xx * frt_kg * & + fertdb(ifrt)%forgn * 10. + soil1(j)%man(l)%n = soil1(j)%man(l)%n + xx * frt_kg * & + fertdb(ifrt)%forgn + soil1(j)%man(l)%p = soil1(j)%man(l)%p + xx * frt_kg * & + fertdb(ifrt)%forgp + end if - soil1(j)%mp(l)%lab = soil1(j)%mp(l)%lab + xx * frt_kg * & - fertdb(ifrt)%fminp + !! for SWAT-C (Century) add n and p to slow humus pool - assume C:N ratio = 10 + if (bsn_cc%cswat == 2) then + soil1(j)%hs(l)%c = soil1(j)%hs(l)%c + xx * frt_kg * & + fertdb(ifrt)%forgn * 10. + soil1(j)%hs(l)%n = soil1(j)%hs(l)%n + xx * frt_kg * & + fertdb(ifrt)%forgn + soil1(j)%hp(l)%p = soil1(j)%hs(l)%p + xx * frt_kg * & + fertdb(ifrt)%forgp + end if end do -!! summary calculations + !! summary calculations fertno3 = frt_kg * fertdb(ifrt)%fminn * (1. - fertdb(ifrt)%fnh3n) fertnh3 = frt_kg * (fertdb(ifrt)%fminn * fertdb(ifrt)%fnh3n) fertorgn = frt_kg * fertdb(ifrt)%forgn @@ -178,5 +92,6 @@ subroutine pl_fert (ifrt, frt_kg, fertop) fertorgp = frt_kg * fertdb(ifrt)%forgp fertn = fertn + frt_kg * (fertdb(ifrt)%fminn + fertdb(ifrt)%forgn) fertp = fertp + frt_kg * (fertdb(ifrt)%fminp + fertdb(ifrt)%forgp) + return end subroutine pl_fert \ No newline at end of file From aa134777839d6fa0944f97c3970fca82915258be Mon Sep 17 00:00:00 2001 From: Taci Ugraskan <143652012+tugraskan@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:14:35 -0600 Subject: [PATCH 03/11] Add pl_manure subroutine for N & P application in pl_manure.f90 A new subroutine `pl_manure` has been added to the `pl_manure.f90` file to handle the application of nitrogen (N) and phosphorus (P) based on the management file (.mgt). This subroutine utilizes several modules, including `mgt_operations_module`, `fertilizer_data_module`, `basin_module`, `organic_mineral_mass_module`, and `hru_module`. --- src/pl_manure.f90 | 183 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 src/pl_manure.f90 diff --git a/src/pl_manure.f90 b/src/pl_manure.f90 new file mode 100644 index 0000000..f193003 --- /dev/null +++ b/src/pl_manure.f90 @@ -0,0 +1,183 @@ + subroutine pl_manure (ifrt, frt_kg, fertop) + +!! ~ ~ ~ PURPOSE ~ ~ ~ +!! this subroutine applies N and P specified by date and +!! amount in the management file (.mgt) +!! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + +!! ~ ~ ~ SUBROUTINES/FUNCTIONS CALLED ~ ~ ~ +!! SWAT: Erfc + +!! ~ ~ ~ ~ ~ ~ END SPECIFICATIONS ~ ~ ~ ~ ~ ~ + + use mgt_operations_module + use fertilizer_data_module + use basin_module + use organic_mineral_mass_module + use hru_module, only : ihru, fertn, fertp, fertnh3, fertno3, fertorgn, fertorgp, fertp, & + fertsolp + + implicit none + + real, parameter :: rtof=0.5 !none |weighting factor used to partition the + ! |organic N & P concentration of septic effluent + ! |between the fresh organic and the stable + ! |organic pools + integer :: j = 0 !none |counter + integer :: l = 0 !none |counter + integer, intent (in) :: ifrt ! |fertilizer type from fert data base + integer, intent (in) :: fertop ! | + real, intent (in) :: frt_kg !kg/ha |amount of fertilizer applied + real :: xx = 0. ! | + + !!added by zhang + !!====================== + real :: X1 = 0. + real :: X8 = 0. + real :: X10 = 0. + real :: XXX = 0. + real :: YY = 0. + real :: ZZ = 0. + real :: XZ = 0. + real :: YZ = 0. + real :: RLN = 0. + real :: orgc_f = 0. + + j = ihru + + X1 = 0. + X8 = 0. + X10 = 0. + XXX = 0. + YY = 0. + ZZ = 0. + XZ = 0. + YZ = 0. + RLN = 0. + orgc_f = 0. + !!added by zhang + !!====================== + + !j = jj + + do l = 1, 2 + xx = 0. + if (l == 1) then + xx = chemapp_db(fertop)%surf_frac + else + xx = 1. - chemapp_db(fertop)%surf_frac + endif + + soil1(j)%mn(l)%no3 = soil1(j)%mn(l)%no3 + xx * frt_kg * & + (1. - fertdb(ifrt)%fnh3n) * fertdb(ifrt)%fminn + + if (bsn_cc%cswat == 0) then + soil1(j)%tot(l)%n = soil1(j)%tot(l)%n + rtof * xx * frt_kg * & + fertdb(ifrt)%forgn + soil1(j)%hact(l)%n = soil1(j)%hact(l)%n + (1. - rtof) * xx * & + frt_kg * fertdb(ifrt)%forgn + soil1(j)%tot(l)%p = soil1(j)%tot(l)%p + rtof * xx * frt_kg * & + fertdb(ifrt)%forgp + soil1(j)%hsta(l)%p = soil1(j)%hsta(l)%p + (1. - rtof)*xx*frt_kg * & + fertdb(ifrt)%forgp + end if + if (bsn_cc%cswat == 1) then + soil1(j)%man(l)%c = soil1(j)%man(l)%c + xx * frt_kg * & + fertdb(ifrt)%forgn * 10. + soil1(j)%man(l)%n = soil1(j)%man(l)%n + xx * frt_kg * & + fertdb(ifrt)%forgn + soil1(j)%man(l)%p = soil1(j)%man(l)%p + xx * frt_kg * & + fertdb(ifrt)%forgp + end if + + !!By Zhang for C/N cycling + !!=========================== + if (bsn_cc%cswat == 2) then + soil1(j)%tot(l)%p = soil1(j)%tot(l)%p + rtof * xx * & + frt_kg * fertdb(ifrt)%forgp + soil1(j)%hsta(l)%p = soil1(j)%hsta(l)%p + (1. - rtof) * xx * & + frt_kg * fertdb(ifrt)%forgp + + !!Allocate organic fertilizer to Slow (SWAT_active) N pool; + soil1(j)%hact(l)%n = soil1(j)%hact(l)%n + (1. - rtof) * xx * & + frt_kg * fertdb(ifrt)%forgn + + !orgc_f is the fraction of organic carbon in fertilizer + !for most fertilziers this value is set to 0. + orgc_f = 0.0 + !X1 is fertlizer applied to layer (kg/ha) + !xx is fraction of fertilizer applied to layer + X1 = xx * frt_kg + !X8: organic carbon applied (kg C/ha) + X8 = X1 * orgc_f + !RLN is calculated as a function of C:N ration in fertilizer + RLN = .175 *(orgc_f)/(fertdb(ifrt)%fminn + fertdb(ifrt)%forgn & + + 1.e-5) + + !X10 is the fraction of carbon in fertilizer that is allocated to metabolic litter C pool + X10 = .85-.018*RLN + if (X10<0.01) then + X10 = 0.01 + else + if (X10 > .7) then + X10 = .7 + end if + end if + + !XXX is the amount of organic carbon allocated to metabolic litter C pool + XXX = X8 * X10 + soil1(j)%meta(l)%c = soil1(j)%meta(l)%c + XXX + !YY is the amount of fertilizer (including C and N) allocated into metabolic litter SOM pool + YY = X1 * X10 + soil1(j)%meta(l)%m = soil1(j)%meta(l)%m + YY + + !ZZ is amount of organic N allocated to metabolic litter N pool + ZZ = X1 *rtof * fertdb(ifrt)%forgn * X10 + + + soil1(j)%meta(l)%n = soil1(j)%meta(l)%n + ZZ + + !!remaining organic N is llocated to structural litter N pool + soil1(j)%str(l)%n = soil1(j)%str(l)%n + X1 * fertdb(ifrt)%forgn - ZZ + !XZ is the amount of organic carbon allocated to structural litter C pool + XZ = X1 *orgc_f-XXX + soil1(j)%str(l)%c = soil1(j)%str(l)%c + XZ + + !assuming lignin C fraction of organic carbon to be 0.175; updating lignin amount in strucutral litter pool + soil1(j)%lig(l)%c = soil1(j)%lig(l)%c + XZ * .175 + !non-lignin part of the structural litter C is also updated; + soil1(j)%lig(l)%n = soil1(j)%lig(l)%n + XZ * (1.-.175) + + !YZ is the amount of fertilizer (including C and N) allocated into strucutre litter SOM pool + YZ = X1 - YY + soil1(j)%str(l)%m = soil1(j)%str(l)%m + YZ + !assuming lignin fraction of the organic fertilizer allocated into structure litter SOM pool to be 0.175; + !update lignin weight in structural litter. + soil1(j)%lig(l)%m = soil1(j)%lig(l)%m + YZ*.175 + soil1(j)%tot(l)%n = soil1(j)%meta(l)%n + soil1(j)%str(l)%n + + !end if + + end if + !!By Zhang for C/N cycling + !!=========================== + + soil1(j)%mn(l)%nh4 = soil1(j)%mn(l)%nh4 + xx * frt_kg * & + fertdb(ifrt)%fnh3n * fertdb(ifrt)%fminn + + soil1(j)%mp(l)%lab = soil1(j)%mp(l)%lab + xx * frt_kg * & + fertdb(ifrt)%fminp + + end do + +!! summary calculations + fertno3 = frt_kg * fertdb(ifrt)%fminn * (1. - fertdb(ifrt)%fnh3n) + fertnh3 = frt_kg * (fertdb(ifrt)%fminn * fertdb(ifrt)%fnh3n) + fertorgn = frt_kg * fertdb(ifrt)%forgn + fertsolp = frt_kg * fertdb(ifrt)%fminp + fertorgp = frt_kg * fertdb(ifrt)%forgp + fertn = fertn + frt_kg * (fertdb(ifrt)%fminn + fertdb(ifrt)%forgn) + fertp = fertp + frt_kg * (fertdb(ifrt)%fminp + fertdb(ifrt)%forgp) + + return + end subroutine pl_manure \ No newline at end of file From 35c6031f9a299a12efebd61bddffdb592a6ba773 Mon Sep 17 00:00:00 2001 From: Taci Ugraskan <143652012+tugraskan@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:17:16 -0600 Subject: [PATCH 04/11] Update total organic content calculation in soil_nutcarb_write.f90 - The calculation of `soil1(j)%tot_org` has been updated to include `soil_prof_meta`. --- src/soil_nutcarb_write.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/soil_nutcarb_write.f90 b/src/soil_nutcarb_write.f90 index aeb71c1..755f5c0 100644 --- a/src/soil_nutcarb_write.f90 +++ b/src/soil_nutcarb_write.f90 @@ -86,7 +86,7 @@ subroutine soil_nutcarb_write(out_freq) soil_prof_microb = soil_prof_microb + soil1(j)%microb(ly) soil_prof_water = soil_prof_water + soil1(j)%water(ly) end do - soil1(j)%tot_org = soil_prof_hs + soil_prof_hp + soil_prof_microb + soil1(j)%tot_org = soil_prof_hs + soil_prof_hp + soil_prof_microb + soil_prof_meta !write all organic carbon for the plant community write (4560,*) time%day, time%mo, time%day_mo, time%yrc, j, ob(iob)%gis_id, ob(iob)%name, & From 011b76a8c5420908248c87e1e7ca883a4a711b44 Mon Sep 17 00:00:00 2001 From: Taci Ugraskan <143652012+tugraskan@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:18:27 -0600 Subject: [PATCH 05/11] Initialize mix_clay, mix_silt, and mix_sand to 0 in mgt_newtillmix.f90 - Added initialization of mix_clay, mix_silt, and mix_sand variables to 0. --- src/mgt_newtillmix.f90 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mgt_newtillmix.f90 b/src/mgt_newtillmix.f90 index b65080e..6a02190 100644 --- a/src/mgt_newtillmix.f90 +++ b/src/mgt_newtillmix.f90 @@ -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) From e393bc34e47c1cfb64c97ec8b5f20b13e1c2a627 Mon Sep 17 00:00:00 2001 From: Taci Ugraskan <143652012+tugraskan@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:20:33 -0600 Subject: [PATCH 06/11] Add variables for stem and seed mass in organic_mineral_mass_module.f90 - Introduced `stem_drop` and `seed_drop` variables of type `organic_mass` - Update units in organic_mass type to kg/ha only --- src/organic_mineral_mass_module.f90 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/organic_mineral_mass_module.f90 b/src/organic_mineral_mass_module.f90 index 071becc..2588f0d 100644 --- a/src/organic_mineral_mass_module.f90 +++ b/src/organic_mineral_mass_module.f90 @@ -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 @@ -170,6 +170,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 From c3951bbff59a34e13257b266fad34d0400d49ad0 Mon Sep 17 00:00:00 2001 From: Taci Ugraskan <143652012+tugraskan@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:39:25 -0600 Subject: [PATCH 07/11] Remove residue_mass1 type and variables in organic_mineral_mass_module --- src/organic_mineral_mass_module.f90 | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/organic_mineral_mass_module.f90 b/src/organic_mineral_mass_module.f90 index 2588f0d..fc5d4b7 100644 --- a/src/organic_mineral_mass_module.f90 +++ b/src/organic_mineral_mass_module.f90 @@ -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 From ffab7e2b7e5f61d58743cff04ffaf97558908026 Mon Sep 17 00:00:00 2001 From: Taci Ugraskan <143652012+tugraskan@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:42:30 -0600 Subject: [PATCH 08/11] Rename & update output header types/variables in output_landscape_module Renamed `output_resc_header` to `output_rsdc_header` and `output_resc_header_units` to `output_rsdc_header_units`. --- src/output_landscape_module.f90 | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/output_landscape_module.f90 b/src/output_landscape_module.f90 index 2aa1172..6fc229f 100644 --- a/src/output_landscape_module.f90 +++ b/src/output_landscape_module.f90 @@ -815,7 +815,7 @@ 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" @@ -823,15 +823,19 @@ module output_landscape_module 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 = " " @@ -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 From 4ccb648523f176b3d31a838963cde3c17659a72a Mon Sep 17 00:00:00 2001 From: Taci Ugraskan <143652012+tugraskan@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:44:41 -0600 Subject: [PATCH 09/11] Enhance perennial dormant period logic and cleanup in Pl_dormant.f90 - Added a new integer variable `ly` to track the soil layer number. - new variable `seed_drop` for seed/fruit mass in the residue pool. - Updated `abgr_drop` calculation to include `stem_drop`, `leaf_drop`, and `seed_drop`. Adjusted `pl_mass` updates to correctly subtract `stem_drop` and `leaf_drop`. - Added a conditional block to update soil metadata (`meta`, `str`, and `lig`) based on `bsn_cc%cswat`. - Removed redundant or incorrect lines related to seed/fruit mass addition and `pl_mass` and `soil1` updates. --- src/pl_dormant.f90 | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/pl_dormant.f90 b/src/pl_dormant.f90 index 8c5d59d..a887660 100644 --- a/src/pl_dormant.f90 +++ b/src/pl_dormant.f90 @@ -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. @@ -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 @@ -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 From 0db886689e2e71929f899cec529cb3f71bbd3e4f Mon Sep 17 00:00:00 2001 From: Taci Ugraskan <143652012+tugraskan@users.noreply.github.com> Date: Mon, 9 Dec 2024 15:03:05 -0600 Subject: [PATCH 10/11] Update file handling and output in output_landscape_init.f90 - Add new output files and headers for soil transformations and carbon output. - Replace "resc" with "rsdc" in file names and headers. - Update output messages to reflect the new file names. --- src/output_landscape_init.f90 | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/output_landscape_init.f90 b/src/output_landscape_init.f90 index fb70246..8738f78 100644 --- a/src/output_landscape_init.f90 +++ b/src/output_landscape_init.f90 @@ -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 @@ -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 @@ -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 From b3b930ad6f5b25ce9fda4afc78d7fc8c583874d5 Mon Sep 17 00:00:00 2001 From: Taci Ugraskan <143652012+tugraskan@users.noreply.github.com> Date: Mon, 9 Dec 2024 15:27:50 -0600 Subject: [PATCH 11/11] Enhance soil residue handling and biomass calculations in pl_mortality - Added `use soil_module`. - Introduced a new integer variable `ly` to represent the soil layer number. - Modified the calculation of surface residue pools by adding above-ground biomass to the surface residue pools. -- Added a conditional block to check if `bsn_cc%cswat` equals 2, and if true, updated the `meta`, `str`, and `lig` pools in the first soil layer with specific fractions of the above-ground biomass. -- Added a new block to handle the addition of dead roots to soil residue pools, iterating over each soil layer and updating the `rsd`, `meta`, `str`, and `lig` pools based on the root fraction and specific fractions of the root biomass. --- src/pl_mortality.f90 | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/pl_mortality.f90 b/src/pl_mortality.f90 index 9388cb2..4c6996b 100644 --- a/src/pl_mortality.f90 +++ b/src/pl_mortality.f90 @@ -6,11 +6,13 @@ subroutine pl_mortality use plant_module use carbon_module use organic_mineral_mass_module + use soil_module implicit none integer :: j = 0 !none |HRU number integer :: idp = 0 ! | + integer :: ly = 0 ! |soil layer number real :: bm_dieoff = 0. real :: rto = 0. real :: rto1 = 0. @@ -35,7 +37,27 @@ subroutine pl_mortality !! add dead material to residue rto1 = 1. - rto rto1 = max (0., rto1) - soil1(j)%rsd(1) = soil1(j)%rsd(1) + rto1 * pl_mass(j)%tot(ipl) + + !! add above ground biomass to surface residue pools + soil1(j)%rsd(1) = soil1(j)%rsd(1) + rto1 * pl_mass(j)%ab_gr(ipl) + if (bsn_cc%cswat == 2) then + soil1(j)%meta(1) = soil1(j)%meta(1) + 0.85 * rto1 * pl_mass(j)%ab_gr(ipl) + soil1(j)%str(1) = soil1(j)%str(1) + 0.15 * rto1 * pl_mass(j)%ab_gr(ipl) + soil1(j)%lig(1) = soil1(j)%lig(1) + 0.12 * rto1 * 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 + 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 * rto1 * soil(j)%ly(ly)%rtfr * pl_mass(j)%root(ipl) + soil1(j)%str(ly) = soil1(j)%str(ly) + 0.15 * rto1 * soil(j)%ly(ly)%rtfr * pl_mass(j)%root(ipl) + soil1(j)%lig(ly) = soil1(j)%lig(ly) + 0.12 * rto1 * 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 + end if return