diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdClm60Cam7LndTuningMode/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdClm60Cam7LndTuningMode/user_nl_clm new file mode 100644 index 0000000000..03acbe5eb4 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdClm60Cam7LndTuningMode/user_nl_clm @@ -0,0 +1 @@ +force_send_to_atm = .true. \ No newline at end of file diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdClm60Cam7LndTuningMode/user_nl_cpl b/cime_config/testdefs/testmods_dirs/clm/FatesColdClm60Cam7LndTuningMode/user_nl_cpl new file mode 100644 index 0000000000..d51fce2d1c --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdClm60Cam7LndTuningMode/user_nl_cpl @@ -0,0 +1 @@ +flds_co2b = .true. \ No newline at end of file diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index 9528e1f02f..a391fe1010 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -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, & diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 22db3d76b5..b217f26389 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -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 @@ -2904,6 +2905,53 @@ 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 + 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 ! ======================================================================================