PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

The following code does not compile with the latest compiler

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming
View previous topic :: View next topic  
Author Message
alfvenwave



Joined: 08 Apr 2010
Posts: 79

PostPosted: Fri May 20, 2011 8:44 am    Post subject: The following code does not compile with the latest compiler Reply with quote

Hi.

This works with old versions of the PGI fortran compiler, but not the latest....


Code:


module pgitest

interface foo
attributes(device) function foo( Eb )  result( a )

      real*8,            intent(in)    :: Eb
      real*8,            intent(out)   :: a(2)
end function
end interface

contains

attributes(device) function foo( Eb ) result( a )

      implicit none

      real*8,            intent(in)    :: Eb
      real*8,            intent(out)   :: a(2)

!     Local variables:

      real*8                           :: rmin(2)

      a = log(rmin)

end function foo

end



I get the following error:

Code:

$ pgfortran -c pgitest.cuf
PGF90-S-0037-Contradictory data type specified for a (pgitest.cuf: 18)
PGF90-S-0095-Expression has wrong data type (pgitest.cuf: 24)
PGF90-S-0083-Vector expression used where scalar expression required (pgitest.cuf: 24)
  0 inform,   0 warnings,   3 severes, 0 fatal for foo


Any suggestions as to why this is, and what I need to do to get my code compiled with the latest compiler?

Rob.
Back to top
View user's profile
alfvenwave



Joined: 08 Apr 2010
Posts: 79

PostPosted: Fri May 20, 2011 8:55 am    Post subject: Reply with quote

I've solved my own problem. Clearly, defining an interface block is not necessary if you use the syntax function foo( a ) result( b ), and intent does not have to be set inside the function either.

It looks like you've removed the "redundancy". Great.....

Rob.
Back to top
View user's profile
alfvenwave



Joined: 08 Apr 2010
Posts: 79

PostPosted: Fri May 20, 2011 9:05 am    Post subject: Reply with quote

Saying that, I still think you need to use an interface if you want to be able to control the intent of all the input parameters - the new compiler does not see to want to play nicely with this.
Back to top
View user's profile
mkcolg



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

PostPosted: Fri May 20, 2011 9:17 am    Post subject: Reply with quote

Hi Rob,

Interfaces should be used to declare external or generic procedures. The module already defines an implicit interface for internal procedures, which in this case is clashing with the one defined in the interface. To fix, remove the interface. Previous compiler versions were not detecting this error.

Hope this helps,
Mat
Back to top
View user's profile
alfvenwave



Joined: 08 Apr 2010
Posts: 79

PostPosted: Fri May 20, 2011 10:12 am    Post subject: Reply with quote

Thanks Mat. At some stage I was planning on making a lot of my routines external, and hence had put the interfaces in ready....I can see that the redundancy is a bit silly though.

Thanks again,

Rob.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming 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