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

Detecting OUTPUT_UNIT and ERROR_UNIT 'equivalence'.

OP1
New Contributor II
362 Views

Is there a way to detect the 'equivalence' of OUTPUT_UNIT (which is 6) and ERROR_UNIT (which is 0) when both are connected to the console, to avoid duplicate output there?

In other words, considering the code

WRITE(UNIT=OUTPUT_UNIT,FMT='(A)') 'Some text'
WRITE(UNIT=ERROR_UNIT,FMT='(A)') 'Some text'

can we avoid having a duplicate output of 'Some text' when using the console? (when the console is not used, it's okay and in fact desired to have separate output to stderr and stdout).

0 Kudos
2 Replies
Steven_L_Intel1
Employee
362 Views

Do an INQUIRE by unit on both units, asking for NAME=. Compare the strings. 

0 Kudos
OP1
New Contributor II
362 Views

It works beautifully, neat trick! Thanks Steve.

0 Kudos
Reply