Silverfrost Forums

Welcome to our forums

SIZE does not return 0 after DEALLOCATE

21 Apr 2008 11:49 #3060

Why does the following program not indicate siez=0 in the third row of output? (The smiley face in line 3, seems to be an error, the code is written as ( : ) without the spaces.)

PROGRAM p IMPLICIT NONE INTEGER, DIMENSION(:), ALLOCATABLE :: i INTEGER :: ios ! WRITE (UNIT=,FMT=) ALLOCATED(i),SIZE(i) ALLOCATE (i(5),STAT=ios) WRITE (UNIT=,FMT=) ALLOCATED(i),SIZE(i) DEALLOCATE (i) WRITE (UNIT=,FMT=) ALLOCATED(i),SIZE(i) ! END PROGRAM p

21 Apr 2008 4:18 #3061

The Fortran 95 Standard says that SIZE must not be used when the array has not be allocated. So this is essentially a programming error that is difficult for FTN95 to trap.

When I tested with /checkmate the result was zero but you may not be able depend on this.

Please login to reply.