Serial program is a reduction: |
sum = 0.0 |
do 10 i=1,n |
10 sum = sum + a(i) |
Correct (but slow) program: |
sum = 0.0 |
c$omp parallel private(i) shared(sum,a,n) |
c$omp pdo |
do 10 i=1,n |
c$omp critical |
sum = sum + a(i) |
c$omp end critical |
10 continue |
c$omp end parallel |