next up previous index
Next: Error Handling Up: The Random Pie Previous: The Discussion

Exercises

1
Program randompie of section 5.2.7 does not check for the correctness of the parameter passed on the command line. It does not check if anything is passed on the command line to begin with. Try running this program without passing the value of epsilon on the command line and see what happens.
2
Rewrite program randompie so that process of rank zero checks the command line for any parameters, then checks if the parameters are correct, then sends the OK message to other processes if it has found the value of $\epsilon$ there. Otherwise process rank zero should write an error message on standard error and send a termination message to other processes that would make them go directly to MPI_Finalize.
3
Try varying epsilon and TOTAL. Observe that the accuracy of $\pi$ does not improve beyond a certain TOTAL number of sand grains used in the computation. Why?



Zdzislaw Meglicki
2004-04-29