(j3.2006) Question on MOVE_ALLOC

Bill Long longb
Tue Aug 23 10:22:00 EDT 2016


Hi Reinhold,

You have a host-associated variable Y that appears in a variable definition context (corresponds to an INTENT(OUT) argument), which is not allowed in a PURE procedure.   C1295 in 16-007r1.  MOVE_ALLOC is PURE as long as the arguments are local variables. 

Cheers,
Bill


On Aug 23, 2016, at 8:43 AM, Bader, Reinhold <Reinhold.Bader at lrz.de> wrote:

> 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
>  
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3

Bill Long                                                                       longb at cray.com
Fortran Technical Support  &                                  voice:  651-605-9024
Bioinformatics Software Development                     fax:  651-605-9142
Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101





More information about the J3 mailing list