forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Valid WHERE construct gets rejected by compiler

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Sat Sep 12, 2020 10:27 am    Post subject: Valid WHERE construct gets rejected by compiler Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Sat Sep 12, 2020 1:52 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Sat Sep 12, 2020 3:52 pm    Post subject: Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Fri Aug 06, 2021 10:28 am    Post subject: Reply with quote

This failure in FTN95 has now been fixed.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group