Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
32ed527
First step towards separating the calculation of averaged/cumulative …
mpaiao Apr 10, 2025
6cddb5f
Update the code for obtaining the average temperature, so it is in li…
mpaiao Apr 10, 2025
2cd8a03
Missing variable declaration for loop counter.
mpaiao Apr 11, 2025
72939db
Loading nearzero.
mpaiao Apr 11, 2025
6e44398
Added numpft to the list of parameters to be loaded.
mpaiao Apr 11, 2025
599b940
Fix missing calls to moisture memory update, and added documentation …
mpaiao Apr 14, 2025
04160ee
Merge branch 'main' into mpaiao-pr-10davgs
mpaiao Apr 14, 2025
58003da
Remove variables that are no longer used in sub-routine phenology.
mpaiao Apr 17, 2025
71a5945
Remove unused parameter from FatesCumulativeMemoryMod.F90
mpaiao Apr 18, 2025
182db6c
Refactor: Per-age outputs, in existing subroutines.
samsrabin Jul 17, 2024
91ac79a
Refactor: Age-class vars to update_history_hifrq2_ageclass().
samsrabin Sep 10, 2024
158bf67
Refactor: Age-class vars to update_history_dyn2_ageclass().
samsrabin Sep 10, 2024
909e156
Bugfix: Add logging mortality to _SZAP outputs.
samsrabin Oct 3, 2024
8ed9018
Add non-per-ageclass versions of some history vars.
samsrabin Sep 17, 2024
f24de49
Change 7 hist vars to not be normalized to age-class area.
samsrabin Oct 2, 2024
22b0ec3
Bugfix: Update FATES_VEGC_APPF even if cohort is new.
samsrabin Oct 2, 2024
afae1c6
Bugfix: Add termination mortality to _SZAP outputs.
samsrabin Oct 3, 2024
dad8084
Add postprocessing info to per-ageclass outputs.
samsrabin Oct 13, 2024
492c437
Cleanup: update_history_dyn2_ageclass().
samsrabin Oct 13, 2024
9beb94b
Cleanup: update_history_hifrq2_ageclass().
samsrabin Oct 13, 2024
4c07332
Move more calculations to update_history_dyn2_ageclass().
samsrabin Oct 13, 2024
560f348
Cleanup: FatesHistoryInterfaceMod.
samsrabin Oct 13, 2024
bcc7c2d
Move FATES_NCL from update_history_dyn2_ageclass() to update_history_…
samsrabin Oct 28, 2024
4943e7a
Add units info to SumMortForHistory().
samsrabin Oct 28, 2024
538dec8
update_history subroutine names/descriptions now more descriptive.
samsrabin Oct 28, 2024
ec1a76a
update_history_dyn_subsite_ageclass(): Resolve a TODO.
samsrabin Oct 28, 2024
4dabc79
Delete unused canopy_area_by_age.
samsrabin Oct 28, 2024
120b2b5
Rename _area_ vars in FatesHistoryInterfaceMod to _fracarea_.
samsrabin Oct 28, 2024
b2902e0
Fix some indentation.
samsrabin Oct 29, 2024
39cf8c5
Resolve TODO about fire variable weighting.
samsrabin Oct 29, 2024
faeb073
Remove unneeded cohort class index updates.
samsrabin Oct 29, 2024
73708ca
Add prt_vartypes subroutine GetBiomass().
samsrabin Nov 6, 2024
e6719ff
Add comment about reproductive mass being 0.
samsrabin Nov 6, 2024
777f744
Combine 2 nearby numpft loops.
samsrabin Jan 27, 2025
aab347a
Merge fix: Don't update hio_npp_si_age if cohort is new.
samsrabin Mar 28, 2025
8765fcc
Add FATES_PRIMARY_AREA history field.
samsrabin Apr 7, 2025
11da014
Rename FATES_SECONDARY_ANTHRODISTAGE_AP to FATES_SECONDARY_ANTHRODIST…
samsrabin Apr 7, 2025
9b7849d
Fix/standardize FATES_SECONDARY_AREA_ANTHRO* names.
samsrabin Apr 8, 2025
22ccdf0
Delete an unneeded get_age_class_index() call.
samsrabin Apr 8, 2025
fdf2232
Delete an outdated comment about fire variables.
samsrabin Apr 8, 2025
7e3d888
Move 2 non-age vars out of update_history_dyn_subsite_ageclass().
samsrabin Apr 9, 2025
dad8a91
Rename *_fuel_amount_age_fuel vars to have _agfc suffix.
samsrabin Apr 9, 2025
7f58290
Clean up calls of get_age_class_index().
samsrabin Apr 9, 2025
eab4465
Rename some loops to satisfy nag compiler.
samsrabin Apr 14, 2025
ab0e144
making dlower_vai(1) = zero, using a dedicated function for veg layer…
rgknox Mar 18, 2025
bdc2e56
declaration fixes for canopy layer fixes
rgknox Mar 18, 2025
f94c8dc
changed vai_dlower index on call for consistency
rgknox Apr 24, 2025
d2a8998
added more comments to the dlower_vai array descriptor
rgknox Apr 24, 2025
4eacc43
altenative bin counting method
rgknox Apr 24, 2025
0e55906
fix to trivial radiation transmission
rgknox Apr 1, 2025
458bf6a
make consistent with ctsm
mvdebolskiy Apr 9, 2025
1932bd3
updated descriptive text on trivial albedo defs
rgknox Apr 9, 2025
47caaec
changed to count method of calculating number of veg layers, its simp…
rgknox Apr 27, 2025
3255e94
Simplified leaf sun-shade fraction for two-stream
rgknox Apr 2, 2025
0df8283
removed unused variables in two-stream absorption call
rgknox Apr 4, 2025
69782df
Merge branch 'api40' into mpaiao-pr-10davgs
mpaiao Jul 3, 2025
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
97 changes: 4 additions & 93 deletions biogeochem/EDPhysiologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,6 @@ module EDPhysiologyMod
! a residual amount of leaves, which may create
! computational problems. The current threshold
! is the same used in ED-2.2.

real(r8), parameter :: smp_lwr_bound = -1000000._r8 ! Imposed soil matric potential lower bound for
! frozen or excessively dry soils, used when
! computing water stress.
! ============================================================================

contains
Expand Down Expand Up @@ -911,13 +907,11 @@ subroutine phenology( currentSite, bc_in )
! Phenology.
!
! !USES:
use FatesConstantsMod, only : tfrz => t_water_freeze_k_1atm
use EDParamsMod, only : ED_val_phen_a, ED_val_phen_b, ED_val_phen_c
use EDParamsMod, only : ED_val_phen_chiltemp
use EDParamsMod, only : ED_val_phen_mindayson
use EDParamsMod, only : ED_val_phen_ncolddayslim
use EDParamsMod, only : ED_val_phen_coldtemp
use EDBtranMod, only : check_layer_water
!
! !ARGUMENTS:
type(ed_site_type), intent(inout), target :: currentSite
Expand All @@ -926,25 +920,15 @@ subroutine phenology( currentSite, bc_in )
!
! !LOCAL VARIABLES:

type(fates_patch_type),pointer :: cpatch
integer :: model_day_int ! integer model day 1 - inf
integer :: ncolddays ! no days underneath the threshold for leaf drop
integer :: i_wmem ! Loop counter for water mem days
integer :: i_tmem ! Loop counter for veg temp mem days
integer :: ipft ! plant functional type index
integer :: j ! Soil layer index
real(r8) :: mean_10day_liqvol ! mean soil liquid volume over last 10 days [m3/m3]
real(r8) :: mean_10day_smp ! mean soil matric potential over last 10 days [mm]
real(r8) :: leaf_c ! leaf carbon [kg]
real(r8) :: fnrt_c ! fineroot carbon [kg]
real(r8) :: sapw_c ! sapwood carbon [kg]
real(r8) :: store_c ! storage carbon [kg]
real(r8) :: struct_c ! structure carbon [kg]
real(r8) :: gdd_threshold ! GDD accumulation function,
real(r8) :: rootfrac_notop ! Total rooting fraction excluding the top soil layer
integer :: ncdstart ! beginning of counting period for chilling degree days.
integer :: gddstart ! beginning of counting period for growing degree days.
integer :: nlevroot ! Number of rooting levels to consider
real(r8) :: temp_in_C ! daily averaged temperature in celsius
real(r8) :: temp_wgt ! canopy area weighting factor for daily average
! vegetation temperature calculation
Expand Down Expand Up @@ -986,38 +970,16 @@ subroutine phenology( currentSite, bc_in )
logical :: last_flush_long_ago ! Has it been a very long time since last flushing?


! This is the integer model day. The first day of the simulation is 1, and it
! continues monotonically, indefinitely
! Advance it. (this should be a global, no reason
! for site level, but we don't have global scalars in the
! restart file)
currentSite%phen_model_date = currentSite%phen_model_date + 1
! This is the elapsed number of days since the very beginning of the simulation time
model_day_int = currentSite%phen_model_date
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this local variable (model_day_int) decreases the readability of the code and we should ditch it. @mpaiao I might make a PR to your branch with this change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, go for it, thanks! Indeed I wasn't sure why we needed model_day_int.



! Parameter of drought decid leaf loss in mm in top layer...FIX(RF,032414)
! - this is arbitrary and poorly understood. Needs work. ED_
!Parameters: defaults from Botta et al. 2000 GCB,6 709-725
!Parameters, default from from SDGVM model of senesence

temp_in_C = 0._r8
temp_wgt = 0._r8
cpatch => CurrentSite%oldest_patch
do while(associated(cpatch))
temp_in_C = temp_in_C + cpatch%tveg24%GetMean()*cpatch%total_canopy_area
temp_wgt = temp_wgt + cpatch%total_canopy_area
cpatch => cpatch%younger
end do
if(temp_wgt>nearzero)then
temp_in_C = temp_in_C/temp_wgt - tfrz
else
! If there is no canopy area, we use the veg temperature
! of the first patch, which is the forcing air temperature
! as defined in CLM/ELM. The forcing air temperature
! should be the same among all patches. (Although
! it is unlikely there are more than 1 in this scenario)
temp_in_C = CurrentSite%oldest_patch%tveg24%GetMean() - tfrz
end if
! Retrieve average canopy temperature of the current day
temp_in_C = currentSite%vegtemp_memory(1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment that index 1 is the present day and was updated at the beginning of the dynamics step. We should probably change the language to reflect that index 1 is the previous 24 hours. (its not actually the present day, as the dynamics happens on the first time-step of the day).



!-----------------Cold Phenology--------------------!

Expand Down Expand Up @@ -1047,10 +1009,6 @@ subroutine phenology( currentSite, bc_in )
! -68 + 638 * (-0.001 * ncd)
gdd_threshold = ED_val_phen_a + ED_val_phen_b*exp(ED_val_phen_c*real(currentSite%nchilldays,r8))

!Accumulate temperature of last 10 days.
currentSite%vegtemp_memory(2:num_vegtemp_mem) = currentSite%vegtemp_memory(1:num_vegtemp_mem-1)
currentSite%vegtemp_memory(1) = temp_in_C

!count number of days for leaves off
ncolddays = 0
do i_tmem = 1,num_vegtemp_mem
Expand Down Expand Up @@ -1188,53 +1146,6 @@ subroutine phenology( currentSite, bc_in )
phen_moist_threshold = prt_params%phen_moist_threshold (ipft)
phen_doff_time = prt_params%phen_doff_time (ipft)


! Update soil moisture information memory (we always track the last 10 days)
do i_wmem = numWaterMem,2,-1 !shift memory to previous day, to make room for current day
currentSite%liqvol_memory(i_wmem,ipft) = currentSite%liqvol_memory(i_wmem-1,ipft)
currentSite%smp_memory (i_wmem,ipft) = currentSite%smp_memory (i_wmem-1,ipft)
end do

! Find the rooting depth distribution for PFT
call set_root_fraction( currentSite%rootfrac_scr, ipft, currentSite%zi_soil, &
bc_in%max_rooting_depth_index_col )
nlevroot = max(2,min(ubound(currentSite%zi_soil,1),bc_in%max_rooting_depth_index_col))

! The top most layer is typically very thin (~ 2cm) and dries rather quickly. Despite
! being thin, it can have a non-negligible rooting fraction (e.g., using
! exponential_2p_root_profile with default parameters make the top layer to contain
! about 7% of the total fine root density). To avoid overestimating dryness, we
! ignore the top layer when calculating the memory.
rootfrac_notop = sum(currentSite%rootfrac_scr(2:nlevroot))
if ( rootfrac_notop <= nearzero ) then
! Unlikely, but just in case all roots are in the first layer, we use the second
! layer the second layer (to avoid FPE issues).
currentSite%rootfrac_scr(2) = 1.0_r8
rootfrac_notop = 1.0_r8
end if

! Set the memory to be the weighted average of the soil properties, using the
! root fraction of each layer (except the topmost one) as the weighting factor.

currentSite%liqvol_memory(1,ipft) = sum( bc_in%h2o_liqvol_sl (2:nlevroot) * &
currentSite%rootfrac_scr(2:nlevroot) ) / &
rootfrac_notop
currentSite%smp_memory (1,ipft) = 0._r8
do j = 2,nlevroot
if(check_layer_water(bc_in%h2o_liqvol_sl(j),bc_in%tempk_sl(j)) ) then
currentSite%smp_memory (1,ipft) = currentSite%smp_memory (1,ipft) + &
bc_in%smp_sl (j) * &
currentSite%rootfrac_scr(j) / &
rootfrac_notop
else
! Nominal extreme suction for frozen or unreasonably dry soil
currentSite%smp_memory (1,ipft) = currentSite%smp_memory (1,ipft) + &
smp_lwr_bound * &
currentSite%rootfrac_scr(j) / &
rootfrac_notop
end if
end do

! Calculate the mean soil moisture ( liquid volume (m3/m3) and matric potential (mm))
! over the last 10 days
mean_10day_liqvol = sum(currentSite%liqvol_memory(1:numWaterMem,ipft)) / &
Expand Down
5 changes: 5 additions & 0 deletions main/EDMainMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ module EDMainMod
use EDPftvarcon, only : EDPftvarcon_inst
use FatesHistoryInterfaceMod, only : fates_hist
use FatesLandUseChangeMod, only: FatesGrazing
use FatesCumulativeMemoryMod, only : UpdateCumulativeMemoryVars

! CIME Globals
use shr_log_mod , only : errMsg => shr_log_errMsg
Expand Down Expand Up @@ -168,6 +169,10 @@ subroutine ed_ecosystem_dynamics(currentSite, bc_in, bc_out)
end do
call currentSite%flux_diags%ZeroFluxDiags()

! Call a routine that will compute cumulative variables and "memory" averages for
! a suite of variables. These variables are mostly used for leaf phenology, but they
! may be useful for other components (disturbances, mortality, management).
call UpdateCumulativeMemoryVars(currentSite,bc_in)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double checked that all memory variables that were refactored here were being incremented before they were being used in their original use, and this is true.


! Call a routine that simply identifies if logging should occur
! This is limited to a global event until more structured event handling is enabled
Expand Down
Loading