program reduction implicit none real(8), dimension(:), allocatable :: T integer :: Nx1 = 4096+4096, i, j, tnot, Total=0 integer,parameter :: seed = 86456 call srand(seed) ! initialize random number allocate(T(1:Nx1)) do i=1,Nx1 T(i) = rand() end do !$OMP PARALLEL SHARED(T,Nx1) PRIVATE(i,j) DEFAULT(SHARED) !$OMP DO SCHEDULE(RUNTIME) REDUCTION(+:Total) do i=1,Nx1 do j=1,Nx1 T(i) = T(i) + dsqrt(dabs((dcos(T(i))+dsin(T(j)))))/T(j) end do Total = Total + T(i) end do !$OMP END DO !$OMP END PARALLEL deallocate(T) print *, "Total=", Total end program reduction #include #include #include #include int main(int argc, char** argv) { double* T; int Nx1=4096+4096; int seed=86456; int Total=0; int i, j, tnot; srand(seed); T=(double*) malloc(Nx1*sizeof(double)); for(i=0;i