(j3.2006) Question on MOVE_ALLOC
Bader, Reinhold
Reinhold.Bader
Tue Aug 23 13:39:59 EDT 2016
> -----Urspr?ngliche Nachricht-----
> Von: j3-bounces at mailman.j3-fortran.org [mailto:j3-bounces at mailman.j3-
> fortran.org] Im Auftrag von Bill Long
> Gesendet: Dienstag, 23. August 2016 19:31
> An: fortran standards email list for J3 <j3 at mailman.j3-fortran.org>
> Betreff: Re: (j3.2006) Question on MOVE_ALLOC
>
>
> On Aug 23, 2016, at 11:33 AM, Bader, Reinhold <Reinhold.Bader at lrz.de>
> wrote:
>
> > Hello Bill,
> >
> > I agree that Y in effect appears in a variable definition context (and
> > X in a variable undefinition context). Unfortunately the list in
> > 16.6.7 does not include the FROM or TO arguments of MOVE_ALLOC. The
> nearest it comes is that item (9) says "allocate-object", but this is not
> referenced In the description of MOVE_ALLOC.
>
> You need item (10). Actual arguments corresponding to INTENT(OUT)
> dummy arguments are not allowed, but the second argument to
> MOVE_ALLOC is INTENT(OUT). It doesn't really matter what MOVE_ALLOC
> does internally, only that it has an explicit interface (as all intrinsics do).
Ah yes, I only looked at the procedure, not at MOVE_ALLOC itself. So it is the compilers that have bugs :-/
Still, this only answers half the question. If I convert Y to a local variable, then there still is X that becomes deallocated.
>
> Cheers,
> Bill
>
>
>
> >
> > All compilers I tried (including yours) happily compile and run the code, by
> the way.
> >
> > Cheers
> > Reinhold
> >
> > -----Urspr?ngliche Nachricht-----
> > Von: j3-bounces at mailman.j3-fortran.org
> > [mailto:j3-bounces at mailman.j3-fortran.org] Im Auftrag von Bill Long
> > Gesendet: Dienstag, 23. August 2016 16:22
> > An: fortran standards email list for J3 <j3 at mailman.j3-fortran.org>
> > Betreff: Re: (j3.2006) Question on MOVE_ALLOC
> >
> > 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
> >
> >
> > _______________________________________________
> > J3 mailing list
> > J3 at mailman.j3-fortran.org
> > http://mailman.j3-fortran.org/mailman/listinfo/j3
> > _______________________________________________
> > 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
>
>
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3
More information about the J3
mailing list