Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
[submodule "fates"]
path = src/fates
url = https://github.com/NorESMhub/fates
fxtag = sci.1.85.1_api.40.0.0_noresm_v0
fxtag = sci.1.85.1_api.40.0.0_noresm_v2
fxrequired = AlwaysRequired
# Standard Fork to compare to with "git fleximod test" to ensure personal forks aren't committed
fxDONOTUSEurl = https://github.com/NorESMhub/fates
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
force_send_to_atm = .true.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flds_co2b = .true.
9 changes: 6 additions & 3 deletions src/biogeochem/CNDriverMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -902,13 +902,16 @@ subroutine CNDriverNoLeaching(bounds,
if (use_c13) call c13_products_inst%ComputeProductSummaryVars(bounds)
if (use_c14) call c14_products_inst%ComputeProductSummaryVars(bounds)
call n_products_inst%ComputeProductSummaryVars(bounds)



call c_products_inst%ComputeSummaryVars(bounds)
if (use_c13) call c13_products_inst%ComputeSummaryVars(bounds)
if (use_c14) call c14_products_inst%ComputeSummaryVars(bounds)
call n_products_inst%ComputeSummaryVars(bounds)


if(use_fates_bgc)then
soilbiogeochem_carbonflux_inst%fates_product_loss_grc(bounds%begg:bounds%endg)=c_products_inst%product_loss_grc(bounds%begg:bounds%endg)
endif

call t_stopf('CNWoodProducts')

!--------------------------------------------
Expand Down
16 changes: 15 additions & 1 deletion src/main/clm_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,21 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro
! don't have explicit bounds on the left-hand-side of this assignment: excluding these
! explicit bounds seemed to be needed to get around other compiler bugs.
allocate(net_carbon_exchange_grc(bounds_proc%begg:bounds_proc%endg))
net_carbon_exchange_grc = bgc_vegetation_inst%get_net_carbon_exchange_grc(bounds_proc)
if (.not. use_fates) then
net_carbon_exchange_grc = bgc_vegetation_inst%get_net_carbon_exchange_grc(bounds_proc)
else
net_carbon_exchange_grc(bounds_proc%begg:bounds_proc%endg) = 0.0_r8
if (use_fates_bgc) then
!$OMP PARALLEL DO PRIVATE (nc, bounds_clump)
do nc = 1,nclumps
call get_clump_bounds(nc, bounds_clump)
call clm_fates%wrap_co2_to_atm(bounds_clump, &
filter_inactive_and_active(nc)%num_bgc_soilc, filter_inactive_and_active(nc)%bgc_soilc, &
soilbiogeochem_carbonflux_inst, net_carbon_exchange_grc(bounds_clump%begg:bounds_clump%endg))
end do
!$OMP END PARALLEL DO
endif
endif

call lnd2atm(bounds_proc, &
atm2lnd_inst, surfalb_inst, temperature_inst, frictionvel_inst, &
Expand Down
16 changes: 13 additions & 3 deletions src/soilbiogeochem/SoilBiogeochemCarbonFluxType.F90
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module SoilBiogeochemCarbonFluxType
use clm_varpar , only : ndecomp_cascade_transitions, ndecomp_pools, ndecomp_cascade_outtransitions
use clm_varpar , only : nlevdecomp_full, nlevgrnd, nlevdecomp, nlevsoi, ndecomp_pools_vr, i_cwdl2
use clm_varcon , only : spval, ispval, dzsoi_decomp
use clm_varctl , only : use_fates,use_cn
use clm_varctl , only : use_fates,use_fates_bgc,use_cn
use pftconMod , only : pftcon
use landunit_varcon , only : istsoil, istcrop, istdlak
use ch4varcon , only : allowlakeprod
Expand Down Expand Up @@ -61,7 +61,9 @@ module SoilBiogeochemCarbonFluxType
real(r8), pointer :: soilc_change_col (:) ! (gC/m2/s) FUN used soil C
real(r8), pointer :: fates_litter_flux (:) ! (gC/m2/s) A summary of the total litter
! flux passed in from FATES.
! This is a diagnostic for balance checks only
! This is a diagnostic for balance checks only
real(r8), pointer :: fates_product_loss_grc (:) ! (gC/m2/s) product loss flux at gridcell scale to be used with FATES is on

! track tradiagonal matrix
real(r8), pointer :: matrix_decomp_fire_k_col (:,:) ! decomposition rate due to fire (gC*m3)/(gC*m3*step))
real(r8), pointer :: tri_ma_vr (:,:) ! vertical C transfer rate in sparse matrix format (gC*m3)/(gC*m3*step))
Expand Down Expand Up @@ -121,11 +123,13 @@ subroutine InitAllocate(this, bounds)
! !LOCAL VARIABLES:
integer :: begp,endp ! Begin and end patch
integer :: begc,endc ! Begin and end column
integer :: begg, endg ! Begin and end gridcell
integer :: Ntrans,Ntrans_diag ! N trans size for matrix solution
!------------------------------------------------------------------------

begp = bounds%begp; endp = bounds%endp
begc = bounds%begc; endc = bounds%endc
begg = bounds%begg; endg = bounds%endg

allocate(this%t_scalar_col (begc:endc,1:nlevdecomp_full)); this%t_scalar_col (:,:) =spval
allocate(this%w_scalar_col (begc:endc,1:nlevdecomp_full)); this%w_scalar_col (:,:) =spval
Expand All @@ -136,7 +140,7 @@ subroutine InitAllocate(this, bounds)
allocate(this%somc_fire_col (begc:endc)) ; this%somc_fire_col (:) =nan
allocate(this%hr_vr_col (begc:endc,1:nlevdecomp_full)); this%hr_vr_col (:,:) =nan

allocate(this%decomp_cpools_sourcesink_col(begc:endc,1:nlevdecomp_full,1:ndecomp_pools))
allocate(this%decomp_cpools_sourcesink_col(begc:endc,1:nlevdecomp_full,1:ndecomp_pools))
this%decomp_cpools_sourcesink_col(:,:,:)= nan

allocate(this%c_overflow_vr(begc:endc,1:nlevdecomp_full,1:ndecomp_cascade_transitions))
Expand Down Expand Up @@ -180,6 +184,7 @@ subroutine InitAllocate(this, bounds)
allocate(this%soilc_change_col (begc:endc)) ; this%soilc_change_col (:) = nan

if(use_fates)then
allocate(this%fates_product_loss_grc(begg:endg)) ; this%fates_product_loss_grc(:) = nan
allocate(this%fates_litter_flux(begc:endc)); this%fates_litter_flux(:) = nan
else
allocate(this%fates_litter_flux(0:0)); this%fates_litter_flux(:) = nan
Expand Down Expand Up @@ -682,6 +687,10 @@ subroutine InitCold(this, bounds)
call this%SetValues (num_column=num_special_col, filter_column=special_col, &
value_column=0._r8)

if(use_fates_bgc)then
this%fates_product_loss_grc(bounds%begg:bounds%endg) = 0._r8
endif

end subroutine InitCold

!-----------------------------------------------------------------------
Expand Down Expand Up @@ -796,6 +805,7 @@ subroutine SetValues ( this, num_column, filter_column, value_column)
this%michr_col(i) = value_column
this%soilc_change_col(i) = value_column
end do


end subroutine SetValues

Expand Down
53 changes: 53 additions & 0 deletions src/utils/clmfates_interfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ module CLMFatesInterfaceMod
procedure, public :: wrap_hydraulics_drive
procedure, public :: WrapUpdateFatesRmean
procedure, public :: wrap_WoodProducts
procedure, public :: wrap_co2_to_atm
procedure, public :: WrapGlobalSeedDispersal
procedure, public :: WrapUpdateFatesSeedInOut
procedure, public :: UpdateCLitterFluxes
Expand Down Expand Up @@ -2904,6 +2905,58 @@ subroutine wrap_WoodProducts(this, bounds_clump, num_soilc, filter_soilc, &

return
end subroutine wrap_WoodProducts

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

subroutine wrap_co2_to_atm(this, bounds_clump, num_soilc, filter_soilc, &
soilbiogeochem_carbonflux_inst, net_carbon_exchange_grc )

! USES
use subgridAveMod, only : c2g
use FatesConstantsMod, only: g_per_kg
! !ARGUMENTS:
class(hlm_fates_interface_type) , intent(inout) :: this
type(bounds_type) , intent(in) :: bounds_clump
integer , intent(in) :: num_soilc ! size of column filter
integer , intent(in) :: filter_soilc(:) ! column filter
type(soilbiogeochem_carbonflux_type), intent(in) :: soilbiogeochem_carbonflux_inst
real(r8) , intent(inout) :: net_carbon_exchange_grc(bounds_clump%begg:bounds_clump%endg)

! Locals
integer :: s,c,g,fc
integer :: ci ! Clump index
real(r8) :: net_carbon_exchange_col(bounds_clump%begc:bounds_clump%endc)

net_carbon_exchange_col(bounds_clump%begc:bounds_clump%endc) = 0.0_r8
net_carbon_exchange_grc(bounds_clump%begg:bounds_clump%endg) = 0.0_r8
ci = bounds_clump%clump_index

! Loop over columns
do fc = 1, num_soilc

c = filter_soilc(fc)
s = this%f2hmap(ci)%hsites(c)
! nbp = npp -fire - graz - soil respiratation
! hr_col is updated above this call in CNDriver summaries
net_carbon_exchange_col(c) = this%fates(ci)%bc_out(s)%npp_site - &
(this%fates(ci)%bc_out(s)%grazing_closs_to_atm_si + &
this%fates(ci)%bc_out(s)%fire_closs_to_atm_si) * g_per_kg - &
soilbiogeochem_carbonflux_inst%hr_col(c)
end do
call c2g( bounds = bounds_clump, &
carr = net_carbon_exchange_col(bounds_clump%begc:bounds_clump%endc), &
garr = net_carbon_exchange_grc(bounds_clump%begg:bounds_clump%endg), &
c2l_scale_type = 'unity', &
l2g_scale_type = 'unity')
! change sign, same way it is done in get_net_carbon_exchange

do g = bounds_clump%begg,bounds_clump%endg
net_carbon_exchange_grc(g) = net_carbon_exchange_grc(g) - soilbiogeochem_carbonflux_inst%fates_product_loss_grc(g)
enddo

net_carbon_exchange_grc(bounds_clump%begg:bounds_clump%endg) = - net_carbon_exchange_grc(bounds_clump%begg:bounds_clump%endg)

end subroutine wrap_co2_to_atm

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

Expand Down