Skip to content

update norms comparison for UM output as of UM#5034#47

Open
Erica Neininger (ericaneininger) wants to merge 1 commit intoMetOffice:mainfrom
ericaneininger:absnorms_format
Open

update norms comparison for UM output as of UM#5034#47
Erica Neininger (ericaneininger) wants to merge 1 commit intoMetOffice:mainfrom
ericaneininger:absnorms_format

Conversation

@ericaneininger
Copy link
Copy Markdown
Collaborator

@ericaneininger Erica Neininger (ericaneininger) commented Mar 31, 2026

PR Summary

Code Reviewer: Sam Clarke-Green (@t00sa)

The format of the Helmholtz problem solver output changed to include both an initial and final error under UM#5024.

********************************************
*    Linear solve for Helmholtz problem    *
* Outer Inner Iterations InitialError      *
*    1     1       17     0.100000E+01     *
*    1     2       12     0.117237E-01     *
********************************************

became

*    Linear solve for Helmholtz problem                       *
* Outer Inner Iterations   InitialError       FinalError      *
*    1     1        3      0.100000E+01      0.828367E-04     *
* 

Until now the MOCI testing which utilised the norms comparison script has used an older version of the UM.
This change allows for both of these formats.
2 new unittests added and new format KGO file added.

Please note, these unit tests will be added to rose-stem under #46. Until then they are command line only.

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

Testing

  • I have tested this change locally, using the Moci rose-stem suite
  • 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.)

Unit tests available: Utilities/verification_scripts/unittests/test_compare_norms.py

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

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

Copy link
Copy Markdown
Collaborator

@t00sa Sam Clarke-Green (t00sa) left a comment

Choose a reason for hiding this comment

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

Looks good. I've suggested a couple of adjustments, assuming that you are interested in capturing the initial error in both cases.

r'\*.*Linear solve for Helmholtz problem.*\*'
)
norms_regex = re.compile(r'\*\s+\d+\s+\d+\s+(\d+)\s+(\S+)\s+\*')
norms_regex = re.compile(r'\*\s+\d+\s+\d+\s+(\d+)(\s+\S+)?\s+(\S+)\s+\*')
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Assuming that you want to capture the initial error in both cases, the match should always be on the first floating point value and the second one should be optional. If the second value isn't required, using a non-matching group removes the need for the change on L91.

Suggested change
norms_regex = re.compile(r'\*\s+\d+\s+\d+\s+(\d+)(\s+\S+)?\s+(\S+)\s+\*')
norms_regex = re.compile(r'\*\s+\d+\s+\d+\s+(\d+)\s+(\S+)\s+(?:\s+\S+)?\s+\*')

elif num_calls > 1:
try:
iterations, error = norms_regex.search(line).groups()
iterations, _, error = norms_regex.search(line).groups()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

By skipping the capture of the unwanted value, this line can be left unchanged:

Suggested change
iterations, _, error = norms_regex.search(line).groups()
iterations, error = norms_regex.search(line).groups()

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.

3 participants