Re: string concatenation



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

.



Relevant Pages

  • Re: Help requested troubleshooting code
    ... I suppose the reason why my program identifier contained a space as in prandtl meyer was because I had originally used prandtl_meyer and my compiler gfortran complained about the underscore, and I figured that it might have been an invalid character to use in the program statement. ... difference between fixed source form and this other form you prefer? ... about fixed source form, ... The simillar thing in free source form is that you can't go past ...
    (comp.lang.fortran)
  • Re: first time using direct access files: recl ??
    ... I suppose the compiler *MIGHT* be omitting non-written trailing ... he was particularly metioning source form issues. ... implicit typing (evil), the compiler will just make one up anyway. ...
    (comp.lang.fortran)
  • Re: Crazy Problem
    ... > with initialization to see how the array contents are laid out. ... compiler managed to do anything useful after this... ... compiler griped about the data statement - it didn't). ... but the way to tell them which source form ...
    (comp.lang.fortran)
  • Re: Error: Unrecognized token ? skipped
    ... When I complie it, always have errors in first line, the message is ... The complier is IntelFortran Compiler 10.0.025. ... which is of course bad in free source form. ...
    (comp.lang.fortran)
  • Re: What did I do?
    ... Just what does that syntax do?Well, first you probably used fixed source form instead of the free ... And the return uses an obsolescent feature known as ... I do not believe that major compiler writers will not ...
    (comp.lang.fortran)