Skip to content

Commit

Permalink
change lupft check to fbg + luh check to mirror fates-side logic
Browse files Browse the repository at this point in the history
  • Loading branch information
glemieux committed May 7, 2024
1 parent 5c5ca6f commit 2a88002
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions src/utils/clmfates_interfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,6 @@ subroutine CLMFatesGlobals2()
integer :: pass_use_potentialveg
integer :: pass_num_luh_states
integer :: pass_num_luh_transitions
integer :: pass_lupftdat

call t_startf('fates_globals2')

Expand Down Expand Up @@ -704,7 +703,7 @@ subroutine init(this, bounds_proc, flandusepftdat)
end if

! Retrieve the landuse x pft static data if the file is present
if (use_fates_lupft) then
if (use_fates_fixed_biogeog .and. use_fates_luh) then
call GetLandusePFTData(bounds_proc, flandusepftdat, landuse_pft_map, landuse_bareground)
end if

Expand Down Expand Up @@ -815,23 +814,23 @@ subroutine init(this, bounds_proc, flandusepftdat)
this%fates(nc)%sites(s)%lon = grc%londeg(g)

! Transfer the landuse x pft data to fates via bc_in if file is given
if (use_fates_lupft) then
this%fates(nc)%bc_in(s)%pft_areafrac_lu(:,1:num_landuse_pft_vars) = landuse_pft_map(g,:,1:num_landuse_pft_vars)
this%fates(nc)%bc_in(s)%baregroundfrac = landuse_bareground(g)
end if

if (.not. use_fates_lupft) then
! initialize static layers for reduced complexity FATES versions from HLM
! maybe make this into a subroutine of it's own later.
this%fates(nc)%bc_in(s)%pft_areafrac(:)=0._r8
do m = surfpft_lb,surfpft_ub
ft = m - surfpft_lb
this%fates(nc)%bc_in(s)%pft_areafrac(ft)=wt_nat_patch(g,m)
end do
if (use_fates_fixed_biogeog) then
if (use_fates_luh) then
this%fates(nc)%bc_in(s)%pft_areafrac_lu(:,1:num_landuse_pft_vars) = landuse_pft_map(g,:,1:num_landuse_pft_vars)
this%fates(nc)%bc_in(s)%baregroundfrac = landuse_bareground(g)
else
! initialize static layers for reduced complexity FATES versions from HLM
! maybe make this into a subroutine of it's own later.
this%fates(nc)%bc_in(s)%pft_areafrac(:)=0._r8
do m = surfpft_lb,surfpft_ub
ft = m - surfpft_lb
this%fates(nc)%bc_in(s)%pft_areafrac(ft)=wt_nat_patch(g,m)
end do

if (abs(sum(this%fates(nc)%bc_in(s)%pft_areafrac(surfpft_lb:surfpft_ub)) - 1.0_r8) > sum_to_1_tol) then
write(iulog,*) 'pft_area error in interfc ', s, sum(this%fates(nc)%bc_in(s) %pft_areafrac(:)) - 1.0_r8
call endrun(msg=errMsg(sourcefile, __LINE__))
if (abs(sum(this%fates(nc)%bc_in(s)%pft_areafrac(surfpft_lb:surfpft_ub)) - 1.0_r8) > sum_to_1_tol) then
write(iulog,*) 'pft_area error in interfc ', s, sum(this%fates(nc)%bc_in(s) %pft_areafrac(:)) - 1.0_r8
call endrun(msg=errMsg(sourcefile, __LINE__))
end if
end if
end if
end do !site
Expand Down Expand Up @@ -876,7 +875,7 @@ subroutine init(this, bounds_proc, flandusepftdat)
call create_fates_fire_data_method( this%fates_fire_data_method )

! deallocate the local landuse x pft array
if (use_fates_lupft) then
if (use_fates_fixed_biogeog .and. use_fates_luh) then
deallocate(landuse_pft_map)
deallocate(landuse_bareground)
end if
Expand Down

0 comments on commit 2a88002

Please sign in to comment.