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

Improve WHERE handling to check the dimensions of full statements inside the condition, instead of just finding the first range object inside the statement. #2876

Open
LonelyCat124 opened this issue Jan 28, 2025 · 0 comments
Labels

Comments

@LonelyCat124
Copy link
Collaborator

PSyclone currently guesses the size of the WHERE loop by assessing the first range in the condition and assuming that is the dimension of the loop. This can lead to incorrect assessments in some cases, e.g. the WHERE statements found in this code fragment.

subroutine test
    real, allocatable, dimension(:) :: pivot, pivot2
    real :: min_pivot

    min_pivot = 1.0
    allocate(pivot(1:10000))

    WHERE(sum(pivot(:)) + pivot(1:5) < min_pivot) pivot(1:5) = min_pivot
    deallocate(pivot)
    end subroutine

We can be smarter now, and evaluate the size of SUM - this first case is wrong technically but we currently do something wrong and turn pivot(1:5) to just index over the full range.

Also this statement will be wrong due to #2722 but thats a separate problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant