From dc8e625bcd42da44f08f726cb25424c8dfda87df Mon Sep 17 00:00:00 2001 From: Maoyi Huang Date: Tue, 10 Oct 2017 22:09:15 -0700 Subject: [PATCH 1/6] Update the logging module for variable names and treatments of collateral/infra/understory damages --- biogeochem/EDCohortDynamicsMod.F90 | 16 +++++----- biogeochem/EDLoggingMortalityMod.F90 | 34 ++++++++++++--------- biogeochem/EDPatchDynamicsMod.F90 | 45 ++++++++++++++-------------- biogeochem/EDPhysiologyMod.F90 | 10 +++---- main/EDParamsMod.F90 | 1 + main/EDTypesMod.F90 | 5 ++-- main/FatesHistoryInterfaceMod.F90 | 20 ++++++------- main/FatesRestartInterfaceMod.F90 | 43 ++++++++++---------------- 8 files changed, 84 insertions(+), 90 deletions(-) diff --git a/biogeochem/EDCohortDynamicsMod.F90 b/biogeochem/EDCohortDynamicsMod.F90 index 89c96b8b..4f4f3ddc 100755 --- a/biogeochem/EDCohortDynamicsMod.F90 +++ b/biogeochem/EDCohortDynamicsMod.F90 @@ -416,7 +416,7 @@ subroutine nan_cohort(cc_p) currentCohort%root_md = nan ! root maintenance demand: kgC/indiv/year currentCohort%carbon_balance = nan ! carbon remaining for growth and storage: kg/indiv/year currentCohort%dmort = nan ! proportional mortality rate. (year-1) - currentCohort%lmort_logging = nan + currentCohort%lmort_direct = nan currentCohort%lmort_infra = nan currentCohort%lmort_collateral = nan @@ -494,7 +494,7 @@ subroutine zero_cohort(cc_p) currentcohort%dmort = 0._r8 currentcohort%gscan = 0._r8 currentcohort%treesai = 0._r8 - currentCohort%lmort_logging = 0._r8 + currentCohort%lmort_direct = 0._r8 currentCohort%lmort_infra = 0._r8 currentCohort%lmort_collateral = 0._r8 ! currentCohort%npp_leaf = 0._r8 @@ -847,8 +847,8 @@ subroutine fuse_cohorts(patchptr, bc_in) currentCohort%dmort = (currentCohort%n*currentCohort%dmort + & nextc%n*nextc%dmort)/newn - currentCohort%lmort_logging = (currentCohort%n*currentCohort%lmort_logging + & - nextc%n*nextc%lmort_logging)/newn + currentCohort%lmort_direct = (currentCohort%n*currentCohort%lmort_direct + & + nextc%n*nextc%lmort_direct)/newn currentCohort%lmort_infra = (currentCohort%n*currentCohort%lmort_infra + & nextc%n*nextc%lmort_infra)/newn currentCohort%lmort_collateral = (currentCohort%n*currentCohort%lmort_collateral + & @@ -867,8 +867,8 @@ subroutine fuse_cohorts(patchptr, bc_in) currentCohort%fmort = (currentCohort%n*currentCohort%fmort + nextc%n*nextc%fmort)/newn ! logging mortality, Yi Xu - currentCohort%lmort_logging = (currentCohort%n*currentCohort%lmort_logging + & - nextc%n*nextc%lmort_logging)/newn + currentCohort%lmort_direct = (currentCohort%n*currentCohort%lmort_direct + & + nextc%n*nextc%lmort_direct)/newn currentCohort%lmort_collateral = (currentCohort%n*currentCohort%lmort_collateral + & nextc%n*nextc%lmort_collateral)/newn currentCohort%lmort_infra = (currentCohort%n*currentCohort%lmort_infra + & @@ -1232,7 +1232,7 @@ subroutine copy_cohort( currentCohort,copyc ) n%root_md = o%root_md n%carbon_balance = o%carbon_balance n%dmort = o%dmort - n%lmort_logging = o%lmort_logging + n%lmort_direct = o%lmort_direct n%lmort_infra = o%lmort_infra n%lmort_collateral= o%lmort_collateral n%seed_prod = o%seed_prod @@ -1250,7 +1250,7 @@ subroutine copy_cohort( currentCohort,copyc ) n%hmort = o%hmort ! logging mortalities, Yi Xu - n%lmort_logging=o%lmort_logging + n%lmort_direct=o%lmort_direct n%lmort_collateral =o%lmort_collateral n%lmort_infra =o%lmort_infra diff --git a/biogeochem/EDLoggingMortalityMod.F90 b/biogeochem/EDLoggingMortalityMod.F90 index 4f87fcaa..85a4c8c8 100644 --- a/biogeochem/EDLoggingMortalityMod.F90 +++ b/biogeochem/EDLoggingMortalityMod.F90 @@ -3,15 +3,16 @@ module EDLoggingMortalityMod ! ==================================================================================== ! Purpose: 1. create logging mortalities: - ! (a)logging mortality (cohort level) - ! (b)collateral mortality (cohort level) - ! (c)infrastructure mortality (cohort level) + ! (a) direct logging mortality (cohort level) + ! (b) collateral mortality (cohort level) + ! (c) infrastructure mortality (cohort level) ! 2. move the logged trunk fluxes from live into product pool ! 3. move logging-associated mortality fluxes from live to CWD ! 4. keep carbon balance (in ed_total_balance_check) ! - ! Yi Xu - ! Date: 2017 + ! Yi Xu & M.Huang + ! Date: 09/2017 + ! Last updated: 10/2017 ! ==================================================================================== use FatesConstantsMod , only : r8 => fates_r8 @@ -142,44 +143,49 @@ end subroutine IsItLoggingTime ! ====================================================================================== - subroutine LoggingMortality_frac( pft_i, dbh, lmort_logging,lmort_collateral,lmort_infra ) + subroutine LoggingMortality_frac( pft_i, dbh, lmort_direct,lmort_collateral,lmort_infra ) ! Arguments integer, intent(in) :: pft_i ! pft index real(r8), intent(in) :: dbh ! diameter at breast height (cm) - real(r8), intent(out) :: lmort_logging ! direct (harvestable) mortality fraction + real(r8), intent(out) :: lmort_direct ! direct (harvestable) mortality fraction real(r8), intent(out) :: lmort_collateral ! collateral damage mortality fraction real(r8), intent(out) :: lmort_infra ! infrastructure mortality fraction ! Parameters real(r8), parameter :: adjustment = 1.0 ! adjustment for mortality rates - + real(r8), parameter :: logging_dbhmax_infra = 35 !(cm), based on Feldpaush et al. (2005) and Ferry et al. (2010) + if (logging_time) then if(EDPftvarcon_inst%woody(pft_i) == 1)then ! only set logging rates for trees ! Pass logging rates to cohort level if (dbh >= logging_dbhmin ) then - lmort_logging = logging_direct_frac * adjustment + lmort_direct = logging_direct_frac * adjustment lmort_collateral = logging_collateral_frac * adjustment else - lmort_logging = 0.0_r8 + lmort_direct = 0.0_r8 lmort_collateral = 0.0_r8 end if - lmort_infra = logging_mechanical_frac * adjustment + if (dbh >= logging_dbhmax_infra) then + lmort_infra = 0.0_r8 + else + lmort_infra = logging_mechanical_frac * adjustment + end if !damage rates for size class < & > threshold_size need to be specified seperately ! Collateral damage to smaller plants below the direct logging size threshold ! will be applied via "understory_death" via the disturbance algorithm else - lmort_logging = 0.0_r8 + lmort_direct = 0.0_r8 lmort_collateral = 0.0_r8 lmort_infra = 0.0_r8 end if else - lmort_logging = 0.0_r8 + lmort_direct = 0.0_r8 lmort_collateral = 0.0_r8 lmort_infra = 0.0_r8 end if @@ -268,7 +274,7 @@ subroutine logging_litter_fluxes(currentSite, currentPatch, newPatch, patch_site if(currentCohort%canopy_layer == 1)then - direct_dead = currentCohort%n * currentCohort%lmort_logging + direct_dead = currentCohort%n * currentCohort%lmort_direct indirect_dead = currentCohort%n * & (currentCohort%lmort_collateral + currentCohort%lmort_infra) diff --git a/biogeochem/EDPatchDynamicsMod.F90 b/biogeochem/EDPatchDynamicsMod.F90 index c5a5025b..d3742b9a 100644 --- a/biogeochem/EDPatchDynamicsMod.F90 +++ b/biogeochem/EDPatchDynamicsMod.F90 @@ -70,9 +70,9 @@ subroutine disturbance_rates( site_in) ! be one disturbance type for each timestep. ! all disturbance rates here are per daily timestep. - ! 2016-2017 - ! Modify to add logging disturbance - + ! 2016-2017 + ! Modify to add logging disturbance + ! !USES: use EDGrowthFunctionsMod , only : c_area, mortality_rates ! loging flux @@ -90,7 +90,7 @@ subroutine disturbance_rates( site_in) real(r8) :: bmort real(r8) :: hmort - real(r8) :: lmort_logging + real(r8) :: lmort_direct real(r8) :: lmort_collateral real(r8) :: lmort_infra @@ -121,9 +121,9 @@ subroutine disturbance_rates( site_in) currentCohort%fmort = 0.0_r8 ! Fire mortality is initialized as zero, but may be changed call LoggingMortality_frac(currentCohort%pft, currentCohort%dbh, & - lmort_logging,lmort_collateral,lmort_infra ) + lmort_direct,lmort_collateral,lmort_infra ) - currentCohort%lmort_logging = lmort_logging + currentCohort%lmort_direct = lmort_direct currentCohort%lmort_collateral = lmort_collateral currentCohort%lmort_infra = lmort_infra @@ -155,7 +155,7 @@ subroutine disturbance_rates( site_in) ! Logging Disturbance Rate currentPatch%disturbance_rates(dtype_ilog) = currentPatch%disturbance_rates(dtype_ilog) + & - min(1.0_r8, currentCohort%lmort_logging + & + min(1.0_r8, currentCohort%lmort_direct + & currentCohort%lmort_collateral + & currentCohort%lmort_infra ) * & currentCohort%c_area/currentPatch%area @@ -218,7 +218,7 @@ subroutine disturbance_rates( site_in) currentCohort%hmort = currentCohort%hmort*(1.0_r8 - fates_mortality_disturbance_fraction) currentCohort%bmort = currentCohort%bmort*(1.0_r8 - fates_mortality_disturbance_fraction) currentCohort%dmort = currentCohort%dmort*(1.0_r8 - fates_mortality_disturbance_fraction) - currentCohort%lmort_logging = 0.0_r8 + currentCohort%lmort_direct = 0.0_r8 currentCohort%lmort_collateral = 0.0_r8 currentCohort%lmort_infra = 0.0_r8 end if @@ -241,7 +241,7 @@ subroutine disturbance_rates( site_in) currentCohort => currentPatch%shortest do while(associated(currentCohort)) if(currentCohort%canopy_layer == 1)then - currentCohort%lmort_logging = 0.0_r8 + currentCohort%lmort_direct = 0.0_r8 currentCohort%lmort_collateral = 0.0_r8 currentCohort%lmort_infra = 0.0_r8 currentCohort%fmort = 0.0_r8 @@ -276,7 +276,7 @@ subroutine spawn_patches( currentSite, bc_in) ! ! !USES: - use EDParamsMod , only : ED_val_understorey_death + use EDParamsMod , only : ED_val_understorey_death, logging_coll_under_frac use EDCohortDynamicsMod , only : zero_cohort, copy_cohort, terminate_cohorts ! @@ -400,7 +400,7 @@ subroutine spawn_patches( currentSite, bc_in) nc%bmort = nan nc%fmort = nan nc%imort = nan - nc%lmort_logging = nan + nc%lmort_direct = nan nc%lmort_collateral = nan nc%lmort_infra = nan @@ -433,7 +433,7 @@ subroutine spawn_patches( currentSite, bc_in) nc%hmort = currentCohort%hmort nc%bmort = currentCohort%bmort nc%dmort = currentCohort%dmort - nc%lmort_logging = currentCohort%lmort_logging + nc%lmort_direct = currentCohort%lmort_direct nc%lmort_collateral = currentCohort%lmort_collateral nc%lmort_infra = currentCohort%lmort_infra @@ -457,7 +457,7 @@ subroutine spawn_patches( currentSite, bc_in) nc%hmort = currentCohort%hmort nc%bmort = currentCohort%bmort nc%dmort = currentCohort%dmort - nc%lmort_logging = currentCohort%lmort_logging + nc%lmort_direct = currentCohort%lmort_direct nc%lmort_collateral = currentCohort%lmort_collateral nc%lmort_infra = currentCohort%lmort_infra @@ -484,7 +484,7 @@ subroutine spawn_patches( currentSite, bc_in) nc%hmort = currentCohort%hmort nc%bmort = currentCohort%bmort nc%dmort = currentCohort%dmort - nc%lmort_logging = currentCohort%lmort_logging + nc%lmort_direct = currentCohort%lmort_direct nc%lmort_collateral = currentCohort%lmort_collateral nc%lmort_infra = currentCohort%lmort_infra @@ -499,7 +499,7 @@ subroutine spawn_patches( currentSite, bc_in) nc%n = 0.0_r8 ! Reduce counts in the existing/donor patch according to the logging rate - currentCohort%n = currentCohort%n * (1.0_r8 - min(1.0_r8,(currentCohort%lmort_logging + & + currentCohort%n = currentCohort%n * (1.0_r8 - min(1.0_r8,(currentCohort%lmort_direct + & currentCohort%lmort_collateral + & currentCohort%lmort_infra))) @@ -509,7 +509,7 @@ subroutine spawn_patches( currentSite, bc_in) nc%bmort = nan nc%fmort = nan nc%imort = nan - nc%lmort_logging = nan + nc%lmort_direct = nan nc%lmort_collateral = nan nc%lmort_infra = nan @@ -530,22 +530,21 @@ subroutine spawn_patches( currentSite, bc_in) ! Step 2: Apply survivor ship function based on the understory death fraction ! remaining of understory plants of those that are knocked over by the overstorey trees dying... - ! CURRENTLY ASSUMING THAT LOGGING SURVIVORSHIP OF UNDERSTORY PLANTS IS SAME AS NATURAL - ! TREEFALL (STILL BEING DISCUSSED) - nc%n = nc%n * (1.0_r8 - ED_val_understorey_death) + ! LOGGING SURVIVORSHIP OF UNDERSTORY PLANTS IS SET AS A NEW PARAMETER in the fatesparameter files + nc%n = nc%n * (1.0_r8 - logging_coll_under_frac) ! Step 3: Reduce the number count of cohorts in the original/donor/non-disturbed patch ! to reflect the area change currentCohort%n = currentCohort%n * (1._r8 - patch_site_areadis/currentPatch%area) - nc%fmort = 0.0_r8 - nc%imort = ED_val_understorey_death/hlm_freq_day + nc%fmort = 0.0_r8 + nc%imort = logging_coll_under_frac/hlm_freq_day nc%cmort = currentCohort%cmort nc%hmort = currentCohort%hmort nc%bmort = currentCohort%bmort nc%dmort = currentCohort%dmort - nc%lmort_logging = currentCohort%lmort_logging + nc%lmort_direct = currentCohort%lmort_direct nc%lmort_collateral = currentCohort%lmort_collateral nc%lmort_infra = currentCohort%lmort_infra @@ -565,7 +564,7 @@ subroutine spawn_patches( currentSite, bc_in) nc%hmort = currentCohort%hmort nc%bmort = currentCohort%bmort nc%dmort = currentCohort%dmort - nc%lmort_logging = currentCohort%lmort_logging + nc%lmort_direct = currentCohort%lmort_direct nc%lmort_collateral = currentCohort%lmort_collateral nc%lmort_infra = currentCohort%lmort_infra diff --git a/biogeochem/EDPhysiologyMod.F90 b/biogeochem/EDPhysiologyMod.F90 index a145616d..25d5037f 100755 --- a/biogeochem/EDPhysiologyMod.F90 +++ b/biogeochem/EDPhysiologyMod.F90 @@ -787,7 +787,7 @@ subroutine Growth_Derivatives( currentSite, currentCohort, bc_in) real(r8) :: bmort ! background mortality rate (fraction per year) real(r8) :: hmort ! hydraulic failure mortality rate (fraction per year) - real(r8) :: lmort_logging ! Mortality fraction associated with direct logging + real(r8) :: lmort_direct ! Mortality fraction associated with direct logging real(r8) :: lmort_collateral ! Mortality fraction associated with logging collateral damage real(r8) :: lmort_infra ! Mortality fraction associated with logging infrastructure real(r8) :: dndt_logging ! Mortality rate (per day) associated with the a logging event @@ -799,14 +799,14 @@ subroutine Growth_Derivatives( currentSite, currentCohort, bc_in) !if trees are in the canopy, then their death is 'disturbance'. This probably needs a different terminology call mortality_rates(currentCohort,cmort,hmort,bmort) call LoggingMortality_frac(currentCohort%pft, currentCohort%dbh, & - currentCohort%lmort_logging, & - currentCohort%lmort_collateral, & + currentCohort%lmort_direct, & + currentCohort%lmort_collateral, & currentCohort%lmort_infra ) if (currentCohort%canopy_layer > 1)then ! Include understory logging mortality rates not associated with disturbance - dndt_logging = (currentCohort%lmort_logging + & + dndt_logging = (currentCohort%lmort_direct + & currentCohort%lmort_collateral + & currentCohort%lmort_infra)/hlm_freq_day @@ -1183,7 +1183,7 @@ subroutine CWD_Input( currentSite, currentPatch) ! Total number of dead understory from direct logging ! (it is possible that large harvestable trees are in the understory) - dead_n_dlogging = ( currentCohort%lmort_logging) * & + dead_n_dlogging = ( currentCohort%lmort_direct) * & currentCohort%n/hlm_freq_day/currentPatch%area ! Total number of dead understory from indirect logging diff --git a/main/EDParamsMod.F90 b/main/EDParamsMod.F90 index b6da0529..f9cc8a54 100644 --- a/main/EDParamsMod.F90 +++ b/main/EDParamsMod.F90 @@ -444,6 +444,7 @@ subroutine FatesReportParams(is_master) write(fates_log(),fmt0) 'hydr_psicap = ',hydr_psicap write(fates_log(),fmt0) 'logging_dbhmin = ',logging_dbhmin write(fates_log(),fmt0) 'logging_collateral_frac = ',logging_collateral_frac + write(fates_log(),fmt0) 'logging_coll_under_frac = ',logging_coll_under_frac write(fates_log(),fmt0) 'logging_direct_frac = ',logging_direct_frac write(fates_log(),fmt0) 'logging_mechanical_frac = ',logging_mechanical_frac write(fates_log(),fmt0) 'logging_event_code = ',logging_event_code diff --git a/main/EDTypesMod.F90 b/main/EDTypesMod.F90 index 82265c09..9c3e8f5b 100755 --- a/main/EDTypesMod.F90 +++ b/main/EDTypesMod.F90 @@ -230,11 +230,10 @@ module EDTypesMod real(r8) :: fmort ! fire mortality n/year ! Logging Mortality Rate - ! Yi Xu - real(r8) :: lmort_logging ! directly logging rate %/per logging activity + ! Yi Xu & M. Huang + real(r8) :: lmort_direct ! directly logging rate %/per logging activity real(r8) :: lmort_collateral ! collaterally damaged rate %/per logging activity real(r8) :: lmort_infra ! mechanically damaged rate %/per logging activity - ! NITROGEN POOLS ! ---------------------------------------------------------------------------------- diff --git a/main/FatesHistoryInterfaceMod.F90 b/main/FatesHistoryInterfaceMod.F90 index 55166eac..ca59ef1d 100644 --- a/main/FatesHistoryInterfaceMod.F90 +++ b/main/FatesHistoryInterfaceMod.F90 @@ -1463,9 +1463,9 @@ subroutine update_history_dyn(this,nc,nsites,sites) hio_m5_si_scpf(io_si,scpf) = hio_m5_si_scpf(io_si,scpf) + ccohort%fmort*ccohort%n - !Y.X. - hio_m7_si_scpf(io_si,scpf) = hio_m7_si_scpf(io_si,scpf) + & - (ccohort%lmort_logging+ccohort%lmort_collateral+ccohort%lmort_infra) * ccohort%n + !Y.X. + hio_m7_si_scpf(io_si,scpf) = hio_m7_si_scpf(io_si,scpf) + & + (ccohort%lmort_direct+ccohort%lmort_collateral+ccohort%lmort_infra) * ccohort%n ! basal area [m2/ha] @@ -1507,7 +1507,7 @@ subroutine update_history_dyn(this,nc,nsites,sites) hio_mortality_canopy_si_scpf(io_si,scpf) = hio_mortality_canopy_si_scpf(io_si,scpf)+ & (ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%imort + ccohort%fmort+ & - ccohort%lmort_logging + ccohort%lmort_collateral + ccohort%lmort_infra) * ccohort%n + ccohort%lmort_direct + ccohort%lmort_collateral + ccohort%lmort_infra) * ccohort%n hio_nplant_canopy_si_scpf(io_si,scpf) = hio_nplant_canopy_si_scpf(io_si,scpf) + ccohort%n hio_nplant_canopy_si_scls(io_si,scls) = hio_nplant_canopy_si_scls(io_si,scls) + ccohort%n @@ -1528,12 +1528,12 @@ subroutine update_history_dyn(this,nc,nsites,sites) ! sum of all mortality hio_mortality_canopy_si_scls(io_si,scls) = hio_mortality_canopy_si_scls(io_si,scls) + & (ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%fmort + & - ccohort%lmort_logging + ccohort%lmort_collateral + ccohort%lmort_infra) * ccohort%n + ccohort%lmort_direct + ccohort%lmort_collateral + ccohort%lmort_infra) * ccohort%n hio_canopy_mortality_carbonflux_si(io_si) = hio_canopy_mortality_carbonflux_si(io_si) + & (ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%fmort) * & ccohort%b * ccohort%n * g_per_kg * days_per_sec * years_per_day * ha_per_m2 + & - (ccohort%lmort_logging + ccohort%lmort_collateral + ccohort%lmort_infra)* ccohort%b * & + (ccohort%lmort_direct + ccohort%lmort_collateral + ccohort%lmort_infra)* ccohort%b * & ccohort%n * g_per_kg * ha_per_m2 hio_leaf_md_canopy_si_scls(io_si,scls) = hio_leaf_md_canopy_si_scls(io_si,scls) + & @@ -1583,7 +1583,7 @@ subroutine update_history_dyn(this,nc,nsites,sites) hio_mortality_understory_si_scpf(io_si,scpf) = hio_mortality_understory_si_scpf(io_si,scpf)+ & (ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%imort + ccohort%fmort + & - ccohort%lmort_logging + ccohort%lmort_collateral + ccohort%lmort_infra) * ccohort%n + ccohort%lmort_direct + ccohort%lmort_collateral + ccohort%lmort_infra) * ccohort%n hio_nplant_understory_si_scpf(io_si,scpf) = hio_nplant_understory_si_scpf(io_si,scpf) + ccohort%n hio_nplant_understory_si_scls(io_si,scls) = hio_nplant_understory_si_scls(io_si,scls) + ccohort%n @@ -1605,12 +1605,12 @@ subroutine update_history_dyn(this,nc,nsites,sites) ! sum of all mortality hio_mortality_understory_si_scls(io_si,scls) = hio_mortality_understory_si_scls(io_si,scls) + & (ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%imort + ccohort%fmort +& - ccohort%lmort_logging + ccohort%lmort_collateral + ccohort%lmort_infra) * ccohort%n + ccohort%lmort_direct + ccohort%lmort_collateral + ccohort%lmort_infra) * ccohort%n hio_understory_mortality_carbonflux_si(io_si) = hio_understory_mortality_carbonflux_si(io_si) + & (ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%imort + ccohort%fmort) * & ccohort%b * ccohort%n * g_per_kg * days_per_sec * years_per_day * ha_per_m2 + & - (ccohort%lmort_logging + ccohort%lmort_collateral + ccohort%lmort_infra) * ccohort%b * & + (ccohort%lmort_direct + ccohort%lmort_collateral + ccohort%lmort_infra) * ccohort%b * & ccohort%n * g_per_kg * ha_per_m2 ! @@ -1799,7 +1799,7 @@ subroutine update_history_dyn(this,nc,nsites,sites) hio_m4_si_scpf(io_si,i_scpf) + & hio_m5_si_scpf(io_si,i_scpf) + & hio_m6_si_scpf(io_si,i_scpf) + & - hio_m7_si_scpf(io_si,i_scpf) + hio_m7_si_scpf(io_si,i_scpf) diff --git a/main/FatesRestartInterfaceMod.F90 b/main/FatesRestartInterfaceMod.F90 index 44ac2ea5..6a736a25 100644 --- a/main/FatesRestartInterfaceMod.F90 +++ b/main/FatesRestartInterfaceMod.F90 @@ -102,7 +102,7 @@ module FatesRestartInterfaceMod integer, private :: ir_fmort_co !Logging - integer, private :: ir_lmort_logging_co + integer, private :: ir_lmort_direct_co integer, private :: ir_lmort_collateral_co integer, private :: ir_lmort_infra_co @@ -750,10 +750,10 @@ subroutine define_restart_vars(this, initialize_variables) hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_fmort_co ) - call this%set_restart_var(vname='fates_lmort_logging', vtype=cohort_r8, & + call this%set_restart_var(vname='fates_lmort_direct', vtype=cohort_r8, & long_name='ed cohort - directly logging mortality rate', & units='%/event', flushval = flushzero, & - hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_lmort_logging_co ) + hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_lmort_direct_co ) call this%set_restart_var(vname='fates_lmort_collateral', vtype=cohort_r8, & long_name='ed cohort - collateral mortality rate', & @@ -1062,14 +1062,9 @@ subroutine set_restart_vectors(this,nc,nsites,sites) rio_cmort_co => this%rvars(ir_cmort_co)%r81d, & rio_imort_co => this%rvars(ir_imort_co)%r81d, & rio_fmort_co => this%rvars(ir_fmort_co)%r81d, & - - - - rio_lmort_logging_co => this%rvars(ir_lmort_logging_co)%r81d, & - rio_lmort_collateral_co => this%rvars(ir_lmort_collateral_co)%r81d, & - rio_lmort_infra_co => this%rvars(ir_lmort_infra_co)%r81d, & - - + rio_lmort_direct_co => this%rvars(ir_lmort_direct_co)%r81d, & + rio_lmort_collateral_co => this%rvars(ir_lmort_collateral_co)%r81d, & + rio_lmort_infra_co => this%rvars(ir_lmort_infra_co)%r81d, & rio_ddbhdt_co => this%rvars(ir_ddbhdt_co)%r81d, & rio_dbalivedt_co => this%rvars(ir_dbalivedt_co)%r81d, & rio_dbdeaddt_co => this%rvars(ir_dbdeaddt_co)%r81d, & @@ -1186,11 +1181,9 @@ subroutine set_restart_vectors(this,nc,nsites,sites) rio_fmort_co(io_idx_co) = ccohort%fmort !Logging - rio_lmort_logging_co(io_idx_co) = ccohort%lmort_logging - rio_lmort_collateral_co(io_idx_co) = ccohort%lmort_collateral - rio_lmort_infra_co(io_idx_co) = ccohort%lmort_infra - - + rio_lmort_direct_co(io_idx_co) = ccohort%lmort_direct + rio_lmort_collateral_co(io_idx_co) = ccohort%lmort_collateral + rio_lmort_infra_co(io_idx_co) = ccohort%lmort_infra rio_ddbhdt_co(io_idx_co) = ccohort%ddbhdt rio_dbalivedt_co(io_idx_co) = ccohort%dbalivedt @@ -1647,11 +1640,9 @@ subroutine get_restart_vectors(this, nc, nsites, sites) rio_imort_co => this%rvars(ir_imort_co)%r81d, & rio_fmort_co => this%rvars(ir_fmort_co)%r81d, & - rio_lmort_logging_co => this%rvars(ir_lmort_logging_co)%r81d, & - rio_lmort_collateral_co => this%rvars(ir_lmort_collateral_co)%r81d, & - rio_lmort_infra_co => this%rvars(ir_lmort_infra_co)%r81d, & - - + rio_lmort_direct_co => this%rvars(ir_lmort_direct_co)%r81d, & + rio_lmort_collateral_co => this%rvars(ir_lmort_collateral_co)%r81d, & + rio_lmort_infra_co => this%rvars(ir_lmort_infra_co)%r81d, & rio_ddbhdt_co => this%rvars(ir_ddbhdt_co)%r81d, & rio_dbalivedt_co => this%rvars(ir_dbalivedt_co)%r81d, & @@ -1752,12 +1743,10 @@ subroutine get_restart_vectors(this, nc, nsites, sites) ccohort%imort = rio_imort_co(io_idx_co) ccohort%fmort = rio_fmort_co(io_idx_co) - !Logging - ccohort%lmort_logging = rio_lmort_logging_co(io_idx_co) - ccohort%lmort_collateral = rio_lmort_collateral_co(io_idx_co) - ccohort%lmort_infra = rio_lmort_infra_co(io_idx_co) - - + !Logging + ccohort%lmort_direct = rio_lmort_direct_co(io_idx_co) + ccohort%lmort_collateral = rio_lmort_collateral_co(io_idx_co) + ccohort%lmort_infra = rio_lmort_infra_co(io_idx_co) ccohort%ddbhdt = rio_ddbhdt_co(io_idx_co) ccohort%dbalivedt = rio_dbalivedt_co(io_idx_co) From f2605037942979eb663e6be5046dd25de29a8675 Mon Sep 17 00:00:00 2001 From: Maoyi Huang Date: Wed, 11 Oct 2017 15:03:20 -0700 Subject: [PATCH 2/6] additional changes related to the logging module --- biogeochem/EDLoggingMortalityMod.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/biogeochem/EDLoggingMortalityMod.F90 b/biogeochem/EDLoggingMortalityMod.F90 index 85a4c8c8..679ea921 100644 --- a/biogeochem/EDLoggingMortalityMod.F90 +++ b/biogeochem/EDLoggingMortalityMod.F90 @@ -30,7 +30,7 @@ module EDLoggingMortalityMod use EDParamsMod , only : logging_collateral_frac use EDParamsMod , only : logging_direct_frac use EDParamsMod , only : logging_mechanical_frac - use EDParamsMod , only : ED_val_understorey_death + use EDParamsMod , only : logging_coll_under_frac use FatesInterfaceMod , only : hlm_current_year use FatesInterfaceMod , only : hlm_current_month use FatesInterfaceMod , only : hlm_current_day @@ -281,7 +281,7 @@ subroutine logging_litter_fluxes(currentSite, currentPatch, newPatch, patch_site else if(EDPftvarcon_inst%woody(currentCohort%pft) == 1)then direct_dead = 0.0_r8 - indirect_dead = ED_val_understorey_death * currentCohort%n * & + indirect_dead = logging_coll_under_frac * currentCohort%n * & (patch_site_areadis/currentPatch%area) !kgC/site/day else ! If the cohort of interest is grass, it will not experience From e3e56087c2a56b189210068fa28412f961ffde2d Mon Sep 17 00:00:00 2001 From: ckoven Date: Wed, 24 Jan 2018 21:48:43 -0700 Subject: [PATCH 3/6] fixes to scalar logic in modify_fates_paramfile.py --- tools/modify_fates_paramfile.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/modify_fates_paramfile.py b/tools/modify_fates_paramfile.py index 92ab14da..c48efdf8 100755 --- a/tools/modify_fates_paramfile.py +++ b/tools/modify_fates_paramfile.py @@ -58,22 +58,25 @@ def main(): ### check to make sure that, if a PFT is specified, the variable has a PFT dimension, and if not, then it doesn't. and also that shape is reasonable. ndim_file = len(var.dimensions) ispftvar = False + # for purposes of current stat eof this script, assume 1D + if ndim_file > 1: + raise ValueError('variable dimensionality is too high for this script') + if ndim_file < 1: + raise ValueError('variable dimensionality is too low for this script. FATES assumes even scalars have a 1-length dimension') for i in range(ndim_file): if var.dimensions[i] == 'fates_pft': ispftvar = True npft_file = var.shape[i] pftdim = 0 - else: + elif var.dimensions[i] == 'fates_scalar': npft_file = None pftdim = None + else: + raise ValueError('variable is not on either the PFT or scalar dimension') if args.pftnum == None and ispftvar: raise ValueError('pft value is missing but variable has pft dimension.') if args.pftnum != None and not ispftvar: raise ValueError('pft value is present but variable does not have pft dimension.') - if ndim_file > 1: - raise ValueError('variable dimensionality is too high for this script') - if ndim_file == 1 and not ispftvar: - raise ValueError('variable dimensionality is too high for this script') if args.pftnum != None and ispftvar: if args.pftnum > npft_file: raise ValueError('PFT specified ('+str(args.pftnum)+') is larger than the number of PFTs in the file ('+str(npft_file)+').') From e3e4d029e264a57d98a743575c4451ad2a7d83db Mon Sep 17 00:00:00 2001 From: ckoven Date: Wed, 24 Jan 2018 22:35:36 -0700 Subject: [PATCH 4/6] changed modify_fates_paramfile.py to first write to temp file and then move that --- tools/modify_fates_paramfile.py | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/tools/modify_fates_paramfile.py b/tools/modify_fates_paramfile.py index c48efdf8..0f7ee15e 100755 --- a/tools/modify_fates_paramfile.py +++ b/tools/modify_fates_paramfile.py @@ -19,6 +19,8 @@ from scipy.io import netcdf as nc import argparse import shutil +import tempfile + # ======================================================================================== # ======================================================================================== @@ -38,20 +40,13 @@ def main(): parser.add_argument('--silent', '--s', dest='silent', help="prevent writing of output.", action="store_true") # args = parser.parse_args() - # print(args.varname, args.pftnum, args.inputfname, args.outputfname, args.val, args.overwrite) # - # check to see if output file exists - if os.path.isfile(args.outputfname): - if args.overwrite: - if not args.silent: - print('replacing file: '+args.outputfname) - os.remove(args.outputfname) - else: - raise ValueError('Output file already exists and overwrite flag not specified for filename: '+args.outputfname) + # work with the file in some random temprary place so that if something goes wrong nothing happens to original file and it doesn't make an output file + tempfilename = os.path.join(tempfile.mkdtemp(), 'temp_fates_param_file.nc') # - shutil.copyfile(args.inputfname, args.outputfname) + shutil.copyfile(args.inputfname, tempfilename) # - ncfile = nc.netcdf_file(args.outputfname, 'a') + ncfile = nc.netcdf_file(tempfilename, 'a') # var = ncfile.variables[args.varname] # @@ -93,6 +88,20 @@ def main(): # # ncfile.close() + # + # + # now move file from temprary location to final location + # + # check to see if output file exists + if os.path.isfile(args.outputfname): + if args.overwrite: + if not args.silent: + print('replacing file: '+args.outputfname) + os.remove(args.outputfname) + else: + raise ValueError('Output file already exists and overwrite flag not specified for filename: '+args.outputfname) + # + shutil.move(tempfilename, args.outputfname) From ce6ac7409bbe1bef2e5bd93c7e257b632d2c83c1 Mon Sep 17 00:00:00 2001 From: ckoven Date: Wed, 24 Jan 2018 22:52:50 -0700 Subject: [PATCH 5/6] added tempdir cleanup and better exception handling --- tools/modify_fates_paramfile.py | 122 +++++++++++++++++--------------- 1 file changed, 63 insertions(+), 59 deletions(-) diff --git a/tools/modify_fates_paramfile.py b/tools/modify_fates_paramfile.py index 0f7ee15e..53bd82de 100755 --- a/tools/modify_fates_paramfile.py +++ b/tools/modify_fates_paramfile.py @@ -42,68 +42,72 @@ def main(): args = parser.parse_args() # # work with the file in some random temprary place so that if something goes wrong nothing happens to original file and it doesn't make an output file - tempfilename = os.path.join(tempfile.mkdtemp(), 'temp_fates_param_file.nc') + tempdir = tempfile.mkdtemp() + tempfilename = os.path.join(tempdir, 'temp_fates_param_file.nc') # - shutil.copyfile(args.inputfname, tempfilename) - # - ncfile = nc.netcdf_file(tempfilename, 'a') - # - var = ncfile.variables[args.varname] - # - ### check to make sure that, if a PFT is specified, the variable has a PFT dimension, and if not, then it doesn't. and also that shape is reasonable. - ndim_file = len(var.dimensions) - ispftvar = False - # for purposes of current stat eof this script, assume 1D - if ndim_file > 1: - raise ValueError('variable dimensionality is too high for this script') - if ndim_file < 1: - raise ValueError('variable dimensionality is too low for this script. FATES assumes even scalars have a 1-length dimension') - for i in range(ndim_file): - if var.dimensions[i] == 'fates_pft': - ispftvar = True - npft_file = var.shape[i] - pftdim = 0 - elif var.dimensions[i] == 'fates_scalar': - npft_file = None - pftdim = None - else: - raise ValueError('variable is not on either the PFT or scalar dimension') - if args.pftnum == None and ispftvar: - raise ValueError('pft value is missing but variable has pft dimension.') - if args.pftnum != None and not ispftvar: - raise ValueError('pft value is present but variable does not have pft dimension.') - if args.pftnum != None and ispftvar: - if args.pftnum > npft_file: - raise ValueError('PFT specified ('+str(args.pftnum)+') is larger than the number of PFTs in the file ('+str(npft_file)+').') - if pftdim == 0: + try: + shutil.copyfile(args.inputfname, tempfilename) + # + ncfile = nc.netcdf_file(tempfilename, 'a') + # + var = ncfile.variables[args.varname] + # + ### check to make sure that, if a PFT is specified, the variable has a PFT dimension, and if not, then it doesn't. and also that shape is reasonable. + ndim_file = len(var.dimensions) + ispftvar = False + # for purposes of current stat eof this script, assume 1D + if ndim_file > 1: + raise ValueError('variable dimensionality is too high for this script') + if ndim_file < 1: + raise ValueError('variable dimensionality is too low for this script. FATES assumes even scalars have a 1-length dimension') + for i in range(ndim_file): + if var.dimensions[i] == 'fates_pft': + ispftvar = True + npft_file = var.shape[i] + pftdim = 0 + elif var.dimensions[i] == 'fates_scalar': + npft_file = None + pftdim = None + else: + raise ValueError('variable is not on either the PFT or scalar dimension') + if args.pftnum == None and ispftvar: + raise ValueError('pft value is missing but variable has pft dimension.') + if args.pftnum != None and not ispftvar: + raise ValueError('pft value is present but variable does not have pft dimension.') + if args.pftnum != None and ispftvar: + if args.pftnum > npft_file: + raise ValueError('PFT specified ('+str(args.pftnum)+') is larger than the number of PFTs in the file ('+str(npft_file)+').') + if pftdim == 0: + if not args.silent: + print('replacing prior value of variable '+args.varname+', for PFT '+str(args.pftnum)+', which was '+str(var[args.pftnum-1])+', with new value of '+str(args.val)) + var[args.pftnum-1] = args.val + elif args.pftnum == None and not ispftvar: if not args.silent: - print('replacing prior value of variable '+args.varname+', for PFT '+str(args.pftnum)+', which was '+str(var[args.pftnum-1])+', with new value of '+str(args.val)) - var[args.pftnum-1] = args.val - elif args.pftnum == None and not ispftvar: - if not args.silent: - print('replacing prior value of variable '+args.varname+', which was '+str(var[:])+', with new value of '+str(args.val)) - var[:] = args.val - else: - raise ValueError('Nothing happened somehow.') - # - # - ncfile.close() - # - # - # now move file from temprary location to final location - # - # check to see if output file exists - if os.path.isfile(args.outputfname): - if args.overwrite: - if not args.silent: - print('replacing file: '+args.outputfname) - os.remove(args.outputfname) + print('replacing prior value of variable '+args.varname+', which was '+str(var[:])+', with new value of '+str(args.val)) + var[:] = args.val else: - raise ValueError('Output file already exists and overwrite flag not specified for filename: '+args.outputfname) - # - shutil.move(tempfilename, args.outputfname) - - + raise ValueError('Nothing happened somehow.') + # + # + ncfile.close() + # + # + # now move file from temprary location to final location + # + # check to see if output file exists + if os.path.isfile(args.outputfname): + if args.overwrite: + if not args.silent: + print('replacing file: '+args.outputfname) + os.remove(args.outputfname) + else: + raise ValueError('Output file already exists and overwrite flag not specified for filename: '+args.outputfname) + # + shutil.move(tempfilename, args.outputfname) + shutil.rmtree(tempdir, ignore_errors=True) + except: + shutil.rmtree(tempdir, ignore_errors=True) + raise # ======================================================================================= From 0eb71d9e6976c202249ef03b81daf321be0d41cc Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Tue, 30 Jan 2018 01:43:30 -0700 Subject: [PATCH 6/6] Removed %imort --- biogeochem/EDPatchDynamicsMod.F90 | 2 -- 1 file changed, 2 deletions(-) diff --git a/biogeochem/EDPatchDynamicsMod.F90 b/biogeochem/EDPatchDynamicsMod.F90 index e2a69101..10d84a22 100644 --- a/biogeochem/EDPatchDynamicsMod.F90 +++ b/biogeochem/EDPatchDynamicsMod.F90 @@ -403,7 +403,6 @@ subroutine spawn_patches( currentSite, bc_in) nc%hmort = nan nc%bmort = nan nc%fmort = nan - nc%imort = nan nc%lmort_direct = nan nc%lmort_collateral = nan nc%lmort_infra = nan @@ -521,7 +520,6 @@ subroutine spawn_patches( currentSite, bc_in) nc%hmort = nan nc%bmort = nan nc%fmort = nan - nc%imort = nan nc%lmort_direct = nan nc%lmort_collateral = nan nc%lmort_infra = nan