PSyclone
PSyclone copied to clipboard
ArrayRangeToLoopTrans over cautious with index expressions
Given the following code:
module my_mod
use some_mod
implicit none
contains
subroutine my_sub()
integer :: iihom, jl
real, dimension(10,10,10) :: ptab
SELECT CASE ( pmpp%nbondi ) ! Read Dirichlet lateral conditions
CASE ( -1, 0, 1 ) ! all exept 2 (i.e. close case)
iihom = pmpp%nlci-pmpp%nreci
DO jl = 1, jpreci
pmpp%flbc%t3ew(:,jl,:,1) = ptab(jpreci+jl,:,:)
pmpp%flbc%t3we(:,jl,:,1) = ptab(iihom +jl,:,:)
END DO
END SELECT
end subroutine my_sub
end module my_mod
NemoAllArrayRange2LoopTrans will successfully convert the last assignment into a loop but refuses to do the penultimate one because it doesn't know anything about the type of jpreci. In this case we can determine that it must be a scalar because otherwise the shape of the RHS would not conform to the shape of the LHS. I'm not sure how easy it would be to put this logic into the transformation but it would be nice to have it as it's quite hard to track down why PSyclone refused to do the transformation.