Skip to content

Fix uninitialised access of met variables during range checks#702

Merged
SeanBryan51 merged 2 commits intomainfrom
fix-check-range-uninitialised-access-to-met-vars
Feb 27, 2026
Merged

Fix uninitialised access of met variables during range checks#702
SeanBryan51 merged 2 commits intomainfrom
fix-check-range-uninitialised-access-to-met-vars

Conversation

@SeanBryan51
Copy link
Collaborator

@SeanBryan51 SeanBryan51 commented Feb 27, 2026

There are a few instances where range checks are performed before the variables met%hod, met%doy, and met%year are initialised in the get_met_data subroutine. When debug flags are enabled, floating point exceptions are produced when attempting to access these arrays. This occurs for configurations where MetType /= " " and check%ranges /= 0 (i.e. range checks are enabled), and when a variable that is outside the range of its allowed values is detected. I hit this case when writing the Area variable in #689. This change makes the met arguments optional when range checks are performed during the initialisation phase to avoid the uninitialised access of met%hod, met%doy, and met%year.

Type of change

Please delete options that are not relevant.

  • Bug fix

Testing

  • Are the changes bitwise-compatible with the main branch? If working on an optional feature, are the results bitwise-compatible when this feature is off? If yes, copy benchcab output showing successful completion of the bitwise compatibility tests or equivalent results below this line.
2026-02-27 14:46:49,061 - INFO - benchcab.benchcab.py:380 - Running comparison tasks...
2026-02-27 14:46:49,087 - INFO - benchcab.benchcab.py:381 - tasks: 168 (models: 2, sites: 42, science configurations: 4)
2026-02-27 14:49:32,135 - INFO - benchcab.benchcab.py:391 - 0 failed, 168 passed

📚 Documentation preview 📚: https://cable--702.org.readthedocs.build/en/702/

There are a few instances where range checks are performed before the
variables `met%hod`, `met%doy`, and `met%year` are initialised in the
`get_met_data` subroutine. When debug flags are enabled, floating point
exceptions are produced when attempting to access these arrays. This
change makes the `met` arguments optional for the cases when range
checks are performed during the initialisation phase.
@SeanBryan51 SeanBryan51 force-pushed the fix-check-range-uninitialised-access-to-met-vars branch from 483882b to 3a40d30 Compare February 27, 2026 01:59
@SeanBryan51 SeanBryan51 changed the title Make met argument to range_abort optional Fix uninitialised access of met variables during range checks Feb 27, 2026
@SeanBryan51 SeanBryan51 marked this pull request as ready for review February 27, 2026 04:25
@SeanBryan51 SeanBryan51 requested review from a team and ccarouge and removed request for a team February 27, 2026 04:26
Copy link
Member

@ccarouge ccarouge left a comment

Choose a reason for hiding this comment

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

Look good. Just a small comment on mpimaster.

@SeanBryan51 SeanBryan51 merged commit 06f513e into main Feb 27, 2026
5 checks passed
@SeanBryan51 SeanBryan51 deleted the fix-check-range-uninitialised-access-to-met-vars branch February 27, 2026 05:04
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.

2 participants