mpiJava Example Programmes
This web page will help you download and run example
parallel codes that are discussed in the lectures.
These instructions will work on the computers in the department's Linux lab.
Before downloading any code you should do the following:
If you don't know how to set environment variables take a look at http://www.codecoffee.com/tipsforlinux/articles/030.html.
You can add these updates to your environmental variables by editing your .bash_login file (if you are using the bash shell) or the .cshrc.mine file (if you are using the csh shell). Then they will be automatically set every time you log on.
- Add /usr/local/mpiJava/lib/classes to your CLASSPATH environmental variable
- Add /usr/local/mpich-1.2.6/bin, /usr/local/mpiJava/src/scripts, and /opt/jdk1.5.0_04/bin to your PATH environmental variable.
- Add /usr/local/mpiJava/lib to your LD_LIBRARY_PATH environmental variable.
The examples listed below are downloaded as binary tar files. For each example you
should create a new directory using the mkdir command. If you don't know how to do this type man mkdir at the command prompt. Having downloaded the
tar file into the newly-created directory you should uncompress it by typing tar xvf filename, where
filename is the name of the file, e.g., Hello.tar. Then just type make, and the example code should compile and run. Once the code is compiled you can always run it again using the prunjava command. For example,
prunjava 4 Hello
will run the Hello example on 4 machines. If you attempt to run an example on more than about 8 machines you may run into trouble, as this seems to bring the machine you're on to a halt.
You should also edit the machines file. This lists the machines that are available for use by mpiJava. If lots of people try to run parallel codes at the same time and they all use the same machines file, then the machines in the file will be heavily used and others will be idle. The machines file consists of names of machines (one per line). The names of the machines that you can use are:
You can generate
your own machines file by listing these machine names in "random" order in the file.
Here are the codes for download:
More example codes will be added later.
If you run into problems then send me
- Hello.java: this is similar to the first example code in the lecture notes.
- Integrate.java: this is similar to the integration example code in the lecture notes.
- VibratingString.java: this is similar to the vibrating string example code in the lecture notes. The code will now give a graphical display of the solution that can be re-run by clicking on the Play button.
- LaplaceEquation.java: this is similar to the Laplace equation example code in the lecture notes. The code will now give a graphical display of the solution that can be re-run by clicking on the Play button.
- Wator.tar: this is a sequential version of the WaTor program written in C. After uncompressing the file type "make" to compile the code, and then "wator" to run it.
You will be ask to supply inputs such as the number of rows and columns in the ocean grid (200 for each is a good value). This version of the code also
allows for fish and sharks to die of old age, which was not included in the rules for sharks and fish given in the lectures - you can set these to high values to conform to these rules.
To start or resume the simulation click in the Wator window.
There is a sample input file which you can you by typing "wator < wator.dat".
If you have your own PC or laptop with Linux installed you can install mpiJava on your own machine. There are two basic steps:
- Install MPICH by downloading the latest version from
http://www.mcs.anl.gov/mpi and following the instructions. Once this is installed you will be able to run MPI programmes in C.
You must make sure that rsh runs on your laptop.
- Install mpiJava by downloading the latest version from
http://www.hpjava.org/mpiJava.html and following the instructons.