Skip to content
2 changes: 1 addition & 1 deletion components/elm/src/external_models/fates
Submodule fates updated from 5869e0 to 80c3bb
60 changes: 33 additions & 27 deletions components/elm/src/main/elmfates_interfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ module ELMFatesInterfaceMod
use CanopyStateType , only : canopystate_type
use TemperatureType , only : temperature_type
use EnergyFluxType , only : energyflux_type

use SoilStateType , only : soilstate_type

use elm_varctl , only : iulog
use elm_varctl , only : use_fates
use elm_varctl , only : use_vertsoilc
Expand Down Expand Up @@ -87,6 +87,7 @@ module ELMFatesInterfaceMod
use elm_varpar , only : ivis
use elm_varpar , only : inir
use elm_varpar , only : nlevsoi
use elm_varpar , only : nlevgrnd
use elm_varpar , only : nlevdecomp
use elm_varpar , only : nlevdecomp_full
use elm_varpar , only : i_met_lit, i_cel_lit, i_lig_lit
Expand Down Expand Up @@ -1295,9 +1296,6 @@ subroutine dynamics_driv(this, bounds_clump, top_as_inst, &
this%fates(nc)%bc_in(s)%h2o_liqvol_sl(1:nlevsoil) = &
col_ws%h2osoi_vol(c,1:nlevsoil)

this%fates(nc)%bc_in(s)%max_rooting_depth_index_col = &
min(nlevsoil, canopystate_inst%altmax_lastyear_indx_col(c))

do j = 1,nlevsoil
this%fates(nc)%bc_in(s)%tempk_sl(j) = col_es%t_soisno(c,j)
end do
Expand Down Expand Up @@ -1576,7 +1574,6 @@ subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, &
z0m => frictionvel_inst%z0m_patch , & ! Output: [real(r8) (:) ] momentum roughness length (m)
displa => canopystate_inst%displa_patch, &
dleaf_patch => canopystate_inst%dleaf_patch, &
snow_depth => col_ws%snow_depth, &
frac_sno_eff => col_ws%frac_sno_eff, &
frac_veg_nosno_alb => canopystate_inst%frac_veg_nosno_alb_patch)

Expand All @@ -1585,7 +1582,6 @@ subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, &
! --------------------------------------------------------------------------------
do s=1,this%fates(nc)%nsites
c = this%f2hmap(nc)%fcolumn(s)
this%fates(nc)%bc_in(s)%snow_depth_si = snow_depth(c)
this%fates(nc)%bc_in(s)%frac_sno_eff_si = frac_sno_eff(c)
end do

Expand Down Expand Up @@ -1978,7 +1974,7 @@ subroutine restart( this, bounds_proc, ncid, flag, &


! Register interface variables handled normally during cold start
call this%RegisterInterfaceVariablesColdStart(nc, canopystate_inst)
call this%RegisterInterfaceVariablesColdStart(nc, canopystate_inst, soilstate_inst)

! Update the interface variables
call this%fates(nc)%UpdateInterfaceVariables(restarting=.true.)
Expand All @@ -1989,8 +1985,6 @@ subroutine restart( this, bounds_proc, ncid, flag, &
do s = 1,this%fates(nc)%nsites

c = this%f2hmap(nc)%fcolumn(s)
this%fates(nc)%bc_in(s)%max_rooting_depth_index_col = &
min(this%fates(nc)%bc_in(s)%nlevsoil, canopystate_inst%altmax_lastyear_indx_col(c))

! When restarting the model, this subroutine has several
! procedures that are incremental or don't need to be performed for
Expand Down Expand Up @@ -2150,7 +2144,7 @@ subroutine init_coldstart(this, canopystate_inst, soilstate_inst, frictionvel_in
if ( this%fates(nc)%nsites>0 ) then

! Register interface variables
call this%RegisterInterfaceVariablesColdStart(nc, canopystate_inst)
call this%RegisterInterfaceVariablesColdStart(nc, canopystate_inst, soilstate_inst)

! Update the interface variables
call this%fates(nc)%UpdateInterfaceVariables(initialize=.true.)
Expand Down Expand Up @@ -2258,8 +2252,6 @@ subroutine init_coldstart(this, canopystate_inst, soilstate_inst, frictionvel_in
do s = 1,this%fates(nc)%nsites

c = this%f2hmap(nc)%fcolumn(s)
this%fates(nc)%bc_in(s)%max_rooting_depth_index_col = this%fates(nc)%bc_in(s)%nlevdecomp


call ed_update_site(this%fates(nc)%sites(s), &
this%fates(nc)%bc_in(s), &
Expand Down Expand Up @@ -2513,20 +2505,19 @@ subroutine wrap_btran(this,bounds_clump,fn,filterc,soilstate_inst, &
do j = 1,nlevsoil
this%fates(nc)%bc_in(s)%tempk_sl(j) = t_soisno(c,j)
this%fates(nc)%bc_in(s)%h2o_liqvol_sl(j) = h2osoi_liqvol(c,j)
this%fates(nc)%bc_in(s)%eff_porosity_sl(j) = eff_porosity(c,j)
this%fates(nc)%bc_in(s)%watsat_sl(j) = watsat(c,j)
end do

else
this%fates(nc)%bc_in(s)%filter_btran = .false.
this%fates(nc)%bc_in(s)%tempk_sl(:) = -999._r8
this%fates(nc)%bc_in(s)%h2o_liqvol_sl(:) = -999._r8
this%fates(nc)%bc_in(s)%eff_porosity_sl(:) = -999._r8
this%fates(nc)%bc_in(s)%watsat_sl(:) = -999._r8
end if

end do

! Update the interface variables that work on the model time step now
call this%fates(nc)%UpdateInterfaceVariablesTimeStep()

! -------------------------------------------------------------------------------
! This function evaluates the ground layer to determine if
! root water uptake can happen, and soil suction should even
Expand Down Expand Up @@ -3141,13 +3132,8 @@ subroutine wrap_update_hifrq_hist(this, bounds_clump )
nc = bounds_clump%clump_index
dtime = real(get_step_size(),r8)

! Summarize Net Fluxes
do s = 1, this%fates(nc)%nsites
c = this%f2hmap(nc)%fcolumn(s)
this%fates(nc)%bc_in(s)%tot_het_resp = hr(c)
this%fates(nc)%bc_in(s)%tot_somc = totsomc(c)
this%fates(nc)%bc_in(s)%tot_litc = totlitc(c)
end do
! Update model timestep interface variables
call this%fates(nc)%UpdateInterfaceVariablesTimeStep()

! Update history variables that track these variables
call fates_hist%update_history_hifrq(nc, &
Expand Down Expand Up @@ -4053,6 +4039,8 @@ subroutine RegisterInterfaceVariablesInit(this, nc)

! Register and initialize the boundary condition variables
! Global variables
call this%fates(nc)%registry(r)%Register(key=hlm_fates_nlevground, &
data=nlevgrnd, hlm_flag=.true.)
call this%fates(nc)%registry(r)%Register(key=hlm_fates_decomp, &
data=nlevdecomp, hlm_flag=.true.)
call this%fates(nc)%registry(r)%Register(key=hlm_fates_decomp_max, &
Expand All @@ -4071,6 +4059,9 @@ subroutine RegisterInterfaceVariablesInit(this, nc)
end if

! Variables that do not need to accumulate
call this%fates(nc)%registry(r)%Register(key=hlm_fates_heterotrophic_respiration, &
data=col_cf%hr(c), hlm_flag=.true., &
subgrid_type=registry_var_intid_column)
call this%fates(nc)%registry(r)%Register(key=hlm_fates_soil_level, &
data=col_pp%nlevbed(c), hlm_flag=.true., &
subgrid_type=registry_var_intid_column)
Expand All @@ -4080,6 +4071,9 @@ subroutine RegisterInterfaceVariablesInit(this, nc)
call this%fates(nc)%registry(r)%Register(key=hlm_fates_decomp_frac_temperature, &
data=col_cf%t_scalar(c,:), hlm_flag=.true., &
subgrid_type=registry_var_intid_column)
call this%fates(nc)%registry(r)%Register(key=hlm_fates_snow_depth, &
data=col_ws%snow_depth(c), hlm_flag=.true., &
subgrid_type=registry_var_intid_column)

! Variables that need to accumulate
call this%fates(nc)%registry(r)%Register(key=hlm_fates_litter_carbon_cellulose, &
Expand Down Expand Up @@ -4144,18 +4138,19 @@ subroutine RegisterInterfaceVariablesInit(this, nc)
subgrid_type=registry_var_intid_column)
end if
end do

end subroutine RegisterInterfaceVariablesInit

! ======================================================================================

subroutine RegisterInterfaceVariablesColdStart(this, nc, canopystate_inst)
subroutine RegisterInterfaceVariablesColdStart(this, nc, canopystate_inst, soilstate_inst)

use FatesInterfaceParametersMod, only : hlm_fates_thaw_max_depth_index
use FatesInterfaceParametersMod

class(hlm_fates_interface_type), intent(inout) :: this
integer, intent(in) :: nc
type(canopystate_type), intent(inout) :: canopystate_inst
type(soilstate_type), intent(inout) :: soilstate_inst

! Locals
integer :: r ! register index
Expand All @@ -4168,7 +4163,18 @@ subroutine RegisterInterfaceVariablesColdStart(this, nc, canopystate_inst)
c = this%fates(nc)%registry(r)%GetColumnIndex()

call this%fates(nc)%registry(r)%Register(key=hlm_fates_thaw_max_depth_index, &
data=canopystate_inst%altmax_lastyear_indx_col(c), hlm_flag=.true.)
data=canopystate_inst%altmax_lastyear_indx_col(c), &
hlm_flag=.true., &
subgrid_type=registry_var_intid_column)
call this%fates(nc)%registry(r)%Register(key=hlm_fates_effective_porosity, &
data=soilstate_inst%eff_porosity_col(c,:), &
hlm_flag=.true., &
subgrid_type=registry_var_intid_column)
call this%fates(nc)%registry(r)%Register(key=hlm_fates_soil_water_saturation, &
data=soilstate_inst%watsat_col(c,:), &
hlm_flag=.true., &
subgrid_type=registry_var_intid_column)

end do

end subroutine RegisterInterfaceVariablesColdStart
Expand Down