Andre
Joined: 19 Jan 2017 Posts: 14
|
Posted: Fri Feb 24, 2017 9:37 am Post subject: DO-loop accepting shape intrinsic as upper limit |
|
|
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.
Code: |
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
Code: |
...
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� |
|