Re: Help requested troubleshooting code



Wow, thank you both for your explanations of free and fixed forms.

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. I figured if I used a space instead that it would ingore it, which it did.

I've been using vim to write out my programs, which with coloring turned on, highlights the 6th column for you as well as the 72nd column to let you know whether your statement has exceeded the length limit. I guess I've just gotten accustomed to this behavior.

Nontheless your tips are very much appreciated. I have Stephen Chapman's "Fortran 90/95 for Scientists and Engineers" text that I use for reference, and haven't come across this difference between fixed/free forms, but neither have I read all the way through.

One other question I had was that someone earlier in their response to my original request was able to use the -fbounds_check compiler flag for gfortran and the output was much more detailed than the output I got when I used it. Namely their output pointed to the line in particular which the compiler was complaining. My compiler went ahead and compiled the program as it was, but then provided the segmentation fault error at runtime. Is there some setting with gfortran, gcc, or gdb to turn on extended debugging output?

On 2008-02-16 15:20:37 -0800, nospam@xxxxxxxxxxxxx (Richard Maine) said:

Zachary Davis <zdavis@xxxxxxx> wrote:

Could you explain or point to some reference that might explain the
difference between fixed source form and this other form you prefer?
It is a notion that is unfamiliar to me as obviously I'm somewhat of a
programming novice. I'd appreciate it.

Any Fortran text (provided it isn't an old F77 one) should cover the
details of this. But the basics are pretty simple. Presumably you know
about fixed source form, as that's what this is. The big differences

Free source form has no special columns. Fixed source form has special
rules for column 1 (comment characters), 1-5 (statement numbers), 6
(continuation), and anything past 72 (often ignored, but implementations
vary). The simillar thing in free source form is that you can't go past
column 132, which is like the role of column 72 in fixed source.

So what do you do instead of the special columns of fixed source form?

For comments, use the !, which I see your code does anyway. That one is
valid in both forms. There is no special meaning for a C or * in col 1.

For statement numbers, no column restrictions are needed. The compiler
can recognize them syntactically (because there is no statement that can
start with a digit).

For continuation, well the exact rules for oddball cases have some
complications, but the basic rule is to put an & at the end of the line
to be continued sort of like

x = some_long_expression + &
some_more

And then the one last rule, which is the difference that came up here...

Blanks are significant in free source form. You can't just add them
randomly in the middle of identifiers. The precise rules on blanks take
longer to state, but the simple version is that you can put them between
"things", but you can't put them in the middle of a single "thing".
Fixed source form, in contrast, completely ignore blanks that are not
part of character literals (or comparable things like Hollerith).

Thus, in fixed source form, your "prantl meyer" was the same thing as
just prantlmeyer with the blank ignored. In free source form, you can't
have a blank there. Individual styles vary on what to do with multi-word
identifiers like that. People have occasionally discussed such style
preferences here. I personally favor using underscores as in
prandtl_meyer. Others like to use capitilaization as in prandtlMeyer or
PrandtlMyer.

Most compilers will assume a source form based on the file name. For
example, a common convention is that a file name ending in .f is fixed
source form, while one ending in .f90 is free source form. (The f90 bit
is unfortunately misleading in that both forms are valid Fortran 90.
Thus .f90 doesn't really mean Fortran 90; it is just a funny way of
spelling free source form.)


.



Relevant Pages

  • Re: string concatenation
    ... number for source line length - at least in fixed source form. ... I recommend moving to a more modern compiler. ... form is still supported in Fortran 90/95/2003, it is basically only for using ... Fixed source form requires that the body of each statement be between columns ...
    (comp.lang.fortran)
  • Re: Help requested troubleshooting code
    ... 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 ... So what do you do instead of the special columns of fixed source form? ...
    (comp.lang.fortran)
  • Re: Help requested troubleshooting code
    ... 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 ... So what do you do instead of the special columns of fixed source form? ...
    (comp.lang.fortran)
  • Re: Converting fixed-to-free format
    ... CONVERTING FIXED-TO-FREE FORMAT. ... "Anyone who wants to take the advantages of free source form ... Fixed source form is inherently an error-prone form ...
    (comp.lang.fortran)
  • Re: NEWBIE QUESTION
    ... >as opposed to fixed source form although free source form was introduced ... name ending .f is in fixed source form, but in .f90 is free source form. ... Some compilers have options like -free or -fixed for specifying it. ...
    (comp.lang.fortran)