Quantcast
Channel: Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2583

Allocatable components and OpenMP?

$
0
0

The following case leads to a segmentation fault at run time with ifort. I think that perhaps allocatable components are only supported in OpenMP 4.0 (?), so in that case perhaps it is too early to expect them to be widely implemented. But I'm curious whether or not this is a case that is supposed to work, and if there's any specific plan about whether to implement it soon. gfortran and ifort are the only recent compilers that seem to have an issue with this; pgfortran, nagfor, and xlf2003 all do about what you'd expect, which is to say, the same behavior as if you were using a bare array instead of one that's a derived type component.

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

 


Viewing all articles
Browse latest Browse all 2583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>