(j3.2006) a question on interp F08/0049
Mon Nov 15 03:26:43 EST 2010
Jim Xia wrote:
> elemental function g (y)
> integer, intent(in) :: y
> character(image_index(x, sub)) g
>If this is allowed, then we will end up with this function call g() on each
>image results in different return result characteristic. Is this something we
>intended to allow?
I don't see any issue here.
Firstly, procedures have characteristics -- an invocation of a procedure does
not have characteristics in itself. So factually, g has characteristics that
are "the same" as themselves. In this case, g has a type (character) with a
length type parameter that that is non-constant, and the exact dependence on the
other entities is also a characteristic.
Secondly, there is no function call to g that executes on multiple images. One
invocation of g only occurs on one image. Elemental doesn't do anything across
images, it does things across elements of an array on the same image.
We have been allowed to have functions that return results with non-constant
type parameter and array bounds/shapes since F90. For non-constant type
parameters, we've been allowed to have them on elemental functions since F90 for
intrinsic functions and F95 for user-defined ones.
Coarrays don't have anything to do with this - independent invocations of a
procedure are independent invocations of a procedure, whether those invocations
are subsequent ones from the same image or possibly-unordered ones from
In any case, whether the function is elemental or not, the specification
expression is evaluated on the invoking image. Nothing weird is going on here.
For elemental functions the specification expression is constrained such that it
will give the same answer for each element (so it only actually needs to be
Don't confuse this with the COELEMENTAL attribute! Of course coelemental
functions cannot have variable type parameters at this time.
................................Malcolm Cohen, Nihon NAG, Tokyo.
More information about the J3