program workshare !$ use OMP_LIB implicit none real(8), dimension(:), allocatable :: T integer :: Nx1 = 4096+4096, i, j, tnot 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) tnot = OMP_GET_NUM_THREADS() ! get the total number of threads currently running this PR !$OMP DO SCHEDULE(STATIC,Nx1/tnot) do i=1,Nx1 do j=1,Nx1 T(i) = T(i) + dsqrt(dabs((dcos(T(i))+dsin(T(j)))))/T(j) end do end do !$OMP END DO !$OMP END PARALLEL deallocate(T) end program workshare