Hi,
I wrote the following little example:
program main
use omp_lib
implicit none
integer :: n, l, m, j, nDEQ, nk
character*13 :: problemType
real*8, allocatable, dimension) :: x0, xIn
real*8, allocatable, dimension, :: chiProbeArray, chiDiffArray
n = 3
m = 3
allocate(xIn, x0, chiProbeArray(m, n), chiDiffArray(m, n))
!$omp parallel do default(private), shared(chiProbeArray, chiDiffArray)
do j = 1, m
print *, omp_get_thread_num()
xIn = x0
do l = 1, n
chiProbeArray(j, l) = l * m
chiDiffArray(j, l) = l * m +1
end do
end do
!$omp end parallel do
print *, sum(chiProbeArray)
print *, sum(chiDiffArray)
deallocate(xIn, x0, chiProbeArray, chiDiffArray)
end program main
It compiles fine. But it never enters the loop, "print *, omp_get_thread_num()" is never invoked. What am I doing wrong? I noticed that it runs when I change default(private) to default(shared), but it does not give the right result (for sum(chiProbeArray) it should be 36). Anybody an idea?
Cheers
Phil
I wrote the following little example:
program main
use omp_lib
implicit none
integer :: n, l, m, j, nDEQ, nk
character*13 :: problemType
real*8, allocatable, dimension) :: x0, xIn
real*8, allocatable, dimension, :: chiProbeArray, chiDiffArray
n = 3
m = 3
allocate(xIn, x0, chiProbeArray(m, n), chiDiffArray(m, n))
!$omp parallel do default(private), shared(chiProbeArray, chiDiffArray)
do j = 1, m
print *, omp_get_thread_num()
xIn = x0
do l = 1, n
chiProbeArray(j, l) = l * m
chiDiffArray(j, l) = l * m +1
end do
end do
!$omp end parallel do
print *, sum(chiProbeArray)
print *, sum(chiDiffArray)
deallocate(xIn, x0, chiProbeArray, chiDiffArray)
end program main
It compiles fine. But it never enters the loop, "print *, omp_get_thread_num()" is never invoked. What am I doing wrong? I noticed that it runs when I change default(private) to default(shared), but it does not give the right result (for sum(chiProbeArray) it should be 36). Anybody an idea?
Cheers
Phil