To: J3 J3/20-120r1
From: Van Snyder
Subject: Rank-agnostic allocation and pointer assignment -- Syntax
Date: 2020-February-28
References: 18-247 19-110r1 19-150 19-173r1
1. Syntax for rank-agnostic allocation
======================================
- The bounds of a deferred-shape object can be specified during
allocation using rank-one integer arrays whose extents are constant
and the same as the rank of the object.
- Either bound can be specified by a scalar, which is broadcast to the
shape of the other.
- The size of the array or arrays that specify the bounds can be zero,
in which case the allocated object shall be a scalar.
- These arrays can be expressions.
Examples:
allocate ( Y ( A ) ) ! lbound(Y) == [1,1,...], ubound(Y) == A,
! SIZE(A,1) is a constant expression
is equivalent to
allocate ( Y ( A(1), A(2), ..., A(size(A,1)) )
allocate ( Y ( B : A ) ) ! lbound(Y) == B, ubound(Y) == A, SIZE(A,1)
! == SIZE(B,1) are constant expressions
is equivalent to
allocate Y ( B(1):A(1), B(2):A(2), ..., B(size(A,1)):A(size(A,1)) )
allocate ( Y ( lbound(A)-1 : ubound(A) + 1 ) ) ! Y is the same shape
! as the interior of A
allocate ( Y ( 0 : ubound(A) + 1 ) )
is equivalent to
allocate ( Y ( 0:ubound(A,1)+1, 0:ubound(A,2)+1, ... &
& 0:ubound(A,size(A),1)+1 )
2. Syntax for rank-agnostic pointer rank remapping
==================================================
- The bounds of a pointer can be specified during rank-remapping pointer
assignment using rank-one integer arrays whose extents are constant
and the same as the rank of the pointer.
- Either bound can be specified by a scalar, which is broadcast to the
shape of the other.
- The size of the array or arrays that specify the bounds can be zero,
in which case the pointer shall be a scalar.
- These arrays can be expressions.
Examples:
P(A:B) => M(...) ! such that the is contiguous
is equivalent to
P ( A(1):B(1), A(2):B(2), ..., A(size(A,1)):B(size(A,1)) ) => M(...)
P ( lbound(A)-1 : ubound(A)+1 ) => M(...)
is equivalent to
P ( lbound(A,1)-1:ubound(A,1)+1, lbound(A,2)-1:ubound(A,2), ... &
& lbound(A,size(A,1))-1:ubound(A,size(A,1))+1 ) => M(...)
P ( 0:ubound(A) ) => M(...)
is equivalent to
P ( 0:ubound(A,1), 0:ubound(A,2), ..., 0:ubound(A,size(A,1)) ) => &
& M(...)
3. Syntax for rank-agnostic specification of pointer lower bounds
=================================================================
- The lower bounds of a pointer can be specified during pointer
assignment using a rank-one integer array whose size is a constant
equal to the dimension of the pointer.
- The size of the array that specifies the lower bounds can be zero, in
which case the pointer shall be a scalar.
- This array can be an expression.
Examples:
P(A:) => M(...)
is equivalent to
P( A(1):, A(2):, ..., A(size(A,1)): ) => M(...)