As an Openmp user, I have used this simple write approach effectively, especially to * output, for debug purposes. I usually include the string id. While there are limitations for understanding the output, it has worked for small I/o lists. I have not experienced corruption of the output list between threads, which may be possible with longer I/o lists? To improve usage, !$omp critical or a unique file unit number to each thread can help. The functionality and the race condition in the example have been tolerable in previous Gfortran versions
> On 3 Jan 2026, at 7:42 am, Thomas Koenig <[email protected]> wrote: > > Am 02.01.26 um 20:52 schrieb Harald Anlauf: >> 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? > > The closest equivalent in pure Fortran is DO CONCURRENT. There, one only > finds > > 11.1.7.5 Additional semantics for DO CONCURRENT constructs > > [...] > > 8 A DO CONCURRENT construct shall not contain an input/output statement > that has an ADVANCE= specifier. > > so the rest is permitted. > > Hmm... after reading that, I changed my mind. I now think that I/O > should also be allowed within OMP PARALLEL. > > Best regards > > Thomas > > >
