Silverfrost Forums

Welcome to our forums

Valid WHERE construct gets rejected by compiler

12 Sep 2020 9:27 #26344

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:

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.

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
12 Sep 2020 12:52 #26345

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.

12 Sep 2020 2:52 #26346

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.

6 Aug 2021 9:28 #28150

This failure in FTN95 has now been fixed.

Please login to reply.