Cnp phosphorus - #158
Cnp phosphorus#158Giorgia (GiorgiaLine) wants to merge 2 commits into
Conversation
|
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). 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. |
There was a problem hiding this comment.
🟡 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_triffidto 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_phosphorusnamelist 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_pftincorrectly 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_pftcomments 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.
| ! TYPES containing field data | ||
| TYPE(trif_vars_type) :: trif_vars | ||
| !trif_vars_mod |
| !!! 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) |
| ! Eq. 1 in CNP GMD paper: | ||
| p_leaf = leaf / l_cp | ||
|
|
| 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)) |
| 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 |
| ! 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? |
| ! 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 |
PR Summary
Sci/Tech Reviewer:
Code Reviewer:
Code Quality Checklist
(Some checks are automatically carried out via the CI pipeline)
rose-meta/jules-sharedthen have you supplied a linked UM and LFRic Apps PR?Testing
trac.log
Security Considerations
Performance Impact
AI Assistance and Attribution
Documentation
Approvals
Please request all relevant approvals. See the CodeOwners.txt file for section owners.
Technical
Scientific
Sci/Tech Review
Please alert the code reviewer via a tag when you have approved the SR
Code Review