      program summation
*---------------------------------------------------------------
c
c     sum.f by Glenn Luecke & Juergen Schnack
c     
*---------------------------------------------------------------
      implicit   none
      integer*8  i,j,n,Dim
      Parameter  (Dim=20000)
*
      real*8     sum,A(Dim)
*
      character  Version*50
*
      Version= '# sum 01 Glenn Luecke & Juergen Schnack 17. 06. 2010' 
*---------------------------------------------------------------
*
*     sum
*
      n = Dim

      sum = 0.d0
!$omp parallel  shared(sum,A) private(i,j)
!$omp do  schedule(static) reduction(+:sum)
           do i = 1, n

              A(i) = 0.d0
              do j = 1, n
                 A(i) = A(i) + 1.d0 * DSIN(DCOS(2.d0*j))
              enddo

              sum = sum + A(i)
           enddo
!$omp end parallel
           
      write(6,*) 'sum = ', sum

*---------------------------------------------------------------
*
      end
