• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1! RUN: %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
2! RUN: %f18 -fopenmp -funparse-with-symbols %s 2>&1 | FileCheck %s
3! CHECK-NOT: do *[1-9]
4
5program P
6implicit none
7integer OMP_GET_NUM_THREADS, OMP_GET_THREAD_NUM
8integer NUMTHRDS, TID
9integer N, CSZ, CNUM, I
10parameter (N=100)
11parameter (CSZ=10)
12real A(N), B(N), C(N)
13
14do 10 I = 1, N
15   A(I) = I * 1.0
1610 continue
17
18B = A
19CNUM = CSZ
20
21!$OMP PARALLEL SHARED(A,B,C,NUMTHRDS,CNUM) PRIVATE(I,TID)
22TID = OMP_GET_THREAD_NUM()
23if (TID .EQ. 0) then
24   NUMTHRDS = OMP_GET_NUM_THREADS()
25   print *, "Number of threads =", NUMTHRDS
26end if
27print *, "Thread", TID, " is starting..."
28
29!$OMP DO SCHEDULE(DYNAMIC,CNUM)
30do 20 I = 1, N
31   C(I) = A(I) + B(I)
32   write (*,100) TID, I, C(I)
3320 continue
34!$OMP END DO NOWAIT
35
36print *, "Thread", TID, " done."
37
38!$OMP END PARALLEL
39100 format(" Thread", I2, ": C(", I3, ")=", F8.2)
40end program P
41