Am 02.01.26 um 8:27 PM schrieb Thomas Koenig:
Am 02.01.26 um 19:38 schrieb Harald Anlauf:
I do not think you are wrong, IMHO the code is invalid as it stands.
Why do you think it is invalid?
There is of course a race condition, and the ordering of the
output characters is undefined, but that's the user's choice.
Because of the very condition that the patch tests: Parallel output
to the same unit.
However, I am willing to be corrected if somebody knows the OpenMP
standard better than I do. Fortran, of course, is silent on this.
Well, it is certainly *not advisable* to write to the same unit.
One way to avoid the race condition is to use sth. like
!$OMP CRITICAL
WRITE(*,*) X
!$OMP END CRITICAL
But is it really required?
(And the above is not even sufficient to guarantee ordering,
if I/O buffering comes into play.)
I agree that the I/O unit must have been opened before entering
the parallel region. But writing from different threads is not
recursive I/O.
What happens if you write from different threads in another
language, e.g. C?
Harald
Best regards
Thomas