|
| View previous topic :: View next topic |
| Author |
Message |
tesfortran
Joined: 04 Dec 2012 Posts: 3
|
Posted: Fri Dec 07, 2012 10:23 am Post subject: compiler bug for array pointer assignments |
|
|
I have come across what appears to be a compiler bug.
I have a very simple program that demonstrates this. I want to point a 3D array at an equivalent sized 1D array
here is the code
| Code: |
MODULE array_1D
integer, allocatable, target, save :: array(:)
end Module array_1D
C-----------------------------------------------------
PROGRAM main
call alloc
call write1
call write2
call sub
call write1
call write2
end
C-----------------------------------------------------
Subroutine alloc
use array_1D
l=2
n=3
m=4
allocate(array(l*n*m))
array =0
return
end
C-----------------------------------------------------
Subroutine sub
use array_1D
l=2
n=3
m=4
do i=1,l*n*m
array(i)=i
end do
return
end
C-----------------------------------------------------
Subroutine write1
use array_1D
l=2
n=3
m=4
write(*,'(24I4)')(array(i),i=1,l*n*m)
return
end
C-----------------------------------------------------
Subroutine write2
use array_1D
integer, pointer :: array3d(:,:,:)
l=2
n=3
m=4
array3d(1:l,1:n,1:m)=>array
write(*,'(24I4)')(((array3d(i,j,k),i=1,l),j=1,n),k=1,m)
return
end
|
when I compile this I don't get any compile time errors; however when I run it I get the following results.
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
1 2 3 4 5 6 6 7 8 9 10 11 11 12 13 14 15 16 16 17 18 19 20 21
As you can see it appears that the compiler is miscalculating the offset in the memory for the third dimension. I get similar results with different ranges of l,n,m. I got the same results using PGF90 or PGFORTRAN
I compiled the exact same source code using another brand of compiler and got the expected results:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Is there something wrong with the compiler or am I missing something here? |
|
| Back to top |
|
 |
mkcolg
Joined: 30 Jun 2004 Posts: 4995 Location: The Portland Group Inc.
|
Posted: Fri Dec 07, 2012 11:14 am Post subject: |
|
|
Hi tesfortran,
Thanks for the report. I was able to recreate the issue here and have sent it to our compiler engineers for further investigation (TPR#19037).
- Mat |
|
| Back to top |
|
 |
jtull
Joined: 30 Jun 2004 Posts: 233
|
Posted: Tue May 21, 2013 6:02 pm Post subject: TPR 19037 is fixed as of 13.1 |
|
|
19037 - UF: Array remapping gives incorrect results
was fixed in the 13.1 release.
thanks,
dave |
|
| 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, 2002 phpBB Group
|