Re: string concatenation
- From: Richard Maine <nospam@xxxxxxxxxxxxx>
- Date: Thu, 25 Jan 2007 15:00:41 -0800
On Thu, 25 Jan 2007 14:25:03 -0800, heavytull wrote
(in article <epbao4$v5o$1@xxxxxxxx>):
character ft*(128)ft='gy'//'hhuffwfffff'//'jf'//'jjij'//'ij'//'fffff'//'ijij'//'ji'//'j'
@compilation:
bash-3.1$ f77 test.for
FORTRAN 77 Compiler 8.2, Copyright (c) 1987-2003, Absoft Corp.
error on line 25 of test.for: illegal syntax
Ah. The above copyright line tells a lot more about your compiler than what
you posted before. Anyway...
Although 32 is not a magic number for character string length, 72 is a magic
number for source line length - at least in fixed source form.
I recommend moving to a more modern compiler. Although the copyright notice
implies that Absoft was selling that compiler as late as 2003, Fortran 77 is
now 30 years old. F95 compilers are available even for free these days.
You have run into one of the many "features" of Fortran 77 - the old fixed
source form, which was designed for punched cards. (Although fixed source
form is still supported in Fortran 90/95/2003, it is basically only for using
old code with the newer compilers). I predict that you will run into other
shortcomings of Fortran 77 if you continue with it. I ran into its
shortcomings, which is why I moved on to Fortran 90 as soon as possible,
about 15 years ago.
Fixed source form requires that the body of each statement be between columns
7 and 72 of each line. Those columns tended to be clearly marked on the
punched cards. It isn't so obvious in most text editors (although some have
provisions to make it so). because of the way that columns 73-80 of each card
were typically used, Fortran 77 compilers often just ignore any columns after
72, often not even giving a warning message about what was being ignored.
Your line goes past column 72. Truncating it at column 72 gives (if I have
counted correctly, and if it starts in column 7)
ft='gy'//'hhuffwfffff'//'jf'//'jjij'//'ij'//'fffff'//'ijij'//'ji'/
which is not a valid Fortran statement because of the trailing / character.
If you want to do this in f77 fixed source form, you need to either use a
continuation line or break it into two separate statements. If you use a
continuation line, then I **VERY STRONGLY** recommend that you not break the
line in the middle of one of the quoted strings; break it before or after one
instead. The issues that come up in continuation of quoted strings in fixed
source form are not worth going into here. Just don't do it. F90 free source
form does not have the same kind of issue with continuations.
--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain| experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
.
- Follow-Ups:
- Re: string concatenation
- From: heavytull
- Re: string concatenation
- From: Greg Lindahl
- Re: string concatenation
- From: Gary Scott
- Re: string concatenation
- References:
- string concatenation
- From: heavytull
- Re: string concatenation
- From: Richard Maine
- Re: string concatenation
- From: heavytull
- string concatenation
- Prev by Date: Re: string concatenation
- Next by Date: Re: string concatenation
- Previous by thread: Re: string concatenation
- Next by thread: Re: string concatenation
- Index(es):
Relevant Pages
|
|