(j3.2006) Question on MOVE_ALLOC
Bader, Reinhold
Reinhold.Bader
Tue Aug 23 09:43:11 EDT 2016
Dear J3,
consider the following program:
module m02
implicit none
real, allocatable :: x(:), y(:)
contains
pure subroutine p(i)
integer, intent(inout) :: i
if (i == 1) call move_alloc(x, y)
i = 2
end subroutine
end module
program q
use m02
implicit none
integer :: i
i = 1
allocate(x(2))
call p(i)
if (i==2) then
write(*,*) 'Computation OK'
end if
end program
Because MOVE_ALLOC is pure, it can be invoked inside the PURE subroutine. On the other hand it appears
that we have a side effect here, not with respect to the data, but to the allocation status of module variables.
Was it a mistake to make MOVE_ALLOC pure, or is there something missing in the PURE constraint list of chapter
12.7 (16-007r1)?
Cheers
Reinhold
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20160823/735865a8/attachment.html
More information about the J3
mailing list