(j3.2006) Simple coarray declaration questions

John Reid John.Reid
Wed Jun 1 08:49:26 EDT 2011


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.

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

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.
-- 
Scanned by iCritical.



More information about the J3 mailing list