Skip to content

Commit

Permalink
Conflict resolution between the parameter update and parteh loop sele…
Browse files Browse the repository at this point in the history
…ct statements
  • Loading branch information
rgknox committed Jun 19, 2022
2 parents 4c01c5a + 63bfacd commit f054c85
Show file tree
Hide file tree
Showing 11 changed files with 279 additions and 189 deletions.
4 changes: 2 additions & 2 deletions biogeochem/EDCohortDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -868,13 +868,13 @@ subroutine terminate_cohort(currentSite, currentPatch, currentCohort, bc_in)
currentSite%term_nindivs_canopy(currentCohort%size_class,currentCohort%pft) = &
currentSite%term_nindivs_canopy(currentCohort%size_class,currentCohort%pft) + currentCohort%n

currentSite%term_carbonflux_canopy = currentSite%term_carbonflux_canopy + &
currentSite%term_carbonflux_canopy(currentCohort%pft) = currentSite%term_carbonflux_canopy(currentCohort%pft) + &
currentCohort%n * (struct_c+sapw_c+leaf_c+fnrt_c+store_c+repro_c)
else
currentSite%term_nindivs_ustory(currentCohort%size_class,currentCohort%pft) = &
currentSite%term_nindivs_ustory(currentCohort%size_class,currentCohort%pft) + currentCohort%n

currentSite%term_carbonflux_ustory = currentSite%term_carbonflux_ustory + &
currentSite%term_carbonflux_ustory(currentCohort%pft) = currentSite%term_carbonflux_ustory(currentCohort%pft) + &
currentCohort%n * (struct_c+sapw_c+leaf_c+fnrt_c+store_c+repro_c)
end if

Expand Down
12 changes: 8 additions & 4 deletions biogeochem/EDPatchDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,8 @@ subroutine spawn_patches( currentSite, bc_in)
nc%n * ED_val_understorey_death / hlm_freq_day


currentSite%imort_carbonflux = currentSite%imort_carbonflux + &
currentSite%imort_carbonflux(currentCohort%pft) = &
currentSite%imort_carbonflux(currentCohort%pft) + &
(nc%n * ED_val_understorey_death / hlm_freq_day ) * &
total_c * g_per_kg * days_per_sec * years_per_day * ha_per_m2

Expand Down Expand Up @@ -879,7 +880,8 @@ subroutine spawn_patches( currentSite, bc_in)
currentSite%fmort_rate_canopy(currentCohort%size_class, currentCohort%pft) + &
nc%n * currentCohort%fire_mort / hlm_freq_day

currentSite%fmort_carbonflux_canopy = currentSite%fmort_carbonflux_canopy + &
currentSite%fmort_carbonflux_canopy(currentCohort%pft) = &
currentSite%fmort_carbonflux_canopy(currentCohort%pft) + &
(nc%n * currentCohort%fire_mort) * &
total_c * g_per_kg * days_per_sec * ha_per_m2

Expand All @@ -888,7 +890,8 @@ subroutine spawn_patches( currentSite, bc_in)
currentSite%fmort_rate_ustory(currentCohort%size_class, currentCohort%pft) + &
nc%n * currentCohort%fire_mort / hlm_freq_day

currentSite%fmort_carbonflux_ustory = currentSite%fmort_carbonflux_ustory + &
currentSite%fmort_carbonflux_ustory(currentCohort%pft) = &
currentSite%fmort_carbonflux_ustory(currentCohort%pft) + &
(nc%n * currentCohort%fire_mort) * &
total_c * g_per_kg * days_per_sec * ha_per_m2
end if
Expand Down Expand Up @@ -1020,7 +1023,8 @@ subroutine spawn_patches( currentSite, bc_in)
nc%n * currentPatch%fract_ldist_not_harvested * &
logging_coll_under_frac / hlm_freq_day

currentSite%imort_carbonflux = currentSite%imort_carbonflux + &
currentSite%imort_carbonflux(currentCohort%pft) = &
currentSite%imort_carbonflux(currentCohort%pft) + &
(nc%n * currentPatch%fract_ldist_not_harvested * &
logging_coll_under_frac/ hlm_freq_day ) * &
total_c * g_per_kg * days_per_sec * years_per_day * ha_per_m2
Expand Down
5 changes: 3 additions & 2 deletions biogeochem/FatesSoilBGCFluxMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,16 @@ subroutine UnPackNutrientAquisitionBCs(sites, bc_in)
end do

! We can exit if this is a c-only simulation
if(hlm_parteh_mode.eq.prt_carbon_allom_hyp) then
select case (hlm_parteh_mode)
case (prt_carbon_allom_hyp)
! These can now be zero'd
do s = 1, nsites
bc_in(s)%plant_nh4_uptake_flux(:,:) = 0._r8
bc_in(s)%plant_no3_uptake_flux(:,:) = 0._r8
bc_in(s)%plant_p_uptake_flux(:,:) = 0._r8
end do
return
end if
end select

do s = 1, nsites

Expand Down
1 change: 1 addition & 0 deletions biogeophys/FatesPlantRespPhotosynthMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ subroutine FatesPlantRespPhotosynthDrive (nsites, sites,bc_in,bc_out,dtime)

end select

! MLO - Shouldn't these numbers be parameters too?
lmr25top = 2.525e-6_r8 * (1.5_r8 ** ((25._r8 - 20._r8)/10._r8))
lmr25top = lmr25top * lnc_top / (umolC_to_kgC * g_per_kg)

Expand Down
18 changes: 12 additions & 6 deletions main/EDInitMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ subroutine init_site_vars( site_in, bc_in, bc_out )
allocate(site_in%growthflux_fusion(1:nlevsclass,1:numpft))
allocate(site_in%mass_balance(1:num_elements))
allocate(site_in%flux_diags(1:num_elements))


allocate(site_in%term_carbonflux_canopy(1:numpft))
allocate(site_in%term_carbonflux_ustory(1:numpft))
allocate(site_in%imort_carbonflux(1:numpft))
allocate(site_in%fmort_carbonflux_canopy(1:numpft))
allocate(site_in%fmort_carbonflux_ustory(1:numpft))

site_in%nlevsoil = bc_in%nlevsoil
allocate(site_in%rootfrac_scr(site_in%nlevsoil))
allocate(site_in%zi_soil(0:site_in%nlevsoil))
Expand Down Expand Up @@ -226,15 +232,15 @@ subroutine zero_site( site_in )
! termination and recruitment info
site_in%term_nindivs_canopy(:,:) = 0._r8
site_in%term_nindivs_ustory(:,:) = 0._r8
site_in%term_carbonflux_canopy = 0._r8
site_in%term_carbonflux_ustory = 0._r8
site_in%term_carbonflux_canopy(:) = 0._r8
site_in%term_carbonflux_ustory(:) = 0._r8
site_in%recruitment_rate(:) = 0._r8
site_in%imort_rate(:,:) = 0._r8
site_in%imort_carbonflux = 0._r8
site_in%imort_carbonflux(:) = 0._r8
site_in%fmort_rate_canopy(:,:) = 0._r8
site_in%fmort_rate_ustory(:,:) = 0._r8
site_in%fmort_carbonflux_canopy = 0._r8
site_in%fmort_carbonflux_ustory = 0._r8
site_in%fmort_carbonflux_canopy(:) = 0._r8
site_in%fmort_carbonflux_ustory(:) = 0._r8
site_in%fmort_rate_cambial(:,:) = 0._r8
site_in%fmort_rate_crown(:,:) = 0._r8

Expand Down
11 changes: 8 additions & 3 deletions main/EDPftvarcon.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,8 @@ subroutine FatesCheckParams(is_master)
if(.not.is_master) return


if (hlm_parteh_mode .eq. prt_cnp_flex_allom_hyp) then
select case (hlm_parteh_mode)
case (prt_cnp_flex_allom_hyp)

! Check to see if either RD/ECA/MIC is turned on

Expand Down Expand Up @@ -1534,14 +1535,18 @@ subroutine FatesCheckParams(is_master)
end if
end if

elseif (hlm_parteh_mode .ne. prt_carbon_allom_hyp) then
case (prt_carbon_allom_hyp)
! No additional checks needed for now.
continue

case default

write(fates_log(),*) 'FATES Plant Allocation and Reactive Transport has'
write(fates_log(),*) 'only 2 modules supported, allometric carbon and CNP.'
write(fates_log(),*) 'fates_parteh_mode must be set to 1 or 2 in the namelist'
write(fates_log(),*) 'Aborting'
call endrun(msg=errMsg(sourcefile, __LINE__))
end if
end select

! If any PFTs are specified as either prescribed N or P uptake
! then they all must be !
Expand Down
63 changes: 31 additions & 32 deletions main/EDTypesMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -787,41 +787,41 @@ module EDTypesMod

! TERMINATION, RECRUITMENT, DEMOTION, and DISTURBANCE

real(r8), allocatable :: term_nindivs_canopy(:,:) ! number of canopy individuals that were in cohorts which
! were terminated this timestep, on size x pft
real(r8), allocatable :: term_nindivs_ustory(:,:) ! number of understory individuals that were in cohorts which
! were terminated this timestep, on size x pft
real(r8) :: term_carbonflux_canopy ! carbon flux from live to dead pools associated
! with termination mortality, per canopy level
real(r8) :: term_carbonflux_ustory ! carbon flux from live to dead pools associated
! with termination mortality, per canopy level
real(r8) :: demotion_carbonflux ! biomass of demoted individuals from canopy to understory [kgC/ha/day]
real(r8) :: promotion_carbonflux ! biomass of promoted individuals from understory to canopy [kgC/ha/day]
real(r8) :: imort_carbonflux ! biomass of individuals killed due to impact mortality per year. [kgC/ha/day]
real(r8) :: fmort_carbonflux_canopy ! biomass of canopy indivs killed due to fire per year. [gC/m2/sec]
real(r8) :: fmort_carbonflux_ustory ! biomass of understory indivs killed due to fire per year [gC/m2/sec]

real(r8) :: recruitment_rate(1:maxpft) ! number of individuals that were recruited into new cohorts
real(r8), allocatable :: demotion_rate(:) ! rate of individuals demoted from canopy to understory per FATES timestep

real(r8), allocatable :: promotion_rate(:) ! rate of individuals promoted from understory to canopy per FATES timestep

real(r8), allocatable :: imort_rate(:,:) ! rate of individuals killed due to impact mortality per year. on size x pft array
real(r8), allocatable :: term_nindivs_canopy(:,:) ! number of canopy individuals that were in cohorts which
! were terminated this timestep, on size x pft
real(r8), allocatable :: term_nindivs_ustory(:,:) ! number of understory individuals that were in cohorts which
! were terminated this timestep, on size x pft

real(r8), allocatable :: term_carbonflux_canopy(:) ! carbon flux from live to dead pools associated
! with termination mortality, per canopy level
real(r8), allocatable :: term_carbonflux_ustory(:) ! carbon flux from live to dead pools associated
! with termination mortality, per canopy level
real(r8), allocatable :: imort_carbonflux(:) ! biomass of individuals killed due to impact mortality per year. [kgC/ha/day]
real(r8), allocatable :: fmort_carbonflux_canopy(:) ! biomass of canopy indivs killed due to fire per year. [gC/m2/sec]
real(r8), allocatable :: fmort_carbonflux_ustory(:) ! biomass of understory indivs killed due to fire per year [gC/m2/sec]

real(r8) :: demotion_carbonflux ! biomass of demoted individuals from canopy to understory [kgC/ha/day]
real(r8) :: promotion_carbonflux ! biomass of promoted individuals from understory to canopy [kgC/ha/day]
real(r8) :: harvest_carbon_flux ! diagnostic site level flux of carbon as harvested plants [kg C / m2 / day]

real(r8) :: recruitment_rate(1:maxpft) ! number of individuals that were recruited into new cohorts
real(r8), allocatable :: demotion_rate(:) ! rate of individuals demoted from canopy to understory per FATES timestep
real(r8), allocatable :: promotion_rate(:) ! rate of individuals promoted from understory to canopy per FATES timestep
real(r8), allocatable :: imort_rate(:,:) ! rate of individuals killed due to impact mortality per year. on size x pft array


real(r8), allocatable :: fmort_rate_canopy(:,:) ! rate of canopy individuals killed due to fire mortality per year.
! on size x pft array (1:nlevsclass,1:numpft)
real(r8), allocatable :: fmort_rate_ustory(:,:) ! rate of understory individuals killed due to fire mortality per year.
! on size x pft array (1:nlevsclass,1:numpft)
real(r8), allocatable :: fmort_rate_canopy(:,:) ! rate of canopy individuals killed due to fire mortality per year.
! on size x pft array (1:nlevsclass,1:numpft)
real(r8), allocatable :: fmort_rate_ustory(:,:) ! rate of understory individuals killed due to fire mortality per year.
! on size x pft array (1:nlevsclass,1:numpft)

real(r8), allocatable :: fmort_rate_cambial(:,:) ! rate of individuals killed due to fire mortality
! from cambial damage per year. on size x pft array
real(r8), allocatable :: fmort_rate_crown(:,:) ! rate of individuals killed due to fire mortality
! from crown damage per year. on size x pft array
real(r8), allocatable :: fmort_rate_cambial(:,:) ! rate of individuals killed due to fire mortality
! from cambial damage per year. on size x pft array
real(r8), allocatable :: fmort_rate_crown(:,:) ! rate of individuals killed due to fire mortality
! from crown damage per year. on size x pft array

real(r8), allocatable :: growthflux_fusion(:,:) ! rate of individuals moving into a given size class bin
! due to fusion in a given day. on size x pft array
real(r8), allocatable :: growthflux_fusion(:,:) ! rate of individuals moving into a given size class bin
! due to fusion in a given day. on size x pft array



Expand All @@ -834,7 +834,6 @@ module EDTypesMod
real(r8) :: disturbance_rates_secondary_to_secondary(N_DIST_TYPES) ! actual disturbance rates from secondary patches to secondary patches [m2/m2/day]
real(r8) :: potential_disturbance_rates(N_DIST_TYPES) ! "potential" disturb rates (i.e. prior to the "which is most" logic) [m2/m2/day]
real(r8) :: primary_land_patchfusion_error ! error term in total area of primary patches associated with patch fusion [m2/m2/day]
real(r8) :: harvest_carbon_flux ! diagnostic site level flux of carbon as harvested plants [kg C / m2 / day]

end type ed_site_type

Expand Down
Loading

0 comments on commit f054c85

Please sign in to comment.