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

Migrate parameter file switches that are moving to HLM namelist #1300

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
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
10 changes: 5 additions & 5 deletions biogeochem/EDCanopyStructureMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ module EDCanopyStructureMod
use FatesCohortMod, only : fates_cohort_type
use EDParamsMod , only : nclmax
use EDParamsMod , only : nlevleaf
use EDParamsMod , only : radiation_model
use EDtypesMod , only : AREA
use EDLoggingMortalityMod , only : UpdateHarvestC
use FatesGlobals , only : endrun => fates_endrun
Expand Down Expand Up @@ -1314,11 +1313,12 @@ subroutine canopy_summarization( nsites, sites, bc_in )
! ---------------------------------------------------------------------------------

use FatesInterfaceTypesMod , only : hlm_use_cohort_age_tracking
use EDPatchDynamicsMod , only : set_patchno
use FatesInterfaceTypesMod , only : hlm_radiation_model
use EDPatchDynamicsMod , only : set_patchno
use FatesSizeAgeTypeIndicesMod, only : sizetype_class_index
use FatesSizeAgeTypeIndicesMod, only : coagetype_class_index
use EDtypesMod , only : area
use FatesConstantsMod , only : itrue
use EDtypesMod , only : area
use FatesConstantsMod , only : itrue

! !ARGUMENTS
integer , intent(in) :: nsites
Expand Down Expand Up @@ -1452,7 +1452,7 @@ subroutine canopy_summarization( nsites, sites, bc_in )

call leaf_area_profile(sites(s))

if(radiation_model.eq.twostr_solver) then
if(hlm_radiation_model.eq.twostr_solver) then
call FatesConstructRadElements(sites(s),bc_in(s)%fcansno_pa,bc_in(s)%coszen_pa)
end if

Expand Down
6 changes: 3 additions & 3 deletions biogeochem/EDMortalityFunctionsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ module EDMortalityFunctionsMod
use FatesCohortMod , only : fates_cohort_type
use EDTypesMod , only : ed_site_type
use EDParamsMod, only : maxpft
use EDParamsMod , only : mort_cstarvation_model
use FatesConstantsMod , only : itrue,ifalse
use FatesConstantsMod , only : cstarvation_model_lin
use FatesConstantsMod , only : cstarvation_model_exp
Expand Down Expand Up @@ -68,6 +67,7 @@ subroutine mortality_rates( cohort_in,bc_in, btran_ft, mean_temp, &
use FatesConstantsMod, only : fates_check_param_set
use DamageMainMod, only : GetDamageMortality
use EDParamsmod, only : soil_tfrz_thresh
use FatesInterfaceTypesMod, only : hlm_mort_cstarvation_model

type (fates_cohort_type), intent(in) :: cohort_in
type (bc_in_type), intent(in) :: bc_in
Expand Down Expand Up @@ -204,7 +204,7 @@ subroutine mortality_rates( cohort_in,bc_in, btran_ft, mean_temp, &
call storage_fraction_of_target(target_leaf_c, store_c, frac)

! Select the carbon starvation mortality model (linear or exponential)s.
select case (mort_cstarvation_model)
select case (hlm_mort_cstarvation_model)
case (cstarvation_model_lin)
! Linear model. Carbon starvation mortality will be zero when fraction of
! storage is greater than or equal to mort_upthresh_cstarvation, and will
Expand All @@ -223,7 +223,7 @@ subroutine mortality_rates( cohort_in,bc_in, btran_ft, mean_temp, &

case default
write(fates_log(),*) &
'Invalid carbon starvation model (',mort_cstarvation_model,').'
'Invalid carbon starvation model (',hlm_mort_cstarvation_model,').'
call endrun(msg=errMsg(sourcefile, __LINE__))
end select

Expand Down
18 changes: 9 additions & 9 deletions biogeochem/EDPatchDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module EDPatchDynamicsMod
use EDTypesMod , only : elem_diag_type
use EDTypesMod , only : min_patch_area
use EDTypesMod , only : min_patch_area_forced
use EDParamsMod , only : regeneration_model
use FatesInterfaceTypesMod, only : hlm_regeneration_model
use FatesInterfaceTypesMod, only : numpft
use FatesConstantsMod , only : dtype_ifall
use FatesConstantsMod , only : dtype_ilog
Expand Down Expand Up @@ -697,7 +697,7 @@ subroutine spawn_patches( currentSite, bc_in)

call newPatch%Create(age, site_areadis, i_landusechange_receiverpatchlabel, i_nocomp_pft, &
num_swb, numpft, currentSite%nlevsoil, hlm_current_tod, &
regeneration_model)
hlm_regeneration_model)

! Initialize the litter pools to zero, these
! pools will be populated by looping over the existing patches
Expand Down Expand Up @@ -1410,7 +1410,7 @@ subroutine spawn_patches( currentSite, bc_in)

call buffer_patch%Create(0._r8, 0._r8, i_land_use_label, 0, &
num_swb, numpft, currentSite%nlevsoil, hlm_current_tod, &
regeneration_model)
hlm_regeneration_model)

! Initialize the litter pools to zero
do el=1,num_elements
Expand Down Expand Up @@ -1598,7 +1598,7 @@ subroutine spawn_patches( currentSite, bc_in)
if ( .not. buffer_patch_in_linked_list) then
if (buffer_patch%area .lt. rsnbl_math_prec) then
! here we need to deallocate the buffer patch so that we don't get a memory leak.
call buffer_patch%FreeMemory(regeneration_model, numpft)
call buffer_patch%FreeMemory(hlm_regeneration_model, numpft)
deallocate(buffer_patch, stat=istat, errmsg=smsg)
if (istat/=0) then
write(fates_log(),*) 'dealloc: fail on deallocate(dp):'//trim(smsg)
Expand All @@ -1615,7 +1615,7 @@ subroutine spawn_patches( currentSite, bc_in)
end if
else
! buffer patch was never even used. deallocate.
call buffer_patch%FreeMemory(regeneration_model, numpft)
call buffer_patch%FreeMemory(hlm_regeneration_model, numpft)
deallocate(buffer_patch, stat=istat, errmsg=smsg)
if (istat/=0) then
write(fates_log(),*) 'dealloc: fail on deallocate(dp):'//trim(smsg)
Expand Down Expand Up @@ -1707,7 +1707,7 @@ subroutine split_patch(currentSite, currentPatch, new_patch, fraction_to_keep, a
call new_patch%Create(0._r8, temp_area, &
currentPatch%land_use_label, currentPatch%nocomp_pft_label, &
num_swb, numpft, currentSite%nlevsoil, hlm_current_tod, &
regeneration_model)
hlm_regeneration_model)

! Initialize the litter pools to zero, these
! pools will be populated shortly
Expand Down Expand Up @@ -3285,7 +3285,7 @@ subroutine fuse_2_patches(csite, dp, rp)
call rp%tveg24%FuseRMean(dp%tveg24,rp%area*inv_sum_area)
call rp%tveg_lpa%FuseRMean(dp%tveg_lpa,rp%area*inv_sum_area)

if ( regeneration_model == TRS_regeneration ) then
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)
Expand Down Expand Up @@ -3378,7 +3378,7 @@ subroutine fuse_2_patches(csite, dp, rp)
end if

! We have no need for the dp pointer anymore, we have passed on it's legacy
call dp%FreeMemory(regeneration_model, numpft)
call dp%FreeMemory(hlm_regeneration_model, numpft)
deallocate(dp, stat=istat, errmsg=smsg)
if (istat/=0) then
write(fates_log(),*) 'dealloc006: fail on deallocate(dp):'//trim(smsg)
Expand Down Expand Up @@ -3927,7 +3927,7 @@ subroutine CopyPatchMeansTimers(dp, rp)
call rp%tveg_lpa%CopyFromDonor(dp%tveg_lpa)
call rp%tveg_longterm%CopyFromDonor(dp%tveg_longterm)

if ( regeneration_model == TRS_regeneration ) then
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)
call rp%sdlng2sap_par%CopyFromDonor(dp%sdlng2sap_par)
Expand Down
28 changes: 14 additions & 14 deletions biogeochem/EDPhysiologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ module EDPhysiologyMod
use EDParamsMod , only : q10_mr
use EDParamsMod , only : q10_froz
use EDParamsMod , only : logging_export_frac
use EDParamsMod , only : regeneration_model
use EDParamsMod , only : sdlng_mort_par_timescale
use FatesPlantHydraulicsMod , only : AccumulateMortalityWaterStorage
use FatesConstantsMod , only : itrue,ifalse
Expand Down Expand Up @@ -144,7 +143,8 @@ module EDPhysiologyMod
use FatesParameterDerivedMod, only : param_derived
use FatesPlantHydraulicsMod, only : InitHydrCohort
use PRTInitParamsFatesMod, only : NewRecruitTotalStoichiometry
use FatesInterfaceTypesMod , only : hlm_use_luh
use FatesInterfaceTypesMod, only : hlm_use_luh
use FatesInterfaceTypesMod, only : hlm_regeneration_model

implicit none
private
Expand Down Expand Up @@ -2161,7 +2161,7 @@ subroutine SeedUpdate( currentSite )
litt%seed_in_local(pft) = litt%seed_in_local(pft) + site_seed_rain(pft)*(1.0_r8-site_disp_frac(pft))/area ![kg/m2/day]

! If we are using the Tree Recruitment Scheme (TRS) with or w/o seedling dynamics
if ( any(regeneration_model == [TRS_regeneration, TRS_no_seedling_dyn]) .and. &
if ( any(hlm_regeneration_model == [TRS_regeneration, TRS_no_seedling_dyn]) .and. &
prt_params%allom_dbh_maxheight(pft) > min_max_dbh_for_trees) then

! Send a fraction of reproductive carbon to litter to account for
Expand Down Expand Up @@ -2219,7 +2219,7 @@ subroutine SeedDecay( litt , currentPatch, bc_in )
!
! !DESCRIPTION:
! 1. Flux from seed pool into leaf litter pool
! 2. If the TRS with seedling dynamics is on (regeneration_model = 3)
! 2. If the TRS with seedling dynamics is on (hlm_regeneration_model = 3)
! then we calculate seedling mortality here (i.e. flux from seedling pool
! (into leaf litter pool)
!
Expand Down Expand Up @@ -2253,7 +2253,7 @@ subroutine SeedDecay( litt , currentPatch, bc_in )

! If the TRS is switched off or the pft can't get big enough to be considered a tree
! then use FATES default regeneration.
if ( regeneration_model == default_regeneration .or. &
if ( hlm_regeneration_model == default_regeneration .or. &
prt_params%allom_dbh_maxheight(pft) < min_max_dbh_for_trees ) then

! Default seed decay (TRS is off)
Expand All @@ -2265,7 +2265,7 @@ subroutine SeedDecay( litt , currentPatch, bc_in )
! If the TRS is switched on and the pft is a tree then add non-seed reproductive biomass
! to the seed decay flux. This was added to litt%seed_decay in the previously called SeedIn
! subroutine
if ( any(regeneration_model == [TRS_regeneration, TRS_no_seedling_dyn]) .and. &
if ( any(hlm_regeneration_model == [TRS_regeneration, TRS_no_seedling_dyn]) .and. &
prt_params%allom_dbh_maxheight(pft) > min_max_dbh_for_trees ) then

litt%seed_decay(pft) = litt%seed_decay(pft) + &! From non-seed reproductive biomass (added in
Expand All @@ -2275,9 +2275,9 @@ subroutine SeedDecay( litt , currentPatch, bc_in )
end if


! If the TRS is switched on with seedling dynamics (regeneration_model = 2)
! If the TRS is switched on with seedling dynamics (hlm_regeneration_model = 2)
! then calculate seedling mortality.
if_trs_germ_decay: if ( regeneration_model == TRS_regeneration .and. &
if_trs_germ_decay: if ( hlm_regeneration_model == TRS_regeneration .and. &
prt_params%allom_dbh_maxheight(pft) > min_max_dbh_for_trees ) then

!----------------------------------------------------------------------
Expand Down Expand Up @@ -2383,16 +2383,16 @@ subroutine SeedGermination( litt, cold_stat, drought_stat, bc_in, currentPatch )

! If the TRS's seedling dynamics is switched off, then we use FATES's default approach
! to germination
if_tfs_or_def: if ( regeneration_model == default_regeneration .or. &
regeneration_model == TRS_no_seedling_dyn .or. &
if_tfs_or_def: if ( hlm_regeneration_model == default_regeneration .or. &
hlm_regeneration_model == TRS_no_seedling_dyn .or. &
prt_params%allom_dbh_maxheight(pft) < min_max_dbh_for_trees ) then

litt%seed_germ_in(pft) = min(litt%seed(pft) * EDPftvarcon_inst%germination_rate(pft), &
max_germination)*years_per_day

! If TRS seedling dynamics is switched on we calculate seedling emergence (i.e. germination)
! as a pft-specific function of understory light and soil moisture.
else if ( regeneration_model == TRS_regeneration .and. &
else if ( hlm_regeneration_model == TRS_regeneration .and. &
prt_params%allom_dbh_maxheight(pft) > min_max_dbh_for_trees ) then

! Step 1. Calculate how germination rate is modified by understory light
Expand Down Expand Up @@ -2638,15 +2638,15 @@ subroutine recruitment(currentSite, currentPatch, bc_in)

! If TRS seedling dynamics is switched off then the available mass to make new recruits
! is everything in the seed_germ pool.
if (regeneration_model == default_regeneration .or. &
regeneration_model == TRS_no_seedling_dyn .or. &
if (hlm_regeneration_model == default_regeneration .or. &
hlm_regeneration_model == TRS_no_seedling_dyn .or. &
prt_params%allom_dbh_maxheight(ft) < min_max_dbh_for_trees) then

mass_avail = currentPatch%area * currentPatch%litter(el)%seed_germ(ft)

! If TRS seedling dynamics is on then calculate the available mass to make new recruits
! as a pft-specific function of light and soil moisture in the seedling layer.
else if (regeneration_model == TRS_regeneration .and. &
else if (hlm_regeneration_model == TRS_regeneration .and. &
prt_params%allom_dbh_maxheight(ft) > min_max_dbh_for_trees) then

sdlng2sap_par = currentPatch%sdlng2sap_par%GetMean()* &
Expand Down
18 changes: 9 additions & 9 deletions biogeophys/FatesPlantHydraulicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ module FatesPlantHydraulicsMod
use EDParamsMod , only : hydr_psi0
use EDParamsMod , only : hydr_psicap
use EDParamsMod , only : hydr_htftype_node
use EDParamsMod , only : hydr_solver

use EDTypesMod , only : ed_site_type
use FatesPatchMod , only : fates_patch_type
Expand All @@ -64,6 +63,7 @@ module FatesPlantHydraulicsMod
use FatesInterfaceTypesMod , only : hlm_ipedof
use FatesInterfaceTypesMod , only : numpft
use FatesInterfaceTypesMod , only : nlevsclass
use FatesInterfaceTypesMod , only : hlm_hydr_solver

use FatesAllometryMod, only : bleaf
use FatesAllometryMod, only : bsap_allom
Expand Down Expand Up @@ -1419,7 +1419,7 @@ subroutine InitHydrSites(sites,bc_in)
case(rhizlayer_aggmeth_none)

csite_hydr%nlevrhiz = bc_in(s)%nlevsoil
call sites(s)%si_hydr%InitHydrSite(numpft,nlevsclass,hydr_solver,bc_in(s)%nlevsoil)
call sites(s)%si_hydr%InitHydrSite(numpft,nlevsclass,hlm_hydr_solver,bc_in(s)%nlevsoil)

do j=1,csite_hydr%nlevrhiz
csite_hydr%map_r2s(j,1) = j
Expand All @@ -1431,7 +1431,7 @@ subroutine InitHydrSites(sites,bc_in)
case(rhizlayer_aggmeth_combine12)

csite_hydr%nlevrhiz = max(1,bc_in(s)%nlevsoil-1)
call sites(s)%si_hydr%InitHydrSite(numpft,nlevsclass,hydr_solver,bc_in(s)%nlevsoil)
call sites(s)%si_hydr%InitHydrSite(numpft,nlevsclass,hlm_hydr_solver,bc_in(s)%nlevsoil)

csite_hydr%map_r2s(1,1) = 1
j_bc = min(2,bc_in(s)%nlevsoil) ! this protects 1 soil layer
Expand All @@ -1449,7 +1449,7 @@ subroutine InitHydrSites(sites,bc_in)
case(rhizlayer_aggmeth_balN)

csite_hydr%nlevrhiz = min(aggN,bc_in(s)%nlevsoil)
call sites(s)%si_hydr%InitHydrSite(numpft,nlevsclass,hydr_solver,bc_in(s)%nlevsoil)
call sites(s)%si_hydr%InitHydrSite(numpft,nlevsclass,hlm_hydr_solver,bc_in(s)%nlevsoil)

ntoagg = int(ceiling(real(bc_in(s)%nlevsoil)/real(csite_hydr%nlevrhiz)-nearzero))

Expand Down Expand Up @@ -2583,21 +2583,21 @@ subroutine hydraulics_bc ( nsites, sites, bc_in, bc_out, dtime)
! from leaf to the current soil layer. This does NOT
! update cohort%th_*

if(hydr_solver == hydr_solver_2DNewton) then
if(hlm_hydr_solver == hydr_solver_2DNewton) then

call MatSolve2D(csite_hydr,ccohort,ccohort_hydr, &
dtime,qflx_tran_veg_indiv, &
sapflow,rootuptake(1:nlevrhiz),wb_err_plant,dwat_plant, &
dth_layershell_col)

elseif(hydr_solver == hydr_solver_2DPicard) then
elseif(hlm_hydr_solver == hydr_solver_2DPicard) then

call PicardSolve2D(csite_hydr,ccohort,ccohort_hydr, &
dtime,qflx_tran_veg_indiv, &
sapflow,rootuptake(1:nlevrhiz),wb_err_plant,dwat_plant, &
dth_layershell_col,csite_hydr%num_nodes)

elseif(hydr_solver == hydr_solver_1DTaylor ) then
elseif(hlm_hydr_solver == hydr_solver_1DTaylor ) then

! ---------------------------------------------------------------------------------
! Approach: do nlevsoi_hyd sequential solutions to Richards' equation,
Expand Down Expand Up @@ -4938,7 +4938,7 @@ subroutine MatSolve2D(csite_hydr,cohort,cohort_hydr, &


! This NaN's the scratch arrays
call csite_hydr%FlushSiteScratch(hydr_solver)
call csite_hydr%FlushSiteScratch(hlm_hydr_solver)

! This is the maximum number of iterations needed for this cohort
! (each soil layer has a different number, this saves the max)
Expand Down Expand Up @@ -5714,7 +5714,7 @@ subroutine PicardSolve2D(csite_hydr,cohort,cohort_hydr, &
ft => cohort%pft)

! This NaN's the scratch arrays
call csite_hydr%FlushSiteScratch(hydr_solver)
call csite_hydr%FlushSiteScratch(hlm_hydr_solver)

! This is the maximum number of iterations needed for this cohort
! (each soil layer has a different number, this saves the max)
Expand Down
Loading