Skip to content

Commit

Permalink
Merge branch 'BabyDriver' into VM_LLPFT.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaRady committed Aug 17, 2021
2 parents 50329a7 + 8009933 commit e5b9fe9
Show file tree
Hide file tree
Showing 5 changed files with 2,628 additions and 735 deletions.
37 changes: 13 additions & 24 deletions biogeochem/EDCohortDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -595,10 +595,9 @@ subroutine nan_cohort(cc_p)
currentCohort%l_degrad = nan

! Vegetation management:
currentCohort%vm_mort_in_place = nan
currentCohort%vm_mort_bole_harvest = nan
currentCohort%vm_pfrac_in_place = nan
currentCohort%vm_pfrac_bole_harvest = nan
currentCohort%vm_mortfrac = nan
currentCohort%vm_pfrac = nan


currentCohort%c_area = nan ! areal extent of canopy (m2)
currentCohort%treelai = nan ! lai of tree (total leaf area (m2) / canopy area (m2)
Expand Down Expand Up @@ -670,10 +669,8 @@ subroutine zero_cohort(cc_p)
currentCohort%lmort_direct = 0._r8
currentCohort%lmort_infra = 0._r8
currentCohort%lmort_collateral = 0._r8
currentCohort%vm_mort_in_place = 0.0_r8
currentCohort%vm_mort_bole_harvest = 0.0_r8
currentCohort%vm_pfrac_in_place = 0.0_r8
currentCohort%vm_pfrac_bole_harvest = 0.0_r8
currentCohort%vm_mortfrac = 0.0_r8
currentCohort%vm_pfrac = 0.0_r8
currentCohort%l_degrad = 0._r8
currentCohort%leaf_cost = 0._r8
currentcohort%excl_weight = 0._r8
Expand Down Expand Up @@ -1445,18 +1442,12 @@ subroutine fuse_cohorts(currentSite, currentPatch, bc_in)
nextc%n*nextc%l_degrad)/newn

! Vegetation management:
currentCohort%vm_mort_in_place = &
(currentCohort%n * currentCohort%vm_mort_in_place + &
nextc%n * nextc%vm_mort_in_place) / newn
currentCohort%vm_mort_bole_harvest = &
(currentCohort%n * currentCohort%vm_mort_bole_harvest + &
nextc%n * nextc%vm_mort_bole_harvest) / newn
currentCohort%vm_pfrac_in_place = &
(currentCohort%n * currentCohort%vm_pfrac_in_place + &
nextc%n * nextc%vm_pfrac_in_place) / newn
currentCohort%vm_pfrac_bole_harvest = &
(currentCohort%n * currentCohort%vm_pfrac_bole_harvest + &
nextc%n * nextc%vm_pfrac_bole_harvest) / newn
currentCohort%vm_mortfrac = &
(currentCohort%n * currentCohort%vm_mortfrac + &
nextc%n * nextc%vm_mortfrac) / newn
currentCohort%vm_pfrac = &
(currentCohort%n * currentCohort%vm_pfrac + &
nextc%n * nextc%vm_pfrac) / newn

! biomass and dbh tendencies
currentCohort%ddbhdt = (currentCohort%n*currentCohort%ddbhdt + &
Expand Down Expand Up @@ -1889,10 +1880,8 @@ subroutine copy_cohort( currentCohort,copyc )
n%l_degrad =o%l_degrad

! Vegetation management:
n%vm_mort_in_place = o%vm_mort_in_place
n%vm_mort_bole_harvest = o%vm_mort_bole_harvest
n%vm_pfrac_in_place = o%vm_pfrac_in_place
n%vm_pfrac_bole_harvest = o%vm_pfrac_bole_harvest
n%vm_mortfrac = o%vm_mortfrac
n%vm_pfrac = o%vm_pfrac

! Flags
n%isnew = o%isnew
Expand Down
64 changes: 39 additions & 25 deletions biogeochem/EDPatchDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,8 @@ subroutine disturbance_rates( site_in, bc_in)
currentCohort%lmort_infra = 0.0_r8
currentCohort%l_degrad = 0.0_r8
! JMR_MOD_START:
currentCohort%vm_mort_in_place = 0.0_r8
currentCohort%vm_mort_bole_harvest = 0.0_r8
currentCohort%vm_pfrac_in_place = 0.0_r8
currentCohort%vm_pfrac_bole_harvest = 0.0_r8
currentCohort%vm_mortfrac = 0.0_r8
currentCohort%vm_pfrac = 0.0_r8
! JMR_MOD_END.
end if

Expand Down Expand Up @@ -426,10 +424,8 @@ subroutine disturbance_rates( site_in, bc_in)
currentCohort%lmort_infra = 0.0_r8
currentCohort%l_degrad = 0.0_r8
! JMR_MOD_START:
currentCohort%vm_mort_in_place = 0.0_r8
currentCohort%vm_mort_bole_harvest = 0.0_r8
currentCohort%vm_pfrac_in_place = 0.0_r8
currentCohort%vm_pfrac_bole_harvest = 0.0_r8
currentCohort%vm_mortfrac = 0.0_r8
currentCohort%vm_pfrac = 0.0_r8
! JMR_MOD_END.
end if
currentCohort => currentCohort%taller
Expand Down Expand Up @@ -752,10 +748,8 @@ subroutine spawn_patches( currentSite, bc_in)
nc%lmort_infra = nan
nc%l_degrad = nan
! JMR_MOD_START:
nc%vm_mort_in_place = nan
nc%vm_mort_bole_harvest = nan
nc%vm_pfrac_in_place = nan
nc%vm_pfrac_bole_harvest = nan
nc%vm_mortfrac= nan
nc%vm_pfrac = nan
! JMR_MOD_END.

else
Expand Down Expand Up @@ -812,10 +806,8 @@ subroutine spawn_patches( currentSite, bc_in)
nc%lmort_collateral = currentCohort%lmort_collateral
nc%lmort_infra = currentCohort%lmort_infra
! JMR_MOD_START:
nc%vm_mort_in_place = currentCohort%vm_mort_in_place
nc%vm_mort_bole_harvest = currentCohort%vm_mort_bole_harvest
nc%vm_pfrac_in_place = currentCohort%vm_pfrac_in_place
nc%vm_pfrac_bole_harvest = currentCohort%vm_pfrac_bole_harvest
nc%vm_mortfrac = currentCohort%vm_mortfrac
nc%vm_pfrac = currentCohort%vm_pfrac
! JMR_MOD_END.

! understory trees that might potentially be knocked over in the disturbance.
Expand Down Expand Up @@ -844,10 +836,8 @@ subroutine spawn_patches( currentSite, bc_in)
nc%lmort_collateral = currentCohort%lmort_collateral
nc%lmort_infra = currentCohort%lmort_infra
! JMR_MOD_START:
nc%vm_mort_in_place = currentCohort%vm_mort_in_place
nc%vm_mort_bole_harvest = currentCohort%vm_mort_bole_harvest
nc%vm_pfrac_in_place = currentCohort%vm_pfrac_in_place
nc%vm_pfrac_bole_harvest = currentCohort%vm_pfrac_bole_harvest
nc%vm_mortfrac = currentCohort%vm_mortfrac
nc%vm_pfrac = currentCohort%vm_pfrac
! JMR_MOD_END.

endif
Expand Down Expand Up @@ -907,10 +897,8 @@ subroutine spawn_patches( currentSite, bc_in)
nc%lmort_collateral = currentCohort%lmort_collateral
nc%lmort_infra = currentCohort%lmort_infra
! JMR_MOD_START:
nc%vm_mort_in_place = currentCohort%vm_mort_in_place
nc%vm_mort_bole_harvest = currentCohort%vm_mort_bole_harvest
nc%vm_pfrac_in_place = currentCohort%vm_pfrac_in_place
nc%vm_pfrac_bole_harvest = currentCohort%vm_pfrac_bole_harvest
nc%vm_mortfrac = currentCohort%vm_mortfrac
nc%vm_pfrac = currentCohort%vm_pfrac
! JMR_MOD_END.


Expand Down Expand Up @@ -2526,7 +2514,28 @@ subroutine fuse_2_patches(csite, dp, rp)

! Generate a litany of area weighted averages

inv_sum_area = 1.0_r8/(dp%area + rp%area)
! VM_MOD_Start:
!write(fates_log(),*) 'fuse_2_patches(): Starting----------'
!write(fates_log(),*) 'fuse_2_patches(): Donor Patch:'
!call dump_patch(dp)
!write(fates_log(),*) 'fuse_2_patches(): Recipient Patch:'
!call dump_patch(rp)

if (dp%area /= 0.0_r8 .or. rp%area /= 0.0_r8) then
! When at least one patch has a non-zero area the original math works fine:
inv_sum_area = 1.0_r8 / (dp%area + rp%area)
else
! If both patches have areas of zero the above inverse area will result in division by zero.
! For absolute stocks it makes sense that when the area is 0 the stocks should be 0, so we set
! inv_sum_area to 0. Also, under the conditions that produce a patch of area 0 the stocks are
! likely 0 already. Some of the quantities below are non-stock states, where values may not
! logically descend to 0. However, since the fused patch will have 0 area it is almost
! certainly bound for elimination and the values don't really matter anymore. We are mainly
! concerned with not breaking the math to produce NaNs.
!write(fates_log(),*) 'fuse_2_patches(): Both patches have 0 area.' ! Temporary reporting.
inv_sum_area = 0.0_r8
endif
! VM_MOD_END.

rp%age = (dp%age * dp%area + rp%age * rp%area) * inv_sum_area
rp%age_since_anthro_disturbance = (dp%age_since_anthro_disturbance * dp%area &
Expand Down Expand Up @@ -2655,6 +2664,11 @@ subroutine fuse_2_patches(csite, dp, rp)
csite%oldest_patch => youngerp
youngerp%older => null()
end if

! VM_MOD_Start: Temporary reporting:
!write(fates_log(),*) 'fuse_2_patches(): Recipient patch out:'
!call dump_patch(rp)
! VM_MOD_END.


end subroutine fuse_2_patches
Expand Down
19 changes: 17 additions & 2 deletions biogeochem/FatesLitterMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,23 @@ subroutine FuseLitter(this,self_area,donor_area,donor_litt)
nlevsoil = size(this%bg_cwd,dim=2)
npft = size(this%seed,dim=1)

self_weight = self_area /(donor_area+self_area)
donor_weight = 1._r8 - self_weight
! VM_MOD_Start:
if (donor_area /= 0.0_r8 .or. self_area /= 0.0_r8) then
! When at least one patch has a non-zero area the original math works fine:
self_weight = self_area / (donor_area + self_area)
donor_weight = 1.0_r8 - self_weight
else
! If both litter patches have areas of zero normalization will result in division by zero.
! There are two solutions. We can either say that at zero area the pools are also logically
! zero and set both weights to zero. Alternatively, we can still calculate a per area average
! based on the fact the patch areas are equal by settting the weights to 0.5. The choice is
! likely moot since the resulting parent patch will almost certainly be pruned. We will use
! the later for now since it doesn't assume as much about the fate of the parent patch.
self_weight = 0.5_r8 ! Or 0.0_r8
donor_weight = 0.5_r8 ! Or 0.0_r8
endif
! VM_MOD_End.



do c=1,ncwd
Expand Down
Loading

0 comments on commit e5b9fe9

Please sign in to comment.