Jing Guo ([log in to unmask]) writes:
>subroutine aeqp(a,h)
> real,dimension(:),intent(out) :: a
> type(rank1fun),intent(in) :: h
>
>! Since h has intent(in), the DEC compiler does not like the idea
>! of deallocate() the memory addressed by an intent(in) argument.
>! A temporary pointer (p) is used to handle the deallocate().
>!
>! My question is: which is more the standard comforming, Cray/SGI
>! or DEC? Is this kind of deallocate() allowed under the standard?
>
> real,pointer,dimension(:) :: p
> p=>h%p
>
> a(:)=h%p(:)
> deallocate(p)
> print*,'dealloc'
>end subroutine aeqp
Here's my reading of the matter, quoting from the F90 standard:
5.1.2.3 INTENT attribute
The INTENT(IN) attribute specifies that the dummy argument
must not be redefined or become undefined during the execution
of the procedure.
6.3.1.2 Allocation of pointer targets
Allocation of a pointer creates an object that implicitly
has the TARGET attribute.
6.3.3 DEALLOCATE statement
The DEALLOCATE statement ... causes pointer targets to become
deallocated and the pointers to be disassociated.
6.3.3.2 Deallocation of pointer targets
Deallocating a pointer target causes the pointer association
of any other pointer that is associated with the target or a
portion of the target to become undefined.
14.7.6 Events that cause variables to become undefined
(15) When the association status of a pointer becomes undefined
or disassociated, the pointer becomes undefined.
Therefore, I conclude that DEALLOCATE of an INTENT(IN) pointer target is
prohibited by the standard. Furthermore, your making a copy of the pointer
h and deallocating it also violates the INTENT(IN) attribute of h, though
our compiler doesn't detect that.
Steve Lionel mailto:[log in to unmask]
Fortran Development http://www.digital.com/info/slionel.html
Digital Equipment Corporation
110 Spit Brook Road, ZKO2-3/N30
Nashua, NH 03062-2698 "Free advice is worth every cent"
For information on DIGITAL Fortran, see http://www.digital.com/fortran
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|