(j3.2006) (SC22WG5.5369) Question on PURE subroutines
Bader, Reinhold
Reinhold.Bader
Thu Dec 4 11:55:36 EST 2014
Hello all,
consider the program
module mod_proc_cont_01
implicit none
type :: cont
real, pointer :: p(:) => null()
end type cont
real, target :: p(2)
contains
pure subroutine pf(x)
type(cont), intent(inout) :: x
integer :: i
if (associated(x%p)) then
x%p = [ (real(2*i), i=1, size(x%p)) ]
end if
end subroutine pf
end module mod_proc_cont_01
program proc_cont_01
use mod_proc_cont_01
implicit none
type(cont) :: xx
p = [ 1.0, 2.0 ]
xx%p => p
call pf(xx)
write(*,*) p
end program proc_cont_01
It appears to conform to the Fortran 2008 standard; it is accepted by the compilers available to me. Yet it
appears to implement a side effect in a PURE procedure. Was this intended? If not, would adding the following
text in 007 fix the problem?
[312:30] After "any designator", add " with the POINTER attribute or "
Cheers
Reinhold
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20141204/4d6d7326/attachment.html
More information about the J3
mailing list