I'm having a spot of trouble making some vector operations in a code of mine parallelized with openmp. I have the following stripped down test case that exhibits the problem for me:
- Code: Select all
Program main
Use omp_lib
Type group
Real(8), Pointer :: a(:),b(:)
End Type group
type(group) :: test
allocate(test%a(100),test%b(100))
!$OMP PARALLEL
!$OMP WORKSHARE
test%a = 2 *test%b
!$OMP END WORKSHARE
!!$OMP DO SCHEDULE(STATIC)
!Do i=1,100
! test%a(i) = 2 *test%b(i)
!end do
!!$OMP END DO
!$OMP END PARALLEL
end Program Main
As you can see, the code contains two versions of the same formula, one using OMP WORKSHARE and the other using OMP DO. If I let things run as is, then I get a segmentation fault. If I comment out the workshare and enable the parallel do, then it runs without error. I do not have this problem if my arrays a and b are 'loose' rather than contained in the type 'group', but in my main code I am forced to use the type declaration so changing that is not an option. Unfortunately, in my real code the arrays are also either of dimension 2 or 3, so changing the syntax to use explicit loops throughout 10k lines is not a desirable solution either. Fortran is not my native programing language though, so I'm hoping there is something subtle (or not so subtle!) here that I'm missing. I'm not compiling with any special options, save the -mp that enables openmp, and handing the --version flag to my compiler gives me 'pgf90 11.9-0 64-bit target on x86-64 Linux -tp k8e'. If there is any other information that would be useful for me to provide please let me know!
Thanks in advance!
