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

Make sure that the bareground patch is being labeled with patchno of zero #976

Merged
merged 10 commits into from
Jan 26, 2023
2 changes: 1 addition & 1 deletion biogeochem/EDPatchDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ subroutine set_patchno( currentSite )
currentPatch => currentPatch%younger
enddo

if(hlm_use_sp.eq.itrue)then
if(hlm_use_fixed_biogeog.eq.itrue .and. hlm_use_nocomp.eq.itrue)then
patchno = 1
currentPatch => currentSite%oldest_patch
do while(associated(currentPatch))
Expand Down
47 changes: 41 additions & 6 deletions fire/SFMainMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ subroutine fire_danger_index ( currentSite, bc_in)
! is simply using the values associated with the first patch.
! which probably won't have much inpact, unless we decide to ever calculated the NI for each patch.

iofp = currentSite%oldest_patch%patchno
iofp = currentSite%youngest_patch%patchno

temp_in_C = currentSite%oldest_patch%tveg24%GetMean() - tfrz
temp_in_C = currentSite%youngest_patch%tveg24%GetMean() - tfrz
rainfall = bc_in%precip24_pa(iofp)*sec_per_day
rh = bc_in%relhumid24_pa(iofp)

Expand Down Expand Up @@ -185,6 +185,8 @@ subroutine charecteristics_of_fuel ( currentSite )
currentPatch => currentSite%oldest_patch;
do while(associated(currentPatch))

if(currentPatch%nocomp_pft_label .ne. 0)then

litt_c => currentPatch%litter(element_pos(carbon12_element))

! How much live grass is there?
Expand Down Expand Up @@ -325,7 +327,7 @@ subroutine charecteristics_of_fuel ( currentSite )
0.0_r8.or.currentPatch%fuel_mef <= 0.0_r8.or.currentPatch%fuel_eff_moist <= 0.0_r8)then
if ( hlm_masterproc == itrue ) write(fates_log(),*) 'problem with spitfire fuel averaging'
endif

endif !nocomp_pft_label check
currentPatch => currentPatch%younger

enddo !end patch loop
Expand Down Expand Up @@ -359,7 +361,7 @@ subroutine wind_effect ( currentSite, bc_in)
! note - this is a patch level temperature, which probably won't have much inpact,
! unless we decide to ever calculated the NI for each patch.

iofp = currentSite%oldest_patch%patchno
iofp = currentSite%youngest_patch%patchno
currentSite%wind = bc_in%wind24_pa(iofp) * sec_per_min !Convert to m/min for SPITFIRE

if(write_SF == itrue)then
Expand All @@ -372,6 +374,9 @@ subroutine wind_effect ( currentSite, bc_in)
grass_fraction = 0.0_r8
currentPatch=>currentSite%oldest_patch;
do while(associated(currentPatch))

if(currentPatch%nocomp_pft_label .ne. 0)then

currentPatch%total_tree_area = 0.0_r8
total_grass_area = 0.0_r8
currentCohort => currentPatch%tallest
Expand All @@ -394,6 +399,8 @@ subroutine wind_effect ( currentSite, bc_in)
write(fates_log(),*) 'SF total_grass_area ',tree_fraction,grass_fraction
write(fates_log(),*) 'SF AREA ',AREA
endif

endif !nocomp_pft_label check

currentPatch => currentPatch%younger
enddo !currentPatch loop
Expand All @@ -409,9 +416,13 @@ subroutine wind_effect ( currentSite, bc_in)
currentPatch=>currentSite%oldest_patch;

do while(associated(currentPatch))
if(currentPatch%nocomp_pft_label .ne. 0)then

currentPatch%total_tree_area = min(currentPatch%total_tree_area,currentPatch%area)
! effect_wspeed in units m/min
currentPatch%effect_wspeed = currentSite%wind * (tree_fraction*0.4_r8+(grass_fraction+bare_fraction)*0.6_r8)

endif ! nocomp_pft_label check

currentPatch => currentPatch%younger
enddo !end patch loop
Expand Down Expand Up @@ -450,6 +461,8 @@ subroutine rate_of_spread ( currentSite )
currentPatch=>currentSite%oldest_patch;

do while(associated(currentPatch))

if(currentPatch%nocomp_pft_label .ne. 0)then

! remove mineral content from net fuel load per Thonicke 2010 for ir calculation
currentPatch%sum_fuel = currentPatch%sum_fuel * (1.0_r8 - SF_val_miner_total) !net of minerals
Expand Down Expand Up @@ -555,6 +568,7 @@ subroutine rate_of_spread ( currentSite )
! backward ROS wind not changed by vegetation
currentPatch%ROS_back = currentPatch%ROS_front*exp(-0.012_r8*currentSite%wind)

end if ! nocomp_pft_label check
currentPatch => currentPatch%younger

enddo !end patch loop
Expand Down Expand Up @@ -583,6 +597,9 @@ subroutine ground_fuel_consumption ( currentSite )
currentPatch => currentSite%oldest_patch;

do while(associated(currentPatch))

if(currentPatch%nocomp_pft_label .ne. 0)then

currentPatch%burnt_frac_litter(:) = 1.0_r8
! Calculate fraction of litter is burnt for all classes.
! Equation B1 in Thonicke et al. 2010---
Expand Down Expand Up @@ -642,6 +659,8 @@ subroutine ground_fuel_consumption ( currentSite )
! ignore 1000hr fuels. Just interested in fuels affecting ROS
currentPatch%TFC_ROS = sum(FC_ground)-FC_ground(tr_sf)

end if ! nocomp_pft_label check

currentPatch=>currentPatch%younger;
enddo !end patch loop

Expand Down Expand Up @@ -703,7 +722,7 @@ subroutine area_burnt_intensity ( currentSite, bc_in )
end if

!NF = number of lighting strikes per day per km2 scaled by cloud to ground strikes
iofp = currentSite%oldest_patch%patchno
iofp = currentSite%youngest_patch%patchno
if (hlm_spitfire_mode == hlm_sf_scalar_lightning_def ) then
currentSite%NF = ED_val_nignitions * years_per_day * cloud_to_ground_strikes
else ! use external daily lightning ignition data
Expand All @@ -726,6 +745,9 @@ subroutine area_burnt_intensity ( currentSite, bc_in )

currentPatch => currentSite%oldest_patch;
do while(associated(currentPatch))

if(currentPatch%nocomp_pft_label .ne. 0)then

! ---initialize patch parameters to zero---
currentPatch%FI = 0._r8
currentPatch%fire = 0
Expand Down Expand Up @@ -829,7 +851,8 @@ subroutine area_burnt_intensity ( currentSite, bc_in )
currentPatch%frac_burnt = 0.0_r8
endif

endif! NF ignitions check
endif ! NF ignitions check
endif ! nocomp_pft_label check

currentPatch => currentPatch%younger

Expand Down Expand Up @@ -861,6 +884,8 @@ subroutine crown_scorching ( currentSite )

currentPatch => currentSite%oldest_patch;
do while(associated(currentPatch))

if(currentPatch%nocomp_pft_label .ne. 0)then

tree_ag_biomass = 0.0_r8
if (currentPatch%fire == 1) then
Expand Down Expand Up @@ -894,6 +919,7 @@ subroutine crown_scorching ( currentSite )
end do

endif !fire
endif !nocomp_pft_label

currentPatch => currentPatch%younger;
enddo !end patch loop
Expand All @@ -916,6 +942,8 @@ subroutine crown_damage ( currentSite )
currentPatch => currentSite%oldest_patch

do while(associated(currentPatch))

if(currentPatch%nocomp_pft_label .ne. 0)then
if (currentPatch%fire == 1) then

currentCohort=>currentPatch%tallest
Expand Down Expand Up @@ -957,6 +985,7 @@ subroutine crown_damage ( currentSite )

enddo !end cohort loop
endif !fire?
endif !nocomp_pft_label check

currentPatch => currentPatch%younger;

Expand All @@ -983,6 +1012,8 @@ subroutine cambial_damage_kill ( currentSite )

do while(associated(currentPatch))

if(currentPatch%nocomp_pft_label .ne. 0)then

if (currentPatch%fire == 1) then
currentCohort => currentPatch%tallest;
do while(associated(currentCohort))
Expand All @@ -1007,6 +1038,7 @@ subroutine cambial_damage_kill ( currentSite )

enddo !end cohort loop
endif !fire?
endif !nocomp_pft_label check

currentPatch=>currentPatch%younger;

Expand All @@ -1033,6 +1065,8 @@ subroutine post_fire_mortality ( currentSite )

do while(associated(currentPatch))

if(currentPatch%nocomp_pft_label .ne. 0)then

if (currentPatch%fire == 1) then
currentCohort => currentPatch%tallest
do while(associated(currentCohort))
Expand All @@ -1052,6 +1086,7 @@ subroutine post_fire_mortality ( currentSite )

enddo !end cohort loop
endif !fire?
endif !nocomp_pft_label check

currentPatch => currentPatch%younger

Expand Down
6 changes: 2 additions & 4 deletions main/EDInitMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ subroutine init_site_vars( site_in, bc_in, bc_out )
allocate(site_in%dz_soil(site_in%nlevsoil))
allocate(site_in%z_soil(site_in%nlevsoil))

if (hlm_use_nocomp .eq. itrue) then
if (hlm_use_nocomp .eq. itrue .and. hlm_use_fixed_biogeog .eq. itrue) then
allocate(site_in%area_pft(0:numpft))
else ! SP and nocomp require a bare-ground patch.
allocate(site_in%area_pft(1:numpft))
Expand Down Expand Up @@ -384,6 +384,7 @@ subroutine set_site_properties( nsites, sites,bc_in )
sites(s)%acc_NI = acc_NI
sites(s)%NF = 0.0_r8
sites(s)%NF_successful = 0.0_r8
sites(s)%area_pft(:) = 0.0_r8

do ft = 1,numpft
sites(s)%rec_l2fr(ft,:) = prt_params%allom_l2fr(ft)
Expand All @@ -399,7 +400,6 @@ subroutine set_site_properties( nsites, sites,bc_in )
! where pft_areafrac is the area of land in each HLM PFT and (from surface dataset)
! hlm_pft_map is the area of that land in each FATES PFT (from param file)

sites(s)%area_pft(1:numpft) = 0._r8
do hlm_pft = 1,size( EDPftvarcon_inst%hlm_pft_map,2)
do fates_pft = 1,numpft ! loop round all fates pfts for all hlm pfts
sites(s)%area_pft(fates_pft) = sites(s)%area_pft(fates_pft) + &
Expand Down Expand Up @@ -453,8 +453,6 @@ subroutine set_site_properties( nsites, sites,bc_in )

if(sumarea.lt.area)then !make some bare ground
sites(s)%area_pft(0) = area - sumarea
else
sites(s)%area_pft(0) = 0.0_r8
end if
end if !sp mode
end if !fixed biogeog
Expand Down
10 changes: 9 additions & 1 deletion main/EDMainMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,15 @@ subroutine ed_ecosystem_dynamics(currentSite, bc_in, bc_out)


if (hlm_use_ed_st3.eq.ifalse.and.hlm_use_sp.eq.ifalse) then ! Bypass if ST3
call fire_model(currentSite, bc_in)

! Check that the site doesn't consist solely of a single bareground patch.
! If so, skip the fire model. Since the bareground patch should be the
! oldest patch per set_patchno, we check that the youngest patch isn't zero.
! If there are multiple patches on the site, the bareground patch is avoided
! at the level of the fire_model subroutines.
if (currentSite%youngest_patch%patchno .ne. 0) then
call fire_model(currentSite, bc_in)
end if

! Calculate disturbance and mortality based on previous timestep vegetation.
! disturbance_rates calls logging mortality and other mortalities, Yi Xu
Expand Down
6 changes: 3 additions & 3 deletions main/FatesHistoryInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ module FatesHistoryInterfaceMod
use FatesInterfaceTypesMod , only : hlm_model_day
use FatesInterfaceTypesMod , only : nlevcoage
use FatesInterfaceTypesMod , only : hlm_use_nocomp
use FatesInterfaceTypesMod , only : hlm_use_fixed_biogeog
use FatesAllometryMod , only : CrownDepth
use FatesAllometryMod , only : bstore_allom
use FatesAllometryMod , only : set_root_fraction
Expand Down Expand Up @@ -4273,10 +4274,9 @@ subroutine update_history_hifrq(this,nc,nsites,sites,bc_in,dt_tstep)
canopy_area_by_age(1:nlevage) = 0._r8

! Calculate the site-level total vegetated area (i.e. non-bareground)
if (hlm_use_nocomp .eq. itrue) then
site_area_veg = area
if (hlm_use_nocomp .eq. itrue .and. hlm_use_fixed_biogeog .eq. itrue) then
site_area_veg = area - sites(s)%area_pft(0)
else
site_area_veg = area
end if

cpatch => sites(s)%oldest_patch
Expand Down