Skip to content

test: add Ci solver pFUnit unit test suite and optional error flag#1590

Open
johnpaulalex wants to merge 1 commit into
NGEET:mainfrom
johnpaulalex:leaf-biophys-solvers-test
Open

test: add Ci solver pFUnit unit test suite and optional error flag#1590
johnpaulalex wants to merge 1 commit into
NGEET:mainfrom
johnpaulalex:leaf-biophys-solvers-test

Conversation

@johnpaulalex

Copy link
Copy Markdown
Contributor

(not intending to submit yet, just sending for discussion)

Adds a new leaf_biophysics_solver test suite targeting the intracellular CO2 (Ci) solver stack in biogeophys/LeafBiophysicsMod.F90:

  • CiMinMax: verifies bracket validity (ci_min < ci_max, physically bounded) and that fval at each endpoint straddles zero
  • CiFunc: verified indirectly via test_CiFunc_zero_at_solution, which asserts |fval| < ci_tol at the Ci returned by CiBisection. Documents the decision process not to use an analytical root due to Medlyn complexity.
  • CiBisection: convergence under full light (anet > 0, gs > gs0, solve_iter < 200), darkness (anet < 0, gs ≈ gs0), varying tolerances (loose vs tight), and different environmental temperatures/low-light.
  • Max Iterations: test_CiBisection_max_iters_sets_ierr tests the maximum iteration failure path by passing ci_tol=0.

To allow testing the failure path, an optional ierr argument is added to CiBisection in biogeophys/LeafBiophysicsMod.F90. If present, the solver returns gracefully with ierr=1 when max iterations is reached instead of calling endrun(). Traditional callers that omit ierr retain the original behavior.

New files:
testing/tests/unit/leaf_biophysics_solver_test/test_LeafBiophysicsSolvers.pf
testing/tests/unit/leaf_biophysics_solver_test/CMakeLists.txt

Integration:
testing/CMakeLists.txt
testing/config/unit.cfg

Description:

Collaborators:

Expectation of Answer Changes:

Description of generative AI usage (as necessary)

Checklist

If this is your first time contributing, please read the CONTRIBUTING document.

All checklist items must be checked to enable merging this pull request:

Contributor

  • The in-code documentation has been updated with descriptive comments
  • The documentation has been assessed to determine if updates are necessary
  • Describe use of generative AI (if necessary)

Integrator

  • FATES PASS/FAIL regression tests were run
  • Evaluation of test results for answer changes was performed and results provided
  • FATES-CLM6 Code Freeze: satellite phenology regression tests are b4b

If satellite phenology regressions are not b4b, please hold merge and notify the FATES development team.

Documentation

Test Results:

CTSM (or) E3SM (specify which) test hash-tag:

CTSM (or) E3SM (specify which) baseline hash-tag:

FATES baseline hash-tag:

Test Output:

Adds a new leaf_biophysics_solver test suite targeting the intracellular
CO2 (Ci) solver stack in biogeophys/LeafBiophysicsMod.F90:

  - CiMinMax: verifies bracket validity (ci_min < ci_max, physically
    bounded) and that fval at each endpoint straddles zero
  - CiFunc: verified indirectly via test_CiFunc_zero_at_solution, which
    asserts |fval| < ci_tol at the Ci returned by CiBisection. Documents
    the decision process not to use an analytical root due to Medlyn complexity.
  - CiBisection: convergence under full light (anet > 0, gs > gs0,
    solve_iter < 200), darkness (anet < 0, gs ≈ gs0), varying tolerances
    (loose vs tight), and different environmental temperatures/low-light.
  - Max Iterations: test_CiBisection_max_iters_sets_ierr tests the
    maximum iteration failure path by passing ci_tol=0.

To allow testing the failure path, an optional ierr argument is added to
CiBisection in biogeophys/LeafBiophysicsMod.F90. If present, the solver returns
gracefully with ierr=1 when max iterations is reached instead of calling
endrun(). Traditional callers that omit ierr retain the original behavior.

New files:
  testing/tests/unit/leaf_biophysics_solver_test/test_LeafBiophysicsSolvers.pf
  testing/tests/unit/leaf_biophysics_solver_test/CMakeLists.txt

Integration:
  testing/CMakeLists.txt
  testing/config/unit.cfg
@rgknox

rgknox commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

@johnpaulalex , I was curious, have you triggered any failures in the photosynthesis code with your tests?

@rgknox rgknox added testing: pure B4B No differences in any tests software: not API changing Does not require a change to the HLM API parameters: no change labels Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parameters: no change software: not API changing Does not require a change to the HLM API testing: pure B4B No differences in any tests

Projects

Status: Finding Reviewers

Development

Successfully merging this pull request may close these issues.

2 participants