1 | Serial program is a reduction: |
2 | sum = 0.0 |
3 | do 10 i=1,n |
4 | 10 sum = sum + a(i) |
5 | Correct (but slow) program: |
6 | sum = 0.0 |
7 | c$omp parallel private(i) shared(sum,a,n) |
8 | c$omp pdo |
9 | do 10 i=1,n |
10 | c$omp critical |
11 | sum = sum + a(i) |
12 | c$omp end critical |
13 | 10 continue |
14 | c$omp end parallel |