1 C******************************************************************************
4 C OpenMP Example - Hello World - Fortran Version
5 C In this simple example, the master thread forks a parallel region.
6 C All threads in the team obtain their unique thread number and print it.
7 C The master thread only prints the total number of threads. Two OpenMP
8 C library routines are used to obtain the number of threads and each
10 C AUTHOR: Blaise Barney 5/99
12 C******************************************************************************
16 INTEGER NTHREADS
, TID
, OMP_GET_NUM_THREADS
,
19 C Fork a team of threads giving them their own copies of variables
20 !$OMP PARALLEL PRIVATE
(NTHREADS
, TID
)
23 C Obtain thread number
24 TID
= OMP_GET_THREAD_NUM
()
25 PRINT
*, 'Hello World from thread = ', TID
27 C Only master thread does this
29 NTHREADS
= OMP_GET_NUM_THREADS
()
30 PRINT
*, 'Number of threads = ', NTHREADS
33 C All threads join master thread and disband