Skip to content

Commit

Permalink
more tweaking and cleaning of patch numbering
Browse files Browse the repository at this point in the history
  • Loading branch information
rgknox committed Jan 8, 2025
1 parent 50ea2d3 commit 0be5cd1
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 28 deletions.
2 changes: 1 addition & 1 deletion main/EDMainMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ subroutine ed_ecosystem_dynamics(currentSite, bc_in, bc_out)
! 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
if (currentSite%youngest_patch%nocomp_pft_label .ne. nocomp_bareground)then
call fire_model(currentSite, bc_in)
end if

Expand Down
4 changes: 2 additions & 2 deletions main/FatesHistoryInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5071,11 +5071,11 @@ subroutine update_history_hifrq1(this,nc,nsites,sites,bc_in,bc_out,dt_tstep)
cpatch%c_lblayer * cpatch%total_canopy_area * mol_per_umol * site_area_veg_inv

! Only accumulate the instantaneous vegetation temperature for vegetated patches
if (cpatch%patchno .ne. 0) then
!if (cpatch%nocomp_pft_label.ne.nocomp_bareground)then
hio_tveg(io_si) = hio_tveg(io_si) + &
(bc_in(s)%t_veg_pa(cpatch%patchno) - t_water_freeze_k_1atm) * &
cpatch%total_canopy_area * site_area_veg_inv
end if
!end if

ccohort => cpatch%shortest
do while(associated(ccohort))
Expand Down
28 changes: 20 additions & 8 deletions main/FatesInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -774,8 +774,9 @@ subroutine SetFatesGlobalElements1(use_fates,surf_numpft,surf_numcft,param_reade
integer, intent(in) :: surf_numpft ! Number of PFTs in surface dataset
integer, intent(in) :: surf_numcft ! Number of CFTs in surface dataset
class(fates_param_reader_type), intent(in) :: param_reader ! HLM-provided param file reader

integer :: fates_numpft ! Number of PFTs tracked in FATES

logical, parameter :: preserve_b4b = .true.

if (use_fates) then

Expand Down Expand Up @@ -807,13 +808,24 @@ subroutine SetFatesGlobalElements1(use_fates,surf_numpft,surf_numcft,param_reade
! If we are using fixed biogeography or no-comp then we
! can also apply those constraints to maxpatch_primaryland and secondary
! and that value will match fates_maxPatchesPerSite

if(hlm_use_nocomp==itrue) then
if_preserve_b4b: if(.not.preserve_b4b)then

maxpatches_by_landuse(primaryland) = max(maxpatches_by_landuse(primaryland),fates_numpft)
maxpatch_total = sum(maxpatches_by_landuse(:))
end if
if(hlm_use_luh==ifalse) then
maxpatches_by_landuse(secondaryland:n_landuse_cats) = 0
end if

maxpatch_total = sum(maxpatches_by_landuse(:))

else

if(hlm_use_nocomp==itrue) then

maxpatches_by_landuse(primaryland) = max(maxpatches_by_landuse(primaryland),fates_numpft)
maxpatch_total = sum(maxpatches_by_landuse(:))
end if

end if if_preserve_b4b

! maxpatch_total does not include the bare ground (so add 1)
fates_maxPatchesPerSite = maxpatch_total+1

Expand Down Expand Up @@ -2110,7 +2122,7 @@ subroutine UpdateFatesRMeansTStep(sites,bc_in, bc_out)

ifp = cpatch%patchno

if (cpatch%patchno .ne. 0) then
nocomp_bare: if(cpatch%nocomp_pft_label.ne.nocomp_bareground)then

call cpatch%tveg24%UpdateRMean(bc_in(s)%t_veg_pa(ifp))
call cpatch%tveg_lpa%UpdateRMean(bc_in(s)%t_veg_pa(ifp))
Expand Down Expand Up @@ -2172,7 +2184,7 @@ subroutine UpdateFatesRMeansTStep(sites,bc_in, bc_out)
ccohort => ccohort%shorter
end do

end if
end if nocomp_bare

cpatch => cpatch%younger
enddo
Expand Down
8 changes: 5 additions & 3 deletions main/FatesRestartInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3822,10 +3822,10 @@ subroutine update_3dpatch_radiation(this, nsites, sites, bc_out)

do s = 1, nsites

ifp = 0
currentpatch => sites(s)%oldest_patch
do while (associated(currentpatch))
ifp = ifp+1

ifp = currentPatch%patchno

currentPatch%f_sun (:,:,:) = 0._r8
currentPatch%fabd_sun_z (:,:,:) = 0._r8
Expand All @@ -3848,6 +3848,7 @@ subroutine update_3dpatch_radiation(this, nsites, sites, bc_out)
! currentPatch%solar_zenith_flag (is there daylight?)
! currentPatch%solar_zenith_angle (what is the value?)
! -----------------------------------------------------------
nocomp_bareground: if(currentPatch%nocomp_pft_label .ne. nocomp_bareground)then

if(currentPatch%solar_zenith_flag)then

Expand Down Expand Up @@ -3920,8 +3921,9 @@ subroutine update_3dpatch_radiation(this, nsites, sites, bc_out)
end select

endif ! is there vegetation?

end if ! if the vegetation and zenith filter is active
end if nocomp_bareground
currentPatch => currentPatch%younger
end do ! Loop linked-list patches
enddo ! Loop Sites
Expand Down
23 changes: 9 additions & 14 deletions radiation/FatesRadiationDriveMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,14 @@ subroutine FatesNormalizedCanopyRadiation(nsites, sites, bc_in, bc_out )

do s = 1, nsites

ifp = 0
currentpatch => sites(s)%oldest_patch
do while (associated(currentpatch))

! 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.

if_notbareground: if(currentpatch%nocomp_pft_label.ne.nocomp_bareground)then

ifp = ifp+1
ifp = currentpatch%patchno

nocomp_bareground: if(currentpatch%nocomp_pft_label.ne.nocomp_bareground)then

! Zero diagnostics
currentPatch%f_sun (:,:,:) = 0._r8
Expand Down Expand Up @@ -240,7 +237,7 @@ subroutine FatesNormalizedCanopyRadiation(nsites, sites, bc_in, bc_out )
end if if_nrad

endif if_zenith_flag
end if if_notbareground
end if nocomp_bareground

currentPatch => currentPatch%younger
end do ! Loop linked-list patches
Expand Down Expand Up @@ -282,17 +279,15 @@ subroutine FatesSunShadeFracs(nsites, sites,bc_in,bc_out)

do s = 1,nsites

ifp = 0
cpatch => sites(s)%oldest_patch

do while (associated(cpatch))

if_notbareground: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.
ifp=ifp+1
ifp = cpatch%patchno

nocomp_bareground: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

! Initialize diagnostics
cpatch%ed_parsun_z(:,:,:) = 0._r8
cpatch%ed_parsha_z(:,:,:) = 0._r8
Expand Down

0 comments on commit 0be5cd1

Please sign in to comment.