1 C******************************************************************************
2 C FILE: omp_workshare2.f
4 C OpenMP Example - Sections Work-sharing - Fortran Version
5 C In this example, the OpenMP SECTION directive is used to assign
6 C different array operations to threads that execute a SECTION. Each
7 C thread receives its own copy of the result array to work with.
8 C AUTHOR: Blaise Barney 5/99
9 C LAST REVISED: 01/09/04
10 C******************************************************************************
14 INTEGER N, I, NTHREADS, TID, OMP_GET_NUM_THREADS,
19 ! Some initializations
25 !$OMP PARALLEL SHARED(A,B,NTHREADS), PRIVATE(C,I,TID)
26 TID = OMP_GET_THREAD_NUM()
28 NTHREADS = OMP_GET_NUM_THREADS()
29 PRINT *, 'Number of threads =', NTHREADS
31 PRINT *, 'Thread',TID,' starting...'
36 PRINT *, 'Thread',TID,' doing section 1'
39 WRITE(*,100) TID,I,C(I)
40 100 FORMAT(' Thread',I2,': C(',I2,')=',F8.2)
44 PRINT *, 'Thread',TID,' doing section 2'
47 WRITE(*,100) TID,I,C(I)
50 !$OMP END SECTIONS NOWAIT
52 PRINT *, 'Thread',TID,' done.'