Greetings everyone,
I'm seeking your feedback on the length-type specification with the
intrinsic type CHARACTER and the ALLOCATABLE attribute.
I'll greatly appreciate replies on the following.
1) Is a variable allowed to have the ALLOCATABLE attribute but with a
constant expression in the length-type specification? For example, is
the following snippet standard-conforming?
--- begin case 1 ---
character(len=42), allocatable :: s
end
--- end case 1 ---
2) If case 1) above is conforming, then can the variable be used in an
ALLOCATE statement? And if yes, can one use it in the LEN function
and not have the result be processor-dependent? That is, is the
following standard-conforming and if so, what should the program
print?
--- begin case 2 ---
character(len=42), allocatable :: s
allocate( s )
print *, "len(s) = ", len(s)
end
--- end case 2 ---
3) Can a dummy argument have the ALLOCATABLE attribute but with
assumed length-type parameter? For example, is the following
standard-conforming?
--- begin case 3 ---
subroutine sub( s )
character(len=*), allocatable :: s
end subroutine
--- end case 3 ---
4) If case 3 above is conforming, then can one include an assumed
length type specification for the dummy argument in an ALLOCATE
statement? For example, is the following conforming?
--- begin case 4 ---
subroutine sub( s )
character(len=*), allocatable :: s
allocate( character(len=*) :: s )
end subroutine
--- end case 4 ---
Please note a couple of processors I tried processed all 4 of the
above snippets and issued no diagnostics.
Thanks very much,
Vipul Parekh
|