Skip to content
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

Fire emissions history output. #7

Open
wants to merge 6 commits into
base: feature/fates-fire-emission
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions fire/SFMainMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ subroutine fire_model( currentSite, bc_in)
call crown_damage(currentSite)
call cambial_damage_kill(currentSite)
call post_fire_mortality(currentSite)
call fire_emissions(currentSite)
end if

end subroutine fire_model
Expand Down Expand Up @@ -1149,9 +1150,12 @@ subroutine fire_emissions ( currentSite )
enddo

currentPatch%fire_emission_height = EDPftvarcon_inst%fire_emission_heights(currentPatch%nocomp_pft_label)

currentPatch => currentPatch%younger
endif
if(currentPatch%fire_emissions(c).gt.0.0_r8)then
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can/should be deleted...

write(*,*) 'postivie emissionssf',currentPatch%fire_emissions(1),biomass_burned
endif
endif ! bare ground
currentPatch => currentPatch%younger

enddo !end patch loop
end if ! is nocomp

Expand Down
78 changes: 71 additions & 7 deletions main/FatesHistoryInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ module FatesHistoryInterfaceMod
integer :: ih_fire_fuel_mef_si
integer :: ih_sum_fuel_si
integer :: ih_fragmentation_scaler_sl

integer :: ih_fire_emission_height_si

integer :: ih_nplant_si_scpf
integer :: ih_gpp_si_scpf
integer :: ih_npp_totl_si_scpf
Expand Down Expand Up @@ -666,6 +667,9 @@ module FatesHistoryInterfaceMod
integer :: ih_burnt_frac_litter_si_fuel
integer :: ih_fuel_amount_si_fuel

! indices to (site x emissions) variables
integer :: ih_fire_emissions_si_emis

! indices to (site x cwd size class) variables
integer :: ih_cwd_ag_si_cwdsc
integer :: ih_cwd_bg_si_cwdsc
Expand Down Expand Up @@ -761,7 +765,8 @@ module FatesHistoryInterfaceMod
integer, private :: levscls_index_, levpft_index_, levage_index_
integer, private :: levfuel_index_, levcwdsc_index_, levscag_index_
integer, private :: levcan_index_, levcnlf_index_, levcnlfpft_index_
integer, private :: levcdpf_index_, levcdsc_index_, levcdam_index_
integer, private :: levcdpf_index_, levcdsc_index_, levcdam_index_
integer, private :: levemis_index_
integer, private :: levscagpft_index_, levagepft_index_
integer, private :: levheight_index_, levagefuel_index_
integer, private :: levelem_index_, levelpft_index_
Expand Down Expand Up @@ -793,6 +798,7 @@ module FatesHistoryInterfaceMod
procedure :: levcacls_index
procedure :: levpft_index
procedure :: levage_index
procedure :: levemis_index
procedure :: levfuel_index
procedure :: levcwdsc_index
procedure :: levcan_index
Expand Down Expand Up @@ -828,6 +834,7 @@ module FatesHistoryInterfaceMod
procedure, private :: set_levscls_index
procedure, private :: set_levpft_index
procedure, private :: set_levage_index
procedure, private :: set_levemis_index
procedure, private :: set_levfuel_index
procedure, private :: set_levcwdsc_index
procedure, private :: set_levcan_index
Expand Down Expand Up @@ -874,7 +881,7 @@ subroutine Init(this, num_threads, fates_bounds)

use FatesIODimensionsMod, only : column, levsoil, levscpf
use FatesIODimensionsMod, only : levscls, levpft, levage
use FatesIODimensionsMod, only : levcacls, levcapf
use FatesIODimensionsMod, only : levcacls, levcapf, levemis
use FatesIODimensionsMod, only : levfuel, levcwdsc, levscag
use FatesIODimensionsMod, only : levscagpft, levagepft
use FatesIODimensionsMod, only : levcan, levcnlf, levcnlfpft
Expand Down Expand Up @@ -933,6 +940,11 @@ subroutine Init(this, num_threads, fates_bounds)
call this%dim_bounds(dim_count)%Init(levage, num_threads, &
fates_bounds%age_class_begin, fates_bounds%age_class_end)

dim_count = dim_count + 1
call this%set_levemis_index(dim_count)
call this%dim_bounds(dim_count)%Init(levemis, num_threads, &
fates_bounds%emis_class_begin, fates_bounds%emis_class_end)

dim_count = dim_count + 1
call this%set_levfuel_index(dim_count)
call this%dim_bounds(dim_count)%Init(levfuel, num_threads, &
Expand Down Expand Up @@ -1086,6 +1098,10 @@ subroutine SetThreadBoundsEach(this, thread_index, thread_bounds)
call this%dim_bounds(index)%SetThreadBounds(thread_index, &
thread_bounds%age_class_begin, thread_bounds%age_class_end)

index = this%levemis_index()
call this%dim_bounds(index)%SetThreadBounds(thread_index, &
thread_bounds%emis_class_begin, thread_bounds%emis_class_end)

index = this%levfuel_index()
call this%dim_bounds(index)%SetThreadBounds(thread_index, &
thread_bounds%fuel_begin, thread_bounds%fuel_end)
Expand Down Expand Up @@ -1177,7 +1193,7 @@ subroutine assemble_history_output_types(this)

use FatesIOVariableKindMod, only : site_r8, site_soil_r8, site_size_pft_r8
use FatesIOVariableKindMod, only : site_size_r8, site_pft_r8, site_age_r8
use FatesIOVariableKindMod, only : site_coage_r8, site_coage_pft_r8
use FatesIOVariableKindMod, only : site_coage_r8, site_coage_pft_r8, site_emis_r8
use FatesIOVariableKindMod, only : site_fuel_r8, site_cwdsc_r8, site_scag_r8
use FatesIOVariableKindMod, only : site_scagpft_r8, site_agepft_r8
use FatesIOVariableKindMod, only : site_can_r8, site_cnlf_r8, site_cnlfpft_r8
Expand Down Expand Up @@ -1216,6 +1232,9 @@ subroutine assemble_history_output_types(this)
call this%set_dim_indices(site_age_r8, 1, this%column_index())
call this%set_dim_indices(site_age_r8, 2, this%levage_index())

call this%set_dim_indices(site_emis_r8, 1, this%column_index())
call this%set_dim_indices(site_emis_r8, 2, this%levemis_index())

call this%set_dim_indices(site_fuel_r8, 1, this%column_index())
call this%set_dim_indices(site_fuel_r8, 2, this%levfuel_index())

Expand Down Expand Up @@ -1432,6 +1451,21 @@ integer function levage_index(this)
class(fates_history_interface_type), intent(in) :: this
levage_index = this%levage_index_
end function levage_index

! =======================================================================
subroutine set_levemis_index(this, index)
implicit none
class(fates_history_interface_type), intent(inout) :: this
integer, intent(in) :: index
this%levemis_index_ = index
end subroutine set_levemis_index

integer function levemis_index(this)
implicit none
class(fates_history_interface_type), intent(in) :: this
levemis_index = this%levemis_index_
end function levemis_index


! =======================================================================
subroutine set_levfuel_index(this, index)
Expand Down Expand Up @@ -1875,7 +1909,7 @@ subroutine init_dim_kinds_maps(this)
! ----------------------------------------------------------------------------------
use FatesIOVariableKindMod, only : site_r8, site_soil_r8, site_size_pft_r8
use FatesIOVariableKindMod, only : site_size_r8, site_pft_r8, site_age_r8
use FatesIOVariableKindMod, only : site_coage_r8, site_coage_pft_r8
use FatesIOVariableKindMod, only : site_coage_r8, site_coage_pft_r8, site_emis_r8
use FatesIOVariableKindMod, only : site_fuel_r8, site_cwdsc_r8, site_scag_r8
use FatesIOVariableKindMod, only : site_scagpft_r8, site_agepft_r8
use FatesIOVariableKindMod, only : site_can_r8, site_cnlf_r8, site_cnlfpft_r8
Expand Down Expand Up @@ -1924,6 +1958,10 @@ subroutine init_dim_kinds_maps(this)
! site x patch-age class
index = index + 1
call this%dim_kinds(index)%Init(site_age_r8, 2)

! site x patch-age class
index = index + 1
call this%dim_kinds(index)%Init(site_emis_r8, 2)

! site x fuel size class
index = index + 1
Expand Down Expand Up @@ -2228,7 +2266,7 @@ subroutine update_history_dyn(this,nc,nsites,sites,bc_in)
use FatesSizeAgeTypeIndicesMod, only : get_cdamagesize_class_index
use FatesSizeAgeTypeIndicesMod, only : get_cdamagesizepft_class_index
use FatesSizeAgeTypeIndicesMod, only : coagetype_class_index

use EDParamsMod , only : num_emission_compounds
use EDParamsMod , only : nlevleaf
use EDParamsMod , only : ED_val_history_height_bin_edges
use FatesInterfaceTypesMod , only : nlevdamage
Expand Down Expand Up @@ -2258,6 +2296,7 @@ subroutine update_history_dyn(this,nc,nsites,sites,bc_in)
integer :: i_scpf,i_pft,i_scls ! iterators for scpf, pft, and scls dims
integer :: i_cacls, i_capf ! iterators for cohort age and cohort age x pft
integer :: i_cwd,i_fuel ! iterators for cwd and fuel dims
integer :: i_emis ! iterators for emissions class
integer :: iscag ! size-class x age index
integer :: iscagpft ! size-class x age x pft index
integer :: iagepft ! age x pft index
Expand Down Expand Up @@ -2366,6 +2405,8 @@ subroutine update_history_dyn(this,nc,nsites,sites,bc_in)
hio_fire_fuel_eff_moist_si => this%hvars(ih_fire_fuel_eff_moist_si)%r81d, &
hio_fire_fuel_sav_si => this%hvars(ih_fire_fuel_sav_si)%r81d, &
hio_fire_fuel_mef_si => this%hvars(ih_fire_fuel_mef_si)%r81d, &
hio_fire_emissions_si_em => this%hvars(ih_fire_emissions_si_emis)%r82d, &
hio_fire_emission_height_si => this%hvars(ih_fire_emission_height_si)%r81d, &
hio_sum_fuel_si => this%hvars(ih_sum_fuel_si)%r81d, &
hio_fragmentation_scaler_sl => this%hvars(ih_fragmentation_scaler_sl)%r82d, &
hio_litter_in_si => this%hvars(ih_litter_in_si)%r81d, &
Expand Down Expand Up @@ -3808,7 +3849,16 @@ subroutine update_history_dyn(this,nc,nsites,sites,bc_in)
cpatch%burnt_frac_litter(i_fuel) * cpatch%frac_burnt * cpatch%area * AREA_INV
end do

! Update fire emissions variables

do i_emis = 1,num_emission_compounds
hio_fire_emissions_si_em(io_si, i_emis) = hio_fire_emissions_si_em(io_si,i_emis) + &
cpatch%fire_emissions(i_emis) * cpatch%area * AREA_INV
enddo

hio_fire_emission_height_si(io_si) = hio_fire_emission_height_si(io_si) + &
cpatch%fire_emission_height * cpatch%area * AREA_INV

hio_fire_intensity_area_product_si(io_si) = hio_fire_intensity_area_product_si(io_si) + &
cpatch%FI * cpatch%frac_burnt * cpatch%area * AREA_INV * J_per_kJ

Expand Down Expand Up @@ -5351,7 +5401,7 @@ subroutine define_history_vars(this, initialize_variables)

use FatesIOVariableKindMod, only : site_r8, site_soil_r8, site_size_pft_r8
use FatesIOVariableKindMod, only : site_size_r8, site_pft_r8, site_age_r8
use FatesIOVariableKindMod, only : site_coage_pft_r8, site_coage_r8
use FatesIOVariableKindMod, only : site_coage_pft_r8, site_coage_r8, site_emis_r8
use FatesIOVariableKindMod, only : site_height_r8, site_agefuel_r8
use FatesInterfaceTypesMod , only : hlm_use_planthydro

Expand Down Expand Up @@ -5382,6 +5432,7 @@ subroutine define_history_vars(this, initialize_variables)
! canopy layer (site_can_r8) : CL
! coarse woody debris size (site_cwdsc_r8) : DC
! element (site_elem_r8) : EL
! fire emissions class (site_emis_r8) : EM
! leaf layer : LL
! fuel class (site_fuel_r8) : FC
! height (site_height_r8) : HT
Expand Down Expand Up @@ -5925,6 +5976,19 @@ subroutine define_history_vars(this, initialize_variables)
hlms='CLM:ALM', upfreq=1, ivar=ivar, initialize=initialize_variables, &
index = ih_burnt_frac_litter_si_fuel)

call this%set_history_var(vname='FATES_FIRE_EMISSIONS_EM', units='kg m-2 s-1', &
long='Fire emissions per emissions compound. ', &
use_default='active', avgflag='A', vtype=site_emis_r8, hlms='CLM:ALM', &
upfreq=1, ivar=ivar, initialize=initialize_variables, &
index = ih_fire_emissions_si_emis)

call this%set_history_var(vname='FATES_FIRE_EMISSION_HEIGHT', units='m', &
long='Fire emissions per emissions compound. ', &
use_default='active', avgflag='A', vtype=site_r8, hlms='CLM:ALM', &
upfreq=1, ivar=ivar, initialize=initialize_variables, &
index = ih_fire_emission_height_si)


! Litter Variables

call this%set_history_var(vname='FATES_LITTER_IN', units='kg m-2 s-1', &
Expand Down
8 changes: 7 additions & 1 deletion main/FatesHistoryVariableType.F90
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module FatesHistoryVariableType
use FatesIOVariableKindMod, only : fates_io_variable_kind_type
use FatesIOVariableKindMod, only : site_r8, site_soil_r8, site_size_pft_r8
use FatesIOVariableKindMod, only : site_size_r8, site_pft_r8, site_age_r8
use FatesIOVariableKindMod, only : site_coage_r8, site_coage_pft_r8
use FatesIOVariableKindMod, only : site_coage_r8, site_coage_pft_r8, site_emis_r8
use FatesIOVariableKindMod, only : site_height_r8
use FatesIOVariableKindMod, only : site_fuel_r8, site_cwdsc_r8, site_scag_r8
use FatesIOVariableKindMod, only : site_scagpft_r8, site_agepft_r8
Expand Down Expand Up @@ -145,6 +145,10 @@ subroutine Init(this, vname, units, long, use_default, &
allocate(this%r82d(lb1:ub1, lb2:ub2))
this%r82d(:,:) = flushval

case(site_emis_r8)
allocate(this%r82d(lb1:ub1, lb2:ub2))
this%r82d(:,:) = flushval

case(site_height_r8)
allocate(this%r82d(lb1:ub1, lb2:ub2))
this%r82d(:,:) = flushval
Expand Down Expand Up @@ -313,6 +317,8 @@ subroutine Flush(this, thread, dim_bounds, dim_kinds)
this%r82d(lb1:ub1, lb2:ub2) = this%flushval
case(site_age_r8)
this%r82d(lb1:ub1, lb2:ub2) = this%flushval
case(site_emis_r8)
this%r82d(lb1:ub1, lb2:ub2) = this%flushval
case(site_height_r8)
this%r82d(lb1:ub1, lb2:ub2) = this%flushval
case(site_fuel_r8)
Expand Down
8 changes: 7 additions & 1 deletion main/FatesIODimensionsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module FatesIODimensionsMod
character(*), parameter, public :: levscls = 'fates_levscls' ! matches histFileMod
character(*), parameter, public :: levpft = 'fates_levpft' ! matches histFileMod
character(*), parameter, public :: levage = 'fates_levage' ! matches histFileMod
character(*), parameter, public :: levemis = 'fates_levemis' ! matches histFileMod
character(*), parameter, public :: levheight = 'fates_levheight' ! matches histFileMod
character(*), parameter, public :: levfuel = 'fates_levfuel' ! matches histFileMod
character(*), parameter, public :: levcwdsc = 'fates_levcwdsc' ! matches histFileMod
Expand Down Expand Up @@ -67,6 +68,9 @@ module FatesIODimensionsMod
! levheight = This is a structure that records the boundaries for the
! number of height dimension

! levemis = This is a structure that records the boundaries for the
! number of emission compounds dimension

! levfuel = This is a structure that records the boundaries for the
! number of fuel-size-class dimension

Expand Down Expand Up @@ -109,7 +113,7 @@ module FatesIODimensionsMod
! levelpft = This records the boundaries for elements x pft
! levelcwd = This records the boundaries for element x cwd
! levelage = This records the boundaries for element x age

! levcdsc = This is a structure that records the boundaries for the
! number of crown damage x size classes dimension

Expand Down Expand Up @@ -155,6 +159,8 @@ module FatesIODimensionsMod
integer :: age_class_end
integer :: height_begin
integer :: height_end
integer :: emis_class_begin
integer :: emis_class_end
integer :: fuel_begin
integer :: fuel_end
integer :: cwdsc_begin
Expand Down
1 change: 1 addition & 0 deletions main/FatesIOVariableKindMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module FatesIOVariableKindMod
character(*), parameter, public :: cohort_int = 'CO_INT'
character(*), parameter, public :: site_pft_r8 = 'SI_PFT_R8'
character(*), parameter, public :: site_age_r8 = 'SI_AGE_R8'
character(*), parameter, public :: site_emis_r8 = 'SI_EMIS_R8'
character(*), parameter, public :: site_height_r8 = 'SI_HEIGHT_R8'
character(*), parameter, public :: site_fuel_r8 = 'SI_FUEL_R8'
character(*), parameter, public :: site_cwdsc_r8 = 'SI_CWDSC_R8'
Expand Down
8 changes: 7 additions & 1 deletion main/FatesInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ subroutine fates_history_maps

use FatesLitterMod, only : NFSC
use EDParamsMod, only : nclmax
use EDParamsMod, only : nlevleaf
use EDParamsMod, only : nlevleaf, num_emission_compounds
use EDParamsMod, only : ED_val_history_sizeclass_bin_edges
use EDParamsMod, only : ED_val_history_ageclass_bin_edges
use EDParamsMod, only : ED_val_history_height_bin_edges
Expand All @@ -1142,6 +1142,7 @@ subroutine fates_history_maps
integer :: ipft
integer :: icwd
integer :: ifuel
integer :: iemis
integer :: ican
integer :: icdam
integer :: ileaf
Expand All @@ -1157,6 +1158,7 @@ subroutine fates_history_maps
allocate( fates_hdim_levpft(1:numpft ))
allocate( fates_hdim_levlanduse(1:n_landuse_cats))
allocate( fates_hdim_levfuel(1:NFSC ))
allocate( fates_hdim_levemis(1:num_emission_compounds ))
allocate( fates_hdim_levcwdsc(1:NCWD ))
allocate( fates_hdim_levage(1:nlevage ))
allocate( fates_hdim_levheight(1:nlevheight ))
Expand Down Expand Up @@ -1214,6 +1216,10 @@ subroutine fates_history_maps
fates_hdim_levfuel(ifuel) = ifuel
end do

do iemis=1,num_emission_compounds
fates_hdim_levemis(iemis) = iemis
end do

! make cwd array
do icwd=1,NCWD
fates_hdim_levcwdsc(icwd) = icwd
Expand Down
1 change: 1 addition & 0 deletions main/FatesInterfaceTypesMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ module FatesInterfaceTypesMod
integer , public, allocatable :: fates_hdim_levpft(:) ! plant pft dimension
integer , public, allocatable :: fates_hdim_levlanduse(:) ! land use label dimension
integer , public, allocatable :: fates_hdim_levfuel(:) ! fire fuel size class (fsc) dimension
integer , public, allocatable :: fates_hdim_levemis(:) ! fire emissions class dimensionn
integer , public, allocatable :: fates_hdim_levcwdsc(:) ! cwd class dimension
integer , public, allocatable :: fates_hdim_levcan(:) ! canopy-layer dimension
real(r8), public, allocatable :: fates_hdim_levleaf(:) ! leaf-layer dimension, integrated VAI [m2/m2]
Expand Down
Loading