      real x(10000), sum, localsum(0:p-1)
      Semaphore slok
      N=10000
        ...
      parallel do k = 0, P-1
        localsum(k) = 0.0
        do i = 1+k*(N/P), (k+1)*(N/P)
          localsum(k) = localsum(k) + x(i)
        enddo
      end parallel do
      barrier()
      sum=localsum(0)
      do k = 1, p-1
        lock(slok)
        sum = sum + localsum(k)
        unlock(slok)
      enddo
