https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92836
Thomas Koenig <tkoenig at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tkoenig at gcc dot gnu.org --- Comment #8 from Thomas Koenig <tkoenig at gcc dot gnu.org> --- > No. The inquire() is used only to see if the file exists already. If it > does, the code branches to read the file, if it does not, the code branches > to generate the data for the file and then write it. You have to watch out here. If you are a) using INQUIRE to check if the file exists b) using OPEN if it does not in a thread, this is classic race condition - separate threads may INQUIRE and then try to open, in parallel. This is not atomic, and is a classic race condition. You should always put such a sequence into OMP CRITICAL. This has the nice side effect that you will also avoid this bug (which should be fixed regardless). Also, why do you use inquire at all? AFAIK, it is not an error to OPEN a file more than one if you don't change anything, so a simple open (10,file="foo.dat",status="unknown") should, in principle, work even with OpenMP; if it doesn't, this is another bug that needs fixing.