(j3.2006) Deallocation of associated pointers
philippe marguinaud
pmarguinaud
Mon Feb 11 01:47:30 EST 2013
Hi all,
I have a question about deallocating a pointer which was associated with an allocated target; Fortran standard says (ISO/IEC FCD 1539-1:2004
6.3.3.2) :
"If a pointer appears in a DEALLOCATE statement, it shall be associated
with the whole of an object that was created by allocation."
When compiled with ifort, the following piece of code produces an error for the second deallocate statement :
PROGRAM MAIN
CALL TOTO (100)
CONTAINS
SUBROUTINE TOTO (N)
REAL, POINTER :: X1 (:), Y1 (:)
REAL, POINTER :: X2 (:), Y2 (:)
ALLOCATE (X1 (1:N), X2 (1:N))
Y1 => X1
Y2 => X2 (1:N)
DEALLOCATE (Y1, STAT = IERR)
WRITE (0, *) " IERR/Y1 = ", IERR
DEALLOCATE (Y2, STAT = IERR)
WRITE (0, *) " IERR/Y2 = ", IERR
END SUBROUTINE TOTO
END
$ ifort alloc.F90
$ ./a.out
IERR/Y1 = 0
IERR/Y2 = 173
Is the Intel compiler right, or is the second deallocate valid Fortran ?
Best regards,
Philippe Marguinaud
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20130211/9752a345/attachment.html
More information about the J3
mailing list