- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear IVF users and developers,
I am learning OpenMP today. I followed a tutorial: http://www.openmp.org/presentations/miguel/F95_OpenMPv1_v2.pdf
But when I compile and run this:
[fortran]
program OpenMPpractice
implicit none
! Variables
! Body of OpenMPpractice
!$OMP PARALLEL
write(*,*) "Hello"
!$OMP PARALLEL
write(*,*) "Hi"
!$OMP END PARALLEL
!$OMP END PARALLEL
end program OpenMPpractice
[/fortran]
The result is:
Hello
Hello
Hello
Hello
Hi
Hello
Hello
Hello
Hi
Hi
Hello
Hi
Hi
Hi
Hi
Hi
But according to the tutorial, I can see that there are 8 threads in the first level of parallel. But in the second level of parallel, the situation is different. I was thinking there should be 64 "Hi"s printed, but there are only 8.
Can anyone tell me what happened there?
Thanks,
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I think you need nested parallelism enabled. Can you try adding:
call omp_set_nested(.true.)
Roman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Roman,
It works! Thanks.
I add use omp_lib. Everything compiles OK.

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