Skip to content

Commit

Permalink
Merge tag 'sci.1.80.6_api.37.0.0' into grazing_merge
Browse files Browse the repository at this point in the history
Bug fix for issue #1301

Corrects when the fraction of burnt fuel is zero'd and how the litter
mass is updated based on that fraction.
  • Loading branch information
glemieux committed Jan 13, 2025
2 parents ac5bf38 + 1689466 commit b3113b7
Show file tree
Hide file tree
Showing 90 changed files with 8,782 additions and 3,128 deletions.
13 changes: 13 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This is a git submodule file to include additional submodules when FATES is checkout out.
#
# It includes optional additional support for
# git-fleximod (https://github.com/ESMCI/git-fleximod)
# that will be used when git-fleximod is used to check it out (i.e. for CESM)
#
[submodule "tools/landusedata"]
path = tools/landusedata
url = https://github.com/NGEET/tools-fates-landusedata
fxtag = v0.1.1
fxrequired = AlwaysRequired
# Standard Fork to compare to with "git fleximod test" to ensure personal forks aren't committed
fxDONOTUSEurl = https://github.com/NGEET/tools-fates-landusedata
27 changes: 16 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.4)

list(APPEND CMAKE_MODULE_PATH ${CIME_CMAKE_MODULE_DIRECTORY})
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../share/cmake")

FIND_PATH(NETCDFC_FOUND libnetcdf.a ${NETCDF_C_DIR}/lib)
FIND_PATH(NETCDFF_FOUND libnetcdff.a ${NETCDF_FORTRAN_DIR}/lib)
Expand Down Expand Up @@ -29,7 +30,10 @@ add_subdirectory(${HLM_ROOT}/src/fates/biogeophys fates_biogeophys)
add_subdirectory(${HLM_ROOT}/src/fates/parteh fates_parteh)
add_subdirectory(${HLM_ROOT}/src/fates/fire fates_fire)
add_subdirectory(${HLM_ROOT}/src/fates/radiation fates_radiation)

# Testing directories
add_subdirectory(${HLM_ROOT}/src/fates/testing/testing_shr test_share)
add_subdirectory(${HLM_ROOT}/src/fates/testing/functional_testing/fire/shr fire_share)

# Remove shr_mpi_mod from share_sources.
# This is needed because we want to use the mock shr_mpi_mod in place of the real one
Expand All @@ -45,23 +49,21 @@ foreach (sourcefile ${share_sources})
endforeach()

# Remove shr_cal_mod from share_sources.
#
# shr_cal_mod depends on ESMF (or the lightweight esmf wrf timemgr, at
# least). Since CTSM doesn't currently use shr_cal_mod, we're avoiding
# the extra overhead of including esmf_wrf_timemgr sources in this
# build.
#
# TODO: like above, this should be moved into a general-purpose function
# in Sourcelist_utils. Then this block of code could be replaced with a
# single call, like: remove_source_file(${share_sources}
# "shr_cal_mod.F90")
foreach (sourcefile ${share_sources})
string(REGEX MATCH "shr_cal_mod.F90" match_found ${sourcefile})
if(match_found)
list(REMOVE_ITEM share_sources ${sourcefile})
endif()
endforeach()

# Remove shr_pio_mod from share_sources.
foreach (sourcefile ${share_sources})
string(REGEX MATCH "shr_pio_mod.F90" match_found ${sourcefile})
if(match_found)
list(REMOVE_ITEM share_sources ${sourcefile})
endif()
endforeach()

# Build libraries containing stuff needed for the unit tests.
# Eventually, these add_library calls should probably be distributed into the correct location, rather than being in this top-level CMakeLists.txt file.
add_library(csm_share ${share_sources})
Expand All @@ -81,10 +83,13 @@ include_directories(${NETCDF_C_DIR}/include
${NETCDF_FORTRAN_DIR}/include)
link_directories(${NETCDF_C_DIR}/lib
${NETCDF_FORTRAN_DIR}/lib)


# Tell cmake to look for libraries & mod files here, because this is where we built libraries
include_directories(${CMAKE_CURRENT_BINARY_DIR})
link_directories(${CMAKE_CURRENT_BINARY_DIR})

# Directories and libraries to include in the link step
link_directories(${CMAKE_CURRENT_BINARY_DIR})

# Add the main test directory
add_subdirectory(${HLM_ROOT}/src/fates/testing)
256 changes: 137 additions & 119 deletions biogeochem/EDCanopyStructureMod.F90

Large diffs are not rendered by default.

35 changes: 20 additions & 15 deletions biogeochem/EDCohortDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Module EDCohortDynamicsMod
use PRTGenericMod , only : max_nleafage
use FatesConstantsMod , only : ican_upper
use EDTypesMod , only : site_fluxdiags_type
use EDTypesMod , only : elem_diag_type
use PRTGenericMod , only : num_elements
use FatesConstantsMod , only : leaves_on
use FatesConstantsMod , only : leaves_off
Expand Down Expand Up @@ -602,7 +603,7 @@ subroutine SendCohortToLitter(csite,cpatch,ccohort,nplant,bc_in)
type(bc_in_type), intent(in) :: bc_in

type(litter_type), pointer :: litt ! Litter object for each element
type(site_fluxdiags_type),pointer :: flux_diags
type(elem_diag_type),pointer :: elflux_diags

real(r8) :: leaf_m ! leaf mass [kg]
real(r8) :: store_m ! storage mass [kg]
Expand Down Expand Up @@ -646,7 +647,7 @@ subroutine SendCohortToLitter(csite,cpatch,ccohort,nplant,bc_in)
endif

litt => cpatch%litter(el)
flux_diags => csite%flux_diags(el)
elflux_diags => csite%flux_diags%elem(el)

!adjust how wood is partitioned between the cwd classes based on cohort dbh
call adjust_SF_CWD_frac(ccohort%dbh,ncwd,SF_val_CWD_frac,SF_val_CWD_frac_adj)
Expand All @@ -667,12 +668,12 @@ subroutine SendCohortToLitter(csite,cpatch,ccohort,nplant,bc_in)
enddo

! above ground
flux_diags%cwd_ag_input(c) = flux_diags%cwd_ag_input(c) + &
elflux_diags%cwd_ag_input(c) = elflux_diags%cwd_ag_input(c) + &
(struct_m+sapw_m) * SF_val_CWD_frac_adj(c) * &
prt_params%allom_agb_frac(pft) * nplant

! below ground
flux_diags%cwd_bg_input(c) = flux_diags%cwd_bg_input(c) + &
elflux_diags%cwd_bg_input(c) = elflux_diags%cwd_bg_input(c) + &
(struct_m + sapw_m) * SF_val_CWD_frac_adj(c) * &
(1.0_r8 - prt_params%allom_agb_frac(pft)) * nplant

Expand All @@ -692,11 +693,11 @@ subroutine SendCohortToLitter(csite,cpatch,ccohort,nplant,bc_in)

end do

flux_diags%leaf_litter_input(pft) = &
flux_diags%leaf_litter_input(pft) + &
elflux_diags%surf_fine_litter_input(pft) = &
elflux_diags%surf_fine_litter_input(pft) + &
(leaf_m+repro_m) * nplant
flux_diags%root_litter_input(pft) = &
flux_diags%root_litter_input(pft) + &
elflux_diags%root_litter_input(pft) = &
elflux_diags%root_litter_input(pft) + &
(fnrt_m+store_m) * nplant


Expand Down Expand Up @@ -1066,20 +1067,24 @@ subroutine fuse_cohorts(currentSite, currentPatch, bc_in)
nextc%n*nextc%gpp_acc)/newn
currentCohort%npp_acc = (currentCohort%n*currentCohort%npp_acc + &
nextc%n*nextc%npp_acc)/newn
currentCohort%resp_acc = (currentCohort%n*currentCohort%resp_acc + &
nextc%n*nextc%resp_acc)/newn
currentCohort%resp_acc_hold = &
(currentCohort%n*currentCohort%resp_acc_hold + &
nextc%n*nextc%resp_acc_hold)/newn
currentCohort%resp_m_acc = (currentCohort%n*currentCohort%resp_m_acc + &
nextc%n*nextc%resp_m_acc)/newn
currentCohort%resp_m_acc_hold = &
(currentCohort%n*currentCohort%resp_m_acc_hold + &
nextc%n*nextc%resp_m_acc_hold)/newn
currentCohort%resp_g_acc_hold = &
(currentCohort%n*currentCohort%resp_g_acc_hold + &
nextc%n*nextc%resp_g_acc_hold)/newn
currentCohort%npp_acc_hold = &
(currentCohort%n*currentCohort%npp_acc_hold + &
nextc%n*nextc%npp_acc_hold)/newn
currentCohort%gpp_acc_hold = &
(currentCohort%n*currentCohort%gpp_acc_hold + &
nextc%n*nextc%gpp_acc_hold)/newn

currentCohort%resp_excess = (currentCohort%n*currentCohort%resp_excess + &
nextc%n*nextc%resp_excess)/newn
currentCohort%resp_excess_hold = &
(currentCohort%n*currentCohort%resp_excess_hold + &
nextc%n*nextc%resp_excess_hold)/newn

currentCohort%dmort = (currentCohort%n*currentCohort%dmort + &
nextc%n*nextc%dmort)/newn
Expand Down
Loading

0 comments on commit b3113b7

Please sign in to comment.