I know this is not strictly a F90 question but I'm hoping it's close enough
that someone can easily help me (cause I'm stuck!)
I'm trying to write my first Openmp program on a Sun Solaris 2 processor
Ultra 60 but I can't get it to work.
I wrote a simple hello.f90 code shown below and compile it with either of:
f95 -c -xopenmp=noopt -Xlist hello.f90
f95 -c -xopenmp=parallel -O3 -XlistMP -Xlist hello.f90
then link. All this goes smoothly (no errors or warnings). I'm using the
lastest available sun compiler (7.1, March 03)
Before running I set the number of threads to 2 using
setenv OMP_NUM_THREADS 2
When I run it, I get the following
----------------------------------------
(darwin 8> ./hello.exe
OMP AWARE!!
Num procs = 1
No. threads = 1
Max No. threads = 1
In parallel region? : F
Hello World
Thread no. 0
Thread no. 0
Thread no. 0
Thread no. 0
-----------------------------------------
The conditional write statement "OMP AWARE" is triggered but nothing else.
In particular, the number of processors is 1 and the maximum number of
threads is 1?!
Any help would be greatly appreciated - I'm stumped on this one.
----------------------------------------
----------------------------------------
program hello
! NOTE: set OMP_NUM_THREADS before running this program
! e.g., setenv OMP_NUM_THREADS 2
! This module is needed to reference library routines
USE omp_lib
implicit none
! integer :: omp_get_num_procs
! integer :: omp_get_num_threads
! integer :: omp_get_thread_num
! logical :: OMP_IN_PARALLEL
integer :: nproc, num_threads,i, max_threads
! write this only if omp-aware compiler
!$ write(*,*) 'OMP AWARE!!'
!$ write(*,*)
nproc = omp_get_num_procs()
write(*,*) 'Num procs = ', nproc
! set the number of threads for the next parallel region
call omp_set_num_threads(2)
num_threads = OMP_get_num_threads()
write(*,*) 'No. threads = ', num_threads
max_threads = OMP_get_max_threads()
write(*,*) 'Max No. threads = ', max_threads
!$OMP PARALLEL
! check whether code is in a parallel region - should be FALSE
!$ write(*,*) 'In parallel region? : ', OMP_IN_PARALLEL()
write(*,*) 'Hello World'
!$OMP DO
do i = 1,4
write(*,*) 'Thread no. ', omp_get_thread_num()
end do
!$OMP end do
!$OMP END PARALLEL
end program hello
|