Skip to content

Commit

Permalink
Merge tag 'sci.1.81.1_api.37.1.0' into parameter-switch-migration
Browse files Browse the repository at this point in the history
An alternative method of conserving patch area for two-stream radiation.
  • Loading branch information
glemieux committed Feb 20, 2025
2 parents 9cb1611 + 655d784 commit 2a6b33e
Show file tree
Hide file tree
Showing 86 changed files with 6,802 additions and 1,365 deletions.
71 changes: 71 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Bug Report
description: Issues related to the model crashing or the other unexpected behavior
# title: "[Bug]: "
# labels: ["bug - science"]
# projects: ["octo-org/1", "octo-org/44"]
# assignees:
# - octocat
body:
- type: markdown
attributes:
value: "Please describe the issue below"
- type: textarea
id: description
attributes:
label: Describe the issue
description: Provide detail on the expected behavior and observed behavior. Attached screen shots and plots as necessary.
validations:
required: true
- type: textarea
id: logs
attributes:
label: Relevant log output
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
render: shell
- type: input
id: fates-tag
attributes:
label: FATES tag
description: The output from running `git describe` in the fates directory
placeholder: e.g. sci.1.80.11_api.37.0.0
validations:
required: true
- type: input
id: hlm-tag
attributes:
label: Host land model tag
description: The output from running `git describe` in the host land model directory
placeholder: e.g. ctsm5.3.022
validations:
required: true
- type: dropdown
id: machine
attributes:
label: Machine
options:
- perlmutter
- derecho
- izumi
- other HLM supported machine
- personal computer
validations:
required: true
- type: input
id: other-machine
attributes:
label: Other supported machine name
placeholder: e.g. frontier
- type: textarea
id: context
attributes:
label: Additional context
description: Please provide any additional context that you think is relevant such as your personal computer environment if applicable.
placeholder: e.g. Ubuntu 22.04
# - type: checkboxes
# id: terms
# attributes:
# label: Code of Conduct
# description: By submitting this issue, you agree to follow our [Code of Conduct](https://example.com).
# options:
# - label: I agree to follow this project's Code of Conduct
# required: true
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/feature.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Feature request
description: Suggest a new feature or update to an existing feature
labels: ["enhancement"]
body:
- type: markdown
attributes:
value: "Please describe your feature suggestion below. Also consider opening a [discussion board thread](https://github.com/NGEET/fates/discussions/categories/ideas) for broader ideas."
- type: textarea
id: description
attributes:
label: Describe the changes
description: A clear and concise description of what you want to happen
validations:
required: true
- type: textarea
id: problem
attributes:
label: Is your request related to a problem?
description: A short description of the impetus for the request, if any.
placeholder: e.g. This parameter should be indexed by pft, not globally [...]
- type: textarea
id: alternatives
attributes:
label: Alternative options
description: Describe alternatives to be considered as necessary
- type: textarea
id: context
attributes:
label: Additional context
description: Provide additional context including attachements or references, as necessary
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Task
description: General issue that describes a specific task to be completed.
body:
- type: markdown
attributes:
value: "Describe the task below."
- type: textarea
id: description
attributes:
label: Task description
description: Provide detail about the necessary task with sub-steps if applicable.
placeholder: e.g. update the refactor the patch fusion subroutine
validations:
required: true
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)
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ We aim to create an open development environment for FATES where scientists can
* Document the version of the code used in any publication, preferably by using a release tag (existing or newly created) if possible, or a commit hash if not.
* Do not use code from anywhere other than the central FATES development repository (the “master” branch of the “NGEET/fates“ github repository) without discussing with the author(s) of the modified code your intentions for using the code and receiving their permission to do so.
* When using model features that have recently been integrated into the central FATES development repository, be mindful of the contributions of others and, where the novel features qualitatively affect the results of a given simulation, involve the author(s) of these features in any resulting manuscripts. Be particularly aware of the concerns of early career researchers, and ensure they have sufficient opportunities to lead publications using their developments.
* When discussing results arising from older model features that have been described in the literature, accurately cite the publications describing those features or releases. A list of some relevant publications can be found at [https://github.com/NGEET/fates/wiki/Relevant-References][wiki_ref_page]
* When discussing results arising from older model features that have been described in the literature, accurately cite the publications describing those features or releases. A list of some relevant publications can be found in the [users guide](https://fates-users-guide.readthedocs.io/en/latest/user/Reference-List.html).

## Our Responsibilities

Expand Down
1 change: 1 addition & 0 deletions biogeochem/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ list(APPEND fates_sources
FatesCohortMod.F90
FatesAllometryMod.F90
DamageMainMod.F90
EDCohortDynamicsMod.F90
FatesPatchMod.F90)

sourcelist_to_parent(fates_sources)
52 changes: 25 additions & 27 deletions biogeochem/EDCanopyStructureMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ module EDCanopyStructureMod
use FatesAllometryMod , only : carea_allom
use EDCohortDynamicsMod , only : terminate_cohorts, terminate_cohort, fuse_cohorts
use EDCohortDynamicsMod , only : InitPRTObject
use FatesAllometryMod , only : tree_lai
use FatesAllometryMod , only : tree_sai
use FatesAllometryMod , only : tree_lai_sai
use EDTypesMod , only : ed_site_type
use EDTypesMod , only : set_patchno
use FatesAllometryMod , only : VegAreaLayer
use FatesAllometryMod , only : CrownDepth
use FatesPatchMod, only : fates_patch_type
Expand Down Expand Up @@ -1313,8 +1313,6 @@ subroutine canopy_summarization( nsites, sites, bc_in )
! ---------------------------------------------------------------------------------

use FatesInterfaceTypesMod , only : hlm_use_cohort_age_tracking
use FatesInterfaceTypesMod , only : hlm_radiation_model
use EDPatchDynamicsMod , only : set_patchno
use FatesSizeAgeTypeIndicesMod, only : sizetype_class_index
use FatesSizeAgeTypeIndicesMod, only : coagetype_class_index
use EDtypesMod , only : area
Expand Down Expand Up @@ -1351,7 +1349,7 @@ subroutine canopy_summarization( nsites, sites, bc_in )
! driving model. Loops through all patches and sets cpatch%patchno to the integer
! order of oldest to youngest where the oldest is 1.
! --------------------------------------------------------------------------------
call set_patchno( sites(s) )
call set_patchno( sites(s) , .false., 0)

currentPatch => sites(s)%oldest_patch

Expand Down Expand Up @@ -1897,7 +1895,6 @@ subroutine update_hlm_dynamics(nsites,sites,fcolumn,bc_out)

do s = 1,nsites

ifp = 0
total_patch_area = 0._r8
total_canopy_area = 0._r8
bc_out(s)%canopy_fraction_pa(:) = 0._r8
Expand All @@ -1909,9 +1906,8 @@ subroutine update_hlm_dynamics(nsites,sites,fcolumn,bc_out)
c = fcolumn(s)
do while(associated(currentPatch))

if(currentPatch%nocomp_pft_label.ne.nocomp_bareground)then ! ignore the bare-ground-PFT patch entirely for these BC outs

ifp = ifp+1
ifp = currentPatch%patchno
if_bare: if(currentPatch%nocomp_pft_label.ne.nocomp_bareground)then ! ignore the bare-ground-PFT patch entirely for these BC outs

if ( currentPatch%total_canopy_area-currentPatch%area > 0.000001_r8 ) then
if(debug)then
Expand Down Expand Up @@ -2029,7 +2025,7 @@ subroutine update_hlm_dynamics(nsites,sites,fcolumn,bc_out)

total_patch_area = total_patch_area + currentPatch%area/AREA

end if
end if if_bare
currentPatch => currentPatch%younger
end do

Expand All @@ -2049,13 +2045,11 @@ subroutine update_hlm_dynamics(nsites,sites,fcolumn,bc_out)
end if

currentPatch => sites(s)%oldest_patch
ifp = 0
do while(associated(currentPatch))
ifp = currentPatch%patchno
if(currentPatch%nocomp_pft_label.ne.nocomp_bareground)then ! for vegetated patches only
ifp = ifp+1
bc_out(s)%canopy_fraction_pa(ifp) = bc_out(s)%canopy_fraction_pa(ifp)/total_patch_area
endif ! veg patch

currentPatch => currentPatch%younger
end do

Expand Down Expand Up @@ -2245,7 +2239,7 @@ subroutine UpdateCohortLAI(currentCohort, canopy_layer_tlai, total_canopy_area)
! Update LAI and related variables for a given cohort

! Uses
use EDParamsMod, only : dlower_vai
use EDParamsMod, only : dlower_vai, dinc_vai

! Arguments
type(fates_cohort_type),intent(inout), target :: currentCohort
Expand All @@ -2254,26 +2248,30 @@ subroutine UpdateCohortLAI(currentCohort, canopy_layer_tlai, total_canopy_area)

! Local variables
real(r8) :: leaf_c ! leaf carbon [kg]

real(r8) :: treesai ! stem area index within crown m2/m2

! Obtain the leaf carbon
leaf_c = currentCohort%prt%GetState(leaf_organ,carbon12_element)


! Note that tree_lai has an internal check on the canopy locatoin
currentCohort%treelai = tree_lai(leaf_c, currentCohort%pft, currentCohort%c_area, &
currentCohort%n, currentCohort%canopy_layer, &
canopy_layer_tlai,currentCohort%vcmax25top )

! Note that tree_lai has an internal check on the canopy location
call tree_lai_sai(leaf_c, currentCohort%pft, currentCohort%c_area, currentCohort%n, &
currentCohort%canopy_layer, canopy_layer_tlai, currentCohort%vcmax25top, currentCohort%dbh, currentCohort%crowndamage, &
currentCohort%canopy_trim, currentCohort%efstem_coh, 4, currentCohort%treelai, treesai )

! Do not update stem area index of SP vegetation
if (hlm_use_sp .eq. ifalse) then
currentCohort%treesai = tree_sai(currentCohort%pft, currentCohort%dbh, currentCohort%crowndamage, &
currentCohort%canopy_trim, currentCohort%efstem_coh, &
currentCohort%c_area, currentCohort%n, currentCohort%canopy_layer, &
canopy_layer_tlai, currentCohort%treelai , &
currentCohort%vcmax25top,4)
currentCohort%treesai = treesai
end if

! Number of actual vegetation layers in this cohort's crown
currentCohort%nv = count((currentCohort%treelai+currentCohort%treesai) .gt. dlower_vai(:)) + 1

if( currentCohort%nv .ne. minloc(dlower_vai, DIM=1, MASK=(dlower_vai>(currentCohort%treelai+currentCohort%treesai))) ) then
write(fates_log(),*) 'We use two methods of finding maximum leaf layers, and they are not equivalent'
write(fates_log(),*) 'count method:',currentCohort%nv
write(fates_log(),*) 'minloc method:',minloc(dlower_vai, DIM=1, MASK=(dlower_vai>(currentCohort%treelai+currentCohort%treesai)))
call endrun(msg=errMsg(sourcefile, __LINE__))
end if

end subroutine UpdateCohortLAI

Expand Down
Loading

0 comments on commit 2a6b33e

Please sign in to comment.