(j3.2006) functions with allocatable result variables

Malcolm Cohen malcolm
Sun Apr 15 20:46:46 EDT 2012


>Suppose a function has an allocatable result variable.
>Paragraph 3 of Clause 12.6.2.2 [307:18-19] states
>
>      If the result variable is not a pointer,
>      its value shall be defined by the function.
>
>For the value of an allocatable variable to be defined,
>the variable must be allocated.

Yes.

>  Is it intended that an
>allocatable result variable must be allocated on return
>from the function?

That is what the words say, and have said so since 1998.  Yes, this was 
intentional.

>Suppose F is a function whose result is allocatable.
>Consider the code fragment
>
>       DO, WHILE(ALLOCATED(F())

This is not conforming.  The result of a function reference does not have the 
ALLOCATABLE attribute any more than it has the ASYNCHRONOUS, TARGET or VOLATILE 
attributes.

I quote
  "An entity with the ALLOCATABLE attribute is a ***VARIABLE***"
(emphasis mine).

Cheers.
-- 
................................Malcolm Cohen, Nihon NAG, Tokyo. 




More information about the J3 mailing list