Is there a way within fortran to direct unit 0 (error output) to a file? Particularly I want to redirect it to standard out. I am hoping for something within Fortran that would be portable across major operating systems. I did try
open(unit=0,file="stuff")
and
open(unit=0,file='/dev/tty')
with gfortran under Linux, but the open statement seemed to have no effect.
Daniel Feenberg
NBER
Daniel Feenberg wrote:...
Is there a way within fortran to direct unit 0 (error output) to a file? Particularly I want to redirect it to standard out. I am hoping for something within Fortran that would be portable across major operating systems. I did try
You can try to close ERROR_UNIT from ISO_FORTRAN_ENVJust tried it out in gfortran Linux and FreeBSD - no effect on the destination of error output. I did want to avoid depending on the shell for this because different shells have different syntax for this, and I don't want to explain that to users or tell
and then re-use that unit number. Not sure if it works.
program foo
use iso_fortran_env
close(ERROR_UNIT)
open(unit=ERROR_UNIT,file=....)
end program foo
--
steve
On Wednesday, September 8, 2021 at 4:07:05 PM UTC-4, steve kargl wrote:tell them which shell to use.
Daniel Feenberg wrote:...
Is there a way within fortran to direct unit 0 (error output) to a file? Particularly I want to redirect it to standard out. I am hoping for something within Fortran that would be portable across major operating systems. I did try
You can try to close ERROR_UNIT from ISO_FORTRAN_ENVJust tried it out in gfortran Linux and FreeBSD - no effect on the destination of error output. I did want to avoid depending on the shell for this because different shells have different syntax for this, and I don't want to explain that to users or
and then re-use that unit number. Not sure if it works.
program foo
use iso_fortran_env
close(ERROR_UNIT)
open(unit=ERROR_UNIT,file=....)
end program foo
--
steve
Daniel Feenberg
Is there a way within fortran to direct unit 0 (error output) to a file?
Gfortran has an environmental variable that allows one to change the unit
to some other value, but suspect that doesn't change the internal use of stderr (as found in C). Even if an EV worked, you would to users how to
an EV for the different shells.
On Wednesday, September 8, 2021 at 4:11:50 PM UTC-7, steve kargl wrote:
(snip)
Gfortran has an environmental variable that allows one to change the unit
to some other value, but suspect that doesn't change the internal use of
stderr (as found in C). Even if an EV worked, you would to users how to
an EV for the different shells.
You can change an EV within the program. Exactly when its value is needed, isn't so obvious. It might be not read until an actual I/O operations is needed.
You can change an EV within the program. Exactly when its value is needed, isn't so obvious. It might be not read until an actual I/O operations is needed.
Depends on the operating system.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 159 |
Nodes: | 16 (0 / 16) |
Uptime: | 98:45:11 |
Calls: | 3,209 |
Files: | 10,563 |
Messages: | 3,009,783 |