Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve vector notation issues (encountering Fortran intrinsics) #398

Open
MichaelSt98 opened this issue Oct 14, 2024 · 0 comments
Open
Labels
bug Something isn't working enhancement New feature or request

Comments

@MichaelSt98
Copy link
Collaborator

What happened?

As an example, execute:

from loki import Subroutine, fgen, resolve_vector_notation

fcode_kernel = """
SUBROUTINE kernel()
INTEGER :: ARR_LEN = 3
INTEGER :: A(ARR_LEN, ARR_LEN + 1)
INTEGER :: B(ARR_LEN + 1)
B(:) = SUM(A(:,:), 2)
END SUBROUTINE kernel
"""

kernel = Subroutine.from_source(fcode_kernel)
resolve_vector_notation(kernel)
print(fgen(kernel))

which yields

SUBROUTINE kernel ()
  INTEGER :: ARR_LEN = 3
  INTEGER :: A(ARR_LEN, ARR_LEN + 1)
  INTEGER :: B(ARR_LEN + 1)
  INTEGER :: i_B_1
  INTEGER :: i_B_0
  DO i_B_1=1,ARR_LEN + 1
    DO i_B_0=1,ARR_LEN
      B(i_B_0) = SUM(A(i_B_0, i_B_1), 2)
    END DO
  END DO
END SUBROUTINE kernel

with the problematic line: B(i_B_0) = SUM(A(i_B_0, i_B_1), 2).

This is just one example of a larger problem/issue and also applies to SCCBaseTransformation.resolve_vector_dimension.

What are the steps to reproduce the bug?

Execute:

from loki import Subroutine, fgen, resolve_vector_notation

fcode_kernel = """
SUBROUTINE kernel()
INTEGER :: ARR_LEN = 3
INTEGER :: A(ARR_LEN, ARR_LEN + 1)
INTEGER :: B(ARR_LEN + 1)
B(:) = SUM(A(:,:), 2)
END SUBROUTINE kernel
"""

kernel = Subroutine.from_source(fcode_kernel)
resolve_vector_notation(kernel)
print(fgen(kernel))

Version

main

Platform (OS and architecture)

Mac / HPC2020

Relevant log output

No response

Accompanying data

No response

Organisation

No response

@MichaelSt98 MichaelSt98 added bug Something isn't working enhancement New feature or request labels Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant