Skip to content

Conversation

@arporter
Copy link
Member

No description provided.

@arporter arporter added enhancement LFRic Issue relates to the LFRic domain labels Dec 19, 2025
@arporter arporter self-assigned this Jan 5, 2026
@codecov
Copy link

codecov bot commented Jan 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.95%. Comparing base (ee25f8a) to head (672284f).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3264   +/-   ##
=======================================
  Coverage   99.95%   99.95%           
=======================================
  Files         376      376           
  Lines       53485    53495   +10     
=======================================
+ Hits        53463    53473   +10     
  Misses         22       22           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@arporter
Copy link
Member Author

arporter commented Jan 5, 2026

This PR shortens the generated names used for various variables in order to avoid hitting compiler limitations as reported by Tom in #3259. Since we're no longer basing the names on existing variable names (which must be unique) I've had to increase the use of tags to ensure we cope in the face of name collisions.
One for @hiker, @LonelyCat124 or @sergisiso.
I've fired off the integration tests.

Copy link
Collaborator

@sergisiso sergisiso 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 @arporter. Its good to see more symbols managed by tags. My only suggestion is to see if we can keep short names still readable, but feel free to ignore if it is to much work.

self._boundary_dofs.append(self.BoundaryDofs(op_arg, bc_fs))

def invoke_declarations(self):
def invoke_declarations(self) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe this is a stylistic choice, but is the "-> None" needed when there is no return? None of my tooling complains with or without

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe some tools do complain - @hiker mentioned this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I suppose this is mypy, I am using ty for typechecking and it does not complain. Anyway, if we need something I suggest NoReturn https://docs.python.org/3/library/typing.html#typing.NoReturn , the method does not return None.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it does. NoReturn indicates that a function never returns while a function without an explicit return does return None (at least, that's what pylint complains about if you ever have a function where it thinks you've missed a return statement).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah yes, I agree

symbol = self.symtab.find_or_create_tag(
basis,
symbol_type=DataSymbol, datatype=UnsupportedFortranType(
f"real(kind=r_def), allocatable :: {basis}{dims}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

As you did somewhere else, you will need to do:
new_name = self.symtab.next_available_name(basis)
if you embed the name in the datatype (as it may end up being different)

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yes, done.

kind = const.QUADRATURE_TYPE_MAP["gh_quadrature_xyoz"]["kind"]
for name in self.qr_weight_vars["xyoz"]:
self.symtab.find_or_create(
self.symtab.find_or_create_tag(
Copy link
Collaborator

Choose a reason for hiding this comment

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

new_name = self.symtab.next_available_name(...)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good spot.

:returns: a shortened form of the name.
'''
new_parts = []
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe its a pain to do not that you already changed lots of tests, but some of the generated code is more cryptic now, have you considered doing:

if len(name) < threshold:
   return name

to keep already short names descriptive?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah! That's a good idea. I've done some googling and realised that the standard actually mandates a maximum length. F2008:
image
while in F95 it was 31 apparently.


# Split name string to find any_*_space ID and create a short name as
# "<start>" + "spc" + "ID"
# "<start>" + "s" + "ID"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this function still necessary now?, we could do:
self._shorten_arg_name(self.orig_name + "_" + arg.name)}

But if you decide not to remove the short_name do we really need to keep the _short_name and _mangled_name as state, it may be safer to compute them in the property method.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've kept this one but have, as you suggest, removed the internal state in favour of dynamic computation.

f"space '{self._orig_name}'")

@staticmethod
def _shorten_arg_name(name: str) -> str:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe just "_shorten_name", it doesn't use the fact is an arg.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yes.

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

Labels

enhancement in progress LFRic Issue relates to the LFRic domain

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants