 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Sun Jul 31, 2011 7:32 pm Post subject: Bug with array sections involving Derived Types |
|
|
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 |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8255 Location: Salford, UK
|
Posted: Mon Aug 01, 2011 6:58 am Post subject: |
|
|
OK. I have logged this as a bug that needs fixing. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8255 Location: Salford, UK
|
Posted: Wed Nov 16, 2011 6:49 pm Post subject: |
|
|
This bug has now been fixed for the next release. |
|
Back to top |
|
 |
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Fri Nov 18, 2011 7:29 pm Post subject: |
|
|
Thanks Paul. _________________ Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl |
|
Back to top |
|
 |
|
|
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
|