public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/60928] New: gfortran issue with allocatable components and OpenMP
@ 2014-04-23  0:53 quantheory at gmail dot com
  2014-05-13 14:17 ` [Bug fortran/60928] " dominiq at lps dot ens.fr
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: quantheory at gmail dot com @ 2014-04-23  0:53 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60928

            Bug ID: 60928
           Summary: gfortran issue with allocatable components and OpenMP
           Product: gcc
           Version: 4.8.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: quantheory at gmail dot com

Just as a disclaimer up front, this is probably an OpenMP 4.0 issue. OpenMP 3.1
sort of glossed over this use case, but OpenMP 4.0 quietly added language about
it. Still, it would be nice to get right, and it doesn't involve any of the new
constructs.

The following test case works with nagfor, xlf, and newer versions of
pgfortran, but not gfortran or ifort:


use omp_lib, only: omp_get_thread_num
implicit none

type :: foo
   integer, allocatable :: a(:)
end type foo

type(foo) :: bar

integer :: i, sum_arr(5)

!$omp parallel private (i, bar)

allocate(bar%a(3))

!$omp do
do i = 1, 5
   bar%a = [1, 2, 3] + omp_get_thread_num()
   sum_arr(i) = sum(bar%a)
end do

!$omp barrier
print *, sum(bar%a)
!$omp barrier

!$omp single
print *, sum(sum_arr)
!$omp end single

deallocate(bar%a)

!$omp end parallel

end


This is the runtime's error message:

Fortran runtime error: Attempting to allocate already allocated variable 'bar'

I think this signifies that the private version of "bar" is not being set up
correctly, so the threads end up sharing the allocatable component.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-08-11 10:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-23  0:53 [Bug fortran/60928] New: gfortran issue with allocatable components and OpenMP quantheory at gmail dot com
2014-05-13 14:17 ` [Bug fortran/60928] " dominiq at lps dot ens.fr
2014-05-13 15:24 ` jakub at gcc dot gnu.org
2014-05-14  6:52 ` burnus at gcc dot gnu.org
2014-05-14 10:17 ` quantheory at gmail dot com
2014-05-14 10:24 ` jakub at gcc dot gnu.org
2014-05-15  3:48 ` quantheory at gmail dot com
2014-06-10  6:06 ` jakub at gcc dot gnu.org
2014-06-30 16:36 ` jakub at gcc dot gnu.org
2014-08-11 10:13 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).