Skip to content

Commit

Permalink
Merge pull request #431 from ecmwf-ifs/naml-pragma-region-end-fix
Browse files Browse the repository at this point in the history
IR: Fix false "end" matches in pragma_regions_attached utility
  • Loading branch information
reuterbal authored Nov 7, 2024
2 parents 19dc642 + 5023365 commit c105ed5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions loki/ir/pragma_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,12 +487,12 @@ def _matches_starting_pragma(start, p):
matches = []
stack = []
for i, p in enumerate(pragmas):
if 'end' not in p.content.lower():
if 'end' not in p.content.lower().split(' '):
# If we encounter one that does have a match, stack it
if any(_matches_starting_pragma(p, p2) for p2 in pragmas[i:]):
stack.append(p)

elif 'end' in p.content.lower() and stack:
elif 'end' in p.content.lower().split(' ') and stack:
# If we and end that matches our last stacked, keep it!
if _matches_starting_pragma(stack[-1], p):
p1 = stack.pop()
Expand Down
2 changes: 1 addition & 1 deletion loki/ir/tests/test_pragma_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ def test_tools_pragma_regions_attached_nested(frontend):
out(0) = -2.0
!$loki data nofoo
!$loki data nofoo endfoo
do i=1,n
!$loki do_nothing
out(i) = 0.0
Expand Down

0 comments on commit c105ed5

Please sign in to comment.