replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Bug with any/all intrinsic functions
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 

Bug with any/all intrinsic functions

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



Joined: 17 Jul 2009
Posts: 560
Location: UK

PostPosted: Sat May 21, 2011 6:05 pm    Post subject: Bug with any/all intrinsic functions Reply with quote

I have isolated a problem with the use of all and any intrinsic functions. I am using the latest version 6.1 of the compiler. Hopefully, the code below is small enough to allow this to be debugged.

The code allocates an array foo to have 5 elements. Each element of foo is a Derived type containing a logical array flags of 4 elements. I use any to test whether any of the flags is true and print a message to the screen.

The compiler should be creating a temporary array for the array section passed to any (edit: actually, it doesn't need to create a temporary array, but should act as if it does) . However, the program fails to compile, giving "Internal Compiler Error 116" in CHECKMATE mode. (I get the same error using the all intrinsic as well). It compiles if I turn CHECKMATE off.

I can get the code to compile and run in CHECKMATE mode by just using a fixed size array for foo (i.e. not allocating the array) so the error is something to do with allocatable arrays with array sub-components I think.

I'm using 32 bit Windows Vista.

Code:

program anon

   ! A Derived type containing a logical array
   type foo_type
      logical :: flags(4)
   end type foo_type

   ! Allocatable array
   type (foo_type), allocatable :: foo(:)

   ! Allocate array
   allocate(foo(5))

   ! Setup some flags in first element (all false except the last one)
   foo(1)%flags = .false.    ! Set all four flags to false
   foo(1)%flags(4) = .true.  ! Set the last flag to true

   ! Print whether any flags  in the first element are true or not
   if (any(foo(1)%flags(1:4))) then
      print *, 'One or more flags in foo is True'
   else
      print *, 'All the flags in foo are False'
   end if

   ! Deallocate array
   deallocate(foo)

end program anon


Best regards
David.


Last edited by davidb on Fri Jul 29, 2011 10:26 am; edited 1 time in total
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Sun May 22, 2011 3:46 pm    Post subject: Reply with quote

OK. I can reproduce this bug and will investigate.
Back to top
View user's profile Send private message AIM Address
davidb



Joined: 17 Jul 2009
Posts: 560
Location: UK

PostPosted: Fri Jul 29, 2011 10:20 am    Post subject: Reply with quote

What did you find? Any chance of this being fixed in the next release, and when this is likely to be.

I have "fixed" it by just doing an element-by-element equivalence with .TRUE. (which should be a "No Operation", NOP, for each element). This seems to repair the compiler's view of the dope vector passed to the any intrinsic (and the all intrinsic which exhibits the same bug).

I also found for strides of 2,3,4 ... (e.g. foo(1)%flags(1:3:2)), the compiler works OK, so its just strides of 1 that have this error.

Code:

program anon

   ! A Derived type containing a logical array
   type foo_type
      logical :: flags(4)
   end type foo_type

   ! Allocatable array
   type (foo_type), allocatable :: foo(:)

   ! Allocate array
   allocate(foo(5))

   ! Setup some flags in first element (all false except the last one)
   foo(1)%flags = .false.    ! Set all four flags to false
   foo(1)%flags(4) = .true.  ! Set the last flag to true

   ! Print whether any flags  in the first element are true or not
   if (any( foo(1)%flags(1:4) .EQV. .TRUE. )) then
      print *, 'One or more flags in foo is True'
   else
      print *, 'All the flags in foo are False'
   end if

   ! Deallocate array
   deallocate(foo)

end program anon


Notice that the scalar .TRUE. is conformable with the array of flags using the rules in Fortran 90/95/2003/2008 rules for relational operators we discussed in another thread.

Regards
David
_________________
Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Sat Jul 30, 2011 6:59 am    Post subject: Reply with quote

This is still on my "to do" list and I still hope to have it fixed for the next release.
Back to top
View user's profile Send private message AIM Address
davidb



Joined: 17 Jul 2009
Posts: 560
Location: UK

PostPosted: Sat Jul 30, 2011 8:48 am    Post subject: Reply with quote

Thank you.
_________________
Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Wed Nov 16, 2011 8:11 pm    Post subject: Reply with quote

This bug has now been fixed for the next release.
Back to top
View user's profile Send private message AIM Address
davidb



Joined: 17 Jul 2009
Posts: 560
Location: UK

PostPosted: Fri Nov 18, 2011 7:27 pm    Post subject: Reply with quote

Thanks very much.
_________________
Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl
Back to top
View user's profile Send private message
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