PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Array Expression

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
lionel@imhd.net



Joined: 09 Feb 2005
Posts: 5

PostPosted: Thu Feb 16, 2006 1:43 pm    Post subject: Array Expression Reply with quote

Hello, why does this little program give me an error?


    program array
    real :: a(4),b(4)

    a=(/0.,3.,3.,1./)
    b=(/0.,3.,3.,1./)

    if (a.eq.b) write (6,*) "a and b are the same"

    stop
    end

PGF90-S-0083-Vector expression used where scalar expression required (array.f: 8)
0 inform, 0 warnings, 1 severes, 0 fatal for array

I thought Fortran 90 allowed these expressions. Thanks!
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6141
Location: The Portland Group Inc.

PostPosted: Thu Feb 16, 2006 5:29 pm    Post subject: Reply with quote

Hi lionel,

The expression "a.eq.b" is valid. However, the expression returns an array of logicals which can't be used in an if statement. Adding the 'all' intrinsic to perform a reduction should get the desired behavior:

Code:
% cat tmp.f90
      program array
      real :: a(4),b(4)

      a=(/0.,3.,3.,1./)
      b=(/0.,3.,3.,1./)

      if (all(a.eq.b)) write (6,*) "a and b are the same"

      stop
      end
% pgf90 tmp.f90
% a.out
 a and b are the same
FORTRAN STOP


Hope this helps,
Mat
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
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 © phpBB Group