Skip to content

Commit

Permalink
Merge pull request NGEET#647 from rgknox/init-order-v2
Browse files Browse the repository at this point in the history
Fixes to initialization order and circular dependencies
  • Loading branch information
glemieux authored May 13, 2020
2 parents b78c500 + 5b7bd67 commit 2d98623
Show file tree
Hide file tree
Showing 26 changed files with 1,015 additions and 1,009 deletions.
16 changes: 8 additions & 8 deletions biogeochem/EDCanopyStructureMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ module EDCanopyStructureMod
use EDTypesMod , only : nlevleaf
use EDtypesMod , only : AREA
use FatesGlobals , only : endrun => fates_endrun
use FatesInterfaceMod , only : hlm_days_per_year
use FatesInterfaceMod , only : hlm_use_planthydro
use FatesInterfaceMod , only : hlm_use_cohort_age_tracking
use FatesInterfaceMod , only : numpft
use FatesInterfaceTypesMod , only : hlm_days_per_year
use FatesInterfaceTypesMod , only : hlm_use_planthydro
use FatesInterfaceTypesMod , only : hlm_use_cohort_age_tracking
use FatesInterfaceTypesMod , only : numpft
use FatesPlantHydraulicsMod, only : UpdateH2OVeg,InitHydrCohort, RecruitWaterStorage
use EDTypesMod , only : maxCohortsPerPatch

Expand Down Expand Up @@ -121,7 +121,7 @@ subroutine canopy_structure( currentSite , bc_in )

use EDParamsMod, only : ED_val_comp_excln
use EDTypesMod , only : min_patch_area
use FatesInterfaceMod, only : bc_in_type
use FatesInterfaceTypesMod, only : bc_in_type
!
! !ARGUMENTS
type(ed_site_type) , intent(inout), target :: currentSite
Expand Down Expand Up @@ -1256,8 +1256,8 @@ subroutine canopy_summarization( nsites, sites, bc_in )
! Much of this routine was once ed_clm_link minus all the IO and history stuff
! ---------------------------------------------------------------------------------

use FatesInterfaceMod , only : bc_in_type
use FatesInterfaceMod , only : hlm_use_cohort_age_tracking
use FatesInterfaceTypesMod , only : bc_in_type
use FatesInterfaceTypesMod , only : hlm_use_cohort_age_tracking
use EDPatchDynamicsMod , only : set_patchno
use FatesSizeAgeTypeIndicesMod, only : sizetype_class_index
use FatesSizeAgeTypeIndicesMod, only : coagetype_class_index
Expand Down Expand Up @@ -1874,7 +1874,7 @@ subroutine update_hlm_dynamics(nsites,sites,fcolumn,bc_out)

use EDTypesMod , only : ed_patch_type, ed_cohort_type, &
ed_site_type, AREA
use FatesInterfaceMod , only : bc_out_type
use FatesInterfaceTypesMod , only : bc_out_type
use EDPftvarcon , only : EDPftvarcon_inst


Expand Down
26 changes: 10 additions & 16 deletions biogeochem/EDCohortDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ module EDCohortDynamicsMod
! !USES:
use FatesGlobals , only : endrun => fates_endrun
use FatesGlobals , only : fates_log
use FatesInterfaceMod , only : hlm_freq_day
use FatesInterfaceMod , only : bc_in_type
use FatesInterfaceMod , only : hlm_use_planthydro
use FatesInterfaceMod , only : hlm_use_cohort_age_tracking
use FatesInterfaceTypesMod , only : hlm_freq_day
use FatesInterfaceTypesMod , only : bc_in_type
use FatesInterfaceTypesMod , only : hlm_use_planthydro
use FatesInterfaceTypesMod , only : hlm_use_cohort_age_tracking
use FatesConstantsMod , only : r8 => fates_r8
use FatesConstantsMod , only : fates_unset_int
use FatesConstantsMod , only : itrue,ifalse
use FatesConstantsMod , only : fates_unset_r8
use FatesConstantsMod , only : nearzero
use FatesConstantsMod , only : calloc_abs_error
use FatesInterfaceMod , only : hlm_days_per_year
use FatesInterfaceMod , only : nleafage
use FatesInterfaceTypesMod , only : hlm_days_per_year
use FatesInterfaceTypesMod , only : nleafage
use SFParamsMod , only : SF_val_CWD_frac
use EDPftvarcon , only : EDPftvarcon_inst
use EDPftvarcon , only : GetDecompyFrac
Expand All @@ -38,8 +38,8 @@ module EDCohortDynamicsMod
use EDTypesMod , only : site_fluxdiags_type
use EDTypesMod , only : num_elements
use EDParamsMod , only : ED_val_cohort_age_fusion_tol
use FatesInterfaceMod , only : hlm_use_planthydro
use FatesInterfaceMod , only : hlm_parteh_mode
use FatesInterfaceTypesMod , only : hlm_use_planthydro
use FatesInterfaceTypesMod , only : hlm_parteh_mode
use FatesPlantHydraulicsMod, only : FuseCohortHydraulics
use FatesPlantHydraulicsMod, only : CopyCohortHydraulics
use FatesPlantHydraulicsMod, only : UpdateSizeDepPlantHydProps
Expand Down Expand Up @@ -953,7 +953,7 @@ subroutine fuse_cohorts(currentSite, currentPatch, bc_in)
! !USES:
use EDParamsMod , only : ED_val_cohort_size_fusion_tol
use EDParamsMod , only : ED_val_cohort_age_fusion_tol
use FatesInterfaceMod , only : hlm_use_cohort_age_tracking
use FatesInterfaceTypesMod , only : hlm_use_cohort_age_tracking
use FatesConstantsMod , only : itrue
use FatesConstantsMod, only : days_per_year
use EDTypesMod , only : maxCohortsPerPatch
Expand Down Expand Up @@ -985,7 +985,6 @@ subroutine fuse_cohorts(currentSite, currentPatch, bc_in)
real(r8) :: leaf_c_target
real(r8) :: dynamic_size_fusion_tolerance
real(r8) :: dynamic_age_fusion_tolerance
integer :: maxCohortsPerPatch_age_tracking
real(r8) :: dbh
real(r8) :: leaf_c ! leaf carbon [kg]

Expand All @@ -1004,11 +1003,6 @@ subroutine fuse_cohorts(currentSite, currentPatch, bc_in)
! set the cohort age fusion tolerance (in fraction of years)
dynamic_age_fusion_tolerance = ED_val_cohort_age_fusion_tol

if ( hlm_use_cohort_age_tracking .eq. itrue) then
maxCohortsPerPatch_age_tracking = 300
end if



!This needs to be a function of the canopy layer, because otherwise, at canopy closure
!the number of cohorts doubles and very dissimilar cohorts are fused together
Expand Down Expand Up @@ -1434,7 +1428,7 @@ subroutine fuse_cohorts(currentSite, currentPatch, bc_in)


if ( hlm_use_cohort_age_tracking .eq.itrue) then
if ( nocohorts > maxCohortsPerPatch_age_tracking ) then
if ( nocohorts > maxCohortsPerPatch ) then
iterate = 1
!---------------------------------------------------------------------!
! Making profile tolerance larger means that more fusion will happen !
Expand Down
16 changes: 8 additions & 8 deletions biogeochem/EDLoggingMortalityMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ module EDLoggingMortalityMod
use EDParamsMod , only : logging_mechanical_frac
use EDParamsMod , only : logging_coll_under_frac
use EDParamsMod , only : logging_dbhmax_infra
use FatesInterfaceMod , only : hlm_current_year
use FatesInterfaceMod , only : hlm_current_month
use FatesInterfaceMod , only : hlm_current_day
use FatesInterfaceMod , only : hlm_model_day
use FatesInterfaceMod , only : hlm_day_of_year
use FatesInterfaceMod , only : hlm_days_per_year
use FatesInterfaceMod , only : hlm_use_logging
use FatesInterfaceMod , only : hlm_use_planthydro
use FatesInterfaceTypesMod , only : hlm_current_year
use FatesInterfaceTypesMod , only : hlm_current_month
use FatesInterfaceTypesMod , only : hlm_current_day
use FatesInterfaceTypesMod , only : hlm_model_day
use FatesInterfaceTypesMod , only : hlm_day_of_year
use FatesInterfaceTypesMod , only : hlm_days_per_year
use FatesInterfaceTypesMod , only : hlm_use_logging
use FatesInterfaceTypesMod , only : hlm_use_planthydro
use FatesConstantsMod , only : itrue,ifalse
use FatesGlobals , only : endrun => fates_endrun
use FatesGlobals , only : fates_log
Expand Down
14 changes: 7 additions & 7 deletions biogeochem/EDMortalityFunctionsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ module EDMortalityFunctionsMod
use FatesConstantsMod , only : itrue,ifalse
use FatesAllometryMod , only : bleaf
use FatesAllometryMod , only : storage_fraction_of_target
use FatesInterfaceMod , only : bc_in_type
use FatesInterfaceMod , only : hlm_use_ed_prescribed_phys
use FatesInterfaceMod , only : hlm_freq_day
use FatesInterfaceMod , only : hlm_use_planthydro
use FatesInterfaceTypesMod , only : bc_in_type
use FatesInterfaceTypesMod , only : hlm_use_ed_prescribed_phys
use FatesInterfaceTypesMod , only : hlm_freq_day
use FatesInterfaceTypesMod , only : hlm_use_planthydro
use EDLoggingMortalityMod , only : LoggingMortality_frac
use EDParamsMod , only : fates_mortality_disturbance_fraction
use FatesInterfaceMod , only : bc_in_type
use FatesInterfaceTypesMod , only : bc_in_type

use PRTGenericMod, only : all_carbon_elements
use PRTGenericMod, only : store_organ
Expand Down Expand Up @@ -50,7 +50,7 @@ subroutine mortality_rates( cohort_in,bc_in,cmort,hmort,bmort,frmort,smort,asmor
! ============================================================================

use FatesConstantsMod, only : tfrz => t_water_freeze_k_1atm
use FatesInterfaceMod , only : hlm_hio_ignore_val
use FatesInterfaceTypesMod , only : hlm_hio_ignore_val
use FatesConstantsMod, only : fates_check_param_set

type (ed_cohort_type), intent(in) :: cohort_in
Expand Down Expand Up @@ -218,7 +218,7 @@ subroutine Mortality_Derivative( currentSite, currentCohort, bc_in)
!
! !USES:

use FatesInterfaceMod, only : hlm_freq_day
use FatesInterfaceTypesMod, only : hlm_freq_day
!
! !ARGUMENTS
type(ed_site_type), intent(inout), target :: currentSite
Expand Down
14 changes: 7 additions & 7 deletions biogeochem/EDPatchDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module EDPatchDynamicsMod
! Controls formation, creation, fusing and termination of patch level processes.
! ============================================================================
use FatesGlobals , only : fates_log
use FatesInterfaceMod , only : hlm_freq_day
use FatesInterfaceTypesMod , only : hlm_freq_day
use EDPftvarcon , only : EDPftvarcon_inst
use EDPftvarcon , only : GetDecompyFrac
use EDCohortDynamicsMod , only : fuse_cohorts, sort_cohorts, insert_cohort
Expand Down Expand Up @@ -37,11 +37,11 @@ module EDPatchDynamicsMod
use EDTypesMod , only : dl_sf
use EDTypesMod , only : dump_patch
use FatesConstantsMod , only : rsnbl_math_prec
use FatesInterfaceMod , only : hlm_use_planthydro
use FatesInterfaceMod , only : hlm_numSWb
use FatesInterfaceMod , only : bc_in_type
use FatesInterfaceMod , only : hlm_days_per_year
use FatesInterfaceMod , only : numpft
use FatesInterfaceTypesMod , only : hlm_use_planthydro
use FatesInterfaceTypesMod , only : hlm_numSWb
use FatesInterfaceTypesMod , only : bc_in_type
use FatesInterfaceTypesMod , only : hlm_days_per_year
use FatesInterfaceTypesMod , only : numpft
use FatesGlobals , only : endrun => fates_endrun
use FatesConstantsMod , only : r8 => fates_r8
use FatesConstantsMod , only : itrue, ifalse
Expand Down Expand Up @@ -75,7 +75,7 @@ module EDPatchDynamicsMod
use PRTGenericMod, only : repro_organ
use PRTGenericMod, only : struct_organ
use PRTLossFluxesMod, only : PRTBurnLosses
use FatesInterfaceMod, only : hlm_parteh_mode
use FatesInterfaceTypesMod, only : hlm_parteh_mode
use PRTGenericMod, only : prt_carbon_allom_hyp
use PRTGenericMod, only : prt_cnp_flex_allom_hyp

Expand Down
26 changes: 13 additions & 13 deletions biogeochem/EDPhysiologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ module EDPhysiologyMod
! ============================================================================

use FatesGlobals, only : fates_log
use FatesInterfaceMod, only : hlm_days_per_year
use FatesInterfaceMod, only : hlm_model_day
use FatesInterfaceMod, only : hlm_freq_day
use FatesInterfaceMod, only : hlm_day_of_year
use FatesInterfaceMod, only : numpft
use FatesInterfaceMod, only : nleafage
use FatesInterfaceMod, only : hlm_use_planthydro
use FatesInterfaceMod, only : hlm_parteh_mode
use FatesInterfaceTypesMod, only : hlm_days_per_year
use FatesInterfaceTypesMod, only : hlm_model_day
use FatesInterfaceTypesMod, only : hlm_freq_day
use FatesInterfaceTypesMod, only : hlm_day_of_year
use FatesInterfaceTypesMod, only : numpft
use FatesInterfaceTypesMod, only : nleafage
use FatesInterfaceTypesMod, only : hlm_use_planthydro
use FatesInterfaceTypesMod, only : hlm_parteh_mode
use FatesConstantsMod, only : r8 => fates_r8
use FatesConstantsMod, only : nearzero
use FatesConstantsMod, only : g_per_kg
use FatesConstantsMod, only : days_per_sec
use EDPftvarcon , only : EDPftvarcon_inst
use EDPftvarcon , only : GetDecompyFrac
use FatesInterfaceMod, only : bc_in_type
use FatesInterfaceTypesMod, only : bc_in_type
use EDCohortDynamicsMod , only : zero_cohort
use EDCohortDynamicsMod , only : create_cohort, sort_cohorts
use EDCohortDynamicsMod , only : InitPRTObject
Expand Down Expand Up @@ -1430,7 +1430,7 @@ subroutine recruitment( currentSite, currentPatch, bc_in )
! spawn new cohorts of juveniles of each PFT
!
! !USES:
use FatesInterfaceMod, only : hlm_use_ed_prescribed_phys
use FatesInterfaceTypesMod, only : hlm_use_ed_prescribed_phys
!
! !ARGUMENTS
type(ed_site_type), intent(inout), target :: currentSite
Expand Down Expand Up @@ -2234,9 +2234,9 @@ subroutine FluxIntoLitterPools(nsites, sites, bc_in, bc_out)

use EDTypesMod, only : AREA
use FatesConstantsMod, only : sec_per_day
use FatesInterfaceMod, only : bc_in_type, bc_out_type
use FatesInterfaceMod, only : hlm_use_vertsoilc
use FatesInterfaceMod, only : hlm_numlevgrnd
use FatesInterfaceTypesMod, only : bc_in_type, bc_out_type
use FatesInterfaceTypesMod, only : hlm_use_vertsoilc
use FatesInterfaceTypesMod, only : hlm_numlevgrnd
use FatesConstantsMod, only : itrue
use FatesGlobals, only : endrun => fates_endrun
use EDParamsMod , only : ED_val_cwd_flig, ED_val_cwd_fcel
Expand Down
2 changes: 1 addition & 1 deletion biogeophys/EDAccumulateFluxesMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ subroutine AccumulateFluxes_ED(nsites, sites, bc_in, bc_out, dt_time)

use EDTypesMod , only : ed_patch_type, ed_cohort_type, &
ed_site_type, AREA
use FatesInterfaceMod , only : bc_in_type,bc_out_type
use FatesInterfaceTypesMod , only : bc_in_type,bc_out_type

!
! !ARGUMENTS
Expand Down
4 changes: 2 additions & 2 deletions biogeophys/EDBtranMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ module EDBtranMod
ed_cohort_type, &
maxpft
use shr_kind_mod , only : r8 => shr_kind_r8
use FatesInterfaceMod , only : bc_in_type, &
use FatesInterfaceTypesMod , only : bc_in_type, &
bc_out_type, &
numpft
use FatesInterfaceMod , only : hlm_use_planthydro
use FatesInterfaceTypesMod , only : hlm_use_planthydro
use FatesGlobals , only : fates_log
use FatesAllometryMod , only : set_root_fraction
use FatesAllometryMod , only : i_hydro_rootprof_context
Expand Down
8 changes: 4 additions & 4 deletions biogeophys/EDSurfaceAlbedoMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ module EDSurfaceRadiationMod
use FatesConstantsMod , only : r8 => fates_r8
use FatesConstantsMod , only : itrue
use FatesConstantsMod , only : pi_const
use FatesInterfaceMod , only : bc_in_type
use FatesInterfaceMod , only : bc_out_type
use FatesInterfaceMod , only : hlm_numSWb
use FatesInterfaceMod , only : numpft
use FatesInterfaceTypesMod , only : bc_in_type
use FatesInterfaceTypesMod , only : bc_out_type
use FatesInterfaceTypesMod , only : hlm_numSWb
use FatesInterfaceTypesMod , only : numpft
use EDTypesMod , only : maxSWb
use EDTypesMod , only : nclmax
use EDTypesMod , only : nlevleaf
Expand Down
4 changes: 2 additions & 2 deletions biogeophys/FatesBstressMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ module FatesBstressMod
ed_cohort_type, &
maxpft
use shr_kind_mod , only : r8 => shr_kind_r8
use FatesInterfaceMod , only : bc_in_type, &
use FatesInterfaceTypesMod , only : bc_in_type, &
bc_out_type, &
numpft
use FatesInterfaceMod , only : hlm_use_planthydro
use FatesInterfaceTypesMod , only : hlm_use_planthydro
use FatesGlobals , only : fates_log
use EDBtranMod , only : check_layer_water
use FatesAllometryMod , only : set_root_fraction
Expand Down
12 changes: 6 additions & 6 deletions biogeophys/FatesPlantHydraulicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ module FatesPlantHydraulicsMod
use EDTypesMod , only : AREA
use EDTypesMod , only : leaves_on

use FatesInterfaceMod , only : bc_in_type
use FatesInterfaceMod , only : bc_out_type
use FatesInterfaceMod , only : hlm_use_planthydro
use FatesInterfaceMod , only : hlm_ipedof
use FatesInterfaceMod , only : numpft
use FatesInterfaceMod , only : nlevsclass
use FatesInterfaceTypesMod , only : bc_in_type
use FatesInterfaceTypesMod , only : bc_out_type
use FatesInterfaceTypesMod , only : hlm_use_planthydro
use FatesInterfaceTypesMod , only : hlm_ipedof
use FatesInterfaceTypesMod , only : numpft
use FatesInterfaceTypesMod , only : nlevsclass

use FatesAllometryMod, only : bleaf
use FatesAllometryMod, only : bsap_allom
Expand Down
12 changes: 6 additions & 6 deletions biogeophys/FatesPlantRespPhotosynthMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ module FATESPlantRespPhotosynthMod
use FatesConstantsMod, only : r8 => fates_r8
use FatesConstantsMod, only : itrue
use FatesConstantsMod, only : nearzero
use FatesInterfaceMod, only : hlm_use_planthydro
use FatesInterfaceMod, only : hlm_parteh_mode
use FatesInterfaceMod, only : numpft
use FatesInterfaceMod, only : nleafage
use FatesInterfaceTypesMod, only : hlm_use_planthydro
use FatesInterfaceTypesMod, only : hlm_parteh_mode
use FatesInterfaceTypesMod, only : numpft
use FatesInterfaceTypesMod, only : nleafage
use EDTypesMod, only : maxpft
use EDTypesMod, only : nlevleaf
use EDTypesMod, only : nclmax
Expand Down Expand Up @@ -89,8 +89,8 @@ subroutine FatesPlantRespPhotosynthDrive (nsites, sites,bc_in,bc_out,dtime)
use EDTypesMod , only : ed_site_type
use EDTypesMod , only : maxpft
use EDTypesMod , only : dinc_ed
use FatesInterfaceMod , only : bc_in_type
use FatesInterfaceMod , only : bc_out_type
use FatesInterfaceTypesMod , only : bc_in_type
use FatesInterfaceTypesMod , only : bc_out_type
use EDCanopyStructureMod, only : calc_areaindex
use FatesConstantsMod, only : umolC_to_kgC
use FatesConstantsMod, only : g_per_kg
Expand Down
Loading

0 comments on commit 2d98623

Please sign in to comment.