View previous topic :: View next topic |
Author |
Message |
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Sat Sep 12, 2020 10:27 am Post subject: Valid WHERE construct gets rejected by compiler |
|
|
The masked array assignment using WHERE in the program below is perfectly valid; indeed, FTN95 8.4 and 7.2 accept it and the output they give is correct, as well. However, FTN95 8.65 rejects it with the message:
Code: | 0007) x(idx) = 2.5*idx
*** The test of the enclosing WHERE statement is rank 1, whereas the left hand side of this assignment is a scalar |
and similarly for Line-9.
Code: | program Where_Bug
implicit none
integer :: idx(8) = (/ 4, 3, 7, 5, 2, 6, 2, 1 /)
real :: x(8)
!
where (idx > 4)
x(idx) = 2.5*idx
else where
x(idx) = 3.1*idx
end where
print '(8F5.1)',x ! Expected: 3.1 6.2 9.3 12.4 12.5 15.0 17.5 0.0
end program |
|
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7924 Location: Salford, UK
|
Posted: Sat Sep 12, 2020 1:52 pm Post subject: |
|
|
mecej4
Thank you for the feedback. It looks like the use of vector subscripts within a WHERE construct was not anticipated. I am assuming that this is permitted in the Fortran 95 standard. |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Sat Sep 12, 2020 3:52 pm Post subject: |
|
|
Paul,
An objection could be raised that an assignment in the WHERE construct involves a many-one array section. The appearance of '2' twice is what produced the '0.0' at the end of the output.
To overcome that objection, which I did not anticipate, simply change the first '2' in the initialisation to '8'.
The rest of the bug report remains unchanged. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7924 Location: Salford, UK
|
Posted: Fri Aug 06, 2021 10:28 am Post subject: |
|
|
This failure in FTN95 has now been fixed. |
|
Back to top |
|
|
|