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

variable soil depth compatibility with CLM5 #381

Merged
merged 14 commits into from
Jun 1, 2018
Merged
Show file tree
Hide file tree
Changes from 10 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
20 changes: 14 additions & 6 deletions biogeochem/EDCanopyStructureMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ subroutine DemoteFromLayer(currentSite,currentPatch,i_lyr)

allocate(copyc)
if( hlm_use_planthydro.eq.itrue ) then
call InitHydrCohort(copyc)
call InitHydrCohort(currentSite,copyc)
endif
call copy_cohort(currentCohort, copyc) !

Expand Down Expand Up @@ -721,7 +721,7 @@ subroutine PromoteIntoLayer(currentSite,currentPatch,i_lyr)
if(cc_gain < currentCohort%c_area)then
allocate(copyc)
if( hlm_use_planthydro.eq.itrue ) then
call InitHydrCohort(copyc)
call InitHydrCohort(CurrentSite,copyc)
endif

call copy_cohort(currentCohort, copyc) !makes an identical copy...
Expand Down Expand Up @@ -890,10 +890,11 @@ subroutine canopy_summarization( nsites, sites, bc_in )

use FatesInterfaceMod , only : bc_in_type
use EDPatchDynamicsMod , only : set_patchno
use EDPatchDynamicsMod , only : set_root_fraction
use FatesAllometryMod , only : set_root_fraction
use FatesAllometryMod , only : i_hydro_rootprof_context
use FatesSizeAgeTypeIndicesMod, only : sizetype_class_index
use EDtypesMod , only : area
use EDPftvarcon , only : EDPftvarcon_inst
use EDPftvarcon , only : EDPftvarcon_inst

! !ARGUMENTS
integer , intent(in) :: nsites
Expand Down Expand Up @@ -928,8 +929,14 @@ subroutine canopy_summarization( nsites, sites, bc_in )

do while(associated(currentPatch))

call set_root_fraction(currentPatch,bc_in(s)%zi_sisl)

! Calculate rooting depth fractions for the patch x pft
do ft = 1, numpft
call set_root_fraction(currentPatch%rootfr_ft(ft,1:bc_in(s)%nlevsoil), ft, &
bc_in(s)%zi_sisl,lowerb=lbound(bc_in(s)%zi_sisl,1), &
icontext=i_hydro_rootprof_context)
end do


!zero cohort-summed variables.
currentPatch%total_canopy_area = 0.0_r8
currentPatch%total_tree_area = 0.0_r8
Expand All @@ -942,6 +949,7 @@ subroutine canopy_summarization( nsites, sites, bc_in )
ft = currentCohort%pft



! Update the cohort's index within the size bin classes
! Update the cohort's index within the SCPF classification system
call sizetype_class_index(currentCohort%dbh,currentCohort%pft, &
Expand Down
6 changes: 3 additions & 3 deletions biogeochem/EDCohortDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ subroutine create_cohort(currentSite, patchptr, pft, nn, hite, dbh, bleaf, bfine
new_cohort%isnew = .true.

if( hlm_use_planthydro.eq.itrue ) then
call InitHydrCohort(new_cohort)
call updateSizeDepTreeHydProps(new_cohort, bc_in)
call initTreeHydStates(currentSite,new_cohort, bc_in)
call InitHydrCohort(CurrentSite,new_cohort)
call updateSizeDepTreeHydProps(CurrentSite,new_cohort, bc_in)
call initTreeHydStates(CurrentSite,new_cohort, bc_in)
if(recruitstatus==1)then
new_cohort%co_hydr%is_newly_recuited = .true.
endif
Expand Down
60 changes: 12 additions & 48 deletions biogeochem/EDPatchDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ module EDPatchDynamicsMod
use EDTypesMod , only : dtype_ilog
use EDTypesMod , only : dtype_ifire
use FatesInterfaceMod , only : hlm_use_planthydro
use FatesInterfaceMod , only : hlm_numlevgrnd
use FatesInterfaceMod , only : hlm_numlevsoil
use FatesInterfaceMod , only : hlm_numSWb
use FatesInterfaceMod , only : bc_in_type
use FatesInterfaceMod , only : hlm_days_per_year
Expand Down Expand Up @@ -57,7 +55,6 @@ module EDPatchDynamicsMod
public :: disturbance_rates
public :: check_patch_area
public :: set_patchno
public :: set_root_fraction
private:: fuse_2_patches

character(len=*), parameter, private :: sourcefile = &
Expand Down Expand Up @@ -346,7 +343,7 @@ subroutine spawn_patches( currentSite, bc_in)
allocate(new_patch)
call create_patch(currentSite, new_patch, age, site_areadis, &
cwd_ag_local, cwd_bg_local, leaf_litter_local, &
root_litter_local)
root_litter_local, bc_in%nlevsoil)

new_patch%tallest => null()
new_patch%shortest => null()
Expand Down Expand Up @@ -381,7 +378,7 @@ subroutine spawn_patches( currentSite, bc_in)
do while(associated(currentCohort))

allocate(nc)
if(hlm_use_planthydro.eq.itrue) call InitHydrCohort(nc)
if(hlm_use_planthydro.eq.itrue) call InitHydrCohort(CurrentSite,nc)
call zero_cohort(nc)

! nc is the new cohort that goes in the disturbed patch (new_patch)... currentCohort
Expand Down Expand Up @@ -1132,7 +1129,7 @@ end subroutine mortality_litter_fluxes

! ============================================================================
subroutine create_patch(currentSite, new_patch, age, areap,cwd_ag_local,cwd_bg_local, &
leaf_litter_local,root_litter_local)
leaf_litter_local,root_litter_local,nlevsoil)
!
! !DESCRIPTION:
! Set default values for creating a new patch
Expand All @@ -1142,12 +1139,13 @@ subroutine create_patch(currentSite, new_patch, age, areap,cwd_ag_local,cwd_bg_l
! !ARGUMENTS:
type(ed_site_type) , intent(inout), target :: currentSite
type(ed_patch_type), intent(inout), target :: new_patch
real(r8), intent(in) :: age ! notional age of this patch in years
real(r8), intent(in) :: areap ! initial area of this patch in m2.
real(r8), intent(in) :: cwd_ag_local(:) ! initial value of above ground coarse woody debris. KgC/m2
real(r8), intent(in) :: cwd_bg_local(:) ! initial value of below ground coarse woody debris. KgC/m2
real(r8), intent(in) :: root_litter_local(:)! initial value of root litter. KgC/m2
real(r8), intent(in) :: leaf_litter_local(:)! initial value of leaf litter. KgC/m2
real(r8), intent(in) :: age ! notional age of this patch in years
real(r8), intent(in) :: areap ! initial area of this patch in m2.
real(r8), intent(in) :: cwd_ag_local(:) ! initial value of above ground coarse woody debris. KgC/m2
real(r8), intent(in) :: cwd_bg_local(:) ! initial value of below ground coarse woody debris. KgC/m2
real(r8), intent(in) :: root_litter_local(:) ! initial value of root litter. KgC/m2
real(r8), intent(in) :: leaf_litter_local(:) ! initial value of leaf litter. KgC/m2
integer, intent(in) :: nlevsoil ! number of soil layers
!
! !LOCAL VARIABLES:
!---------------------------------------------------------------------
Expand All @@ -1160,8 +1158,8 @@ subroutine create_patch(currentSite, new_patch, age, areap,cwd_ag_local,cwd_bg_l
allocate(new_patch%fabi(hlm_numSWb))
allocate(new_patch%sabs_dir(hlm_numSWb))
allocate(new_patch%sabs_dif(hlm_numSWb))
allocate(new_patch%rootfr_ft(numpft,hlm_numlevgrnd))
allocate(new_patch%rootr_ft(numpft,hlm_numlevgrnd))
allocate(new_patch%rootfr_ft(numpft,nlevsoil))
allocate(new_patch%rootr_ft(numpft,nlevsoil))

call zero_patch(new_patch) !The nan value in here is not working??

Expand Down Expand Up @@ -1906,38 +1904,4 @@ function countPatches( nsites, sites ) result ( totNumPatches )

end function countPatches

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

subroutine set_root_fraction( cpatch , zi )
!
! !DESCRIPTION:
! Calculates the fractions of the root biomass in each layer for each pft.
!
! !USES:

!
! !ARGUMENTS
type(ed_patch_type),intent(inout), target :: cpatch
real(r8),intent(in) :: zi(0:hlm_numlevsoil)
!
! !LOCAL VARIABLES:
integer :: lev,p,c,ft
!----------------------------------------------------------------------

do ft = 1,numpft
do lev = 1, hlm_numlevgrnd
cpatch%rootfr_ft(ft,lev) = 0._r8
enddo

do lev = 1, hlm_numlevsoil-1
cpatch%rootfr_ft(ft,lev) = .5_r8*( &
exp(-EDPftvarcon_inst%roota_par(ft) * zi(lev-1)) &
+ exp(-EDPftvarcon_inst%rootb_par(ft) * zi(lev-1)) &
- exp(-EDPftvarcon_inst%roota_par(ft) * zi(lev)) &
- exp(-EDPftvarcon_inst%rootb_par(ft) * zi(lev)))
end do
end do

end subroutine set_root_fraction

end module EDPatchDynamicsMod
Loading