(j3.2006) LEN type parameter

Steve Lionel steve
Mon Dec 18 18:41:56 EST 2017


On 12/18/2017 6:28 PM, Van Snyder wrote:
>
>> Compiler 1: Error for both X and Y lines
>> Compiler 2: No errors
>> Compiler 3: Error for Y line only
>> Compiler 4: (Evidently does not support pdt yet. Every line that includes ?p5? got an error.)
>>
>> It reduces to whether a LEN type parameter is a constant expression.
>> Does not seem to be reasonable to me that it would be.
> We should clarify what we want.  Maybe the type definition is OK, but
> you can't declare any objects of the type with a specification
> expression for the value of the type parameter.
>
A related issue came up lately, and I agree with Van that we are rather 
ambiguous about just what LEN type parameters are in usage contexts. 
Consider this:

Module testmod
 ? Type, abstract :: myroot(k)
 ??? Integer(4), kind :: k
 ? End type myroot
 ? Type, extends(myroot), abstract :: myvec(lb1,ub1)
 ??? Integer(8), len :: lb1=1,ub1
 ? End type myvec
 ? Type, extends(myvec) :: myvec_int
 ??? Integer(k) :: val(lb1:ub1)
 ? End type myvec_int
End Module testmod
Program Test
 ? use testmod
 ? Implicit none
 ? Type(myvec_int(8,:,:)), allocatable :: a
 ? Allocate(myvec_int(8,ub1=5)::a)
 ? a%lb1=6
End Program Test

Is the assignment to the length parameter a%lb1 valid? If one looks at 
the definition of assignment, one follows the chain of the LHS from 
"variable" to "designator" to "structure component" to "data-ref". 
data-ref is a syntax term for which a%lb1 qualifies. There's no text I 
can find that specifies that a LEN parameter can't be assigned to.

Steve



More information about the J3 mailing list