Re: writing output listing onto screen (or not) and onto file
- From: bru <bru@xxxxxxxx>
- Date: Mon, 17 Jul 2006 17:45:41 +0200
jwm wrote:
bru wrote:In my case your code is a little bit simpler with a test only on StdOutput :
Some time I want to have at the same time output on screen (Unit 6 or *)
and onto a file (OPEN(8,FILE= 'sosout')
An an other time I want only output on file (here unit 8) (for me it is
easier to visualize the output using vim editor) So I put in this case
OPEN(6,FILE= 'NO') because I dont need it
What about this:
integer, parameter :: USR_UNIT(2) = [6, 8]
integer i
logical StdOutput, FileOutput
real a, b, c
a = 1.; b = 2.; c = 3.
write(*, '("Std output? [T/F]: ")', ADVANCE = 'NO')
read(*, *) StdOutput
write(*, '("File? [T/F]: ")', ADVANCE = 'NO')
read(*, *) FileOutput
if (FileOutput) Open(unit = USR_UNIT(2), file = 'userfile.txt')
do i = 1, 2
if (i == 1 .AND. (.NOT.StdOutput)) cycle
if (i == 2 .AND. (.NOT.FileOutput)) cycle
write(USR_UNIT(i), "(' A B C=', 3F12.4)") a, b, c
enddo
integer, parameter :: USR_UNIT(2) = (/6, 8/)
integer i
logical StdOutput
real a, b, c
a = 1.; b = 2.; c = 3.
write(*, '("Std output? [T/F]: ")', ADVANCE = 'NO')
read(*, *) StdOutput
Open(unit = USR_UNIT(2), file = 'userfile.txt')
do i = 1, 2
if (i == 1 .AND. (.NOT.StdOutput)) cycle
write(USR_UNIT(i), "(' A B C=', 3F12.4)") a, b, c
enddo
end
.
- Follow-Ups:
- References:
- Prev by Date: Re: writing output listing onto screen (or not) and onto file
- Next by Date: Re: double confusion
- Previous by thread: Re: writing output listing onto screen (or not) and onto file
- Next by thread: Re: writing output listing onto screen (or not) and onto file
- Index(es):