|
| "John Harper" <harper@mcs.vuw.ac.nz> wrote in message news:1195513222.320328@bats.mcs.vuw.ac.nz...
> Is the following program standard-conforming (a) in f95 (b) in f2003?
> Some compilers print
> out = aabbccddee should be aabbccddee
> but others don't, so I'm suspicious.
>
> PROGRAM testchararray
> IMPLICIT NONE
> INTEGER :: i
> CHARACTER :: in(5)*1=(/'a','b','c','d','e'/), out(5)*2
> out = (/(trim(repeat(in(i),2)),i=1,5)/)
> WRITE(*,'(7a)')' out = ',out,' should be aabbccddee'
> END PROGRAM testchararray
F95 compiler says that array constructor elements must be of fixed
length.
Having TRIM present suggests that the lengths might be different.
>F95 5.4 says "each ac-value expression in the array-constructor
>shall have the same character length parameter." In the above program,
>the value of out is given by an array constructor in which each
>expression happens to have the same length, 2, because there are no
>blanks in the argument of TRIM, but that information is discovered
>at run time, not compile time.
But the compiler has to compile the code. The message is
given at compilation time.
|
|