Fix ifunc detection in target-supports.exp file.
[official-gcc.git] / libgomp / testsuite / libgomp.fortran / omp_workshare2.f
blob9e61da91e9be65778ad1b3a81f16da825a2eefa7
1 C******************************************************************************
2 C FILE: omp_workshare2.f
3 C DESCRIPTION:
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******************************************************************************
12 PROGRAM WORKSHARE2
14 INTEGER N, I, NTHREADS, TID, OMP_GET_NUM_THREADS,
15 + OMP_GET_THREAD_NUM
16 PARAMETER (N=50)
17 REAL A(N), B(N), C(N)
19 ! Some initializations
20 DO I = 1, N
21 A(I) = I * 1.0
22 B(I) = A(I)
23 ENDDO
25 !$OMP PARALLEL SHARED(A,B,NTHREADS), PRIVATE(C,I,TID)
26 TID = OMP_GET_THREAD_NUM()
27 IF (TID .EQ. 0) THEN
28 NTHREADS = OMP_GET_NUM_THREADS()
29 PRINT *, 'Number of threads =', NTHREADS
30 END IF
31 PRINT *, 'Thread',TID,' starting...'
33 !$OMP SECTIONS
35 !$OMP SECTION
36 PRINT *, 'Thread',TID,' doing section 1'
37 DO I = 1, N
38 C(I) = A(I) + B(I)
39 WRITE(*,100) TID,I,C(I)
40 100 FORMAT(' Thread',I2,': C(',I2,')=',F8.2)
41 ENDDO
43 !$OMP SECTION
44 PRINT *, 'Thread',TID,' doing section 2'
45 DO I = 1+N/2, N
46 C(I) = A(I) * B(I)
47 WRITE(*,100) TID,I,C(I)
48 ENDDO
50 !$OMP END SECTIONS NOWAIT
52 PRINT *, 'Thread',TID,' done.'
54 !$OMP END PARALLEL
56 END