Length(s) of allocatable character array?

This is a very interesting question. Length is a type parameter, so changing the length of an individual array element would imply changing that element’s type parameter, but elements don’t have type parameters, only variables do; I haven’t found words saying so explicitly, though (they must exist somewhere!)

I then was looking at the description of intrinsic assignment, which is where you’re changing the length. 10.2.1.3 is where this is found, and it says, in part, “If the variable is an allocated allocatable variable, it is deallocated if expr is an array of different shape, any corresponding length type parameter values of the variable and expr differ, or the variable is polymorphic and the dynamic type or any corresponding kind type parameter values of the variable and expr differ.” You can’t, of course, deallocate an array element, but it seems to me that this wording could use some improvement. I will ask.

2 Likes