PSyclone
PSyclone copied to clipboard
[PSyIR-FE] fparser2 frontend fails for a nested WHERE construct.
In nemovar, ens_grd.F90 (at least) contains a nested WHERE:
WHERE ( z_lenp4(:,:) <= 0.0_wp )
! Set off-diagonal elements to zero
p_dal%D12(:,:,1) = 0.0_wp
! Compute the square of the geometric mean of the length scales associated with the principal axes
z_lenp2(:,:) = SQRT( p_dal%D11(:,:,1) * p_dal%D22(:,:,1) )
WHERE ( z_lenp2(:,:) == 0.0_wp )
! Minimum allowed values
p_dal%D11(:,:,1) = p_ens%D11_min(:,:)
p_dal%D22(:,:,1) = p_ens%D22_min(:,:)
z_lenp2(:,:) = z_lenp2_min(:,:)
END WHERE
END WHERE
and PSyclone falls over with an internal error:
File "/home/kbc59144/Projects/PSyclone/src/psyclone/psyir/frontend/fparser2.py", line 3150, in _where_construct_handler
self._array_syntax_to_indexed(ifblock, loop_vars)
File "/home/kbc59144/Projects/PSyclone/src/psyclone/psyir/frontend/fparser2.py", line 2851, in _array_syntax_to_indexed
_ = self._array_notation_rank(assign.lhs)
File "/home/kbc59144/Projects/PSyclone/src/psyclone/psyir/frontend/fparser2.py", line 2799, in _array_notation_rank
raise InternalError(psyclone.errors.InternalError: PSyclone internal error: No array access found in node 'p_dal'
I've added a test on 1651_nested_where.
An update: I've just brought the branch mentioned above to master and the 'new' test that has been added still fails in the same way.