Skip to content

Commit

Permalink
Merge pull request #472 from ecmwf-ifs/naml-fix-downcasing-inlinefunc…
Browse files Browse the repository at this point in the history
…tions

Transformations: Fix downcasing of nested `InlineCall` symbols
  • Loading branch information
reuterbal authored Jan 15, 2025
2 parents c054b46 + 53a8036 commit eff4036
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion loki/transformations/tests/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,20 @@ def test_transform_convert_to_lower_case(frontend):
do K=1,ANOTHER_VAR
LOWER_CASE(MIXEd_cASE(1, K)) = K - 1
end do
miXed_CasE(1, 1) = Max(mIn(sQrT(9.0), 2.0), 1.0)
end subroutine my_NOT_ALL_lowercase_ROUTINE
""".strip()
routine = Subroutine.from_source(fcode, frontend=frontend)
convert_to_lower_case(routine)
assert all(var.name.islower() and str(var).islower() for var in FindVariables(unique=False).visit(routine.ir))
assert all(
var.name.islower() and str(var).islower()
for var in FindVariables(unique=True).visit(routine.ir)
)
assert all(
f.name.islower() and str(f).islower()
for f in FindInlineCalls().visit(routine.ir)
)


@pytest.mark.parametrize('frontend', available_frontends())
Expand Down
1 change: 1 addition & 0 deletions loki/transformations/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def convert_to_lower_case(routine):
(stmt.variable, stmt.variable.clone(name=stmt.variable.name.lower()))
for stmt in FindNodes(StatementFunction).visit(routine.spec)
)
mapper = recursive_expression_map_update(mapper, case_sensitive=True)
routine.spec = SubstituteExpressions(mapper).visit(routine.spec)
routine.body = SubstituteExpressions(mapper).visit(routine.body)

Expand Down

0 comments on commit eff4036

Please sign in to comment.