-
Notifications
You must be signed in to change notification settings - Fork 109
site-level mass flux accounting part 2 #1473
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
Changes from 3 commits
0ba914c
a7c739a
2c9a15e
283bc8e
546326c
95c4bcb
759ed00
ed117e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -198,7 +198,7 @@ subroutine ed_ecosystem_dynamics(currentSite, bc_in, bc_out) | |
| call ZeroBCOutCarbonFluxes(bc_out) | ||
|
|
||
| ! Zero mass balance | ||
| call TotalBalanceCheck(currentSite, 0) | ||
| call TotalBalanceCheck(currentSite, 0, is_restarting=.false.) | ||
|
|
||
| ! We do not allow phenology while in ST3 mode either, it is hypothetically | ||
| ! possible to allow this, but we have not plugged in the litter fluxes | ||
|
|
@@ -263,7 +263,7 @@ subroutine ed_ecosystem_dynamics(currentSite, bc_in, bc_out) | |
| currentPatch => currentPatch%younger | ||
| enddo | ||
|
|
||
| call TotalBalanceCheck(currentSite,1) | ||
| call TotalBalanceCheck(currentSite,1,is_restarting=.false.) | ||
|
|
||
| currentPatch => currentSite%oldest_patch | ||
| do while (associated(currentPatch)) | ||
|
|
@@ -286,7 +286,7 @@ subroutine ed_ecosystem_dynamics(currentSite, bc_in, bc_out) | |
|
|
||
| end if | ||
|
|
||
| call TotalBalanceCheck(currentSite,2) | ||
| call TotalBalanceCheck(currentSite,2,is_restarting=.false.) | ||
|
|
||
| !********************************************************************************* | ||
| ! Patch dynamics sub-routines: fusion, new patch creation (spwaning), termination. | ||
|
|
@@ -304,7 +304,7 @@ subroutine ed_ecosystem_dynamics(currentSite, bc_in, bc_out) | |
|
|
||
| call spawn_patches(currentSite, bc_in) | ||
|
|
||
| call TotalBalanceCheck(currentSite,3) | ||
| call TotalBalanceCheck(currentSite,3,is_restarting=.false.) | ||
|
|
||
| ! fuse on the spawned patches. | ||
| call fuse_patches(currentSite, bc_in ) | ||
|
|
@@ -319,14 +319,14 @@ subroutine ed_ecosystem_dynamics(currentSite, bc_in, bc_out) | |
| end if | ||
|
|
||
| ! SP has changes in leaf carbon but we don't expect them to be in balance. | ||
| call TotalBalanceCheck(currentSite,4) | ||
| call TotalBalanceCheck(currentSite,4,is_restarting=.false.) | ||
|
|
||
| ! kill patches that are too small | ||
| call terminate_patches(currentSite, bc_in) | ||
| end if | ||
|
|
||
| ! Final instantaneous mass balance check | ||
| call TotalBalanceCheck(currentSite,5) | ||
| call TotalBalanceCheck(currentSite,5,is_restarting=.false.) | ||
|
|
||
|
|
||
| end subroutine ed_ecosystem_dynamics | ||
|
|
@@ -668,11 +668,6 @@ subroutine ed_integrate_state_variables(currentSite, bc_in, bc_out ) | |
| currentSite%mass_balance(element_pos(carbon12_element))%net_root_uptake - & | ||
| currentCohort%daily_c_efflux*currentCohort%n | ||
|
|
||
| ! Save NPP diagnostic for flux accounting [kg/m2/day] | ||
|
|
||
| currentSite%flux_diags%npp = currentSite%flux_diags%npp + & | ||
| currentCohort%npp_acc_hold/real( hlm_days_per_year,r8) * currentCohort%n * area_inv | ||
|
|
||
| ! And simultaneously add the input fluxes to mass balance accounting | ||
| site_cmass%gpp_acc = site_cmass%gpp_acc + & | ||
| currentCohort%gpp_acc * currentCohort%n | ||
|
|
@@ -682,8 +677,6 @@ subroutine ed_integrate_state_variables(currentSite, bc_in, bc_out ) | |
| currentCohort%resp_excess_hold*currentCohort%n + & | ||
| currentCohort%resp_g_acc_hold*currentCohort%n/real( hlm_days_per_year,r8) | ||
|
|
||
|
|
||
|
|
||
| call currentCohort%prt%CheckMassConservation(ft,5) | ||
|
|
||
| ! Update the leaf biophysical rates based on proportion of leaf | ||
|
|
@@ -848,10 +841,7 @@ subroutine ed_update_site( currentSite, bc_in, bc_out, is_restarting ) | |
| call set_patchno(currentSite,.true.,1) | ||
| end if | ||
|
|
||
| ! Pass site-level mass fluxes to output boundary conditions | ||
| ! [kg/site/day] * [site/m2 day/sec] = [kgC/m2/s] | ||
| bc_out%gpp_site = site_cmass%gpp_acc * area_inv / sec_per_day | ||
| bc_out%ar_site = site_cmass%aresp_acc * area_inv / sec_per_day | ||
|
|
||
|
|
||
| if(hlm_use_sp.eq.ifalse .and. (.not.is_restarting))then | ||
| call canopy_spread(currentSite) | ||
|
|
@@ -860,13 +850,13 @@ subroutine ed_update_site( currentSite, bc_in, bc_out, is_restarting ) | |
| site_cmass%aresp_acc = 0._r8 | ||
| end if | ||
|
|
||
| call TotalBalanceCheck(currentSite,6) | ||
| call TotalBalanceCheck(currentSite,6,is_restarting=is_restarting) | ||
|
|
||
| if(hlm_use_sp.eq.ifalse .and. (.not.is_restarting) )then | ||
| call canopy_structure(currentSite, bc_in) | ||
| endif | ||
|
|
||
| call TotalBalanceCheck(currentSite,final_check_id) | ||
| call TotalBalanceCheck(currentSite,final_check_id,is_restarting=is_restarting) | ||
|
|
||
| ! Update recruit L2FRs based on new canopy position | ||
| call SetRecruitL2FR(currentSite) | ||
|
|
@@ -927,26 +917,34 @@ subroutine ed_update_site( currentSite, bc_in, bc_out, is_restarting ) | |
| ! Set boundary condition to HLM for carbon loss to atm from fires and grazing | ||
| ! [kgC/ha/day]*[ha/m2]*[day/s] = [kg/m2/s] | ||
|
|
||
| bc_out%fire_closs_to_atm_si = site_cmass%burn_flux_to_atm * ha_per_m2 * days_per_sec | ||
| bc_out%grazing_closs_to_atm_si = site_cmass%herbivory_flux_out * ha_per_m2 * days_per_sec | ||
|
|
||
|
|
||
| bc_out%fire_closs_to_atm_si = site_cmass%burn_flux_to_atm * area_inv * days_per_sec | ||
| bc_out%grazing_closs_to_atm_si = site_cmass%herbivory_flux_out * area_inv * days_per_sec | ||
| bc_out%gpp_site = site_cmass%gpp_acc * area_inv * days_per_sec | ||
| bc_out%ar_site = site_cmass%aresp_acc * area_inv * days_per_sec | ||
|
|
||
| end subroutine ed_update_site | ||
|
|
||
| !-------------------------------------------------------------------------------! | ||
|
|
||
| subroutine TotalBalanceCheck (currentSite, call_index ) | ||
| subroutine TotalBalanceCheck (currentSite, call_index, is_restarting ) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be an optional argument? With a local variable that is .false. by default and takes the argument value when the argument is present? Then you don't have to alter every call of this routine
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds fine to me, I'll submit the change |
||
|
|
||
| ! | ||
| ! !DESCRIPTION: | ||
| ! This routine looks at the mass flux in and out of the FATES and compares it to | ||
| ! the change in total stocks (states). | ||
| ! Fluxes in are NPP. Fluxes out are decay of CWD and litter into SOM pools. | ||
| ! Note: If the model is restarting, it is assumed that the mass stocks | ||
| ! that were saved in the restart file are the "old" stocks, and they | ||
| ! should equal the stocks that are currently in the sites. However, | ||
| ! the fluxes on a restart are saved so that they can inform the HLM | ||
| ! on the next day, so we have to modify our mass balance check to ignore | ||
| ! fluxes on restarts. | ||
| ! | ||
| ! !ARGUMENTS: | ||
| type(ed_site_type) , intent(inout) :: currentSite | ||
| integer , intent(in) :: call_index | ||
| logical , intent(in) :: is_restarting | ||
|
|
||
| ! | ||
| ! !LOCAL VARIABLES: | ||
| type(site_massbal_type),pointer :: site_mass | ||
|
|
@@ -987,32 +985,35 @@ subroutine TotalBalanceCheck (currentSite, call_index ) | |
|
|
||
| change_in_stock = 0.0_r8 | ||
|
|
||
|
|
||
| ! Loop through the number of elements in the system | ||
|
|
||
| do el = 1, num_elements | ||
| do_elem_loop: do el = 1, num_elements | ||
|
|
||
| site_mass => currentSite%mass_balance(el) | ||
|
|
||
| call SiteMassStock(currentSite,el,total_stock,biomass_stock,litter_stock,seed_stock) | ||
|
|
||
| change_in_stock = total_stock - site_mass%old_stock | ||
|
|
||
| flux_in = site_mass%seed_in + & | ||
| site_mass%net_root_uptake + & | ||
| site_mass%gpp_acc + & | ||
| site_mass%flux_generic_in + & | ||
| site_mass%patch_resize_err | ||
|
|
||
| flux_out = sum(site_mass%wood_product_harvest(:)) + & | ||
| sum(site_mass%wood_product_landusechange(:)) + & | ||
| site_mass%burn_flux_to_atm + & | ||
| site_mass%seed_out + & | ||
| site_mass%flux_generic_out + & | ||
| site_mass%frag_out + & | ||
| site_mass%aresp_acc + & | ||
| site_mass%herbivory_flux_out | ||
|
|
||
| if(is_restarting) then | ||
| flux_in = 0._r8 | ||
| flux_out = 0._r8 | ||
| else | ||
| flux_in = site_mass%seed_in + & | ||
| site_mass%net_root_uptake + & | ||
| site_mass%gpp_acc + & | ||
| site_mass%flux_generic_in + & | ||
| site_mass%patch_resize_err | ||
|
|
||
| flux_out = sum(site_mass%wood_product_harvest(:)) + & | ||
| sum(site_mass%wood_product_landusechange(:)) + & | ||
| site_mass%burn_flux_to_atm + & | ||
| site_mass%seed_out + & | ||
| site_mass%flux_generic_out + & | ||
| site_mass%frag_out + & | ||
| site_mass%aresp_acc + & | ||
| site_mass%herbivory_flux_out | ||
| end if | ||
|
|
||
| net_flux = flux_in - flux_out | ||
| error = abs(net_flux - change_in_stock) | ||
|
|
||
|
|
@@ -1110,12 +1111,13 @@ subroutine TotalBalanceCheck (currentSite, call_index ) | |
|
|
||
| ! This is the last check of the sequence, where we update our total | ||
| ! error check and the final fates stock | ||
| if(call_index == final_check_id) then | ||
| site_mass%old_stock = total_stock | ||
| site_mass%err_fates = net_flux - change_in_stock | ||
| if(call_index == final_check_id .and. .not.is_restarting) then | ||
| site_mass%old_stock = total_stock | ||
| site_mass%err_fates = net_flux - change_in_stock | ||
| end if | ||
|
|
||
| end do | ||
| end do do_elem_loop | ||
|
|
||
| end if ! not SP mode | ||
| end subroutine TotalBalanceCheck | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.