Skip to content

Allow lfric_atm to compile for oasis coupled models#486

Open
Paul Earnshaw (pdearnshaw) wants to merge 6 commits into
MetOffice:mainfrom
pdearnshaw:92_coupled_compilation_fix
Open

Allow lfric_atm to compile for oasis coupled models#486
Paul Earnshaw (pdearnshaw) wants to merge 6 commits into
MetOffice:mainfrom
pdearnshaw:92_coupled_compilation_fix

Conversation

@pdearnshaw
Copy link
Copy Markdown

@pdearnshaw Paul Earnshaw (pdearnshaw) commented May 7, 2026

PR Summary

Sci/Tech Reviewer: Mike Hobson (@mike-hobson)
Code Reviewer: Alistair Pirrie (@mo-alistairp)

This PR will allow the lfric_atm app to be used for oasis coupled models. The changes add a conditional statement to the lfric_atm makefile controlled by the environment variable COUPLED. If set and true then the internal dependency $(CORE_ROOT_DIR)/components/coupling is added to the list of INTERNAL_DEPENDENCIES while also adding to the list of PRE_PROCESS_MACROS the values MCT and COUPLED. If not set or not true then nothing happens.

The lfric_atm.f90 program file is modified to a F90 file in order to allow of pre-processing, and under the macro MCT extra statements are added to the code that allow for the initialistion of the coupled context.

No new tests have been added to cover this functionality as these will added a later date to cover all GC6 requirements.

fixes #92 (auto-closes the issue)

Code Quality Checklist

  • 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
  • All automated checks in the CI pipeline have completed successfully

Testing

  • I have tested this change locally, using the LFRic Apps rose-stem suite
  • If any tests fail (rose-stem or CI) the reason is understood and acceptable (e.g. kgo changes)
  • I have added tests to cover new functionality as appropriate (e.g. system tests, unit tests, etc.)
  • Any new tests have been assigned an appropriate amount of compute resource and have been allocated to an appropriate testing group (i.e. the developer tests are for jobs which use a small amount of compute resource and complete in a matter of minutes)

This branch (and previous versions of) has been used extensively in GC6 testing over a number of releases and has worked fine.

trac.log

Test Suite Results - lfric_apps - lfric_apps_92_coupled_compilation_fix/run1

Suite Information

Item Value
Suite Name lfric_apps_92_coupled_compilation_fix/run1
Suite User paul.earnshaw
Workflow Start 2026-05-07T12:19:39
Groups Run developer
Dependency Reference Main Like
casim MetOffice/casim@2026.03.2 True
jules MetOffice/jules@2026.03.2 True
lfric_apps pdearnshaw/lfric_apps@92_coupled_compilation_fix False
lfric_core MetOffice/lfric_core@2026.03.2 True
moci MetOffice/moci@2026.03.2 True
SimSys_Scripts MetOffice/SimSys_Scripts@2026.03.2 True
socrates MetOffice/socrates@2026.03.2 True
socrates-spectral MetOffice/socrates-spectral@2026.03.2 True
ukca MetOffice/ukca@2026.03.2 True

Task Information

✅ succeeded tasks - 1164

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

PSyclone Approval

  • If you have edited any PSyclone-related code (e.g. PSyKAl-lite, Kernel interface, optimisation scripts, LFRic data structure code) then please contact the TCD Team

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 May 7, 2026
@pdearnshaw Paul Earnshaw (pdearnshaw) added bug Something isn't working and removed cla-required The CLA has not yet been signed by the author of this PR - added by GA labels May 7, 2026
@pdearnshaw Paul Earnshaw (pdearnshaw) added this to the Summer 2026 milestone May 7, 2026
@github-actions github-actions Bot added the cla-signed The CLA has been signed as part of this PR - added by GA label May 7, 2026
Copy link
Copy Markdown
Contributor

@mike-hobson Mike Hobson (mike-hobson) left a comment

Choose a reason for hiding this comment

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

This is a straightforward change that will more easily allow lfric_atm jobs to run as coupled systems. I just have one comment about the use of #ifdefs.

Comment thread applications/lfric_atm/source/lfric_atm.F90
Comment thread applications/lfric_atm/source/lfric_atm.F90
Comment thread applications/lfric_atm/source/lfric_atm.F90
Copy link
Copy Markdown
Contributor

@mike-hobson Mike Hobson (mike-hobson) left a comment

Choose a reason for hiding this comment

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

Thanks for looking at the ifdefs I'm happy that they stay in. That means the the PR is ready for code review with Alistair Pirrie (@mo-alistairp).

@mo-alistairp
Copy link
Copy Markdown
Contributor

Can I check whether this is ready for Code Review, because it seems to have been moved out?

@mike-hobson
Copy link
Copy Markdown
Contributor

This has passed sci/tech review and is ready for code review - so you're free to start looking at it. I don't know why the tracker script isn't moving the state on - I'll have a word with the script's maintainer.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Owner (Build System) Review: Just a quick question.

Comment on lines +48 to +49
ifdef COUPLED
ifeq ("$(COUPLED)","True")

Choose a reason for hiding this comment

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

Normally we would just test for the existence of the macro. What is the reason for requiring it to have a particular value?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The COUPLED here is not a macro, it is an environment variable. What we want in this test is to make sure firstly that it has been set, and then that it has been set to True. The idea being that if it is not set, or set to False then the coupled model infrastructure is not applied.

As I understand it the ifdef statement can test for environment variables or keyword-like arguments in the make command, it cannot act on PRE_PROCESS_MACRO entries. So the choice in how to identify if we wanted to compile as a coupled model was to use an optional environment variable.

Happy to consider other ways of doing this.

Choose a reason for hiding this comment

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

The PRE_PROCESS_MACROS are converted into a set of -D<key>=<value> arguments to the compiler. So they will appear to the preprocessor as macros. In which case you can just test on their presence. Unless you think there will be cases where people are setting that value to False.

There's no correctness reason not to do it the way you have, it just runs the risk of people getting unexpected behaviour if they say COUPLED=YES.

I don't mind which you do so feel free to resolve this conversation when you have made a decision.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code owner (Build system) further commentary.

Comment on lines +48 to +49
ifdef COUPLED
ifeq ("$(COUPLED)","True")

Choose a reason for hiding this comment

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

The PRE_PROCESS_MACROS are converted into a set of -D<key>=<value> arguments to the compiler. So they will appear to the preprocessor as macros. In which case you can just test on their presence. Unless you think there will be cases where people are setting that value to False.

There's no correctness reason not to do it the way you have, it just runs the risk of people getting unexpected behaviour if they say COUPLED=YES.

I don't mind which you do so feel free to resolve this conversation when you have made a decision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cla-signed The CLA has been signed as part of this PR - added by GA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow lfric_atm to compile for oasis coupled models

5 participants