PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

pointer args. to subroutine (different answer in 5.2)

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
oysteinls



Joined: 04 Aug 2004
Posts: 1

PostPosted: Mon Sep 27, 2004 2:58 pm    Post subject: pointer args. to subroutine (different answer in 5.2) Reply with quote

Hi,
I don't know if this qualifies as a compiler bug, but the following little program gives different answer in version 5.2 of the compiler than in 5.0 or 5.1:
----------------
Code:
program test
  real ,dimension(:), pointer :: a
  real, target :: e(2)

  a => e
  a(1) = 1
  a(2) = 3
  print*, 'a=',a
  call sub(a,a)
  print*, 'a=',a
end program test

subroutine sub(x,y)
  real x(2),y(2)
  y = x+1
  return
end subroutine sub

-----------------------------

With the new version of the compiler I get:
[ols@dhcp4154 tmp]$ pgf90 -V -g test.f90

pgf90 5.2-2
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2004, STMicroelectronics, Inc. All Rights Reserved.
PGF90/any Linux/x86 5.2-2
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2004, STMicroelectronics, Inc. All Rights Reserved.
PGF90/x86 Linux/x86 5.2-2
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2004, STMicroelectronics, Inc. All Rights Reserved.
[ols@dhcp4154 tmp]$ ./a.out
a= 1.000000 3.000000
a= 1.000000 3.000000
---------------------------------
while in the 5.1 release I get the expected result (2.0, 4.0) in the second output line. This only happens when I declare A as a pointer; with A an ordinary array I get the expected result.

So am I using pointers incorrectly or is this a compiler bug?

Oystein
Back to top
View user's profile
mkcolg



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

PostPosted: Mon Sep 27, 2004 4:47 pm    Post subject: Error only in 5.2-2 Reply with quote

The code works in 5.2-1, but fails with 5.2-2, so we obviously have a bug. The good news is that this has been fixed as part of the upcoming 5.2-4 release. Once available, I would recommend upgrading.

Thanks for the great example!

- 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