This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/38382] Open(Unit=6 fails



------- Comment #1 from burnus at gcc dot gnu dot org  2008-12-03 16:49 -------
If you write:

   OPEN(UNIT=OUTPUT_UNIT, FILE="foo.dat")

then you want that all output to the OUTPUT_UNIT is written to the file
"foo.dat". And a asterix UNIT=* in a PRINT or WRITE statement denotes the
OUTPUT_UNIT.

In many compilers, including gfortran, the standard output is unit 6, the
standard error output is 0 (ERROR_UNIT) and the standard input unit is 5 (=
INPUT_UNIT).

(The constants such as OUTPUT_UNIT are defined in the intrinsic module
"ISO_FORTRAN_ENV".)

As a general advise, you should try not to use unit numbers smaller than 10 as
some of them are likely to have a special meaning, depending on the compiler;
especially the numbers 0, 5, 6 should be avoided (unless you want to redirect
stdin/stderr/stdout).

If a compiler prints "Hello" to the screen for the following program, it is
invalid according to the Fortran 2003 standard, previous Fortran standard have
not specified this.

use iso_fortran_env  ! Needs a (partially) Fortran 2003 supporting compiler
open(unit=OUTPUT_UNIT, file="foo.txt")
print *, "Hello"
end


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38382


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]