I am new to parallel programming, and am having trouble getting a simple parallel Fortran program to use multiple threads in OpenMP. The following program:
Program Hello
Use omp_lib
Implicit None
INTEGER nthreads
nthreads = 4
CALL OMP_SET_NUM_THREADS(nthreads)
write(*,*) omp_get_num_procs()
write(*,*) omp_get_max_threads()
write(*,*) omp_get_num_threads()
!$OMP PARALLEL
Write(*,*) 'Hello'
Write(*,*) omp_get_num_threads()
!%OMP END PARALLEL
End Program Hello
Produces the result:
32
4
1
Hello
1
What is the reason that the number of threads inside the parallel region is not the same as nthreads that I set above? I am compiling the program using gfortran -f openmp Hello.f on a Windows machine running cygwin.