Skip to content

Commit

Permalink
Call routine to calc fire's btran2 from CNFireArea
Browse files Browse the repository at this point in the history
This has a few advantages:
- It makes the logic of CNFireArea more clear (rather than depending on
  a btran2 variable that is calculated from some other part of the code)

- This avoids having the biogeophysics depend on the biogeochemistry

- This lets us avoid doing this btran calc if using no-fire – or other,
  future, fire methods that don't need it

The placement in the driver loop differs from before; in order to get
bit-for-bit results, we need to save h2osoi_vol and used that saved
version from earlier in the driver loop; in a follow-up, answer-changing
step, I plan to change this.
  • Loading branch information
billsacks committed Sep 18, 2020
1 parent a1526b8 commit e345c39
Show file tree
Hide file tree
Showing 12 changed files with 114 additions and 98 deletions.
12 changes: 10 additions & 2 deletions src/biogeochem/CNDriverMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module CNDriverMod
use EnergyFluxType , only : energyflux_type
use SaturatedExcessRunoffMod , only : saturated_excess_runoff_type
use ActiveLayerMod , only : active_layer_type
use SoilWaterRetentionCurveMod , only : soil_water_retention_curve_type
!
! !PUBLIC TYPES:
implicit none
Expand Down Expand Up @@ -80,7 +81,8 @@ end subroutine CNDriverInit

!-----------------------------------------------------------------------
subroutine CNDriverNoLeaching(bounds, &
num_soilc, filter_soilc, num_soilp, filter_soilp, num_pcropp, filter_pcropp, doalb, &
num_soilc, filter_soilc, num_soilp, filter_soilp, num_pcropp, filter_pcropp, &
num_exposedvegp, filter_exposedvegp, doalb, &
cnveg_state_inst, &
cnveg_carbonflux_inst, cnveg_carbonstate_inst, &
c13_cnveg_carbonflux_inst, c13_cnveg_carbonstate_inst, &
Expand All @@ -94,7 +96,8 @@ subroutine CNDriverNoLeaching(bounds,
soilbiogeochem_nitrogenflux_inst, soilbiogeochem_nitrogenstate_inst, &
active_layer_inst, &
atm2lnd_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, waterfluxbulk_inst, &
wateratm2lndbulk_inst, canopystate_inst, soilstate_inst, temperature_inst, crop_inst, ch4_inst, &
wateratm2lndbulk_inst, canopystate_inst, soilstate_inst, temperature_inst, &
soil_water_retention_curve, crop_inst, ch4_inst, &
dgvs_inst, photosyns_inst, saturated_excess_runoff_inst, energyflux_inst, &
nutrient_competition_method, cnfire_method, dribble_crophrv_xsmrpool_2atm)
!
Expand Down Expand Up @@ -146,6 +149,8 @@ subroutine CNDriverNoLeaching(bounds,
integer , intent(in) :: filter_soilp(:) ! filter for soil patches
integer , intent(in) :: num_pcropp ! number of prog. crop patches in filter
integer , intent(in) :: filter_pcropp(:) ! filter for prognostic crop patches
integer , intent(in) :: num_exposedvegp ! number of points in filter_exposedvegp
integer , intent(in) :: filter_exposedvegp(:) ! patch filter for non-snow-covered veg
logical , intent(in) :: doalb ! true = surface albedo calculation time step
type(cnveg_state_type) , intent(inout) :: cnveg_state_inst
type(cnveg_carbonflux_type) , intent(inout) :: cnveg_carbonflux_inst
Expand Down Expand Up @@ -178,6 +183,7 @@ subroutine CNDriverNoLeaching(bounds,
type(canopystate_type) , intent(inout) :: canopystate_inst
type(soilstate_type) , intent(inout) :: soilstate_inst
type(temperature_type) , intent(inout) :: temperature_inst
class(soil_water_retention_curve_type) , intent(in) :: soil_water_retention_curve
type(crop_type) , intent(inout) :: crop_inst
type(ch4_type) , intent(in) :: ch4_inst
type(dgvs_type) , intent(inout) :: dgvs_inst
Expand Down Expand Up @@ -747,7 +753,9 @@ subroutine CNDriverNoLeaching(bounds,

call t_startf('CNFire')
call cnfire_method%CNFireArea(bounds, num_soilc, filter_soilc, num_soilp, filter_soilp, &
num_exposedvegp, filter_exposedvegp, &
atm2lnd_inst, energyflux_inst, saturated_excess_runoff_inst, waterdiagnosticbulk_inst, wateratm2lndbulk_inst, &
waterstatebulk_inst, soilstate_inst, soil_water_retention_curve, &
cnveg_state_inst, cnveg_carbonstate_inst, &
totlitc_col=soilbiogeochem_carbonstate_inst%totlitc_col(begc:endc), &
decomp_cpools_vr_col=soilbiogeochem_carbonstate_inst%decomp_cpools_vr_col(begc:endc,1:nlevdecomp_full,1:ndecomp_pools), &
Expand Down
46 changes: 4 additions & 42 deletions src/biogeochem/CNFireBaseMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ module CNFireBaseMod
procedure, public :: FireReadNML ! Read in namelist for CNFire
procedure, public :: CNFireRestart ! Restart for CNFire
procedure, public :: CNFireReadParams ! Read in constant parameters from the paramsfile
procedure, public :: CNFireArea ! Calculate fire area
procedure, public :: CNFireFluxes ! Calculate fire fluxes
procedure, public :: CNFire_calc_fire_root_wetness ! Calcualte CN-fire specific root wetness
!
Expand Down Expand Up @@ -168,19 +167,19 @@ subroutine CNFireRestart( this, bounds, ncid, flag )
end subroutine CNFireRestart

!----------------------------------------------------------------------
subroutine CNFire_calc_fire_root_wetness( this, bounds, nlevgrnd, num_exposedvegp, filter_exposedvegp, &
subroutine CNFire_calc_fire_root_wetness( this, bounds, num_exposedvegp, filter_exposedvegp, &
waterstatebulk_inst, soilstate_inst, soil_water_retention_curve )
!
! Calculate the root wetness term that will be used by the fire model
!
use pftconMod , only : pftcon
use clm_varpar , only : nlevgrnd
use PatchType , only : patch
use WaterStateBulkType , only : waterstatebulk_type
use SoilStateType , only : soilstate_type
use SoilWaterRetentionCurveMod, only : soil_water_retention_curve_type
class(cnfire_base_type) :: this
type(bounds_type) , intent(in) :: bounds !bounds
integer , intent(in) :: nlevgrnd !number of vertical layers
integer , intent(in) :: num_exposedvegp !number of filters
integer , intent(in) :: filter_exposedvegp(:) !filter array
type(waterstatebulk_type), intent(in) :: waterstatebulk_inst
Expand All @@ -201,13 +200,10 @@ subroutine CNFire_calc_fire_root_wetness( this, bounds, nlevgrnd, num_exposedveg
watsat => soilstate_inst%watsat_col , & ! Input: [real(r8) (:,:) ] volumetric soil water at saturation
btran2 => this%btran2_patch , & ! Output: [real(r8) (:) ] integrated soil water stress square
rootfr => soilstate_inst%rootfr_patch , & ! Input: [real(r8) (:,:) ] fraction of roots in each soil layer
h2osoi_vol => waterstatebulk_inst%h2osoi_vol_col & ! Input: [real(r8) (:,:) ] volumetric soil water (0<=h2osoi_vol<=watsat) [m3/m3] (porosity) (constant)
! FIXME(wjs, 2020-09-18) change this to use h2osoi_vol_col instead of the prehydrology version
h2osoi_vol => waterstatebulk_inst%h2osoi_vol_prehydrology_col & ! Input: [real(r8) (:,:) ] volumetric soil water (0<=h2osoi_vol<=watsat) [m3/m3] (porosity) (constant)
)

SHR_ASSERT_ALL_FL((ubound(watsat) == (/bounds%endc,nlevgrnd/)), sourcefile, __LINE__)
SHR_ASSERT_ALL_FL((ubound(h2osoi_vol) == (/bounds%endc,nlevgrnd/)), sourcefile, __LINE__)
SHR_ASSERT_ALL_FL((ubound(rootfr) == (/bounds%endp,nlevgrnd/)), sourcefile, __LINE__)
SHR_ASSERT_ALL_FL((ubound(btran2) == (/bounds%endp/)), sourcefile, __LINE__)
do f = 1, num_exposedvegp
p = filter_exposedvegp(f)
btran2(p) = btran0
Expand Down Expand Up @@ -338,40 +334,6 @@ subroutine FireReadNML( this, NLFilename )

end subroutine FireReadNML

!-----------------------------------------------------------------------
subroutine CNFireArea (this, bounds, num_soilc, filter_soilc, num_soilp, filter_soilp, &
atm2lnd_inst, energyflux_inst, saturated_excess_runoff_inst, &
waterdiagnosticbulk_inst, wateratm2lndbulk_inst, &
cnveg_state_inst, cnveg_carbonstate_inst, totlitc_col, decomp_cpools_vr_col, t_soi17cm_col)
!
! !DESCRIPTION:
! Computes column-level burned area
!
! !USES:
!
! !ARGUMENTS:
class(cnfire_base_type) :: this
type(bounds_type) , intent(in) :: bounds
integer , intent(in) :: num_soilc ! number of soil columns in filter
integer , intent(in) :: filter_soilc(:) ! filter for soil columns
integer , intent(in) :: num_soilp ! number of soil patches in filter
integer , intent(in) :: filter_soilp(:) ! filter for soil patches
type(atm2lnd_type) , intent(in) :: atm2lnd_inst
type(energyflux_type) , intent(in) :: energyflux_inst
type(saturated_excess_runoff_type) , intent(in) :: saturated_excess_runoff_inst
type(waterdiagnosticbulk_type) , intent(in) :: waterdiagnosticbulk_inst
type(wateratm2lndbulk_type) , intent(in) :: wateratm2lndbulk_inst
type(cnveg_state_type) , intent(inout) :: cnveg_state_inst
type(cnveg_carbonstate_type) , intent(inout) :: cnveg_carbonstate_inst
real(r8) , intent(in) :: totlitc_col(bounds%begc:)
real(r8) , intent(in) :: decomp_cpools_vr_col(bounds%begc:,1:,1:)
real(r8) , intent(in) :: t_soi17cm_col(bounds%begc:)
!

call endrun( 'cnfire_base::CNFireArea: this method MUST be implemented!' )

end subroutine CNFireArea

!-----------------------------------------------------------------------
subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filter_soilp, &
dgvs_inst, cnveg_state_inst, &
Expand Down
24 changes: 19 additions & 5 deletions src/biogeochem/CNFireLi2014Mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ module CNFireLi2014Mod
use SoilBiogeochemDecompCascadeConType , only : decomp_cascade_con
use EnergyFluxType , only : energyflux_type
use SaturatedExcessRunoffMod , only : saturated_excess_runoff_type
use WaterDiagnosticBulkType , only : waterdiagnosticbulk_type
use Wateratm2lndBulkType , only : wateratm2lndbulk_type
use WaterDiagnosticBulkType , only : waterdiagnosticbulk_type
use Wateratm2lndBulkType , only : wateratm2lndbulk_type
use WaterStateBulkType , only : waterstatebulk_type
use SoilStateType , only : soilstate_type
use SoilWaterRetentionCurveMod , only : soil_water_retention_curve_type
use GridcellType , only : grc
use ColumnType , only : col
use PatchType , only : patch
Expand Down Expand Up @@ -79,8 +82,10 @@ end function need_lightning_and_popdens

!-----------------------------------------------------------------------
subroutine CNFireArea (this, bounds, num_soilc, filter_soilc, num_soilp, filter_soilp, &
num_exposedvegp, filter_exposedvegp, &
atm2lnd_inst, energyflux_inst, saturated_excess_runoff_inst, waterdiagnosticbulk_inst, &
wateratm2lndbulk_inst, cnveg_state_inst, cnveg_carbonstate_inst, totlitc_col, decomp_cpools_vr_col, t_soi17cm_col)
wateratm2lndbulk_inst, waterstatebulk_inst, soilstate_inst, soil_water_retention_curve, &
cnveg_state_inst, cnveg_carbonstate_inst, totlitc_col, decomp_cpools_vr_col, t_soi17cm_col)
!
! !DESCRIPTION:
! Computes column-level burned area
Expand All @@ -100,11 +105,16 @@ subroutine CNFireArea (this, bounds, num_soilc, filter_soilc, num_soilp, filter_
integer , intent(in) :: filter_soilc(:) ! filter for soil columns
integer , intent(in) :: num_soilp ! number of soil patches in filter
integer , intent(in) :: filter_soilp(:) ! filter for soil patches
integer , intent(in) :: num_exposedvegp ! number of points in filter_exposedvegp
integer , intent(in) :: filter_exposedvegp(:) ! patch filter for non-snow-covered veg
type(atm2lnd_type) , intent(in) :: atm2lnd_inst
type(energyflux_type) , intent(in) :: energyflux_inst
type(saturated_excess_runoff_type) , intent(in) :: saturated_excess_runoff_inst
type(waterdiagnosticbulk_type) , intent(in) :: waterdiagnosticbulk_inst
type(wateratm2lndbulk_type) , intent(in) :: wateratm2lndbulk_inst
type(waterdiagnosticbulk_type) , intent(in) :: waterdiagnosticbulk_inst
type(wateratm2lndbulk_type) , intent(in) :: wateratm2lndbulk_inst
type(waterstatebulk_type) , intent(in) :: waterstatebulk_inst
type(soilstate_type) , intent(in) :: soilstate_inst
class(soil_water_retention_curve_type), intent(in) :: soil_water_retention_curve
type(cnveg_state_type) , intent(inout) :: cnveg_state_inst
type(cnveg_carbonstate_type) , intent(inout) :: cnveg_carbonstate_inst
real(r8) , intent(in) :: totlitc_col(bounds%begc:)
Expand Down Expand Up @@ -322,6 +332,10 @@ subroutine CNFireArea (this, bounds, num_soilc, filter_soilc, num_soilp, filter_
dtrotr_col(c)=0._r8
end if
end do

call this%CNFire_calc_fire_root_wetness(bounds, num_exposedvegp, filter_exposedvegp, &
waterstatebulk_inst, soilstate_inst, soil_water_retention_curve)

do pi = 1,max_patch_per_col
do fc = 1,num_soilc
c = filter_soilc(fc)
Expand Down
24 changes: 19 additions & 5 deletions src/biogeochem/CNFireLi2016Mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ module CNFireLi2016Mod
use SoilBiogeochemDecompCascadeConType , only : decomp_cascade_con
use EnergyFluxType , only : energyflux_type
use SaturatedExcessRunoffMod , only : saturated_excess_runoff_type
use WaterDiagnosticBulkType , only : waterdiagnosticbulk_type
use Wateratm2lndBulkType , only : wateratm2lndbulk_type
use WaterDiagnosticBulkType , only : waterdiagnosticbulk_type
use Wateratm2lndBulkType , only : wateratm2lndbulk_type
use WaterStateBulkType , only : waterstatebulk_type
use SoilStateType , only : soilstate_type
use SoilWaterRetentionCurveMod , only : soil_water_retention_curve_type
use GridcellType , only : grc
use ColumnType , only : col
use PatchType , only : patch
Expand Down Expand Up @@ -83,8 +86,10 @@ end function need_lightning_and_popdens

!-----------------------------------------------------------------------
subroutine CNFireArea (this, bounds, num_soilc, filter_soilc, num_soilp, filter_soilp, &
num_exposedvegp, filter_exposedvegp, &
atm2lnd_inst, energyflux_inst, saturated_excess_runoff_inst, waterdiagnosticbulk_inst, &
wateratm2lndbulk_inst, cnveg_state_inst, cnveg_carbonstate_inst, totlitc_col, decomp_cpools_vr_col, t_soi17cm_col)
wateratm2lndbulk_inst, waterstatebulk_inst, soilstate_inst, soil_water_retention_curve, &
cnveg_state_inst, cnveg_carbonstate_inst, totlitc_col, decomp_cpools_vr_col, t_soi17cm_col)
!
! !DESCRIPTION:
! Computes column-level burned area
Expand All @@ -105,11 +110,16 @@ subroutine CNFireArea (this, bounds, num_soilc, filter_soilc, num_soilp, filter_
integer , intent(in) :: filter_soilc(:) ! filter for soil columns
integer , intent(in) :: num_soilp ! number of soil patches in filter
integer , intent(in) :: filter_soilp(:) ! filter for soil patches
integer , intent(in) :: num_exposedvegp ! number of points in filter_exposedvegp
integer , intent(in) :: filter_exposedvegp(:) ! patch filter for non-snow-covered veg
type(atm2lnd_type) , intent(in) :: atm2lnd_inst
type(energyflux_type) , intent(in) :: energyflux_inst
type(saturated_excess_runoff_type) , intent(in) :: saturated_excess_runoff_inst
type(waterdiagnosticbulk_type) , intent(in) :: waterdiagnosticbulk_inst
type(wateratm2lndbulk_type) , intent(in) :: wateratm2lndbulk_inst
type(waterdiagnosticbulk_type) , intent(in) :: waterdiagnosticbulk_inst
type(wateratm2lndbulk_type) , intent(in) :: wateratm2lndbulk_inst
type(waterstatebulk_type) , intent(in) :: waterstatebulk_inst
type(soilstate_type) , intent(in) :: soilstate_inst
class(soil_water_retention_curve_type), intent(in) :: soil_water_retention_curve
type(cnveg_state_type) , intent(inout) :: cnveg_state_inst
type(cnveg_carbonstate_type) , intent(inout) :: cnveg_carbonstate_inst
real(r8) , intent(in) :: totlitc_col(bounds%begc:)
Expand Down Expand Up @@ -343,6 +353,10 @@ subroutine CNFireArea (this, bounds, num_soilc, filter_soilc, num_soilp, filter_
dtrotr_col(c)=0._r8
end if
end do

call this%CNFire_calc_fire_root_wetness(bounds, num_exposedvegp, filter_exposedvegp, &
waterstatebulk_inst, soilstate_inst, soil_water_retention_curve)

do pi = 1,max_patch_per_col
do fc = 1,num_soilc
c = filter_soilc(fc)
Expand Down
Loading

0 comments on commit e345c39

Please sign in to comment.