PSyclone icon indicating copy to clipboard operation
PSyclone copied to clipboard

psyir support for arrays declared with indexed bounds

Open rupertford opened this issue 1 year ago • 1 comments

We need to add support for arrays declared like a(0:n-1). At the moment they are stored as unknown fortran type, however this caused psyad to fail in poly2d_w3_reconstruction_kernel_mod.F90

rupertford avatar Jul 17 '22 13:07 rupertford

This is also an issue in WW3 code - it prevents the application of HoistLocalArrayTrans to quite a number of arrays.

arporter avatar Sep 30 '22 15:09 arporter

It is also an issue in NEMO 4.2 now that the tiling complicates the array declarations.

arporter avatar Dec 12 '22 16:12 arporter

Simon has reported that when PSyclone processes, e.g.:

subroutine my_sub(arg)
  implicit none
  real, dimension(2:) :: arg
  arg(:) = 0.0
end subroutine my_sub

then it loses the lower bound of the array declaration and generates incorrect code:

subroutine my_sub(arg)
  real, dimension(:) :: arg

  arg(:) = 0.0

end subroutine my_sub

arporter avatar Mar 22 '23 13:03 arporter

So far it seems that the forms of declaration that this issue was originally opened for are already supported. However, a(4:) ends up with an ArrayType with shape = [Extent.Attribute] which explains why we lose the lower bound.

arporter avatar Mar 23 '23 12:03 arporter

I think we want shape = [ArrayBounds(Literal(4), Extent.Attribute)]

arporter avatar Mar 23 '23 12:03 arporter

image

arporter avatar Mar 23 '23 16:03 arporter