The following code does not compile with the latest compiler

Hi.

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


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:

$ 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.

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.

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.

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

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.