value and intent(out) on kernels

I’m quite confused about the Fortran compiler behavior, when using the value keyword on a kernel parameter. It seems to be possible to declare a parameter both value and intent(out) at the same time, although this clearly cannot be directly translated to CUDA C.

In my tests it does not work, data is never received back on the host, but also no compiler error is produced. Shouldn’t the combinations value,intent(out) and value,intent(inout) be forbidden by the compiler?

— Example code —
module device_code

contains

attributes(global) subroutine eval(x,y)
implicit none
integer, value, intent(in) :: x
integer, value, intent(out) :: y
y=x
end subroutine eval

end module device_code

program demo

use device_code

implicit none

integer :: x,y

x=2
y=3

call eval<<<1>>>(x,y)

print *,“x=”,x
print *,“y=”,y

end program demo

Hi Denis,

You are correct in that the F2003 standard explicitly forbids the use of INTENT(OUT) together with VALUE. Since INTENT is only used as a hint to the compiler, in this case, the compiler is simply ignoring the INTENT(OUT) since it’s use together with VALUE doesn’t make sense. However, we agree that the compiler should be issuing an error in these cases to avoid possible confusion by a user.

I have submitted a report (TPR#18010) and requested our engineers flag this situation as a semantic error.

Best Regards,
Mat