Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and standardize per-ageclass history #1252

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d7b5097
Refactor: Per-age outputs, in existing subroutines.
samsrabin Jul 17, 2024
3458eb6
Refactor: Age-class vars to update_history_hifrq2_ageclass().
samsrabin Sep 10, 2024
f66a99b
Refactor: Age-class vars to update_history_dyn2_ageclass().
samsrabin Sep 10, 2024
ae92beb
Bugfix: Add logging mortality to _SZAP outputs.
samsrabin Oct 3, 2024
9492573
Add non-per-ageclass versions of some history vars.
samsrabin Sep 17, 2024
8375545
Change 7 hist vars to not be normalized to age-class area.
samsrabin Oct 2, 2024
bf3684d
Bugfix: Update FATES_VEGC_APPF even if cohort is new.
samsrabin Oct 2, 2024
7e1bf60
Bugfix: Add termination mortality to _SZAP outputs.
samsrabin Oct 3, 2024
92ddeeb
Add postprocessing info to per-ageclass outputs.
samsrabin Oct 13, 2024
309086c
Cleanup: update_history_dyn2_ageclass().
samsrabin Oct 13, 2024
8356d40
Cleanup: update_history_hifrq2_ageclass().
samsrabin Oct 13, 2024
92c6ebd
Move more calculations to update_history_dyn2_ageclass().
samsrabin Oct 13, 2024
1aff666
Cleanup: FatesHistoryInterfaceMod.
samsrabin Oct 13, 2024
7d5d8f9
Move FATES_NCL from update_history_dyn2_ageclass() to update_history_…
samsrabin Oct 28, 2024
e11f2fd
Add units info to SumMortForHistory().
samsrabin Oct 28, 2024
4d22d79
update_history subroutine names/descriptions now more descriptive.
samsrabin Oct 28, 2024
ae499bf
update_history_dyn_subsite_ageclass(): Resolve a TODO.
samsrabin Oct 28, 2024
9d9da65
Delete unused canopy_area_by_age.
samsrabin Oct 28, 2024
bcc15e7
Rename _area_ vars in FatesHistoryInterfaceMod to _fracarea_.
samsrabin Oct 28, 2024
d967fdc
Fix some indentation.
samsrabin Oct 29, 2024
c60f83b
Resolve TODO about fire variable weighting.
samsrabin Oct 29, 2024
f54db49
Remove unneeded cohort class index updates.
samsrabin Oct 29, 2024
acb58bb
Add prt_vartypes subroutine GetBiomass().
samsrabin Nov 6, 2024
2242bd1
Add comment about reproductive mass being 0.
samsrabin Nov 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions biogeochem/FatesCohortMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ module FatesCohortMod
use FatesConstantsMod, only : ifalse, itrue
use FatesConstantsMod, only : nearzero
use FatesConstantsMod, only : ican_upper, ican_ustory
use FatesConstantsMod, only : sec_per_day, days_per_year
use FatesConstantsMod, only : days_per_sec, years_per_day
use EDParamsMod, only : nlevleaf
use EDParamsMod, only : nclmax
use FatesGlobals, only : endrun => fates_endrun
Expand Down Expand Up @@ -281,6 +283,7 @@ module FatesCohortMod
procedure :: Copy
procedure :: FreeMemory
procedure :: CanUpperUnder
procedure, public :: SumMortForHistory
procedure :: InitPRTBoundaryConditions
procedure :: UpdateCohortBioPhysRates
procedure :: Dump
Expand Down Expand Up @@ -1002,6 +1005,44 @@ end function CanUpperUnder

!===========================================================================

function SumMortForHistory(this, per_year) result(mort_sum)
samsrabin marked this conversation as resolved.
Show resolved Hide resolved
!
! DESCRIPTION:
! Sum the various cohort-level mortality variables for saving to history.
! Units depend on per_year:
! per_year true: kg m-2 yr-1
! per_year false: kg m-2 s-1

! ARGUMENTS:
class(fates_cohort_type) :: this ! current cohort of interest
logical :: per_year
!
! VARIABLES
! Units depend on per_year; see description above.
real(r8) :: mort_natural
samsrabin marked this conversation as resolved.
Show resolved Hide resolved
real(r8) :: mort_logging
real(r8) :: mort_sum

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets double check the units on the natural versus the logging mortality, I seem to remember they were different, such as their usage here:

https://github.com/NGEET/fates/blob/main/biogeochem/EDMortalityFunctionsMod.F90#L347-L354

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's what the per_year option is for—depending on its value, one will be converted into units of the other. I'll add units to comments in revision.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the problem is that one is in # individuals and the other is fraction.

  • Fix this.

Copy link
Contributor

@rgknox rgknox Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samsrabin here is an example of how to get total carbon biomass from the cohort, if you want to add it into this routine. This will help you convert from number of individuals to kgC:

https://github.com/NGEET/fates/blob/main/main/FatesHistoryInterfaceMod.F90#L3895-L3903

I looked at how this sum mortality was being used, and I had the units wrong, it looks like the function is being called with the expectation that the output units are not in carbon but the abundance rate.

Part of the confusion is related to our incorrect labeling of the rates on the cohort structures. Here is where we apply mortality to actually change number density, dndt is a fraction per time (because that fraction is multiplying by cohort%n:

https://github.com/NGEET/fates/blob/main/main/EDMainMod.F90#L804

https://github.com/NGEET/fates/blob/main/biogeochem/EDMortalityFunctionsMod.F90#L352-L354

! "Natural" mortality
mort_natural = this%bmort + this%hmort + this%cmort + this%frmort + this%smort + this%asmort + this%dgmort
if (.not. per_year) then
! Convert kg m-2 yr-1 to kg m-2 s-1
mort_natural = mort_natural * days_per_sec * years_per_day
end if

! Logging mortality
mort_logging = this%lmort_direct + this%lmort_collateral + this%lmort_infra
if (per_year) then
! Convert kg m-2 s-1 to kg m-2 yr-1
mort_logging = mort_logging * sec_per_day * days_per_year
end if

mort_sum = mort_natural + mort_logging

end function SumMortForHistory

!===========================================================================

subroutine Dump(this)
!
! DESCRIPTION:
Expand Down
Loading