Note that there are several example codes in the class repository that might be useful, e.g.
- $UWHPSC/codes/openmp
- $UWHPSC/codes/lapack/random
- $UWHPSC/2013/homeworks
- $UWHPSC/2013/solutions
Discussion of random number generators. See UWHPSC/labs/lab11
Questions about OpenMP?
Work on this in groups!
Write a Fortran program to do the following:
Since random_number produces numbers that should be uniformly distributed between 0 and 1, the mean should be approximately 0.5 for large n. It can also be shown that for a uniform distribution, the difference between the mean of a sample of n numbers and the true mean of the distribution should decay to zero like \(1/\sqrt{n}\) as \(n\longrightarrow\infty\). Do you observe this?
Modify your code to use OpenMP by using an omp parallel do loop with a suitable reduction to compute the mean.
There is a quiz for this lab.