Skip to content

Remove finalise method from adjoint lookup tables#311

Closed
DrTVockerodtMO wants to merge 7 commits intoMetOffice:mainfrom
DrTVockerodtMO:lu_cache_memory_leak_fix
Closed

Remove finalise method from adjoint lookup tables#311
DrTVockerodtMO wants to merge 7 commits intoMetOffice:mainfrom
DrTVockerodtMO:lu_cache_memory_leak_fix

Conversation

@DrTVockerodtMO
Copy link
Contributor

@DrTVockerodtMO DrTVockerodtMO commented Mar 3, 2026

PR Summary

Sci/Tech Reviewer:
Code Reviewer: @andrewcoughtrie

Please ignore the branch name as this was meant to address #310 which was a false alarm.

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)

trac.log

Test Suite Results - lfric_apps - remove_finaliser/run1

Suite Information

Item Value
Suite Name remove_finaliser/run1
Suite User terence.vockerodt
Workflow Start 2026-03-05T16:59:50
Groups Run developer
Dependency Reference Main Like
casim MetOffice/[email protected] True
jules MetOffice/[email protected] True
lfric_apps DrTVockerodtMO/lfric_apps@lu_cache_memory_leak_fix False
lfric_core MetOffice/[email protected] True
moci MetOffice/[email protected] True
SimSys_Scripts MetOffice/[email protected] True
socrates MetOffice/[email protected] True
socrates-spectral MetOffice/[email protected] True
ukca MetOffice/[email protected] 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

@DrTVockerodtMO DrTVockerodtMO self-assigned this Mar 3, 2026
Copy link
Collaborator

@andrewcoughtrie andrewcoughtrie left a comment

Choose a reason for hiding this comment

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

A couple of points that need addressing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

For this to be called as destructor (i.e. when the object goes out of scope) because it isn't a finaliser (even though it is called finalise).

Suggested change
final :: finalise => adj_lookup_table_finaliser

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually on second look you don't need a finaliser at all, the default destructor would do the job fine so you can remove this and the subroutine as well.

Comment on lines +244 to +245
call self%lookup_field%clear()
call self%set_count_field%clear()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make the subroutine a finaliser as described (see my other comment) and you shouldn't need to call any of this. In fact you shouldn't be calling clear (they are only for pFUnit tests - don't ask)

Suggested change
call self%lookup_field%clear()
call self%set_count_field%clear()

Copy link
Collaborator

Choose a reason for hiding this comment

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

As mentioned earlier you don't need this subroutine at all.

@DrTVockerodtMO
Copy link
Contributor Author

Thank you for having a look. So in other words there isn't a memory leak, I was just confused since I thought I had to manually destruct the fields. I'll keep this PR open and change it into removing the finalise of the lookup tables. On the other hand, the lookup table caches do allocate data so their finalise methods can stay so that is properly taken care of.

@DrTVockerodtMO DrTVockerodtMO changed the title Added clearing of member integer fields of adjoint lookup tables ~~Added clearing of member integer fields of adjoint lookup tables~~ Mar 3, 2026
@DrTVockerodtMO DrTVockerodtMO changed the title ~~Added clearing of member integer fields of adjoint lookup tables~~ ~Added clearing of member integer fields of adjoint lookup tables~ Mar 3, 2026
@DrTVockerodtMO DrTVockerodtMO changed the title ~Added clearing of member integer fields of adjoint lookup tables~ Remove finalise method from adjoint lookup tables Mar 3, 2026
@DrTVockerodtMO DrTVockerodtMO added this to the Summer 2026 milestone Mar 5, 2026
@DrTVockerodtMO DrTVockerodtMO deleted the lu_cache_memory_leak_fix branch March 16, 2026 15:12
@DrTVockerodtMO
Copy link
Contributor Author

I renamed the branch which deleted this pull request.

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.

Vestigial finalise method in adjoint lookup tables

2 participants