In the book Fortran 95/2003 for Scientists and Engineers, there is much talk given to the importance of recognizing that the first column in a format statement is reserved for control characters. I've also seen control characters referred to as carriage control on the internet.
To avoid confusion, by control characters, I refer to the characters "1, a blank (i.e. \s), 0, and +" as having an effect on the vertical spacing of output when placed in the first column (character) of a FORMAT statement.
Also, see this text-only web page written entirely in fixed-width typeface : Fortran carriage-control (because nothing screams accuracy and antiquity better than prose in monospaced font). I found this page and others like it to be not quite clear.
According to Fortran 95/2003 for Scientists and Engineers, failure to recall that the first column is reserved for carriage control can lead to horrible unintended output. Paraphrasing Dave Barry, type the wrong character, and nuclear missiles get fired at Norway.
However, when I attempt to adhere to this stern warning, I find that gfortran has no idea what I'm talking about.
Allow me to illustrate my point with some example code. I am trying to print out the number Pi:
PROGRAM test_format
IMPLICIT NONE
REAL :: PI = 2 * ACOS(0.0)
WRITE (*, 100) PI
WRITE (*, 200) PI
WRITE (*, 300) PI
100 FORMAT ('1', "New page: ", F11.9)
200 FORMAT (' ', "Single Space: ", F11.9)
300 FORMAT ('0', "Double Space: ", F11.9)
END PROGRAM test_format
This is the output:
1New page: 3.141592741
Single Space: 3.141592741
0Double Space: 3.141592741
The "1" and "0" are not typos. It appears that gfortran is completely ignoring the control character column.
My question, then, is this:
Are control characters still implemented in standards compliant compilers or is gfortran simply not standards compliant?
For clarity, here is the output of my gfortran -v
Using built-in specs.
Target: powerpc-apple-darwin9
Configured with: ../gcc-4.4.0/configure --prefix=/sw --prefix=/sw/lib/gcc4.4 --mandir=/sw/share/man --infodir=/sw/share/info --enable-languages=c,c++,fortran,objc,java --with-gmp=/sw --with-libiconv-prefix=/sw --with-ppl=/sw --with-cloog=/sw --with-system-zlib --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --disable-libjava-multilib --build=powerpc-apple-darwin9 --host=powerpc-apple-darwin9 --target=powerpc-apple-darwin9
Thread model: posix
gcc version 4.4.0 (GCC)