私は並列プログラミングが初めてで、単純な並列 Fortran プログラムで OpenMP で複数のスレッドを使用するのに苦労しています。次のプログラム:
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
結果を生成します。
32
4
1
Hello
1
並列領域内のスレッドの数が、上で設定した nthreads と同じではない理由は何ですか? cygwin を実行している Windows マシンで gfortran -f openmp Hello.f を使用してプログラムをコンパイルしています。