-
Notifications
You must be signed in to change notification settings - Fork 105
Migrate 10-day memory variables out of the main phenology sub-routine #1389
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
base: main
Are you sure you want to change the base?
Changes from all commits
32ed527
6cddb5f
2cd8a03
72939db
6e44398
599b940
04160ee
58003da
71a5945
182db6c
91ac79a
158bf67
909e156
8ed9018
f24de49
22b0ec3
afae1c6
dad8084
492c437
9beb94b
4c07332
560f348
bcc7c2d
4943e7a
538dec8
ec1a76a
4dabc79
120b2b5
b2902e0
39cf8c5
faeb073
73708ca
e6719ff
777f744
aab347a
8765fcc
11da014
9b7849d
22ccdf0
fdf2232
7e3d888
dad8a91
7f58290
eab4465
ab0e144
bdc2e56
f94c8dc
d2a8998
4eacc43
0e55906
458bf6a
1932bd3
47caaec
3255e94
0df8283
69782df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -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 | ||
|
|
@@ -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 | ||
|
|
@@ -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 | ||
|
|
||
|
|
||
| ! 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) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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--------------------! | ||
|
|
||
|
|
@@ -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 | ||
|
|
@@ -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)) / & | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -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) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.