User account creation filtered due to spam.
Type parameter inquiry:
str%len is equivalent to len(str)
a%kind is equivalent to kind(a)
The real fun part starts with user-defined kinds, e.g.
integer, KIND :: dim
real :: dist(dim)
end type tp
type(tp) :: t(5)
print *, t%dist%dim
Quote from F2008 but F2003 should be the same:
"A type parameter inquiry is used to inquire about a type parameter of a data object. It applies to both intrinsic and derived types.
R616 type-param-inquiry is designator % type-param-name
C622 (R616) The type-param-name shall be the name of a type parameter of the declared type of the object designated by the designator.
A deferred type parameter of a pointer that is not associated or of an unallocated allocatable variable shall not be inquired about."
Another related item are complex parts; contrary to the type parameter inquiry above, those are lvalues and can be assigned to. (Again a F2003 feature, quote is however from F2008.)
"R615 complex-part-designator is designator % RE
or designator % IM
C621 (R615) The designator shall be of complex type.
If complex-part-designator is designator%RE it designates the real part of
designator. If it is designator%IM it designates the imaginary part of
designator. The type of a complex-part-designator is real, and its kind and
shape are those of the designator.
The following are examples of complex part designators:
impedance%re !-- Same value as REAL(impedance)
fft%im !-- Same value as AIMAG(fft)
x%im = 0.0 !-- Sets the imaginary part of X to zero"
Type parameter inquiries are also mentioned in PR29962, comment #10.
Real/imaginary parts seem to be Fortran 2008 only. Len/kind are still Fortran 2003.