Silverfrost Forums

Welcome to our forums

DO-loop accepting shape intrinsic as upper limit

24 Feb 2017 8:37 #18886

The following code compiles fine in ftn95 (32bit) which it shouldn't. shape(a) returns an integer array, but the upper limit of a DO loop must be scalar.

subroutine foo(a)
    implicit none
    integer, intent(in) :: a(:,:)

    integer :: i

    print *, 'Shape of a:', shape(a)

    do i = 1, shape(a) ! <-- This should be size(shape(a))
        print *, 'Dimension', i, 'of a has', size(a, i), 'elements'
    enddo
end subroutine

Interestingly, adding /iso yields the same result but if used with /64 /iso, the compiler fails with

...
0009)     do i = 1, shape(a)
*** DO upper limit must be scalar valued
...

which is the correct behaviour. Summarized: ftn95 foo.f95 → Compiles ftn95 /iso foo.f95 → Compiles ftn95 /64 foo.f95 → Compiles ftn95 /64 /iso foo.f95 → Fails (correct behavior).

Best, André

25 Feb 2017 8:23 #18892

Thank you. I have made not of this.

23 Mar 2017 9:43 #19226

This has now been fixed for the next release of FTN95.

Please login to reply.