- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I was able to compile the following simple code but the output doesn't seem right:
module data_mod
integer :: my_id
!$omp threadprivate(my_id)
end module data_mod
program test
use data_mod
!$ use omp_lib
implicit none
integer :: data(5), i
!$omp parallel
!$ my_id = omp_get_thread_num()
!$omp end parallel
do i = 1, 5
data(i) = i
end do
call sub (data)
end program test
subroutine sub (data)
use data_mod
implicit none
integer, intent(in) :: data(5)
integer :: ldata(5)
print *, my_id, ' ===== in sub ', data
!$omp parallel
!$ $ default(none)
!$ $ private(ldata)
!$ $ firstprivate(data)
ldata = data + my_id
print *, my_id, ' ==+== in sub ', data, ' == ', ldata
!$omp end parallel
print *, my_id, ' ----- in sub ', data, ' == ', ldata
end subroutine sub
Is it due to compiler problem or I am missing somthing? Please advise.
By the way, here is the way I compiled the code:
/direct/linux/intel8.0/bin/ifc -132 -openmp -c e.f
/direct/linux/intel8.0/bin/ifc -Vaxlib -Bstatic -openmp -o e.x e.o
and here is the output I had (with 2 threads):
0 ===== in sub 1 2 3 4 5
1 ==+== in sub 1 1073965176 1077938680 1073914275
134520856 == 2 1073965177 1077938681 1073914276 134520857
0 ==+== in sub 0 0 1124464348 0
0 == 0 0 1124464348 0 0
0 ----- in sub 1 2 3 4
5 == -1073751844 0 0 1108574732 134520734
Thanks,
David Wong
I was able to compile the following simple code but the output doesn't seem right:
module data_mod
integer :: my_id
!$omp threadprivate(my_id)
end module data_mod
program test
use data_mod
!$ use omp_lib
implicit none
integer :: data(5), i
!$omp parallel
!$ my_id = omp_get_thread_num()
!$omp end parallel
do i = 1, 5
data(i) = i
end do
call sub (data)
end program test
subroutine sub (data)
use data_mod
implicit none
integer, intent(in) :: data(5)
integer :: ldata(5)
print *, my_id, ' ===== in sub ', data
!$omp parallel
!$ $ default(none)
!$ $ private(ldata)
!$ $ firstprivate(data)
ldata = data + my_id
print *, my_id, ' ==+== in sub ', data, ' == ', ldata
!$omp end parallel
print *, my_id, ' ----- in sub ', data, ' == ', ldata
end subroutine sub
Is it due to compiler problem or I am missing somthing? Please advise.
By the way, here is the way I compiled the code:
/direct/linux/intel8.0/bin/ifc -132 -openmp -c e.f
/direct/linux/intel8.0/bin/ifc -Vaxlib -Bstatic -openmp -o e.x e.o
and here is the output I had (with 2 threads):
0 ===== in sub 1 2 3 4 5
1 ==+== in sub 1 1073965176 1077938680 1073914275
134520856 == 2 1073965177 1077938681 1073914276 134520857
0 ==+== in sub 0 0 1124464348 0
0 == 0 0 1124464348 0 0
0 ----- in sub 1 2 3 4
5 == -1073751844 0 0 1108574732 134520734
Thanks,
David Wong
Link Copied
0 Replies

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page