From e3a884f47c4bafe61a3f1f44702a9b59e8bbcad4 Mon Sep 17 00:00:00 2001 From: rgknox Date: Thu, 17 Jun 2021 08:22:49 -0700 Subject: [PATCH 1/3] These fixes are needed to enable b4b restarts in elm --- biogeochem/EDPatchDynamicsMod.F90 | 10 +++++++++ biogeochem/FatesSoilBGCFluxMod.F90 | 33 ++++++++---------------------- main/FatesRestartInterfaceMod.F90 | 17 +++++++++++++++ 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/biogeochem/EDPatchDynamicsMod.F90 b/biogeochem/EDPatchDynamicsMod.F90 index 472c8eb48c..e5bd982225 100644 --- a/biogeochem/EDPatchDynamicsMod.F90 +++ b/biogeochem/EDPatchDynamicsMod.F90 @@ -1384,6 +1384,16 @@ subroutine TransLitterNewPatch(currentSite, & enddo + do pft = 1,numpft + + new_litt%seed_decay(pft) = new_litt%seed_decay(pft) + & + curr_litt%seed_decay(pft)*patch_site_areadis/newPatch%area + + new_litt%seed_germ_decay(pft) = new_litt%seed_germ_decay(pft) + & + curr_litt%seed_germ_decay(pft)*patch_site_areadis/newPatch%area + + end do + ! ----------------------------------------------------------------------------- ! Distribute the existing litter that was already in place on the donor ! patch. Some of this burns and is sent to the atmosphere, and some goes to the diff --git a/biogeochem/FatesSoilBGCFluxMod.F90 b/biogeochem/FatesSoilBGCFluxMod.F90 index a09dc3725b..c96728f661 100644 --- a/biogeochem/FatesSoilBGCFluxMod.F90 +++ b/biogeochem/FatesSoilBGCFluxMod.F90 @@ -826,9 +826,9 @@ subroutine FluxIntoLitterPools(csite, bc_in, bc_out) select case (element_list(el)) case (carbon12_element) - bc_out%litt_flux_cel_c_si(:) = 0._r8 - bc_out%litt_flux_lig_c_si(:) = 0._r8 - bc_out%litt_flux_lab_c_si(:) = 0._r8 + bc_out%litt_flux_cel_c_si(:) = 0.0_r8 + bc_out%litt_flux_lig_c_si(:) = 0.0_r8 + bc_out%litt_flux_lab_c_si(:) = 0.0_r8 flux_cel_si => bc_out%litt_flux_cel_c_si(:) flux_lab_si => bc_out%litt_flux_lab_c_si(:) flux_lig_si => bc_out%litt_flux_lig_c_si(:) @@ -861,31 +861,16 @@ subroutine FluxIntoLitterPools(csite, bc_in, bc_out) end select + ! Add efflux to the litter pool. kg/ha/day -> kg/m2/day + do id = 1,nlev_eff_decomp + flux_lab_si(id) = flux_lab_si(id) + & + sum(csite%flux_diags(el)%nutrient_efflux_scpf)*surface_prof(id)*area_inv + end do + currentPatch => csite%oldest_patch do while (associated(currentPatch)) - ! If there is any efflux (from stores overflowing) - ! than pass that to the labile litter pool - - currentCohort => currentPatch%tallest - do while(associated(currentCohort)) - if(.not.currentCohort%isnew)then - if(element_list(el).eq.carbon12_element) then - efflux_ptr => currentCohort%daily_c_efflux - elseif(element_list(el).eq.nitrogen_element) then - efflux_ptr => currentCohort%daily_n_efflux - elseif(element_list(el).eq.phosphorus_element) then - efflux_ptr => currentCohort%daily_p_efflux - end if - do id = 1,nlev_eff_decomp - flux_lab_si(id) = flux_lab_si(id) + & - efflux_ptr*currentCohort%n* AREA_INV * surface_prof(id) - end do - end if - currentCohort => currentCohort%shorter - end do - ! Set a pointer to the litter object ! for the current element on the current ! patch diff --git a/main/FatesRestartInterfaceMod.F90 b/main/FatesRestartInterfaceMod.F90 index 0b621dec0a..621e8f81ce 100644 --- a/main/FatesRestartInterfaceMod.F90 +++ b/main/FatesRestartInterfaceMod.F90 @@ -149,6 +149,8 @@ module FatesRestartInterfaceMod integer :: ir_fnrt_litt integer :: ir_seed_litt integer :: ir_seedgerm_litt + integer :: ir_seed_decay_litt + integer :: ir_seedgerm_decay_litt integer :: ir_seed_prod_co integer :: ir_livegrass_pa integer :: ir_age_pa @@ -936,6 +938,17 @@ subroutine define_restart_vars(this, initialize_variables) units='kg/m2', veclength=num_elements, flushval = flushzero, & hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_seedgerm_litt) + + call this%RegisterCohortVector(symbol_base='fates_seed_decay', vtype=cohort_r8, & + long_name_base='seed bank (non-germinated)', & + units='kg/m2', veclength=num_elements, flushval = flushzero, & + hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_seed_decay_litt) + + call this%RegisterCohortVector(symbol_base='fates_seedgerm_decay', vtype=cohort_r8, & + long_name_base='seed bank (germinated)', & + units='kg/m2', veclength=num_elements, flushval = flushzero, & + hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_seedgerm_decay_litt) + call this%RegisterCohortVector(symbol_base='fates_ag_cwd_frag', vtype=cohort_r8, & long_name_base='above ground CWD frag flux', & units='kg/m2/day', veclength=num_elements, flushval = flushzero, & @@ -1954,6 +1967,8 @@ subroutine set_restart_vectors(this,nc,nsites,sites) do i = 1,numpft this%rvars(ir_seed_litt+el)%r81d(io_idx_pa_pft) = litt%seed(i) this%rvars(ir_seedgerm_litt+el)%r81d(io_idx_pa_pft) = litt%seed_germ(i) + this%rvars(ir_seed_decay_litt+el)%r81d(io_idx_pa_pft) = litt%seed_decay(i) + this%rvars(ir_seedgerm_decay_litt+el)%r81d(io_idx_pa_pft) = litt%seed_germ_decay(i) io_idx_pa_pft = io_idx_pa_pft + 1 end do @@ -2723,6 +2738,8 @@ subroutine get_restart_vectors(this, nc, nsites, sites) do i = 1,numpft litt%seed(i) = this%rvars(ir_seed_litt+el)%r81d(io_idx_pa_pft) litt%seed_germ(i) = this%rvars(ir_seedgerm_litt+el)%r81d(io_idx_pa_pft) + litt%seed_decay(i) = this%rvars(ir_seed_decay_litt+el)%r81d(io_idx_pa_pft) + litt%seed_germ_decay(i) = this%rvars(ir_seedgerm_decay_litt+el)%r81d(io_idx_pa_pft) io_idx_pa_pft = io_idx_pa_pft + 1 end do From 07330264d89a5837bf10a9adae0fc8d0d6c8b769 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Tue, 22 Jun 2021 10:55:52 -0400 Subject: [PATCH 2/3] Updated metadata on the restart variables fates_seedgerm_frag and fates_seed_frag --- main/FatesRestartInterfaceMod.F90 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main/FatesRestartInterfaceMod.F90 b/main/FatesRestartInterfaceMod.F90 index 0f49b1e06e..7ae00ed0b2 100644 --- a/main/FatesRestartInterfaceMod.F90 +++ b/main/FatesRestartInterfaceMod.F90 @@ -947,13 +947,13 @@ subroutine define_restart_vars(this, initialize_variables) hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_seedgerm_litt) - call this%RegisterCohortVector(symbol_base='fates_seed_decay', vtype=cohort_r8, & - long_name_base='seed bank (non-germinated)', & + call this%RegisterCohortVector(symbol_base='fates_seed_frag', vtype=cohort_r8, & + long_name_base='seed bank fragmentation flux (non-germinated)', & units='kg/m2', veclength=num_elements, flushval = flushzero, & hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_seed_decay_litt) - call this%RegisterCohortVector(symbol_base='fates_seedgerm_decay', vtype=cohort_r8, & - long_name_base='seed bank (germinated)', & + call this%RegisterCohortVector(symbol_base='fates_seedgerm_frag', vtype=cohort_r8, & + long_name_base='seed bank fragmentation flux (germinated)', & units='kg/m2', veclength=num_elements, flushval = flushzero, & hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_seedgerm_decay_litt) From 6aaabe91e072b136d696b75faa9cb672b574c11a Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Tue, 22 Jun 2021 12:04:16 -0600 Subject: [PATCH 3/3] Revered labile fluxes to HLM from efflux to be from cohort level not the diagnostic. The diagnostic is not restartable --- biogeochem/FatesSoilBGCFluxMod.F90 | 33 +++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/biogeochem/FatesSoilBGCFluxMod.F90 b/biogeochem/FatesSoilBGCFluxMod.F90 index 9ced535220..9f210e8404 100644 --- a/biogeochem/FatesSoilBGCFluxMod.F90 +++ b/biogeochem/FatesSoilBGCFluxMod.F90 @@ -1022,16 +1022,35 @@ subroutine FluxIntoLitterPools(csite, bc_in, bc_out) end select - ! Add efflux to the litter pool. kg/ha/day -> kg/m2/day - do id = 1,nlev_eff_decomp - flux_lab_si(id) = flux_lab_si(id) + & - sum(csite%flux_diags(el)%nutrient_efflux_scpf)*surface_prof(id)*area_inv - end do - - currentPatch => csite%oldest_patch do while (associated(currentPatch)) + ! If there is any efflux (from stores overflowing) + ! than pass that to the labile litter pool + + currentCohort => currentPatch%tallest + do while(associated(currentCohort)) + if(.not.currentCohort%isnew)then + if(element_list(el).eq.carbon12_element) then + efflux_ptr => currentCohort%daily_c_efflux + elseif(element_list(el).eq.nitrogen_element) then + efflux_ptr => currentCohort%daily_n_efflux + elseif(element_list(el).eq.phosphorus_element) then + efflux_ptr => currentCohort%daily_p_efflux + end if + + ! Unit conversion + ! kg/plant/day * plant/ha * ha/m2 -> kg/m2/day + + do id = 1,nlev_eff_decomp + flux_lab_si(id) = flux_lab_si(id) + & + efflux_ptr * currentCohort%n* AREA_INV * surface_prof(id) + end do + end if + currentCohort => currentCohort%shorter + end do + + ! Set a pointer to the litter object ! for the current element on the current ! patch