Install and configure MPI

This article explains how to install and configure MPI to be able to run the  ESTEL model in parallel on a network of computers. Note that this article is merely a quick run through the MPI Installer's Guide at http://www-unix.mcs.anl.gov/mpi/mpich2/.

This article is general an can be used to configure MPI for any application requiring a Fortran 90 compiler really.

= Pre-requesites=

ssh key authentication
To use MPI on a network of computers, you need to be able to log in any of the computer without user interaction (password etc...) This is easily achieved using secure shell key authentication. The methodology to setup ssh to use key authentication is described in the article entitled " Configure ssh for MPI".

Fortran 90 compiler
You need a Fortran90 compiler to compile and run the TELEMAC system. When running simulations in parallel mode, MPI use a wrapper to your existing compiler, usually called. This wrapper is built when MPI is compiled and therefore, you need to have a Fortran 90 compiler installed before you attempt to compile MPI.

= Download MPI = You can download from http://www-unix.mcs.anl.gov/mpi/mpich2/. You will end up with a gzipped tarball called something like  with a version number in the name as well. Note that the TELEMAC system uses MPI-1 statements but we encourage you to install MPICH-2 (which is backward compatible) as TELEMAC will probably move towards MPI 2 at some point in the future.

For the sake of this article, we assume that you have extracted the tarball into a directory called.

= Compilation = The compilation of MPI is fairly straightforward but beforehand, you need to create an install folder (called  here) and a build folder (called   here):

To configure the MPI build, the only required step is to assign to the environment variable  the name of your Fortran 90 compiler. This name needs to be in your  or you have to give the full path to the Fortran 90- compiler if not. Then the  command will automatically configure the build for you:

This will test many factors on your machine and configure the build. If the  command finished without problem, you are ready to build MPI. Note that you can inspect  for problems. In particular, you want to make sure that the Fortran 90 compiler is OK for the build.

To compile and install MPI, just issue the standard  and   commands:

This will install MPI in.

Note that you will need to install MPI on all the nodes in your network that will be used for MPI jobs. As they probably have the same computer architecture, you could just copy the  accross.

= Configuration of MPI=

PATH
Add  to. This often means adding the following lines to your  file:

Now, you should be able to see the MPI Fortran 90 wrapper  and the MPI multiprocessor daemon  :

Note that the  needs to be set on each node which will be used for MPI simulations. This is straightforward if your home directory is shared for all the nodes or you need to do it manually otherwise.

Password in
MPI requires a file in your home directory called  (yes, there are two dots) which contains the line:

This file should be readable and writable only by you.

'''Check if this needs to be done on all nodes.... and if the secret thing needs to be the same. Probably yes.'''

Now that the passord has been set, you should be able to start the multiprocessor daemon on one host with the command. You can check it is up with, run a simple command via MPI with   and bring it down with  , for instance when trying on the master:

It is interesting to note that we asked for two processes with the  command with the arguments   although we have only one machine in our network yet. The  is intelligent enough to just wrap around. In the output above, the  is used and we can see that processes 0 and 1 return the sdame value so thay are definitely run on the same host. This is very useful to test parallel programs on a single machine.

Hosts in
To be able to send the processes to other hosts on the network, create a file in your home directory called  which contain a list of the nodes to be used by MPI, one per line. If the network consists of the master and two slaves slave1 and slave2,  would contain:

This file should be created on the master node, i.e. the one that you will use to launch MPI jobs. All the hosts in the list need to have a working installation of MPI.

= Using an  ring =

To dispatch MPI rocesses to other hosts on the network, we need to start a ring of multiprocessor daemons, which we will simply call a  ring. The ring is started from the master node and will include the nodes in the  file.

Start the ring
The  ring is started from the master node with the   command. The syntax is self-explanatory:

In the example above, "3" is the number of nodes to include in the ring. By default, the master is always included in the ring. The option  is used to specify the name of the hosts file.

Test the ring
The command  can be used to list which machines are in the ring:

To test the ring, use. That will send a message to circle around the ring (a loop) and tell you how long it took. One loop is very fast so make the message circle round a few times:

You can also send a command in parallel using. The option  will append the process number before the output of the command. The option  request the job to start 5 processes, as we only have 3 hosts in the ring, the processes will "wrap around" as shown in the listing below; "master" and "slave2" have been used twice:

If you can do this, congratulations! You should be able to run parallel ESTEL jobs on your ring now!

Just remember to start a  ring before running your parallel job.

Close the ring
The command  is used to terminate the   ring:

= Trouble shooting = The MPI Installer's Guide has a good section about troubleshooting (Appendix A). To summarise things that might be helpful:
 * make sure you can start  on each host separately first
 * check that the  on each host is correct and has an entry for each host with the right IP address.
 * read the MPI manual!
 * take your time...