Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Seeking a sneaky solution

Stuart_M_
Beginner
665 Views

Hi folks

I have an old Fortran file that prints to an output filewith the beautiful formatting precision and line-by-line tender loving care that only having to code in the old days and the old ways could have produced.

While it's very pretty to look at, with a dash of post-modern penchant for the macabre, Iwant it to stop. I now have the code writing the same results in a much more efficient and Stu-friendly format so I no longer need this printout. However, I or others may in the future, since the code does a lot I'm not using right now, so I don't want to simply comment out every single line containing WRITE(10,... - for one because this seems crass, and for two because there are many such lines already commented out by previous editors of the code in their efforts to perfect the formatting for themselves. It would be downright malicious to force whoever uses the code next to have to back-calculate which writes to uncomment for a legible printout.

So, my long-winded question: is there a way to get Fortran to simply disregard all write statements to a particular unit, or to somehow dupe it into not doing so?

Much 'bliged

0 Kudos
1 Solution
IanH
Honored Contributor II
665 Views
[fortran]OPEN(10, FILE='NUL')
WRITE(10, "(A)") 'He suggests you connect the file to the NUL device'
WRITE (10,"(A)") 'See http://en.wikipedia.org/wiki//dev/null for more information'
CLOSE(10)[/fortran]

View solution in original post

0 Kudos
4 Replies
DavidWhite
Valued Contributor II
665 Views

I think you can attach the until to 'NUL', which will result in the output being discarded. the writes will still be executed, but you won't have the output file.

David

0 Kudos
Stuart_M_
Beginner
665 Views

Hi David

I'm sorry, but I'm not quite following you. Would you mind elaborating?

I did some digging and I found no mention of 'NUL' associated with WRITE statements anywhere, so perhaps you're implying using a pointer somehow? I have never yet used a pointer in Fortran to be totally honest (I am relatively new to the FOR-game, and largely trapped in 1977 if you get my drift) so this allusion might be going over my head...

0 Kudos
IanH
Honored Contributor II
666 Views
[fortran]OPEN(10, FILE='NUL')
WRITE(10, "(A)") 'He suggests you connect the file to the NUL device'
WRITE (10,"(A)") 'See http://en.wikipedia.org/wiki//dev/null for more information'
CLOSE(10)[/fortran]

0 Kudos
Stuart_M_
Beginner
665 Views
Ahhh - that makes beautiful sense. Thank you both! Worked like a charm.
0 Kudos
Reply