Skip to content

fix(hydraulics): fix SumBetweenDepths layer integration logic and add pFUnit test - #1

Closed
johnpaulalex wants to merge 1 commit into
test/hydr-plant+hydr-basefrom
fix/sum-btwn-depths+hydr-plant
Closed

fix(hydraulics): fix SumBetweenDepths layer integration logic and add pFUnit test#1
johnpaulalex wants to merge 1 commit into
test/hydr-plant+hydr-basefrom
fix/sum-btwn-depths+hydr-plant

Conversation

@johnpaulalex

@johnpaulalex johnpaulalex commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Description of changes

Fixes partial-layer depth integration calculations in SumBetweenDepths within biogeophys/FatesPlantHydraulicsMod.F90. Specifically:

  1. Single-layer integration fix: Handles cases where both the top depth (depth_t) and bottom depth (depth_b) fall within the exact same soil rhizosphere layer (i_rhiz_t - 1 == i_rhiz_b + 1). Previously, partial layer fractions were miscalculated or double-counted across layer boundaries.
  2. Layer 0 boundary fix: Adds explicit boundary handling for i_rhiz_b == 0 when integrating from the surface down through the top layer (frac = depth_b / dz_rhiz(1)).
  3. pFUnit Test Suite: Exposes SumBetweenDepths for unit testing and adds comprehensive test coverage (test_SumBetweenDepths in FatesPlantHydraulicsMod_geom_test.pf) verifying integration density across non-uniform soil layer interfaces, partial overlaps, and out-of-bound depth limits.

Specific notes

Contributors other than yourself, if any:

Linked issues addressed, if any:

Description of generative AI usage:

  • Google Antigravity was used to write the code and tests, followed by human-guided verification.

Answer Changes & Scientific Impact

  • Expected Answer Changes (ECA)
    • Details: Answers change for simulations with active plant hydraulics when depth integration intervals fall within a single soil layer or at the topmost layer boundary (i_rhiz_b == 0). Simulations without plant hydraulics remain Bit-for-Bit (B4B).

User Interface & Namelist Changes

  • Namelist / Defaults modified? No.
  • XML / Build script changes? Updated testing/CMakeLists.txt and testing/config/unit.cfg to register fates_plant_hydraulics_test.

Testing planned or performed, if any:

  • Executed pFUnit unit tests for FatesPlantHydraulicsMod:
    • FatesPlantHydraulicsMod_cohort_test
    • FatesPlantHydraulicsMod_drive_test
    • FatesPlantHydraulicsMod_geom_test
    • FatesPlantHydraulicsMod_sizedep_test
  • Verified clean compilation on gfortran/Intel compilers.

FATES baseline hash-tag: 5efa6fbf
PR branch hash-tag: de7afd15

Requirements before merge:

  • The code in this PR branch builds with no errors.
  • The code in this PR branch runs with no errors.
  • In-code documentation and Fortran docstrings updated.
  • This PR either (a) does not create a need to update documentation or (b) includes required documentation updates. Which?: (a) Bug fix and unit test addition; no user guide or tech note changes required.

@johnpaulalex
johnpaulalex changed the base branch from main to test/hydr-plant+hydr-base August 7, 2026 18:36
@johnpaulalex
johnpaulalex force-pushed the fix/sum-btwn-depths+hydr-plant branch from 9be779b to 6cc2a4c Compare August 7, 2026 18:44
@johnpaulalex
johnpaulalex force-pushed the test/hydr-plant+hydr-base branch from ff6d4ad to 3c185fb Compare August 7, 2026 18:54
@johnpaulalex
johnpaulalex force-pushed the fix/sum-btwn-depths+hydr-plant branch 3 times, most recently from 882a63e to 33b1222 Compare August 7, 2026 19:56
@johnpaulalex
johnpaulalex force-pushed the test/hydr-plant+hydr-base branch from 6a89caa to eeaf06d Compare August 7, 2026 19:58
@johnpaulalex
johnpaulalex force-pushed the fix/sum-btwn-depths+hydr-plant branch from 33b1222 to de02de9 Compare August 7, 2026 19:59
… pFUnit test

Corrects partial-layer depth integration calculations in SumBetweenDepths when
top and bottom integration depths fall within a single soil layer or at the
topmost layer boundary (i_rhiz_b == 0). Adds test_SumBetweenDepths to
FatesPlantHydraulicsMod_geom_test.pf.
@johnpaulalex
johnpaulalex force-pushed the fix/sum-btwn-depths+hydr-plant branch from de02de9 to de7afd1 Compare August 7, 2026 20:00
@johnpaulalex johnpaulalex changed the title fix(hydraulics): Correct SumBetweenDepths layer bounds and expand unit tests fix(hydraulics): fix SumBetweenDepths layer integration logic and add pFUnit test Aug 7, 2026
@johnpaulalex

Copy link
Copy Markdown
Owner Author

Closing draft PR on fork; moved to draft PR on main repository: NGEET#1603

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant