https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78387
Thomas Koenig <tkoenig at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |tkoenig at gcc dot gnu.org
Resolution|--- |INVALID
--- Comment #1 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Hi Andrew,
I/O operations are not thread safe. If you enclose them
in !$omp critical, you will get the expected result:
ig25@linux-fd1f:/tmp> cat omp.f90
program p
double precision :: b
b=0.1d0
!$omp parallel
call s(b)
!$omp end parallel
contains
subroutine s(a)
implicit none
double precision, intent(in) :: a
character(len=10) :: f,c
!$omp critical
write (f,'(a5,i1,a1)') "(e10.",2,")"
write (c,f) a
write (0,*) trim(c)
!$omp end critical
return
end subroutine s
end program p
ig25@linux-fd1f:/tmp> gfortran -fopenmp omp.f90
ig25@linux-fd1f:/tmp> ./a.out
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00
0.10E+00