public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/50926] New: Output to 'fort.6" file instead of console
@ 2011-10-30 20:09 dm.vl.ivanov at gmail dot com
  2011-10-30 20:56 ` [Bug fortran/50926] " kargl at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: dm.vl.ivanov at gmail dot com @ 2011-10-30 20:09 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50926
           Summary: Output to 'fort.6" file instead of console
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dm.vl.ivanov@gmail.com


Console output suddenly stops to be console: at some point (usually when
write(*,*) and write(6,*) operators are being used for some times but non only
in that case, see the details below) the "fort.6" file is being created and
fill with the rest of program's output. Seems not a very big deal but it is
quite uncomfortable and eliminates the possibility to make a
console-interactive program. 

I also tried to avoid using "write" and mix my fortran code with C module
(compiled with g++) containing functions for console output. It helps just a
bit: some more strings go to the console and some less - to the "fort.6" file. 

This seems to be exactly the matter of compiler, not anything else: the same
code compiled with ifort runs just fine, no problems noticed. 

I imagine some more details would be good but my code is too big to upload
here. I can just tell some numbers: about 10 times write(*,*) and write(6,*)
functions produce their output to the console, all the rest - to the "fort.6"
file. When I use C functions instead of fortran's "write" this number becomes
slightly more, about 15 strings show up at the console. 

Environment: gcc version 4.6.1 (Debian 4.6.1-15), Debian testing/sid


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/50926] Output to 'fort.6" file instead of console
  2011-10-30 20:09 [Bug fortran/50926] New: Output to 'fort.6" file instead of console dm.vl.ivanov at gmail dot com
@ 2011-10-30 20:56 ` kargl at gcc dot gnu.org
  2011-10-31  8:09 ` burnus at gcc dot gnu.org
  2011-10-31 16:32 ` dm.vl.ivanov at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: kargl at gcc dot gnu.org @ 2011-10-30 20:56 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #1 from kargl at gcc dot gnu.org 2011-10-30 20:55:52 UTC ---
(In reply to comment #0)

> I imagine some more details would be good but my code is too big to upload
> here. I can just tell some numbers: about 10 times write(*,*) and write(6,*)
> functions produce their output to the console, all the rest - to the "fort.6"
> file. When I use C functions instead of fortran's "write" this number becomes
> slightly more, about 15 strings show up at the console. 

This bug report is almost useless without the code.
Put the code someplace and post the URL.

Try compiling your code with -fcheck=all.

PS: If you're doing mix language programming, it is
advisable to use only Fortran IO or C IO.  Do not 
mix the two unless you know what happens under the
hood.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/50926] Output to 'fort.6" file instead of console
  2011-10-30 20:09 [Bug fortran/50926] New: Output to 'fort.6" file instead of console dm.vl.ivanov at gmail dot com
  2011-10-30 20:56 ` [Bug fortran/50926] " kargl at gcc dot gnu.org
@ 2011-10-31  8:09 ` burnus at gcc dot gnu.org
  2011-10-31 16:32 ` dm.vl.ivanov at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-10-31  8:09 UTC (permalink / raw)
  To: gcc-bugs

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).


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/50926] Output to 'fort.6" file instead of console
  2011-10-30 20:09 [Bug fortran/50926] New: Output to 'fort.6" file instead of console dm.vl.ivanov at gmail dot com
  2011-10-30 20:56 ` [Bug fortran/50926] " kargl at gcc dot gnu.org
  2011-10-31  8:09 ` burnus at gcc dot gnu.org
@ 2011-10-31 16:32 ` dm.vl.ivanov at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: dm.vl.ivanov at gmail dot com @ 2011-10-31 16:32 UTC (permalink / raw)
  To: gcc-bugs

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

Dmitry <dm.vl.ivanov at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #3 from Dmitry <dm.vl.ivanov at gmail dot com> 2011-10-31 16:31:17 UTC ---
Tobias, thank you very much, you are completely right, the problem was
close(6). Thanks also for your advise to avoid output units 0-9, I won't repeat
this mistake again. 

kargl, thank you for your response, if I happen to encounter a real bug, I'll
provide more information about it.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-10-31 16:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-30 20:09 [Bug fortran/50926] New: Output to 'fort.6" file instead of console dm.vl.ivanov at gmail dot com
2011-10-30 20:56 ` [Bug fortran/50926] " kargl at gcc dot gnu.org
2011-10-31  8:09 ` burnus at gcc dot gnu.org
2011-10-31 16:32 ` dm.vl.ivanov at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).