1 (edited by JohnWasilewski 2013-02-20 09:57:06)

Topic: C comment bug in gFortran?

Has anyone any similar experience of the following strange behaviour?

I have just yesterday started experiencing it, in SF3.9.1117.
It seems mot likely to be something strange going on in gFortran, not in Simply Fortran.

I have started to find that the compiler is ignoring the first statement appearing immediately after a long C-comment line.
To make the compiler see and obey all such statements, I am having to insert an extra blank line after every C-comment line.


EXAMPLE
-----------
Whenever I insert one of these I always top and tail it with a particular C-comment, as shown below.
In this example:
  - The C--------debug----... lines are exactly 72 chars long;
  - The variables called CR$, Bold$ etc are defined elsewhere;
  - F%O%LU has an integer value, of an opened Fortran output file unit.
  - I use the Insight debugger all the time but I also insert  debug print statements.


With THIS code,the program sends nothing to the output file:
C-------------------------------------------------------------debug----\
      WRITE(F%O%LU,'(A)') CR$//CR$//CR$//Bold$//'SOLVE'//unBold$//CR$
      |
      [more debug statements]
      |
C-------------------------------------------------------------debug----/


With THIS code, the program prints the word, "SOLVE" to the output file
(Please (note the extra blank line) after the first C--------- comment statement):
C-------------------------------------------------------------debug----\

      WRITE(F%O%LU,'(A)') CR$//CR$//CR$//Bold$//'SOLVE'//unBold$//CR$
      |
      [more debug statements]
      |
C-------------------------------------------------------------debug----/

---
John

Re: C comment bug in gFortran?

I think it may be something to do with my use of a backslash at the end of the line indicating the start of my debug code.
Does anyone know if gFortran interprets this as some kind of a signal to the compiler?
---
J.

Re: C comment bug in gFortran?

John,

GNU Fortran is probably interpreting the backslash as the traditional UNIX line continuation character.  I didn't think GNU Fortran would do so, but it appears that would be the case. You should avoid ending lines with backslash in general.

Jeff Armstrong
Approximatrix, LLC