[fortran]program allocatable type pippo real(8), allocatable :: vec(:) end type pippo type(pippo) :: a !$omp parallel !$omp single allocate(a%vec(10)) !$omp end single !$omp end parallel end program allocatable[/fortran]crashes when compiled with:
Link Copied
!$ompparallel
if(.not. allocated(a%vec) then
!$ompcritical
if (.not. allocated(a%vec)allocate(a%vec(10))
!$ompendcritical
endif
(assume other code here)
!$ompendparallel
Your program was in error.
Jim Dempsey
[bash]!$omp parallel !$omp single allocate(a%vec(10)) !$omp end single {any code here can experience problems} !$omp end parallel { code here should be OK}
Often postings on this forum are in "sketch" format (meaning missing details).
Jim Dempsey
[/bash]
Try adding shared(a)
!$ompparallelshared(a)
!$ompsingle
allocate(a%vec(10))
!$ompendsingle
!$ompendparallel
For more complete information about compiler optimizations, see our Optimization Notice.