(j3.2006) Simple coarray declaration questions
Bill Long
longb
Wed Jun 1 09:01:53 EDT 2011
On 6/1/11 7:49 AM, John Reid wrote:
> Tobias Burnus wrote:
>> The following is probably trivial, but I still cannot make up my mind.
>> The code compiles with three compilers and is rejected with one. Is the
>> following program valid or not? I think it is invalid:
>>
>> subroutine test2()
>> type t
>> integer, allocatable :: a(:)[:]
>> end type t
>> type(t) :: x
>> allocate(x%a(1)[*])
>> end subroutine test2
>>
>> C526 A coarray or an object with a coarray ultimate
>> component shall be a dummy argument or have the
>> ALLOCATABLE or SAVE attribute.
>
> It is not valid since the constraint is not satisfied.
I agree, although for this example the constraint is a bit of overkill.
This could be implemented without much trouble, but is caught in a
constraint net that is somewhat over covering. The alternative is to
try to craft constraints that are narrower, but they then end up being
more complicated and detailed. Alternately, we could have gone the
simpler route and disallowed coarray components all together. This was
the compromise.
>
>> * * *
>>
>> And another example, rejected by two compilers, accepted by two:
>>
>> subroutine sub(n)
>> integer :: n
>> integer, SAVE :: A(4)[n,*]
>> end subroutine sub
>>
>> The rejecting compiler claim that the bounds need to be constant for
>> automatic arrays. I think the example is valid. While there is
Well, A is certainly not an automatic array. It has the SAVE attribute,
and its bounds are constant. That is about as un-automatic as possible.
>>
>> C513 An automatic object shall not have the SAVE attribute.
>>
>> the following shouldn't apply: "An automatic data object is a nondummy
>> data object with a type parameter or array bound that depends on the
>> value of a specification-expr that is not a constant expression."
>> Note the "bound" and not "cobound" (Cf. "1.3.27 cobound: bound (limit)
>> of a codimension" vs. "1.3.17 bound / array bound: limit of a dimension
>> of an array".)
>>
>> Is it indeed valid?
Yes, as explained below.
Cheers,
Bill
>
> I think it is, though I do not recall seeing such a declaration before. Every
> image has a coarray of size 4.
>
> In 5.3.6.3, we have:
>
> C529 (R511) A lower-cobound or upper-cobound that is not a constant expression
> shall appear only in a subprogram, BLOCK construct, or interface body.
>
> If an explicit-coshape coarray is a local variable of a subprogram or BLOCK
> construct and has cobounds that are not constant expressions, the cobounds are
> determined on entry to a procedure defined by the subprogram, or on execution of
> the BLOCK statement, by evaluating the cobounds expressions. The cobounds of
> such a coarray are unaffected by the redefinition or undefinition of any
> variable during execution of the procedure or BLOCK construct.
>
>
> Cheers,
>
> John.
--
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