Skip to content

Commit

Permalink
add checks for bareground and fix canopy fluxes
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdebolskiy committed Dec 6, 2024
1 parent 7f42386 commit b9e4b4f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/biogeochem/VOCEmissionMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,9 @@ subroutine VOCEmission (bounds, num_soilp, filter_soilp, &
if (use_fates) then
do fp = 1,num_soilp
p = filter_soilp(fp)
l_pft_itype(p) = canopystate_inst%voc_pftindex_patch(p)
if (patch%is_fates(p)) then
l_pft_itype(p) = canopystate_inst%voc_pftindex_patch(p)
endif
end do
else
do fp = 1,num_soilp
Expand Down Expand Up @@ -625,12 +627,12 @@ subroutine VOCEmission (bounds, num_soilp, filter_soilp, &
! Activity factor for CO2 (only for isoprene)
if (trim(meg_cmp%name) == 'isoprene') then
! Check of valid intercellular co2 pressure values.
if (cisha_z(p,nlevcan) < smallValue .or. cisun_z(p,nlevcan) < smallValue) then
write(iulog,*) 'Invalid intercellular co2 pressure (patch itype, sunlit, shaded): ', l_pft_itype(p),cisun_z(p,nlevcan),cisha_z(p,nlevcan)
if (cisha_z(p,1) < 0.0_r8 .or. cisun_z(p,1) < 0.0_r8) then
write(iulog,*) 'Invalid intercellular co2 pressure (patch itype, sunlit, shaded): ', l_pft_itype(p),cisun_z(p,1),cisha_z(p,1)
call endrun(subgrid_index=p, subgrid_level=subgrid_level_patch, msg=errMsg(sourcefile, __LINE__))
endif
co2_ppmv = 1.e6_r8*forc_pco2(g)/forc_pbot(c)
gamma_c = get_gamma_C(cisun_z(p,nlevcan),cisha_z(p,nlevcan),forc_pbot(c),fsun(p), co2_ppmv)
gamma_c = get_gamma_C(cisun_z(p,1),cisha_z(p,1),forc_pbot(c),fsun(p), co2_ppmv)

else
gamma_c = 1._r8
Expand Down
4 changes: 1 addition & 3 deletions src/biogeophys/CanopyFluxesMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1111,11 +1111,9 @@ subroutine CanopyFluxes(bounds, num_exposedvegp, filter_exposedvegp,
vpd(p) = max((svpts(p) - eah(p)), 50._r8) * 0.001_r8

end do

if ( use_fates ) then
! zeroed out here for megan isoprene calculations, in case patches are not transfered properly.
photosyns_inst%cisha_z_patch(begp:endp,:) = -999._r8
photosyns_inst%cisun_z_patch(begp:endp,:) = -999._r8

call clm_fates%wrap_photosynthesis(nc, bounds, fn, filterp(1:fn), &
svpts(begp:endp), eah(begp:endp), o2(begp:endp), &
co2(begp:endp), rb(begp:endp), dayl_factor(begp:endp), &
Expand Down
9 changes: 9 additions & 0 deletions src/utils/clmfates_interfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1616,6 +1616,10 @@ subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, &
patch%is_bareground(col%patchi(c)) = .true.
npatch = this%fates(nc)%sites(s)%youngest_patch%patchno

! set voc_pft_index of bareground to 0 explicitly, so the bare ground is properly ignored in VOCEmissionMod
if (patch%is_bareground(col%patchi(c))) then
voc_pftindex(col%patchi(c)) = 0
endif
! Precision errors on the canopy_fraction_pa sum, even small (e-12)
! do exist, and can create potentially negetive bare-soil fractions
! (ie -1e-12 or smaller). Even though this is effectively zero,
Expand Down Expand Up @@ -2650,6 +2654,11 @@ subroutine wrap_photosynthesis(this, nc, bounds, fn, filterp, &
! this is needed for MEGAN to work with FATES
cisun_z(p,:) = this%fates(nc)%bc_out(s)%ci_pa(ifp)
cisha_z(p,:) = this%fates(nc)%bc_out(s)%ci_pa(ifp)
if (this%fates(nc)%bc_out(s)%ci_pa(ifp) <0.0_r8) then
write(iulog,*) 'ci_pa is less than 0: ', this%fates(nc)%bc_out(s)%ci_pa(ifp)
write(iulog,*) 'filter ran photosynthesis s p icp ifp ilter',s,p,icp,ifp
call endrun(msg=errMsg(sourcefile, __LINE__))
endif
! These fields are marked with a bad-value flag
photosyns_inst%psnsun_patch(p) = spval
photosyns_inst%psnsha_patch(p) = spval
Expand Down

0 comments on commit b9e4b4f

Please sign in to comment.