(j3.2006) issues with branching out a BLOCK construct

Bill Long longb
Thu Oct 21 16:23:01 EDT 2010



Jim Xia wrote:
> 
> I can't recall if this has been discussed.  Consider the following code
> 
> BLOCK
>    real, allocatable :: x(:), y(:)[:]
> ...
>    allocate (x(n))
>    allocate (y(n)[*])
> ...
>    if (condition) GO TO 10
> ,..
> END BLOCK
> 
> 
> 10 .. code to continue
> ...
> 

Quoted text lifted from 10-007.
> 
> The issue is when the execution branches out of the BLOCK construct, 

"Execution of the block is completed when
       ? the last executable construct in the sequence is executed,
       ? a branch (8.2) within the block that has a branch target 
outside the block occurs,"
....

> what happens to local allocatable variables x and y.  Are they 
> automatically deallocated? 

"When a BLOCK construct terminates, an unsaved allocatable local 
variable of the construct is deallocated."

[Should we say "completes" instead of "terminates" here, to be consistent?]

> Does standard say anything about their 
> deallocation?  

Yes, see above.

> Also what happens to the entities require finalizations?

"When an allocatable entity is deallocated, it is finalized."

>  Does branching out of a BLOCK construct considered as termination of a 
> BLOCK construct?

Yes, see above.

Cheers,
Bill

> 
> 
> Jim Xia
> 
> XL Fortran Compiler Test
> IBM Toronto Lab at 8200 Warden Ave, Markham, On, L6G 1C7
> Phone (905) 413-3444  Tie-line 313-3444
> email: jimxia at ca.ibm.com
> D2/YF7/8200 /MKM
> 
> http://www.ibm.com/software/awdtools/fortran/xlfortran
> 

-- 
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