replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Bug with array sections involving Derived Types
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 array sections involving Derived Types

 
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: Sun Jul 31, 2011 7:32 pm    Post subject: Bug with array sections involving Derived Types Reply with quote

In Fortran 90/95, array sections can be formed from arrays of derived types. However, it does not work in FTN95 if the derived type component is an array.

In the following code, the compiler complains that foo(:)%a(1) and has extent 1 and b has extent 10. But, actually they both have extent 10.

I get similar errors at run time using most of the intrinsics which expect arrays (pack, minval, maxval etc.)

I discovered this today; I am trying to pack a derived type array section under the control of a MASK so I can pass it to my own subroutine.

It seems the compiler is confusing the dimensions of a and foo. (It compiles if a and foo are both dimension 10).

It also works if the component variables is not an array.

Hope this is clear; its kind of difficult to explain.

Code:

program anon

   type :: foo_type
      real :: a(1)
   end type foo_type

   integer i
   type(foo_type) :: foo(10) !< Array of derived type
   real :: b(10) 

   ! Assign some values
   do i=1, 10
      foo(i)%a(1) = 1.0
   end do

   ! Compiler thinks RHS has extent 1 (but its extent 10)
   ! error 331 - Non-conformant array shapes in first rank of an array expression (10 and 1)
   b = foo(:)%a(1)

   ! The next line works (I think)
   !forall(i=1:10) b(i)=foo(i)%a(1)

   ! This doesn't work
   ! print *, maxval(foo(:)%a(1))

   ! This doesn't work either.
   ! call my_array_proc(  pack(foo(:)%a(1), flags(:))  )

   do i=1, 10
      print *, b(i)
   end do

end program anon

_________________
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: Mon Aug 01, 2011 6:58 am    Post subject: Reply with quote

OK. I have logged this as a bug that needs fixing.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


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

PostPosted: Wed Nov 16, 2011 6:49 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:29 pm    Post subject: Reply with quote

Thanks Paul.
_________________
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