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

V2 Land Use Change #1116

Merged
merged 131 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 101 commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
0c35e38
first attempt to reconcile patch initialization logic with land-use +…
ckoven Jul 14, 2023
2d9dd68
starting to put in logic to handle nocomp PFT transitions during LU c…
ckoven Jul 14, 2023
9a08430
fixing some bugs I see while reading through code
ckoven Jul 28, 2023
a93efe4
added new generalized split_patch function
ckoven Jul 31, 2023
255e709
refactored and reused logic to put new patches into linked list
ckoven Jul 31, 2023
b4159dc
some compile-time bugfixes
ckoven Aug 9, 2023
148eaf4
more compile-time bugfixes
ckoven Aug 9, 2023
c594f80
adding logic to clean up temporary patches
ckoven Aug 9, 2023
e842bdd
adding logic to handle crop PFTs on crop land use types
ckoven Aug 10, 2023
74fefd3
adding logic for crops at recruitmetn step
ckoven Aug 10, 2023
66a5b2d
pasted code from grazing branch for adding land use dimension to para…
ckoven Aug 10, 2023
6c43b61
passing crop landuse/PFT info through parameter interface
ckoven Aug 11, 2023
5380c7f
merged main and resolved conflicts
ckoven Aug 14, 2023
3e9925a
merged luh2 and resolved conflicts (both had new patch insertion subr…
ckoven Aug 22, 2023
6b462cc
added logic to handle transitioning from a restart with no-land-use t…
ckoven Sep 6, 2023
b56044b
merged luh2 and resolved conflicts
ckoven Sep 18, 2023
a441e93
added edparamsmod changed to merge
ckoven Sep 18, 2023
b94fefa
fixed merged conflict
ckoven Sep 18, 2023
7d05c7a
Merge branch 'luh1' into luh2_nocomp_merge
ckoven Sep 19, 2023
50494e7
merged luh2 and resolved conflicts
ckoven Oct 6, 2023
71deea8
added logic to handle case where nocomp and land use are on but not e…
ckoven Oct 12, 2023
01212d1
error/edge-case handling for if the LU x PFT area dataset has NaNs
ckoven Oct 12, 2023
110ef78
startign to add logic to handle PFT_level harvest parameters for both…
ckoven Oct 12, 2023
94ed776
adding parameter values and passing to land use change and logging su…
ckoven Oct 13, 2023
c823fb6
do nocomp PFT shuffle for newly secondary lands as well in case prima…
ckoven Oct 13, 2023
4985e94
Merge branch 'luh2' into luh2_nocomp_merge
ckoven Oct 16, 2023
75df884
various compile-time bugfixes
ckoven Oct 18, 2023
b2e427d
more compile-time bugfixes
ckoven Oct 18, 2023
a967b7f
various runtime-failure fixes and attempted fixes
ckoven Oct 20, 2023
e1813e8
more runtime bugfixes
ckoven Oct 20, 2023
7d5ce7e
tiny bugfixes
ckoven Oct 21, 2023
7d632a0
various bugfixes and the diagnostics used to identify them
ckoven Oct 27, 2023
fbcaa33
moar bugfix
ckoven Oct 27, 2023
f698158
fixed anothe rbug and turning disturbance back on
ckoven Oct 30, 2023
ac4b61d
more bugfixes; add diagnostic for transition matrix; zeroed diags on …
ckoven Oct 31, 2023
4671798
moving storage of transition matrix to site variable to simplify hist…
ckoven Oct 31, 2023
3af2936
added use_fates_potentialveg flag and logic based on it
ckoven Nov 1, 2023
0269b22
buggfix and added a print statement
ckoven Nov 1, 2023
c9414d2
moar bugs
ckoven Nov 2, 2023
39ecc27
fix true/false check for the potential veg
glemieux Nov 2, 2023
1b42aeb
identify patch with matching land use to copy from for the buffer patch
glemieux Nov 2, 2023
382782e
Merge branch 'luh2_nocomp_merge' into luh2_nocomp_merge-switchfix-buf…
ckoven Nov 2, 2023
ea06ba0
Merge pull request #17 from glemieux/luh2_nocomp_merge-switchfix-buff…
ckoven Nov 2, 2023
321616b
some cleanup but still not working
ckoven Nov 2, 2023
8493d5b
possible fix to raction_to_keep logic
ckoven Nov 2, 2023
b01960d
fix for fusing a patch that isn't part of the linked list structure i…
ckoven Nov 2, 2023
fe43f5c
another fix in the patch nocomp-pft reweighting after land use change…
ckoven Nov 2, 2023
a7b8d88
fixed another thing that was wrong
ckoven Nov 2, 2023
998aa48
more bugfixes, attempted bugfixes, and diagnostics
ckoven Nov 6, 2023
cce0963
i think maybe it works now?
ckoven Nov 7, 2023
6e608d4
made the minimum land use fraction a named variable that depends on s…
ckoven Nov 8, 2023
9574a1c
added new parameter fates_max_nocomp_pfts_by_landuse and using instea…
ckoven Nov 9, 2023
5a6c0bd
bugfix
ckoven Nov 9, 2023
d7d989e
adding min_allowed_landuse_fraction to restart files, and other error…
ckoven Nov 9, 2023
7d79def
one bugfix and one temporary change to turn off all disturbance to se…
ckoven Nov 9, 2023
8afbe48
better bugfix
ckoven Nov 9, 2023
f8fe5ff
added restart for site%bareground
ckoven Nov 9, 2023
c07fc03
fix bug related to bareground area in the application of the transiti…
ckoven Nov 10, 2023
eb0671b
adding some documentation
ckoven Nov 10, 2023
32ee1bf
bugfixes: init logging rates, and handling when pft compositn doesnt …
ckoven Nov 10, 2023
401bdd8
changing shape of albedo arrays to avoid crash on restart reads
ckoven Nov 10, 2023
3f09166
added logic to handle case where LU type was below min area and then …
ckoven Nov 22, 2023
00241bf
bugfix to handle case of abandonment to secondary when secondary area…
ckoven Nov 27, 2023
689e7b2
another bugfix to handle another edge condition
ckoven Nov 29, 2023
3be4586
actually solve the edge case of initial harvest once 2ndry area excee…
ckoven Dec 6, 2023
afd5c19
merged main and resolved conflicts
ckoven Dec 19, 2023
d3c13f0
bugfix to prevent crashes when inserting patch at end of linked list
ckoven Feb 22, 2024
d37d973
various fixes to edge cases encountered
ckoven Mar 3, 2024
2ade2b1
move get_current_landuse_statevector into ed_site_type
glemieux Apr 2, 2024
833e397
covert get_current_landuse_statevector to a function
glemieux Apr 2, 2024
157df2b
condense common code into a new subroutine
glemieux Apr 4, 2024
44fc070
move CopyPatchMeansTimers around to find more common patterns
glemieux Apr 4, 2024
63045a9
remove subroutine stub
glemieux Apr 4, 2024
c19d973
remove duplicate tveg_longterm update that has been condensed
glemieux Apr 4, 2024
2a5b19f
fixing typos and minor formatting
glemieux Apr 11, 2024
f90412b
refactor pft area normalization to avoid checking sumarea in pft loop
glemieux Apr 11, 2024
e77dda4
convert loop to single line call
glemieux Apr 11, 2024
b835a84
simplify indexing across all pfts for given landuse type now that we
glemieux Apr 11, 2024
1508b7b
more minor typo fixes
glemieux Apr 11, 2024
73cd037
Convert an array index from real to int, satisfing nag compiler.
samsrabin Apr 18, 2024
c03a4ba
Change crop_lu_pft_vector from real to int.
samsrabin Apr 18, 2024
c1a7453
Merge pull request #21 from samsrabin/luh2_nocomp_merge-ssr
ckoven Apr 18, 2024
c611b0d
syntax style updates
rgknox Apr 23, 2024
b105d56
PascalCase
ckoven Apr 23, 2024
34dcc5f
shortening line lengths
ckoven Apr 24, 2024
5a5dea1
vasrious changes in response to review comments
ckoven Apr 30, 2024
530c99d
Update biogeochem/FatesLandUseChangeMod.F90
ckoven Apr 30, 2024
d74a625
Merge pull request #20 from glemieux/landuse_v2-edinit-refac_norm
ckoven Apr 30, 2024
d5b0640
Update main/FatesInterfaceMod.F90
ckoven May 1, 2024
c348a7d
aded error check if trying to go back into potential veg mode
ckoven May 2, 2024
a35f3ea
Merge branch 'luh2_nocomp_merge_merge' into luh2_nocomp_merge
ckoven May 2, 2024
0b415cf
minor typo and renaming corrections
glemieux May 7, 2024
153b0bd
add landuse mode checks for setting site_secondarylands...
glemieux May 7, 2024
063eb10
Merge branch 'luh2_nocomp_merge' into edpatchdyn-refactor-condense-co…
glemieux May 8, 2024
e36df66
fix missing end subroutine
glemieux May 8, 2024
19e0b16
remove target and fix missing indexing definition
glemieux May 8, 2024
69558bc
fix patch name typo
glemieux May 8, 2024
c090218
fix incorrect argument order for new subroutine
glemieux May 8, 2024
ff16157
Merge pull request #18 from glemieux/edpatchdyn-refactor-condense-common
glemieux May 8, 2024
7fe31f9
Merge pull request #19 from glemieux/landusev2-sitefunc
glemieux May 8, 2024
3594045
fix procedure declaration
glemieux May 8, 2024
6080ab6
fixing error in harvest rate calculations
ckoven May 10, 2024
94fddfd
conflict resolutions between v2 lu and api 35
rgknox May 13, 2024
827ab3f
minor build fixes
glemieux May 14, 2024
48c7894
conflict resolution in v2
rgknox May 15, 2024
f7318a0
bug fixes from luhv2 merge
rgknox May 17, 2024
d00ece6
added parameter file patch for api 36
rgknox May 17, 2024
7084c0d
updated parameter api update xml
rgknox May 20, 2024
37f0245
fixed logic on when to initialize patches when not in nocomp-fixedbio
rgknox May 20, 2024
a997af5
updated parameter check to ignore SP
rgknox May 22, 2024
8712862
conflict resolution
rgknox May 22, 2024
d38bc59
remove merge conflict artifacts
glemieux May 29, 2024
9d8628e
shortened some restart var names
rgknox May 30, 2024
9c2444f
change nocomp_pft_area_vector check to first diff then sum for better…
glemieux Jun 4, 2024
737e81d
change check for buffer split to use fraction to keep
glemieux Jun 6, 2024
4b018ea
add check to avoid bareground patches
glemieux Jun 6, 2024
3c05ecf
Merge tag 'sci.1.76.4_api.35.1.0' into luh2_nocomp_merge
Jun 17, 2024
b43cb3a
update split_patches to take optional area input
glemieux Jun 24, 2024
29621bc
fix split patch optional argument name error
glemieux Jun 24, 2024
9b724ea
correct bad merge
glemieux Jun 24, 2024
3c02ded
refactor checks to determine what is sent to buffer patch
glemieux Jun 24, 2024
7add4a1
make sure to skip the buffer patch split loop if the buffer patch is …
glemieux Jun 24, 2024
fe795df
refactor newp_area calculation to avoid potential precision error
glemieux Jun 24, 2024
28511d1
move the fraction to keep calculation earlier
glemieux Jun 24, 2024
e823830
check absolute value of buffer area to keep
glemieux Jun 24, 2024
2ec67f9
remove this check as we are now checking the new and remaining areas …
glemieux Jun 25, 2024
69e8f6a
correct whitespace
glemieux Jun 25, 2024
88ce982
Add logic to check for cases in which buffer should be inserted strai…
glemieux Jun 26, 2024
c9e7271
add sp mode check to litter initialization for bareground patches
glemieux Jun 27, 2024
bb3d58e
initialize current tag for event code logging
glemieux Jun 28, 2024
4ae398b
Revert "initialize current tag for event code logging"
glemieux Jul 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
209 changes: 143 additions & 66 deletions biogeochem/EDLoggingMortalityMod.F90

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions biogeochem/EDMortalityFunctionsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ end subroutine mortality_rates

subroutine Mortality_Derivative( currentSite, currentCohort, bc_in, btran_ft, &
mean_temp, land_use_label, age_since_anthro_disturbance, &
frac_site_primary, harvestable_forest_c, harvest_tag)
frac_site_primary, frac_site_secondary, harvestable_forest_c, harvest_tag)

!
! !DESCRIPTION:
Expand All @@ -255,6 +255,7 @@ subroutine Mortality_Derivative( currentSite, currentCohort, bc_in, btran_ft, &
integer, intent(in) :: land_use_label
real(r8), intent(in) :: age_since_anthro_disturbance
real(r8), intent(in) :: frac_site_primary
real(r8), intent(in) :: frac_site_secondary

real(r8), intent(in) :: harvestable_forest_c(:) ! total carbon available for logging, kgC site-1
integer, intent(out) :: harvest_tag(:) ! tag to record the harvest status
Expand Down Expand Up @@ -283,7 +284,7 @@ subroutine Mortality_Derivative( currentSite, currentCohort, bc_in, btran_ft, &
!if trees are in the canopy, then their death is 'disturbance'. This probably needs a different terminology
call mortality_rates(currentCohort,bc_in,btran_ft, mean_temp, &
cmort,hmort,bmort,frmort, smort, asmort, dgmort)
call LoggingMortality_frac(ipft, currentCohort%dbh, currentCohort%canopy_layer, &
call LoggingMortality_frac(currentSite, bc_in, ipft, currentCohort%dbh, currentCohort%canopy_layer, &
currentCohort%lmort_direct, &
currentCohort%lmort_collateral, &
currentCohort%lmort_infra, &
Expand All @@ -293,7 +294,7 @@ subroutine Mortality_Derivative( currentSite, currentCohort, bc_in, btran_ft, &
bc_in%hlm_harvest_units, &
land_use_label, &
age_since_anthro_disturbance, &
frac_site_primary, harvestable_forest_c, harvest_tag)
frac_site_primary, frac_site_secondary, harvestable_forest_c, harvest_tag)

if (currentCohort%canopy_layer > 1)then
! Include understory logging mortality rates not associated with disturbance
Expand Down
872 changes: 715 additions & 157 deletions biogeochem/EDPatchDynamicsMod.F90

Large diffs are not rendered by default.

43 changes: 31 additions & 12 deletions biogeochem/EDPhysiologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module EDPhysiologyMod
use FatesInterfaceTypesMod, only : hlm_parteh_mode
use FatesInterfaceTypesMod, only : hlm_use_fixed_biogeog
use FatesInterfaceTypesMod, only : hlm_use_nocomp
use EDParamsMod , only : crop_lu_pft_vector
use FatesInterfaceTypesMod, only : hlm_nitrogen_spec
use FatesInterfaceTypesMod, only : hlm_phosphorus_spec
use FatesInterfaceTypesMod, only : hlm_use_tree_damage
Expand All @@ -34,6 +35,8 @@ module EDPhysiologyMod
use FatesConstantsMod, only : g_per_kg
use FatesConstantsMod, only : ndays_per_year
use FatesConstantsMod, only : nocomp_bareground
use FatesConstantsMod, only : nocomp_bareground_land
use FatesConstantsMod, only : is_crop
use FatesConstantsMod, only : area_error_2
use EDPftvarcon , only : EDPftvarcon_inst
use PRTParametersMod , only : prt_params
Expand Down Expand Up @@ -140,7 +143,8 @@ module EDPhysiologyMod
use FatesParameterDerivedMod, only : param_derived
use FatesPlantHydraulicsMod, only : InitHydrCohort
use PRTInitParamsFatesMod, only : NewRecruitTotalStoichiometry

use FatesInterfaceTypesMod , only : hlm_use_luh

implicit none
private

Expand Down Expand Up @@ -2489,20 +2493,35 @@ subroutine recruitment(currentSite, currentPatch, bc_in)
real(r8) :: seedling_layer_smp ! soil matric potential at seedling rooting depth [mm H2O suction]
integer, parameter :: recruitstatus = 1 ! whether the newly created cohorts are recruited or initialized
integer :: ilayer_seedling_root ! the soil layer at seedling rooting depth

logical :: use_this_pft ! logical flag for whether or not to allow a given PFT to recruit
!---------------------------------------------------------------------------

do ft = 1, numpft

! The following if block is for the prescribed biogeography and/or nocomp modes.
! Since currentSite%use_this_pft is a site-level quantity and thus only limits whether a given PFT
! is permitted on a given gridcell or not, it applies to the prescribed biogeography case only.
! If nocomp is enabled, then we must determine whether a given PFT is allowed on a given patch or not.
! The following if block is for the prescribed biogeography and/or nocomp modes and/or crop land use types
! Since currentSite%use_this_pft is a site-level quantity and thus only limits whether a given PFT
! is permitted on a given gridcell or not, it applies to the prescribed biogeography case only.
! If nocomp is enabled, then we must determine whether a given PFT is allowed on a given patch or not.
! Whether or not nocomp or prescribed biogeography is enabled, if land use change is enabled, then we only want to
! allow crop PFTs on patches with crop land use types

use_this_pft = .false.
if(currentSite%use_this_pft(ft).eq.itrue &
.and. ((hlm_use_nocomp .eq. ifalse) .or. (ft .eq. currentPatch%nocomp_pft_label)))then
use_this_pft = .true.
end if

if (currentSite%use_this_pft(ft) .eq. itrue .and. &
((hlm_use_nocomp .eq. ifalse) .or. &
(ft .eq. currentPatch%nocomp_pft_label))) then
if ( currentPatch%land_use_label .ne. nocomp_bareground_land ) then ! cdk
if ((hlm_use_luh .eq. itrue) .and. (is_crop(currentPatch%land_use_label))) then
if ( crop_lu_pft_vector(currentPatch%land_use_label) .eq. ft ) then
use_this_pft = .true.
else
use_this_pft = .false.
end if
end if
endif

use_this_pft_if: if(use_this_pft) then
height = EDPftvarcon_inst%hgt_min(ft)
stem_drop_fraction = prt_params%phen_stem_drop_fraction(ft)
fnrt_drop_fraction = prt_params%phen_fnrt_drop_fraction(ft)
Expand Down Expand Up @@ -2746,11 +2765,11 @@ subroutine recruitment(currentSite, currentPatch, bc_in)
currentSite%recruitment_rate(ft) = currentSite%recruitment_rate(ft) + cohort_n

endif any_recruits
endif !use_this_pft
endif use_this_pft_if
enddo !pft loop
end subroutine recruitment

! ======================================================================================
! ======================================================================================

subroutine CWDInput( currentSite, currentPatch, litt, bc_in)

Expand Down Expand Up @@ -3019,7 +3038,7 @@ subroutine CWDInput( currentSite, currentPatch, litt, bc_in)
SF_val_CWD_frac_adj(c) * dead_n_dlogging * &
prt_params%allom_agb_frac(pft)

site_mass%wood_product = site_mass%wood_product + &
site_mass%wood_product_harvest(pft) = site_mass%wood_product_harvest(pft) + &
trunk_wood * currentPatch%area * logging_export_frac

! Add AG wood to litter from the non-exported fraction of wood
Expand Down
Loading