For Programmers: Free Programming Magazines  


Home > Archive > Fortran > November 2007 > Re: character array constructor question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: character array constructor question
robin

2007-11-20, 7:15 pm

"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.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com