http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50926
Tobias Burnus <burnus at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |burnus at gcc dot gnu.org --- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-10-31 08:09:01 UTC --- (In reply to comment #0) > Console output suddenly stops to be console: at some point (usually when > write(*,*) and write(6,*) operators are being used for some times Only glancing at your summary, I would assume the following: Your program does at some point: close(6) In gfortran (and most other compilers), the unit * and the unit 6 are the same unit. Thus, if you 'open(6, file="test.dat")', all output of write(*,*) and of write(6,*) go into the same file. Thus, if you expect that 6 and * are separately, you might easily get in trouble. The Fortran 2003 standard explicitly states that the OUTPUT_UNIT and unit * end up in the same file. (The OUTPUT_UNIT parameter is part of the intrinsic ISO_Fortran_env module and has in gfortran the value 6.) The only compiler I know, which treats the units * and 6 differently, is the Intel compiler. In order to get the proper Fortran 2003 behaviour, one needs to specify -assume noold_unit_star. Note additionally that after close(6), it is really depends on the compiler whether how it behaves: * it might use again the console as output (ifort, pathf95) * create a file "fort.6" or similar (gfortran, g95) * or give an error because the unit has been close (NAG f95) Thus: Please avoid to call OPEN to connect the units 0 to 9 to a file - unless you want to direct all output to a file - and even then, avoid to call CLOSE for those units. I mention 0 to 9 as those are the most likely units for console-related I/O. In gfortran and most other compilers, the units are 0 (ERROR_UNIT), 5 (INPUT_UNIT) and 6 (OUTPUT_UNIT).