Skip to content

Cnp phosphorus - #158

Draft
Giorgia (GiorgiaLine) wants to merge 2 commits into
MetOffice:mainfrom
GiorgiaLine:cnp_phosphorus
Draft

Giorgia (GiorgiaLine) wants to merge 2 commits into
MetOffice:mainfrom
GiorgiaLine:cnp_phosphorus

Conversation

@GiorgiaLine

Copy link
Copy Markdown

PR Summary

Sci/Tech Reviewer:
Code Reviewer:

Code Quality Checklist

(Some checks are automatically carried out via the CI pipeline)

  • I have performed a self-review of my own code
  • My code follows the project's style guidelines
  • Comments have been included that aid understanding and enhance the readability of the code
  • My changes generate no new warnings
  • If editing rose-meta/jules-shared then have you supplied a linked UM and LFRic Apps PR?

Testing

  • I have tested this change locally, using the JULES rose-stem suite
  • If shared files have been modified, I have run the UM and LFRic Apps rose stem suites
  • If any tests fail (rose-stem or CI) the reason is understood and acceptable (eg. kgo changes)
  • I have added tests to cover new functionality as appropriate (eg. system tests, unit tests, etc.)

trac.log

Security Considerations

  • I have reviewed my changes for potential security issues
  • Sensitive data is properly handled (if applicable)
  • Authentication and authorisation are properly implemented (if applicable)

Performance Impact

  • Performance of the code has been considered and, if applicable, suitable performance measurements have been conducted

AI Assistance and Attribution

  • Some of the content of this change has been produced with the assistance of Generative AI tool name (e.g., Met Office Github Copilot Enterprise, Github Copilot Personal, ChatGPT GPT-4, etc) and I have followed the Simulation Systems AI policy (including attribution labels)

Documentation

  • Where appropriate I have updated documentation related to this change and confirmed that it builds correctly

Approvals

Please request all relevant approvals. See the CodeOwners.txt file for section owners.

Technical

  • JULES Code Owner
  • OpenMP
  • River Routing
  • Rose Stem
  • Rose Metadata
  • Upgrade Macros

Scientific

  • Surface
  • Hydrology
  • Vegetation
  • Veg3 RED Demography
  • Biogeochemistry
  • Biogenic fluxes
  • Fire
  • Lakes
  • Evaluation
  • Imogen

Sci/Tech Review

  • I understand this area of code and the changes being added
  • The proposed changes correspond to the pull request description
  • Documentation is sufficient (do documentation papers need updating)
  • Sufficient testing has been completed

Please alert the code reviewer via a tag when you have approved the SR

Code Review

  • All dependencies have been resolved
  • Related Issues have been properly linked and addressed
  • CLA compliance has been confirmed
  • Code quality standards have been met
  • Tests are adequate and have passed
  • Documentation is complete and accurate
  • Security considerations have been addressed
  • Performance impact is acceptable

@github-actions github-actions Bot added the cla-required The CLA has not yet been signed by the author of this PR - added by GA label Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

Hello Giorgia (@GiorgiaLine)! 👋

Thank you for your contribution. Since this is your first time contributing to this repository, we ask that you sign our Contributor Licence Agreement (CLA).

📄 You can read the CLA here.

To agree to the CLA, please add your details (GitHub username, Real Name, Affiliation, and Date) to the CONTRIBUTORS.md file (create one, if required) in the development branch for this PR. After signing the CLA, you won't need to do this again for future PRs.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

There are confirmed functional issues (notably unassociated P arrays used in TRIFFID and an incomplete Rose upgrade macro) that can cause runtime failures or prevent upgrades from running.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR introduces initial plumbing for a phosphorus (P) scheme alongside the existing nitrogen (N) scheme, extending vegetation diagnostics/state to carry P pools and adding a new l_phosphorus switch with associated metadata/docs.

Changes:

  • Extend calc_n_comps_triffid to accept leaf carbon and diagnose leaf/root/stem P pools, and update call sites accordingly.
  • Add a large set of P-related fields to trif_vars_mod (allocation/assoc/nullify) and initialise new P pools in standalone initialisation.
  • Add Rose upgrade/meta constraints and documentation for the new l_phosphorus namelist option.
File summaries
File Description
src/science/vegetation/vegcarb_jls.F90 Updates calc_n_comps_triffid calls to pass leaf C and receive P pools.
src/science/vegetation/triffid_jls.F90 Attempts to wire P pools into TRIFFID diagnostics via calc_n_comps_triffid.
src/science/vegetation/plant_growth_n.F90 Updates N-growth calculations to also diagnose P pools via calc_n_comps_triffid.
src/initialisation/standalone/init_vars_tmp.F90 Initialises new P pools and computes initial veg P diagnostics.
src/control/shared/trif_vars_mod.F90 Adds extensive P state/diagnostic fields and allocation/association support.
src/control/shared/p_s_parms.F90 Adds stype_soilt ancillary for soil-type-dependent C:P parameters.
src/control/shared/jules_soil_biogeochem_mod.F90 Adds P-related parameter arrays/variables (e.g., C:P ratios).
src/control/shared/CN_utils_mod.F90 Extends calc_n_comps_triffid signature and adds P pool diagnosis using C:P ratios.
rose-meta/jules-standalone/versions.py Adds an upgrade macro intended to introduce l_phosphorus.
rose-meta/jules-standalone/HEAD/rose-meta.conf Adds meta validation requiring P-state fields when l_phosphorus is enabled.
doc/source/overview/key-switches.rst Documents the new phosphorus switch in the key switches overview.
doc/source/namelists/jules_vegetation.nml.rst Documents the new l_phosphorus namelist member.
Review details

Suppressed comments (3)

src/control/shared/trif_vars_mod.F90:213

  • The comment for harvest_p_pft incorrectly says nitrogen is harvested; this is the phosphorus harvest flux.
                        ! Nitrogen harvested from crops (kg/(m2 PFT)/360days).

src/control/shared/trif_vars_mod.F90:235

  • p_root_trif_pft/p_stem_trif_pft comments refer to N content, but these are phosphorus pools; misleading comments make diagnostics hard to interpret.
                        ! Root N content scaled by LAI_BAL, in triffid (kg/m2).
  REAL(KIND=real_jlslsm), ALLOCATABLE :: p_stem_trif_pft(:,:)
                        ! Stem N content scaled by LAI_BAL, in triffid (kg/m2).

rose-meta/jules-standalone/versions.py:61

  • The upgrade macro does not return (config, self.reports), so the macro will not function correctly when invoked by rose upgrade.
        # Adding logical and real to the jules biogeochemical namelist
        self.add_setting(config,
                ["namelist:jules_vegetation", "l_phosphorus"], ".false.")

  • Files reviewed: 12/12 changed files
  • Comments generated: 9
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +268 to 270
! TYPES containing field data
TYPE(trif_vars_type) :: trif_vars
!trif_vars_mod
Comment on lines +119 to +129
!!! GL CNP_PHOS Something is missing here
st_real = psparms%stype_soilt(l,1,1)
st_int = INT(st_real)
!!! GL CNP_PHOS This should be a warning but doing it to check everything else
IF (st_int < 1) THEN
st_int = 1
END IF
! Need the index to be an integer not a real?
l_cp = l_cp_r(st_int)
r_cp = r_cp_r(st_int)
w_cp = w_cp_r(st_int)
Comment on lines +197 to +199
! Eq. 1 in CNP GMD paper:
p_leaf = leaf / l_cp

Comment on lines +1153 to +1155
ALLOCATE(trif_vars_data%p_leaf_pft(land_pts,npft))
ALLOCATE(trif_vars_data%p_root_pft(land_pts,npft))
ALLOCATE(trif_vars_data%p_stem_pft(land_pts,npft))
Comment on lines 17 to +21
When TRIFFID is on, competition between tiles is switched on with
:nml:mem:`JULES_VEGETATION::l_veg_compete` and the effect of nitrogen on
vegetation growth is enabled via :nml:mem:`JULES_VEGETATION::l_nitrogen`.

:nml:mem:`JULES_VEGETATION::l_veg_compete`, the effect of nitrogen on
Comment on lines +99 to +101
! P Vars
REAL(KIND=real_jlslsm), ALLOCATABLE :: stype_soilt(:,:,:)
! Soil pH, defined on soil layers. - ported from CNP_FAR
NULLIFY(psparms%v_close_pft)
NULLIFY(psparms%v_open_pft)
NULLIFY(psparms%stype_soilt)
!!! GL CNP_PHOS: DO I need to put the the other soilt vars here?
Comment on lines +207 to +208
! Root P moved to soil nitrogen during
! landuse change (kg/(m2 PFT)/360days).
n_stem_pot, dvi_cpft)
n_stem_pot, p_leaf_pot, p_root_pot, p_stem_pot, &
dvi_cpft)
!!! GL CNP_PHOS: Having calculations in argument lists is probably bot ideal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-required The CLA has not yet been signed by the author of this PR - added by GA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants