Topic: Strange GFortran problem suppressing CR
I'm having great trouble with a short bit of Fortran code.
I have a library subroutine coded as follows.
Its purpose is to indent a line in readiness for further output.
The variable, LU, is the file unit of an open write file.
SUBROUTINE INDENT(LU,nTAB)
C --------------------------------------
C Indent LU
C jw / 13.08.04
C jw / 21.01.14 last rev.
INTEGER nTAB
DO iTAB=1,nTAB
C WRITE (LU,'('' '',$)')
C WRITE (LU,'('' '',$)')
C WRITE (LU,'(A)', ADVANCE = 'NO') ' '
WRITE (LU,'(A,$)') ' '
END DO
RETURN
END
As will be apparent from the above, I've made four attempts at achieving the same thing (three are commented out).
What happens is that it compiles OK but fails at runtime.
When I run the program, it does SOMETIMES work.
But then, on re-running immediately, it immediately fails.
From the debugger, I see that it always fails, by freezing, on the WRITE statements.
It tends to work (50% of the time) immediately after re-compiling/rebuilding.
It never works twice in a row. Mostly, it fails.
As far as I can see, my code is all correct.
I've tried altering the environment variable
GFORTRAN_UNBUFFERED_ALL
between Y and N, and then back to Y.
This makes no difference.
Has anyone any ideas that would help me with this?
---
John