|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
mhudson
Joined: 05 Jan 2006 Posts: 18
|
Posted: Wed Jun 13, 2007 11:41 am Post subject: Copying into array slices - new error? |
|
|
Hi All,
In a product that has always appeared to work fine up till now I have some code a bit like this:
Code: | integer :: a(10,10,10,10), b(10)
do i = 1,10
a(:,:,1:10,i) = b(1:10)
end do
| The code is supposed to be copying the contents of the array b into the relevant 3rd dimension elements of array a such that for any values of i and j (for fixed l).
Compiling the following program:
Code: | program test
implicit none
integer :: i
integer :: a(10,10,10,10), b(10)
do i = 1,10
a(:,:,1:10,i) = b(1:10)
end do
end program test
| leads to the error message:
0008) a(:,:,1:10,i) = b(1:10)
*** Rank 1 arrays cannot be mixed with rank 3 arrays in an array expression
Now, I *know* that this code compiles under 4.9.1 and pretty sure it comppiled fine under 5.01. I am now using 5.10 and the code does not compile.
Am I trying to do something that should never have worked?
Mark. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Wed Jun 13, 2007 12:57 pm Post subject: |
|
|
There is a new test in the compiler and it looks like it needs refining.
In the mean time, if you are sure that the code has the desired result then you could get the error number <n> for this particular error and use /IGNORE <n> on the FTN95 command line. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Tue Jun 26, 2007 2:02 pm Post subject: |
|
|
We have checked this out and the array assignment is not valid Fortran.
The arrays must have the same "shape" or the RHS must be a scalar.
A previous version of FTN95 allowed this but only gave the expected result in exceptional circumstances (perhaps when the shape was uniform, i.e. the same length on each dimension).
You should be able to use
a(j,k,1:10,i) = b(1:10)
and range over i, j and k.
The current version of FTN95 is correct in not allowing this construction. |
|
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
|