https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82378
Thomas Koenig <tkoenig at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #1 from Thomas Koenig <tkoenig at gcc dot gnu.org> --- The races do not happen for program main use omp_lib !$OMP PARALLEL NUM_THREADS(100) call file_open(OMP_get_thread_num()) !$OMP END PARALLEL contains recursive subroutine file_open(i) integer :: i integer :: nunit nunit = i + 20 write (nunit,*) 'asdf',i close (nunit) end subroutine file_open end program main so it might be advisable to close files local to a thread as a workaround.