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 

Copying into array slices - new error?

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



Joined: 05 Jan 2006
Posts: 18

PostPosted: Wed Jun 13, 2007 11:41 am    Post subject: Copying into array slices - new error? Reply with quote

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
Code:
a(i,j,k,l) = b(k)
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
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Wed Jun 13, 2007 12:57 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


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

PostPosted: Tue Jun 26, 2007 2:02 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
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