Skip to content

Commit

Permalink
Merge pull request #976 from glemieux/tveg-973-fix
Browse files Browse the repository at this point in the history
Make sure that the bareground patch is being labeled with `patchno` of zero
  • Loading branch information
glemieux authored Jan 26, 2023
2 parents e663a6e + fc02012 commit 0e74107
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 31 deletions.
7 changes: 4 additions & 3 deletions biogeochem/EDCanopyStructureMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module EDCanopyStructureMod
use FatesConstantsMod , only : tinyr8
use FatesConstantsMod , only : nearzero
use FatesConstantsMod , only : rsnbl_math_prec
use FatesConstantsMod , only : nocomp_bareground
use FatesGlobals , only : fates_log
use EDPftvarcon , only : EDPftvarcon_inst
use PRTParametersMod , only : prt_params
Expand Down Expand Up @@ -1369,7 +1370,7 @@ subroutine canopy_summarization( nsites, sites, bc_in )
endif

! adding checks for SP and NOCOMP modes.
if(currentPatch%nocomp_pft_label.eq.0)then
if(currentPatch%nocomp_pft_label.eq.nocomp_bareground)then
write(fates_log(),*) 'cohorts in barepatch',currentPatch%total_canopy_area,currentPatch%nocomp_pft_label
call endrun(msg=errMsg(sourcefile, __LINE__))
end if
Expand Down Expand Up @@ -1828,7 +1829,7 @@ subroutine update_hlm_dynamics(nsites,sites,fcolumn,bc_out)
c = fcolumn(s)
do while(associated(currentPatch))

if(currentPatch%nocomp_pft_label.ne.0)then ! ignore the bare-ground-PFT patch entirely for these BC outs
if(currentPatch%nocomp_pft_label.ne.nocomp_bareground)then ! ignore the bare-ground-PFT patch entirely for these BC outs

ifp = ifp+1

Expand Down Expand Up @@ -1970,7 +1971,7 @@ subroutine update_hlm_dynamics(nsites,sites,fcolumn,bc_out)
currentPatch => sites(s)%oldest_patch
ifp = 0
do while(associated(currentPatch))
if(currentPatch%nocomp_pft_label.ne.0)then ! for vegetated patches only
if(currentPatch%nocomp_pft_label.ne.nocomp_bareground)then ! for vegetated patches only
ifp = ifp+1
bc_out(s)%canopy_fraction_pa(ifp) = bc_out(s)%canopy_fraction_pa(ifp)/total_patch_area
endif ! veg patch
Expand Down
7 changes: 4 additions & 3 deletions biogeochem/EDPatchDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module EDPatchDynamicsMod
use EDTypesMod , only : AREA_INV
use FatesConstantsMod , only : rsnbl_math_prec
use FatesConstantsMod , only : fates_tiny
use FatesConstantsMod , only : nocomp_bareground
use FatesInterfaceTypesMod , only : hlm_use_planthydro
use FatesInterfaceTypesMod , only : hlm_numSWb
use FatesInterfaceTypesMod , only : bc_in_type
Expand Down Expand Up @@ -1282,11 +1283,11 @@ 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))
if(currentPatch%nocomp_pft_label.eq.0)then
if(currentPatch%nocomp_pft_label.eq.nocomp_bareground)then
! for bareground patch, we make the patch number 0
! we also do not count this in the veg. patch numbering scheme.
currentPatch%patchno = 0
Expand Down Expand Up @@ -2027,7 +2028,7 @@ subroutine create_patch(currentSite, new_patch, age, areap, label,nocomp_pft)
real(r8), intent(in) :: age ! notional age of this patch in years
real(r8), intent(in) :: areap ! initial area of this patch in m2.
integer, intent(in) :: label ! anthropogenic disturbance label
integer, intent(in) :: nocomp_pft
integer, intent(in) :: nocomp_pft ! no competition mode pft label


! Until bc's are pointed to by sites give veg a default temp [K]
Expand Down
3 changes: 2 additions & 1 deletion biogeochem/EDPhysiologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module EDPhysiologyMod
use FatesInterfaceTypesMod, only : hlm_use_tree_damage
use FatesConstantsMod, only : r8 => fates_r8
use FatesConstantsMod, only : nearzero
use FatesConstantsMod, only : nocomp_bareground
use EDPftvarcon , only : EDPftvarcon_inst
use PRTParametersMod , only : prt_params
use EDPftvarcon , only : GetDecompyFrac
Expand Down Expand Up @@ -2668,7 +2669,7 @@ subroutine fragmentation_scaler( currentPatch, bc_in)
catanf(t1) = 11.75_r8 +(29.7_r8 / pi) * atan( pi * 0.031_r8 * ( t1 - 15.4_r8 ))
catanf_30 = catanf(30._r8)

if(currentPatch%nocomp_pft_label.ne.0)then
if(currentPatch%nocomp_pft_label.ne.nocomp_bareground)then

! Use the hlm temp and moisture decomp fractions by default
if ( use_hlm_soil_scalar ) then
Expand Down
3 changes: 2 additions & 1 deletion biogeophys/EDAccumulateFluxesMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module EDAccumulateFluxesMod
use FatesGlobals, only : fates_log
use shr_log_mod , only : errMsg => shr_log_errMsg
use FatesConstantsMod , only : r8 => fates_r8
use FatesConstantsMod , only : nocomp_bareground


implicit none
Expand Down Expand Up @@ -64,7 +65,7 @@ subroutine AccumulateFluxes_ED(nsites, sites, bc_in, bc_out, dt_time)

cpatch => sites(s)%oldest_patch
do while (associated(cpatch))
if(cpatch%nocomp_pft_label.ne.0)then
if(cpatch%nocomp_pft_label.ne.nocomp_bareground)then
ifp = ifp+1

if( bc_in(s)%filter_photo_pa(ifp) == 3 ) then
Expand Down
3 changes: 2 additions & 1 deletion biogeophys/EDBtranMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module EDBtranMod
use EDPftvarcon , only : EDPftvarcon_inst
use FatesConstantsMod , only : tfrz => t_water_freeze_k_1atm
use FatesConstantsMod , only : itrue,ifalse,nearzero
use FatesConstantsMod , only : nocomp_bareground
use EDTypesMod , only : ed_site_type, &
ed_patch_type, &
ed_cohort_type, &
Expand Down Expand Up @@ -138,7 +139,7 @@ subroutine btran_ed( nsites, sites, bc_in, bc_out)
ifp = 0
cpatch => sites(s)%oldest_patch
do while (associated(cpatch))
if(cpatch%nocomp_pft_label.ne.0)then ! only for veg patches
if(cpatch%nocomp_pft_label.ne.nocomp_bareground)then ! only for veg patches
ifp=ifp+1

! THIS SHOULD REALLY BE A COHORT LOOP ONCE WE HAVE rootfr_ft FOR COHORTS (RGK)
Expand Down
5 changes: 3 additions & 2 deletions biogeophys/EDSurfaceAlbedoMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module EDSurfaceRadiationMod
use FatesConstantsMod , only : r8 => fates_r8
use FatesConstantsMod , only : itrue
use FatesConstantsMod , only : pi_const
use FatesConstantsMod , only : nocomp_bareground
use FatesInterfaceTypesMod , only : bc_in_type
use FatesInterfaceTypesMod , only : bc_out_type
use FatesInterfaceTypesMod , only : hlm_numSWb
Expand Down Expand Up @@ -100,7 +101,7 @@ subroutine ED_Norman_Radiation (nsites, sites, bc_in, bc_out )
ifp = 0
currentpatch => sites(s)%oldest_patch
do while (associated(currentpatch))
if(currentpatch%nocomp_pft_label.ne.0)then
if(currentpatch%nocomp_pft_label.ne.nocomp_bareground)then
! do not do albedo calculations for bare ground patch in SP mode
! and (more impotantly) do not iterate ifp or it will mess up the indexing wherein
! ifp=1 is the first vegetated patch.
Expand Down Expand Up @@ -1147,7 +1148,7 @@ subroutine ED_SunShadeFracs(nsites, sites,bc_in,bc_out)
cpatch => sites(s)%oldest_patch

do while (associated(cpatch))
if(cpatch%nocomp_pft_label.ne.0)then !only for veg patches
if(cpatch%nocomp_pft_label.ne.nocomp_bareground)then !only for veg patches
! do not do albedo calculations for bare ground patch in SP mode
! and (more impotantly) do not iterate ifp or it will mess up the indexing wherein
! ifp=1 is the first vegetated patch.
Expand Down
3 changes: 2 additions & 1 deletion biogeophys/FatesPlantHydraulicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module FatesPlantHydraulicsMod
use FatesConstantsMod, only : cm3_per_m3
use FatesConstantsMod, only : kg_per_g
use FatesConstantsMod, only : fates_unset_r8
use FatesConstantsMod, only : nocomp_bareground

use EDParamsMod , only : hydr_kmax_rsurf1
use EDParamsMod , only : hydr_kmax_rsurf2
Expand Down Expand Up @@ -2546,7 +2547,7 @@ subroutine hydraulics_bc ( nsites, sites, bc_in, bc_out, dtime)
ifp = 0
cpatch => sites(s)%oldest_patch
do while (associated(cpatch))
if(cpatch%nocomp_pft_label.ne.0)then
if(cpatch%nocomp_pft_label.ne.nocomp_bareground)then
ifp = ifp + 1

! ----------------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion biogeophys/FatesPlantRespPhotosynthMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module FATESPlantRespPhotosynthMod
use FatesConstantsMod, only : rgas_J_K_mol
use FatesConstantsMod, only : fates_unset_r8
use FatesConstantsMod, only : tfrz => t_water_freeze_k_1atm
use FatesConstantsMod, only : nocomp_bareground
use FatesInterfaceTypesMod, only : hlm_use_planthydro
use FatesInterfaceTypesMod, only : hlm_parteh_mode
use FatesInterfaceTypesMod, only : numpft
Expand Down Expand Up @@ -324,7 +325,7 @@ subroutine FatesPlantRespPhotosynthDrive (nsites, sites,bc_in,bc_out,dtime)
ifp = 0
currentpatch => sites(s)%oldest_patch
do while (associated(currentpatch))
if(currentpatch%nocomp_pft_label.ne.0)then
if(currentpatch%nocomp_pft_label.ne.nocomp_bareground)then
ifp = ifp+1
NCL_p = currentPatch%NCL_p

Expand Down
Loading

0 comments on commit 0e74107

Please sign in to comment.