Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions biogeochem/EDCanopyStructureMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ subroutine DemoteFromLayer(currentSite,currentPatch,i_lyr,bc_in)
!!allocate(copyc%l2fr_ema)
! Note, no need to give a starter value here,
! that will be taken care of in copy()
!!call copyc%l2fr_ema%InitRMean(ema_60day)
!!call copyc%l2fr_ema%InitRSumm(ema_60day)

! Initialize the PARTEH object and point to the
! correct boundary condition fields
Expand Down Expand Up @@ -1157,7 +1157,7 @@ subroutine PromoteIntoLayer(currentSite,currentPatch,i_lyr)
!!allocate(copyc%l2fr_ema)
! Note, no need to give a starter value here,
! that will be taken care of in copy()
!!call copyc%l2fr_ema%InitRMean(ema_60day)
!!call copyc%l2fr_ema%InitRSumm(ema_60day)

! Initialize the PARTEH object and point to the
! correct boundary condition fields
Expand All @@ -1172,7 +1172,7 @@ subroutine PromoteIntoLayer(currentSite,currentPatch,i_lyr)
! (keep as an example)
! Initialize running means
!allocate(copyc%tveg_lpa)
!call copyc%tveg_lpa%InitRMean(ema_lpa,&
!call copyc%tveg_lpa%InitRSumm(ema_lpa,&
! init_value=currentPatch%tveg_lpa%GetMean())

call currentCohort%Copy(copyc) !makes an identical copy...
Expand Down
2 changes: 1 addition & 1 deletion biogeochem/EDCohortDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ subroutine create_cohort(currentSite, patchptr, pft, nn, height, coage, dbh,

! (Keeping as an example)
!! allocate(newCohort%tveg_lpa)
!! call newCohort%tveg_lpa%InitRMean(ema_lpa,init_value=patchptr%tveg_lpa%GetMean())
!! call newCohort%tveg_lpa%InitRSumm(ema_lpa,init_value=patchptr%tveg_lpa%GetMean())

if (hlm_use_planthydro .eq. itrue) then

Expand Down
37 changes: 23 additions & 14 deletions biogeochem/EDPatchDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ module EDPatchDynamicsMod
use EDParamsMod, only : logging_event_code
use EDParamsMod, only : logging_export_frac
use EDParamsMod, only : maxpatches_by_landuse
use FatesRunningMeanMod, only : ema_sdlng_mdd
use FatesRunningMeanMod, only : ema_sdlng_emerg_h2o, ema_sdlng_mort_par, ema_sdlng2sap_par
use FatesRunningMeanMod, only : ema_24hr, fixed_24hr, ema_lpa, ema_longterm
use FatesRunningSummMod, only : ema_sdlng_mdd
use FatesRunningSummMod, only : ema_sdlng_emerg_h2o, ema_sdlng_mort_par, ema_sdlng2sap_par
use FatesRunningSummMod, only : ema_24hr, fixed_24hr, ema_lpa, ema_longterm
use FatesRadiationMemMod, only : num_swb

! CIME globals
Expand Down Expand Up @@ -808,7 +808,7 @@ subroutine spawn_patches( currentSite, bc_in)
! (Keeping as an example)
! Allocate running mean functions
!allocate(nc%tveg_lpa)
!call nc%tveg_lpa%InitRMean(ema_lpa,init_value=newPatch%tveg_lpa%GetMean())
!call nc%tveg_lpa%InitRSumm(ema_lpa,init_value=newPatch%tveg_lpa%GetMean())

call nc%ZeroValues()

Expand Down Expand Up @@ -1701,7 +1701,7 @@ subroutine split_patch(currentSite, currentPatch, new_patch, fraction_to_keep, a
! (Keeping as an example)
! Allocate running mean functions
!allocate(nc%tveg_lpa)
!call nc%tveg_lpa%InitRMean(ema_lpa,init_value=new_patch%tveg_lpa%GetMean())
!call nc%tveg_lpa%InitRSumm(ema_lpa,init_value=new_patch%tveg_lpa%GetMean())

call nc%ZeroValues()

Expand Down Expand Up @@ -3183,21 +3183,26 @@ subroutine fuse_2_patches(csite, dp, rp)
call endrun(msg=errMsg(sourcefile, __LINE__))
endif

! Weighted mean of the running means
call rp%tveg24%FuseRMean(dp%tveg24,rp%area*inv_sum_area)
call rp%tveg_lpa%FuseRMean(dp%tveg_lpa,rp%area*inv_sum_area)
! Weighted mean of the running summaries
call rp%tveg24%FuseRSumm(dp%tveg24,rp%area*inv_sum_area)
call rp%tveg_lpa%FuseRSumm(dp%tveg_lpa,rp%area*inv_sum_area)

do pft = 1,numpft
call rp%btran24_ft(pft)%p%FuseRSumm(dp%btran24_ft(pft)%p,rp%area*inv_sum_area)
enddo


if ( hlm_regeneration_model == TRS_regeneration ) then
call rp%seedling_layer_par24%FuseRMean(dp%seedling_layer_par24,rp%area*inv_sum_area)
call rp%sdlng_mort_par%FuseRMean(dp%sdlng_mort_par,rp%area*inv_sum_area)
call rp%sdlng2sap_par%FuseRMean(dp%sdlng2sap_par,rp%area*inv_sum_area)
call rp%seedling_layer_par24%FuseRSumm(dp%seedling_layer_par24,rp%area*inv_sum_area)
call rp%sdlng_mort_par%FuseRSumm(dp%sdlng_mort_par,rp%area*inv_sum_area)
call rp%sdlng2sap_par%FuseRSumm(dp%sdlng2sap_par,rp%area*inv_sum_area)
do pft = 1,numpft
call rp%sdlng_emerg_smp(pft)%p%FuseRMean(dp%sdlng_emerg_smp(pft)%p,rp%area*inv_sum_area)
call rp%sdlng_mdd(pft)%p%FuseRMean(dp%sdlng_mdd(pft)%p,rp%area*inv_sum_area)
call rp%sdlng_emerg_smp(pft)%p%FuseRSumm(dp%sdlng_emerg_smp(pft)%p,rp%area*inv_sum_area)
call rp%sdlng_mdd(pft)%p%FuseRSumm(dp%sdlng_mdd(pft)%p,rp%area*inv_sum_area)
enddo
end if

call rp%tveg_longterm%FuseRMean(dp%tveg_longterm,rp%area*inv_sum_area)
call rp%tveg_longterm%FuseRSumm(dp%tveg_longterm,rp%area*inv_sum_area)

rp%livegrass = (dp%livegrass*dp%area + rp%livegrass*rp%area) * inv_sum_area
rp%ros_front = (dp%ros_front*dp%area + rp%ros_front*rp%area) * inv_sum_area
Expand Down Expand Up @@ -3811,6 +3816,10 @@ subroutine CopyPatchMeansTimers(dp, rp)
call rp%tveg_lpa%CopyFromDonor(dp%tveg_lpa)
call rp%tveg_longterm%CopyFromDonor(dp%tveg_longterm)

do ipft = 1,numpft
call rp%btran24_ft(ipft)%p%CopyFromDonor(dp%btran24_ft(ipft)%p)
end do

if ( hlm_regeneration_model == TRS_regeneration ) then
call rp%seedling_layer_par24%CopyFromDonor(dp%seedling_layer_par24)
call rp%sdlng_mort_par%CopyFromDonor(dp%sdlng_mort_par)
Expand Down
65 changes: 41 additions & 24 deletions biogeochem/FatesPatchMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module FatesPatchMod
use FatesUtilsMod, only : check_hlm_list
use FatesUtilsMod, only : check_var_real
use FatesCohortMod, only : fates_cohort_type
use FatesRunningMeanMod, only : rmean_type, rmean_arr_type
use FatesRunningSummMod, only : rsumm_type, rsumm_arr_type
use FatesLitterMod, only : litter_type
use FatesFuelMod, only : fuel_type
use PRTGenericMod, only : num_elements
Expand All @@ -24,9 +24,9 @@ module FatesPatchMod
use EDParamsMod, only : nlevleaf, nclmax, maxpft
use FatesConstantsMod, only : n_dbh_bins, n_dist_types
use FatesConstantsMod, only : t_water_freeze_k_1atm
use FatesRunningMeanMod, only : ema_24hr, fixed_24hr, ema_lpa, ema_longterm
use FatesRunningMeanMod, only : ema_sdlng_emerg_h2o, ema_sdlng_mort_par
use FatesRunningMeanMod, only : ema_sdlng2sap_par, ema_sdlng_mdd
use FatesRunningSummMod, only : ema_24hr, fixed_24hr, ema_lpa, ema_longterm
use FatesRunningSummMod, only : ema_sdlng_emerg_h2o, ema_sdlng_mort_par
use FatesRunningSummMod, only : ema_sdlng2sap_par, ema_sdlng_mdd
use TwoStreamMLPEMod, only : twostream_type
use FatesRadiationMemMod, only : num_swb
use FatesRadiationMemMod, only : num_rad_stream_types
Expand Down Expand Up @@ -75,23 +75,24 @@ module FatesPatchMod
!---------------------------------------------------------------------------

! RUNNING MEANS
!class(rmean_type), pointer :: t2m ! place-holder for 2m air temperature (variable window-size)
class(rmean_type), pointer :: tveg24 ! 24-hour mean vegetation temperature [K]
class(rmean_type), pointer :: tveg_lpa ! running mean of vegetation temperature at the
!class(rsumm_type), pointer :: t2m ! place-holder for 2m air temperature (variable window-size)
class(rsumm_type), pointer :: tveg24 ! 24-hour summary vegetation temperature [K]
class(rsumm_type), pointer :: tveg_lpa ! running mean of vegetation temperature at the
! leaf photosynthesis acclimation timescale [K]
class(rmean_type), pointer :: tveg_longterm ! long-term running mean of vegetation temperature at the
class(rsumm_type), pointer :: tveg_longterm ! long-term running mean of vegetation temperature at the
! leaf photosynthesis acclimation timescale [K] (i.e T_home)
class(rmean_type), pointer :: seedling_layer_par24 ! 24-hour mean of photosynthetically active radiation at seedling layer [W/m2]
class(rmean_arr_type), pointer :: sdlng_emerg_smp(:) ! running mean of soil matric potential at the seedling
class(rsumm_arr_type), pointer :: btran24_ft(:) ! 24-hour summary of transpiration wetness factor (aka btran)
class(rsumm_type), pointer :: seedling_layer_par24 ! 24-hour summary of photosynthetically active radiation at seedling layer [W/m2]
class(rsumm_arr_type), pointer :: sdlng_emerg_smp(:) ! running mean of soil matric potential at the seedling
! rooting depth at the H2O seedling emergence timescale (see sdlng_emerg_h2o_timescale parameter)
class(rmean_type), pointer :: sdlng_mort_par ! running mean of photosythetically active radiation
class(rsumm_type), pointer :: sdlng_mort_par ! running mean of photosythetically active radiation
! at the seedling layer and at the par-based seedling
! mortality timescale (sdlng_mort_par_timescale)
class(rmean_arr_type), pointer :: sdlng_mdd(:) ! running mean of moisture deficit days
class(rsumm_arr_type), pointer :: sdlng_mdd(:) ! running mean of moisture deficit days
! at the seedling layer and at the mdd-based seedling
! mortality timescale (sdlng_mdd_timescale)
! (sdlng2sap_par_timescale)
class(rmean_type), pointer :: sdlng2sap_par ! running mean of photosythetically active radiation
class(rsumm_type), pointer :: sdlng2sap_par ! running mean of photosythetically active radiation
! at the seedling layer and at the par-based seedling
! to sapling transition timescale
! (sdlng2sap_par_timescale)
Expand Down Expand Up @@ -614,18 +615,28 @@ subroutine InitRunningMeans(this, current_tod, regeneration_model, numpft)
! Until bc's are pointed to by sites give veg a default temp [K]
real(r8), parameter :: temp_init_veg = 15._r8 + t_water_freeze_k_1atm
real(r8), parameter :: init_seedling_par = 5.0_r8 ! arbitrary initialization for seedling layer [MJ m-2 d-1]
real(r8), parameter :: init_seedling_smp = -26652.0_r8 ! abitrary initialization of smp [mm]
real(r8), parameter :: init_seedling_smp = -26652.0_r8 ! arbitrary initialization of smp [mm]
real(r8), parameter :: init_btran = 1.0_r8 ! arbitrary initial value for btran [fraction]
integer :: pft ! pft looping index

allocate(this%tveg24)
allocate(this%tveg_lpa)
allocate(this%tveg_longterm)
allocate(this%btran24_ft(numpft))

! set initial values for running means
call this%tveg24%InitRMean(fixed_24hr, init_value=temp_init_veg, &
! set initial values for running summaries
call this%tveg24%InitRSumm(fixed_24hr, init_value=temp_init_veg, &
init_offset=real(current_tod, r8))
call this%tveg_lpa%InitRmean(ema_lpa, init_value=temp_init_veg)
call this%tveg_longterm%InitRmean(ema_longterm, init_value=temp_init_veg)
call this%tveg_lpa%InitRSumm(ema_lpa, init_value=temp_init_veg)
call this%tveg_longterm%InitRSumm(ema_longterm, init_value=temp_init_veg)

do pft = 1,numpft
allocate(this%btran24_ft(pft)%p)

call this%btran24_ft(pft)%p%InitRSumm(fixed_24hr,init_value=init_btran, &
init_offset=real(current_tod, r8))
end do


if (regeneration_model == TRS_regeneration) then
allocate(this%seedling_layer_par24)
Expand All @@ -634,20 +645,20 @@ subroutine InitRunningMeans(this, current_tod, regeneration_model, numpft)
allocate(this%sdlng_mort_par)
allocate(this%sdlng2sap_par)

call this%seedling_layer_par24%InitRMean(fixed_24hr, &
call this%seedling_layer_par24%InitRSumm(fixed_24hr, &
init_value=init_seedling_par, init_offset=real(current_tod, r8))
call this%sdlng_mort_par%InitRMean(ema_sdlng_mort_par, &
call this%sdlng_mort_par%InitRSumm(ema_sdlng_mort_par, &
init_value=temp_init_veg)
call this%sdlng2sap_par%InitRMean(ema_sdlng2sap_par, &
call this%sdlng2sap_par%InitRSumm(ema_sdlng2sap_par, &
init_value=init_seedling_par)

do pft = 1,numpft
allocate(this%sdlng_mdd(pft)%p)
allocate(this%sdlng_emerg_smp(pft)%p)

call this%sdlng_mdd(pft)%p%InitRMean(ema_sdlng_mdd, &
call this%sdlng_mdd(pft)%p%InitRSumm(ema_sdlng_mdd, &
init_value=0.0_r8)
call this%sdlng_emerg_smp(pft)%p%InitRMean(ema_sdlng_emerg_h2o, &
call this%sdlng_emerg_smp(pft)%p%InitRSumm(ema_sdlng_emerg_h2o, &
init_value=init_seedling_smp)
end do
end if
Expand Down Expand Up @@ -911,7 +922,7 @@ subroutine FreeMemory(this, regeneration_model, numpft)
call endrun(msg=errMsg(sourcefile, __LINE__))
endif

! deallocate running means
! deallocate running summaries
deallocate(this%tveg24, stat=istat, errmsg=smsg)
if (istat/=0) then
write(fates_log(),*) 'dealloc011: fail on deallocate(this%tveg24):'//trim(smsg)
Expand All @@ -928,6 +939,12 @@ subroutine FreeMemory(this, regeneration_model, numpft)
call endrun(msg=errMsg(sourcefile, __LINE__))
endif

do pft = 1, numpft
deallocate(this%btran24_ft(pft)%p)
end do
deallocate(this%btran24_ft)


if (regeneration_model == TRS_regeneration) then
deallocate(this%seedling_layer_par24)
deallocate(this%sdlng_mort_par)
Expand Down
2 changes: 1 addition & 1 deletion main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ list(APPEND fates_sources
EDParamsMod.F90
EDTypesMod.F90
FatesHydraulicsMemMod.F90
FatesRunningMeanMod.F90
FatesRunningSummMod.F90
FatesParameterDerivedMod.F90
FatesSizeAgeTypeIndicesMod.F90
FatesIntegratorsMod.F90
Expand Down
2 changes: 1 addition & 1 deletion main/EDTypesMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module EDTypesMod
use FatesLitterMod, only : litter_type
use FatesLitterMod, only : ncwd
use FatesConstantsMod, only : days_per_year
use FatesRunningMeanMod, only : rmean_type,rmean_arr_type
use FatesRunningSummMod, only : rsumm_type,rsumm_arr_type
use FatesConstantsMod, only : fates_unset_r8
use FatesInterfaceTypesMod,only : bc_in_type
use FatesInterfaceTypesMod,only : bc_out_type
Expand Down
25 changes: 25 additions & 0 deletions main/FatesHistoryInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,8 @@ module FatesHistoryInterfaceMod
integer :: ih_site_dstatus_si_pft
integer :: ih_dleafoff_si_pft
integer :: ih_dleafon_si_pft
integer :: ih_meanbtran24_si_pft
integer :: ih_minbtran24_si_pft
integer :: ih_meanliqvol_si_pft
integer :: ih_meansmp_si_pft
integer :: ih_elong_factor_si_pft
Expand Down Expand Up @@ -3266,6 +3268,8 @@ subroutine update_history_dyn_subsite(this,nc,nsites,sites,bc_in)
associate( hio_site_dstatus_si_pft => this%hvars(ih_site_dstatus_si_pft)%r82d, &
hio_dleafoff_si_pft => this%hvars(ih_dleafoff_si_pft)%r82d, &
hio_dleafon_si_pft => this%hvars(ih_dleafon_si_pft)%r82d, &
hio_meanbtran24_si_pft => this%hvars(ih_meanbtran24_si_pft)%r82d, &
hio_minbtran24_si_pft => this%hvars(ih_minbtran24_si_pft)%r82d, &
hio_meanliqvol_si_pft => this%hvars(ih_meanliqvol_si_pft)%r82d, &
hio_meansmp_si_pft => this%hvars(ih_meansmp_si_pft)%r82d, &
hio_elong_factor_si_pft => this%hvars(ih_elong_factor_si_pft)%r82d, &
Expand Down Expand Up @@ -3422,6 +3426,13 @@ subroutine update_history_dyn_subsite(this,nc,nsites,sites,bc_in)
cpatch%frac_burnt * cpatch%area * AREA_INV / sec_per_day
endif

! 24hr mean btran
hio_meanbtran24_si_pft(io_si,ft) = hio_meanbtran24_si_pft(io_si,ft) + &
cpatch%btran24_ft(ft)%p%GetMean() * cpatch%area * AREA_INV

! 24hr minimum btran
hio_minbtran24_si_pft(io_si,ft) = hio_minbtran24_si_pft(io_si,ft) + &
cpatch%btran24_ft(ft)%p%GetMin() * cpatch%area * AREA_INV
end do

! loop through cohorts on patch
Expand Down Expand Up @@ -7086,6 +7097,20 @@ subroutine define_history_vars(this, initialize_variables)
upfreq=group_dyna_complx, ivar=ivar, initialize=initialize_variables, &
index=ih_dleafon_si_pft)

call this%set_history_var(vname='FATES_MEANBTRAN24_PF', &
units='1', &
long='PFT-level 24hr mean transpiration wetness factor (btran)', &
use_default='inactive', avgflag='A', vtype=site_pft_r8, hlms='CLM:ALM', &
upfreq=group_dyna_complx, ivar=ivar, initialize=initialize_variables, &
index=ih_meanbtran24_si_pft)

call this%set_history_var(vname='FATES_MINBTRAN24_PF', &
units='1', &
long='PFT-level 24hr minimum transpiration wetness factor (btran)', &
use_default='active', avgflag='A', vtype=site_pft_r8, hlms='CLM:ALM', &
upfreq=group_dyna_complx, ivar=ivar, initialize=initialize_variables, &
index=ih_minbtran24_si_pft)

call this%set_history_var(vname='FATES_MEANLIQVOL_DROUGHTPHEN_PF', &
units='m3 m-3', &
long='PFT-level mean liquid water volume for drought phenolgy', &
Expand Down
Loading