From b97565a96f93625aff4afcf0336eb7fa0a67a55b Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 16 Jul 2021 10:29:46 -0400 Subject: [PATCH 1/2] Fixing restarting of efflux variables --- biogeochem/FatesSoilBGCFluxMod.F90 | 36 +++++++++--------------------- main/FatesHistoryInterfaceMod.F90 | 6 ----- 2 files changed, 10 insertions(+), 32 deletions(-) diff --git a/biogeochem/FatesSoilBGCFluxMod.F90 b/biogeochem/FatesSoilBGCFluxMod.F90 index 9f210e8404..133d6a3efd 100644 --- a/biogeochem/FatesSoilBGCFluxMod.F90 +++ b/biogeochem/FatesSoilBGCFluxMod.F90 @@ -1022,35 +1022,19 @@ subroutine FluxIntoLitterPools(csite, bc_in, bc_out) end select + + ! If there is any efflux (from stores overflowing) + ! than pass that to the labile litter pool + + do id = 1,nlev_eff_decomp + flux_lab_si(id) = flux_lab_si(id) + & + sum(csite%flux_diags(el)%nutrient_efflux_scpf(:)) * & + area_inv * surface_prof(id) + 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 diff --git a/main/FatesHistoryInterfaceMod.F90 b/main/FatesHistoryInterfaceMod.F90 index 97f3342b43..2d5af9c724 100644 --- a/main/FatesHistoryInterfaceMod.F90 +++ b/main/FatesHistoryInterfaceMod.F90 @@ -3377,12 +3377,6 @@ subroutine update_history_dyn(this,nc,nsites,sites) end do - ! and reset the disturbance-related field buffers - - do el = 1, num_elements - call sites(s)%flux_diags(el)%ZeroFluxDiags() - end do - enddo ! site loop end associate From b225db8501482561d45053a9ade373887d4f5ef6 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 16 Jul 2021 10:32:15 -0400 Subject: [PATCH 2/2] Updating pft index swapper script to use newer dimensions --- tools/FatesPFTIndexSwapper.py | 37 +++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/tools/FatesPFTIndexSwapper.py b/tools/FatesPFTIndexSwapper.py index 9e0830d626..7e39056fa8 100755 --- a/tools/FatesPFTIndexSwapper.py +++ b/tools/FatesPFTIndexSwapper.py @@ -25,7 +25,9 @@ pft_dim_name = 'fates_pft' prt_dim_name = 'fates_prt_organs' - +hydro_dim_name = 'fates_hydr_organs' +litt_dim_name = 'fates_litterclass' +string_dim_name = 'fates_string_length' class timetype: @@ -165,22 +167,31 @@ def main(argv): # Idenfity if this variable has pft dimension pft_dim_found = -1 prt_dim_found = -1 + hydro_dim_found = -1 + litt_dim_found = -1 + string_dim_found = -1 pft_dim_len = len(fp_in.variables.get(key).dimensions) for idim, name in enumerate(fp_in.variables.get(key).dimensions): + # Manipulate data if(name==pft_dim_name): pft_dim_found = idim if(name==prt_dim_name): prt_dim_found = idim - + if(name==litt_dim_name): + litt_dim_found = idim + if(name==hydro_dim_name): + hydro_dim_found = idim + if(name==string_dim_name): + string_dim_found = idim # Copy over the input data # Tedious, but I have to permute through all combinations of dimension position if( pft_dim_len == 0 ): out_var = fp_out.createVariable(key,'d',(fp_in.variables.get(key).dimensions)) out_var.assignValue(float(fp_in.variables.get(key).data)) - elif( (pft_dim_found==-1) & (prt_dim_found==-1) ): + elif( (pft_dim_found==-1) & (prt_dim_found==-1) & (litt_dim_found==-1) & (hydro_dim_found==-1) ): out_var = fp_out.createVariable(key,'d',(fp_in.variables.get(key).dimensions)) out_var[:] = in_var[:] elif( (pft_dim_found==0) & (pft_dim_len==1) ): # 1D fates_pft @@ -208,14 +219,28 @@ def main(argv): for id,ipft in enumerate(donor_pft_indices): out_var[id] = fp_in.variables.get(key).data[ipft-1] - elif( (prt_dim_found==0) & (pft_dim_len==2) ): # fates_prt_organs - string_length + elif( (prt_dim_found==0) & (pft_dim_len==2) ): + out_var = fp_out.createVariable(key,'c',(fp_in.variables.get(key).dimensions)) + out_var[:] = in_var[:] + + elif( (hydro_dim_found==0) & (string_dim_found>=0) ): out_var = fp_out.createVariable(key,'c',(fp_in.variables.get(key).dimensions)) out_var[:] = in_var[:] + + elif( (litt_dim_found==0) & (string_dim_found>=0) ): + out_var = fp_out.createVariable(key,'c',(fp_in.variables.get(key).dimensions)) + out_var[:] = in_var[:] + + elif( prt_dim_found==0 ): # fates_prt_organs - indices + out_var = fp_out.createVariable(key,'d',(fp_in.variables.get(key).dimensions)) + out_var[:] = in_var[:] - elif( prt_dim_found==0 ): + elif( litt_dim_found==0 ): + out_var = fp_out.createVariable(key,'d',(fp_in.variables.get(key).dimensions)) + out_var[:] = in_var[:] + elif( hydro_dim_found==0): out_var = fp_out.createVariable(key,'d',(fp_in.variables.get(key).dimensions)) out_var[:] = in_var[:] - else: print('This variable has a dimensioning that we have not considered yet.') print('Please add this condition to the logic above this statement.')