(j3.2006) Did we intend to prohibit this?

Clune, Thomas L. GSFC-6101 thomas.l.clune
Fri Mar 10 16:47:01 EST 2017

> On Mar 10, 2017, at 2:09 PM, Van Snyder <Van.Snyder at jpl.nasa.gov> wrote:
> On Fri, 2017-03-10 at 16:13 +0900, Cohen Malcolm wrote:
>>> So how does it get deallocated?
>> "it" is not a variable, so does not get deallocated (in the Fortran
>> language sense of "deallocated").
>> You know what the function result variable is, and it is not the value
>> that is returned by the function, nor has it ever been.  The result
>> variable is what gets deallocated.
> So what does mean?
>        "If an executable construct references a function whose result
>        is allocatable or has an allocatable subobject, and the function
>        reference is executed, an allocatable result and any allocated
>        allocatable subobject of the result is deallocated after
>        execution of the innermost executable construct containing the
>        reference."
> If the result variable is in fact what gets deallocated, even though the
> word "variable" does not appear in, then the result variable
> of F(X) in
>  call move_alloc ( f(x), v )
> IS a variable, right?  So what's the problem with executing it?

The result variable of F(X) is not in the expression you provide.   Outside of F all you can ?see" is the result _value_.

I think that what you probably want in this situation is:

allocate(v, source=f(x))


- Tom

> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3

More information about the J3 mailing list