Re: merge of character strings
- From: harper@xxxxxxxxxxxxx (John Harper)
- Date: 16 Jun 2008 11:21:57 +1200
In article <i1G4k.84350$SV4.74552@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
*** Hendrickson <***.hendrickson@xxxxxxx> wrote:
John Harper wrote:
PROGRAM testmergeIt looks OK to me. The rules for MERGE say that the two thingos
* What happens in merge(string1,string2,mask) if lengths of strings
* are not known at compile time, but are in fact equal at run time?
INTEGER,PARAMETER:: maxlen=60
CHARACTER:: stuff*(maxlen-2),empty*(maxlen)='a blank string'
PRINT *,'Enter a character string (possibly empty or all blanks)'
READ "(A)",stuff
PRINT *, 'You entered '//merge(empty,
$ '"'//trim(stuff)//'"'//repeat(' ',maxlen-2-len_trim(stuff)),
$ len_trim(stuff)==0)
END PROGRAM testmerge
should have the same type parameters. But that doesn't mean they have
to be known at compile time.
I'd suggest trying a simpler example
PROGRAM testmergecharacter*20 a,b
a = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
b = 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
something = 12
do
READ(*,*) N,Menddo
PRINT *, n,m, merge(a(1:n), b(1:m), n==something)
END PROGRAM testmerge
and see what happens with the 4 compilers for various n and m.
***'s version compiled and ran with all 4 compilers. None complained
at run-time if n /= m, though I did get various results as is permitted
by the standard in that case. Bug reports are on their way to the
compilers that my version found internal errors in.
-- John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington 6140, New Zealand
e-mail john.harper@xxxxxxxxx phone (+64)(4)463 6780 fax (+64)(4)463 5045
.
- References:
- merge of character strings
- From: John Harper
- Re: merge of character strings
- From: *** Hendrickson
- merge of character strings
- Prev by Date: Re: TYPE declaration/statement in Fortran 77 code
- Next by Date: J3 request for interpretation, f.p. semantics of the REAL intrinsic function
- Previous by thread: Re: merge of character strings
- Next by thread: difference
- Index(es):