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

Updates and fixes to maintenance respiration #138

Merged
merged 13 commits into from
Oct 31, 2016
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
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
27 changes: 7 additions & 20 deletions components/clm/src/ED/biogeochem/EDCanopyStructureMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ subroutine canopy_summarization( nsites, sites, bc_in )

use FatesInterfaceMod , only : bc_in_type
use EDPatchDynamicsMod , only : set_patchno
use EDCohortDynamicsMod , only : size_and_type_class_index
use EDGrowthFunctionsMod , only : tree_lai, c_area
use EDEcophysConType , only : EDecophyscon
use EDtypesMod , only : area
Expand All @@ -675,7 +676,6 @@ subroutine canopy_summarization( nsites, sites, bc_in )
integer :: ft ! plant functional type
integer :: ifp
integer :: patchn ! identification number for each patch.
real(r8) :: coarse_wood_frac
real(r8) :: canopy_leaf_area ! total amount of leaf area in the vegetated area. m2.

!----------------------------------------------------------------------
Expand Down Expand Up @@ -710,26 +710,13 @@ subroutine canopy_summarization( nsites, sites, bc_in )
do while(associated(currentCohort))

ft = currentCohort%pft
currentCohort%livestemn = currentCohort%bsw / pftcon%leafcn(currentCohort%pft)

currentCohort%livecrootn = 0.0_r8

if (pftcon%woody(ft) == 1) then
coarse_wood_frac = 0.5_r8
else
coarse_wood_frac = 0.0_r8
end if

if ( DEBUG ) then
write(fates_log(),*) 'canopy_summarization 724 ',currentCohort%livecrootn
write(fates_log(),*) 'canopy_summarization 725 ',currentCohort%br
write(fates_log(),*) 'canopy_summarization 726 ',coarse_wood_frac
write(fates_log(),*) 'canopy_summarization 727 ',pftcon%leafcn(ft)
endif

currentCohort%livecrootn = currentCohort%br * coarse_wood_frac / pftcon%leafcn(ft)


if ( DEBUG ) write(fates_log(),*) 'canopy_summarization 732 ',currentCohort%livecrootn
! Update the cohort's index within the size bin classes
! Update the cohort's index within the SCPF classification system
call size_and_type_class_index(currentCohort%dbh,currentCohort%pft, &
currentCohort%size_class,currentCohort%size_by_pft_class)


currentCohort%b = currentCohort%balive+currentCohort%bdead+currentCohort%bstore
currentCohort%treelai = tree_lai(currentCohort)
Expand Down
45 changes: 31 additions & 14 deletions components/clm/src/ED/biogeochem/EDCohortDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module EDCohortDynamicsMod
public :: sort_cohorts
public :: copy_cohort
public :: count_cohorts
! public :: countCohorts
public :: size_and_type_class_index
public :: allocate_live_biomass

logical, parameter :: DEBUG = .false. ! local debug flag
Expand Down Expand Up @@ -92,6 +92,9 @@ subroutine create_cohort(patchptr, pft, nn, hite, dbh, &
new_cohort%balive = balive
new_cohort%bstore = bstore

call size_and_type_class_index(new_cohort%dbh,new_cohort%pft, &
new_cohort%size_class,new_cohort%size_by_pft_class)

if ( DEBUG ) write(iulog,*) 'EDCohortDyn I ',bstore

if (new_cohort%dbh <= 0.0_r8 .or. new_cohort%n == 0._r8 .or. new_cohort%pft == 0 &
Expand Down Expand Up @@ -316,6 +319,8 @@ subroutine nan_cohort(cc_p)
currentCohort%canopy_layer = 999 ! canopy status of cohort (1 = canopy, 2 = understorey, etc.)
currentCohort%NV = 999 ! Number of leaf layers: -
currentCohort%status_coh = 999 ! growth status of plant (2 = leaves on , 1 = leaves off)
currentCohort%size_class = 999 ! size class index
Copy link
Contributor

Choose a reason for hiding this comment

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

These magic numbers should be replaced with a parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I grabbed your definition of fates_unset_int from the history PR, I will use that, we should expect a trivial merge conflict with either this or History refactors, which every gets pulled second.

I'm going to leave the nan initialization in that subroutine as is. I will be investigating that part of the code anyway while I'm applying the fix to #133.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not concerned about the conflict, it's easy enough to resolve. There are going to be a few conflicts with the hist mod anyway. At a minimum the set_hist_var calls need to be updated.

currentCohort%size_by_pft_class = 999 ! size by pft classification index

currentCohort%n = nan ! number of individuals in cohort per 'area' (10000m2 default)
currentCohort%dbh = nan ! 'diameter at breast height' in cm
Expand Down Expand Up @@ -361,7 +366,7 @@ subroutine nan_cohort(cc_p)


!RESPIRATION
currentCohort%rd = nan
currentCohort%rdark = nan
currentCohort%resp_m = nan ! Maintenance respiration. kGC/cohort/year
currentCohort%resp_g = nan ! Growth respiration. kGC/cohort/year
currentCohort%livestem_mr = nan ! Live stem maintenance respiration. kgC/indiv/s-1
Expand All @@ -381,11 +386,6 @@ subroutine nan_cohort(cc_p)
currentCohort%leaf_litter = nan ! leaf litter from phenology: KgC/m2
currentCohort%woody_turnover = nan ! amount of wood lost each day: kgC/indiv/year. Currently set to zero.

! NITROGEN POOLS
currentCohort%livestemn = nan ! live stem nitrogen : KgN/invid
currentCohort%livecrootn = nan ! live coarse root nitrogen: KgN/invid
currentCohort%frootn = nan ! fine root nitrogen : KgN/invid

! VARIABLES NEEDED FOR INTEGRATION
currentCohort%dndt = nan ! time derivative of cohort size
currentCohort%dhdt = nan ! time derivative of height
Expand Down Expand Up @@ -423,7 +423,7 @@ subroutine zero_cohort(cc_p)

currentCohort%NV = 0
currentCohort%status_coh = 0
currentCohort%rd = 0._r8
currentCohort%rdark = 0._r8
currentCohort%resp_m = 0._r8
currentCohort%resp_g = 0._r8
currentCohort%livestem_mr = 0._r8
Expand Down Expand Up @@ -1040,18 +1040,13 @@ subroutine copy_cohort( currentCohort,copyc )
n%npp_store = o%npp_store

!RESPIRATION
n%rd = o%rd
n%rdark = o%rdark
n%resp_m = o%resp_m
n%resp_g = o%resp_g
n%livestem_mr = o%livestem_mr
n%livecroot_mr = o%livecroot_mr
n%froot_mr = o%froot_mr

! NITROGEN POOLS
n%livestemn = o%livestemn
n%livecrootn = o%livecrootn
n%frootn = o%frootn

! ALLOCATION
n%md = o%md
n%leaf_md = o%leaf_md
Expand Down Expand Up @@ -1137,6 +1132,28 @@ function count_cohorts( currentPatch ) result ( backcount )

end function count_cohorts

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

subroutine size_and_type_class_index(dbh,pft,size_class,size_by_pft_class)

use EDTypesMod, only: sclass_ed, &
nlevsclass_ed

! Arguments
real(r8),intent(in) :: dbh
integer,intent(in) :: pft
integer,intent(out) :: size_class
integer,intent(out) :: size_by_pft_class

size_class = count(dbh-sclass_ed.ge.0.0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Need an _r8.


size_by_pft_class = (pft-1)*nlevsclass_ed+size_class

return
end subroutine size_and_type_class_index



!-------------------------------------------------------------------------------------!
! function countCohorts( bounds, ed_allsites_inst ) result ( totNumCohorts )
!
Expand Down
Loading