https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92836
Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jvdelisle at gcc dot gnu.org --- Comment #3 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> --- With the the following example I see varying results: program inq use OMP_Lib implicit none logical :: s character(len=27) :: c integer :: i, j i=64 !$omp parallel private(c,j,s) print *, OMP_Get_Thread_Num(), omp_get_num_threads(), omp_get_num_threads()/2 do while (.true.) if (OMP_Get_Thread_Num() < omp_get_num_threads()/2) then open(newUnit=j,file='test.txt',form='formatted',status='unknown') write (c,'(e17.10, ">>>",i5, i5, "<<<")') 1.23456d0, j, OMP_Get_Thread_Num() write (j,*) trim(c) close(j) else inquire(file='test.txt',exist=s) end if end do !$omp end parallel end program I get randomly: $ ./a.out 0 8 4 3 8 4 6 8 4 5 8 4 4 8 4 1 8 4 2 8 4 At line 14 of file bug1.f90 At line 14 of file bug1.f90 7 8 4 Fortran runtime error: Fortran runtime error: End of recordEnd of record $ ./a.out 2 8 4 5 8 4 6 8 4 1 8 4 7 8 4 0 8 4 4 8 4 3 8 4 At line 14 of file bug1.f90 At line 14 of file bug1.f90 At line 14 of file bug1.f90 At line 14 of file bug1.f90 Fortran runtime error: Fortran runtime error: Fortran runtime error: End of recordFortran runtime error: End of recordEnd of record End of record [jerry@amdr threadbug]$ ./a.out 0 8 4 2 8 4 6 8 4 1 8 4 5 8 4 7 8 4 At line 14 of file bug1.f90 Fortran runtime error: End of record 3 8 4 Program received signal SIGSEGV: Segmentation fault - invalid memory reference. Backtrace for this error: $ ./a.out 2 8 4 6 8 4 1 8 4 0 8 4 5 8 4 7 8 4 3 8 4 4 8 4 At line 14 of file bug1.f90 At line 14 of file bug1.f90 Fortran runtime error: At line 14 of file bug1.f90 At line 14 of file bug1.f90 End of recordFortran runtime error: Fortran runtime error: Fortran runtime error: End of recordEnd of recordEnd of record $ ./a.out 7 8 4 6 8 4 1 8 4 0 8 4 5 8 4 2 8 4 3 8 4 At line 14 of file bug1.f90 Fortran runtime error: 4 8 4 End of record At line 14 of file bug1.f90 Fortran runtime error: End of file