Skip to content

Refactor wet model drivers and controllers - #55

Open
Pierre Siddall (Pierre-siddall) wants to merge 64 commits into
MetOffice:mainfrom
Pierre-siddall:refactor-wet-model
Open

Refactor wet model drivers and controllers#55
Pierre Siddall (Pierre-siddall) wants to merge 64 commits into
MetOffice:mainfrom
Pierre-siddall:refactor-wet-model

Conversation

@Pierre-siddall

@Pierre-siddall Pierre Siddall (Pierre-siddall) commented May 11, 2026

Copy link
Copy Markdown
Contributor

PR Summary

Code Reviewer: Erica Neininger (@ericaneininger)

This PR migrates over the ticket number 523 from subversion which was authored by Harry Shepherd (@harry-shepherd) and contained the following description:

As part of the first priority items for the drivers refactor, there is extensive work to do on the wet model drivers and controllers. For this context I take these to be:

  • NEMO
  • TOP (Medusa)
  • SI^3

As all of these have similar functionality, and areas of code that work in the same way. The original design brief for the drivers was to ensure orthogonality between components, and this will still be followed to allow the SI^3^ controller to easily be reconfigured into a driver if that is desired. However code reuse will be made use of as much as possible (which was not the case in the original implementation of the controllers).

As CICE is not part of GC5, refactoring of that driver is a 2nd tier priority item.

Work in this ticket includes (but is not limited to):
NEMO

  • Splitting up {{{setup_executable}}} into discrete tasks that can be unit tested
  • Splitting up {{{finalize_executable}}} in a similar way
  • Unit testing other functions

SI^3 and Top
The controllers will be removed

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 undertanding 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.)

Test Suite Results - moci - test-refactor-wet-model/run2

Suite Information

Item Value
Suite Name test-refactor-wet-model/run2
Suite User pierre.siddall
Workflow Start 2026-06-03T08:21:17
Groups Run all
Dependency Reference Main Like
moci Pierre-siddall/moci@refactor-wet-model False
SimSys_Scripts MetOffice/SimSys_Scripts@main True

Task Information

✅ succeeded tasks - 120

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

Co-authored-by: harry-shepherd <17930806+harry-shepherd@users.noreply.github.com>
@Pierre-siddall
Pierre Siddall (Pierre-siddall) marked this pull request as ready for review June 9, 2026 07:58

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.

  • I believe some of the functionality added since the original SRS branch was committed has been lost - particularly anything that was removed from nemo_driver.py into new files. The branch was cut a r4173. There are (at least) two diffs which should be considered:
  1. https://code.metoffice.gov.uk/trac/moci/changeset?reponame=&new=5833%40main%2Ftrunk%2FCoupled_Drivers&old=4161%40main%2Ftrunk%2FCoupled_Drivers
  2. https://github.com/MetOffice/moci/commits/main/Coupled_Drivers/nemo_driver.py

I may not have picked up on all the specifics here - this may be an iterative review process!

  • Since this affects all UM jobs using the drivers, Can you please run the UM rose-stem "coupled" group with this branch added to the dependencies.yaml file?

  • Copyright notice - Please replace all headers in modified files with the updated Momentum Copyright notice. New files obviously get the new one as well please.

Comment thread Coupled_Drivers/dr_env_lib/nemo_def.py Outdated
Comment thread Coupled_Drivers/unittests/test_aprun_command_construction.py Outdated
Comment thread Coupled_Drivers/unittests/test_common.py Outdated
Comment thread Coupled_Drivers/unittests/test_envar_lib.py
Comment thread Coupled_Drivers/unittests/test.py Outdated
Comment on lines +96 to +102
We look for files conforming to the naming convention:
<arbitrary suite name>_yyyymmdd_restart_<PE rank>.nc where
<arbitrary suite name> may itself contain underscores, hence we
do not parse details based on counting the number of underscores.
'''
nemo_restart_files = [f for f in os.listdir(nemo_rst) if
re.findall(r'.+_\d{8}_restart(_\d+)?\.nc', f)]

@ericaneininger Erica Neininger (ericaneininger) Jul 28, 2026

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.

Please include modifications made under SRS tickets #605 & 667, to nemo_driver.py between lines 333-339 (original) and lines 343-351 (updated)
https://code.metoffice.gov.uk/trac/moci/changeset?reponame=&new=5562%40main%2Ftrunk%2FCoupled_Drivers%2Fnemo_driver.py&old=4876%40main%2Ftrunk%2FCoupled_Drivers%2Fnemo_driver.py

Comment thread Coupled_Drivers/nemo_restart_lib.py
' from a state of zero icebergs\n'
_ = ocn_lib.setup_nrun(nemo_envar['NEMO_ICEBERGS_START'],
nemo_envar['RST_LINK_DIR'],
'restart_icebergs', nemo_init_dir,

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.

I think that restart_icebergs here is now variable - it may alternatively be restart_icb?? depending on NEMO version.

Please see changes made under SRS tickets #605 & #667 in nemo_driver.py beginning around line 410 in the modified file.
https://code.metoffice.gov.uk/trac/moci/changeset?reponame=&new=5562%40main%2Ftrunk%2FCoupled_Drivers%2Fnemo_driver.py&old=4876%40main%2Ftrunk%2FCoupled_Drivers%2Fnemo_driver.py

self._variables \
= {'nemo_first_step': NamelistVal(r'nn_it000=(.+),', None),
'nemo_last_step': NamelistVal(r'nn_itend=(.+),', None),
'nemo_step_int': NamelistVal(r'rn_rdt=(\d*)', None),

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.

I think that, depending on NEMO version, the namelist variable may alternatively be rn_dt.

Please see changes made under SRS tickets #605 & #667, in nemo_driver.py beginning around line 410.
https://code.metoffice.gov.uk/trac/moci/changeset?reponame=&new=5562%40main%2Ftrunk%2FCoupled_Drivers%2Fnemo_driver.py&old=4876%40main%2Ftrunk%2FCoupled_Drivers%2Fnemo_driver.py

restart_types = [
Restarts('NEMO', '%so_%s_restart', 'restart'),
Restarts('SI3', '%so_%s_restart_ice', 'restart_ice'),
Restarts('Icebergs', '%so_icebergs_%s_restart', 'restart_icebergs'),

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.

        Restarts('Icebergs', '%so_icebergs_%s_restart', 'restart_icebergs'),

The NEMO restart file for icebergs changed at NEMO4 to better match all the others -
So depending on version, I think this call to Restarts might alternatively need to be (I think!)

        Restarts('Icebergs', '%so_$s_restart_icb', 'restart_icb'),

Please see changes made in SRS tickets #605 & #667 in nemo_driver.py around line 537.
https://code.metoffice.gov.uk/trac/moci/changeset?reponame=&new=5562%40main%2Ftrunk%2FCoupled_Drivers%2Fnemo_driver.py&old=4876%40main%2Ftrunk%2FCoupled_Drivers%2Fnemo_driver.py

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.

  • I believe some of the functionality added since the original SRS branch was committed has been lost - particularly anything that was removed from nemo_driver.py into new files. The branch was cut a r4173. There are (at least) two diffs which should be considered:
  1. https://code.metoffice.gov.uk/trac/moci/changeset?reponame=&new=5833%40main%2Ftrunk%2FCoupled_Drivers&old=4161%40main%2Ftrunk%2FCoupled_Drivers
  2. https://github.com/MetOffice/moci/commits/main/Coupled_Drivers/nemo_driver.py

I may not have picked up on all the specifics here - this may be an iterative review process!

  • Since this affects all UM jobs using the drivers, Can you please run the UM rose-stem "coupled" group with this branch added to the dependencies.yaml file?

  • Copyright notice - Please replace all headers in modified files with the updated Momentum Copyright notice. New files obviously get the new one as well please.

Co-authored-by: Erica Neininger <107684099+ericaneininger@users.noreply.github.com>
Co-authored-by: Erica Neininger <107684099+ericaneininger@users.noreply.github.com>
@github-actions github-actions Bot added cla-required The CLA has not yet been signed by the author of this PR - added by GA cla-modified The CLA has been modified as part of this PR - added by GA and removed cla-required The CLA has not yet been signed by the author of this PR - added by GA labels Jul 29, 2026
Co-authored-by: Erica Neininger <107684099+ericaneininger@users.noreply.github.com>
Co-authored-by: Erica Neininger <107684099+ericaneininger@users.noreply.github.com>
Co-authored-by: Erica Neininger <107684099+ericaneininger@users.noreply.github.com>
Co-authored-by: Erica Neininger <107684099+ericaneininger@users.noreply.github.com>
@github-actions github-actions Bot removed the cla-modified The CLA has been modified as part of this PR - added by GA label Jul 29, 2026
Co-authored-by: Erica Neininger <107684099+ericaneininger@users.noreply.github.com>
Co-authored-by: Erica Neininger <107684099+ericaneininger@users.noreply.github.com>
Co-authored-by: Erica Neininger <107684099+ericaneininger@users.noreply.github.com>
Co-authored-by: Erica Neininger <107684099+ericaneininger@users.noreply.github.com>
Co-authored-by: Erica Neininger <107684099+ericaneininger@users.noreply.github.com>
Co-authored-by: Erica Neininger <107684099+ericaneininger@users.noreply.github.com>
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