LAM/MPI F77 Example

Compiling F77 Example Using the lam modules

First you need to create your source code. See example mpi_hello.f  below:
c mpi_hello for fortran77
c
      PROGRAM MAIN
      INCLUDE 'mpif.h'
      INTEGER IRANK,IPROC,IERR,IFINISH
C
      CALL MPI_INIT (IERR)
      CALL MPI_COMM_RANK (MPI_COMM_WORLD,IRANK,IERR)
      CALL MPI_COMM_SIZE (MPI_COMM_WORLD,IPROC,IERR)
      PRINT*, 'Hello world, I am ', IRANK, ' of ', IPROC
      CALL MPI_FINALIZE(IFINISH)
      STOP
      END
Then you must load the lam-intel module
$ module load lam-intel (Loads the intel-10 module)
or
$ module load lammpi/intel-9
or
$ module load lammpi/intel-10
or
$ module load lammpi/intel-11
or
$ module load lammpi/gnu
or
$ module load lam-gnu (Loads the lammpi/gnu module)
Then compile the code
$ mpif77 -o lam-hello mpi_hello.f
 
You should not see any error output, and should have an executable file called lam-hello in current your directory.
CAUTION: If you do not load the module your code will not compile correctly!

Write the jobfile

#PBS -N lam-hello
#PBS -q @nic-cluster.mst.edu
#PBS -l nodes=2
#PBS -l walltime=01:00:00
#PBS -m abe
#PBS -M joeminer@mst.edu
#PBS -V
cd $PBS_O_WORKDIR
mpiexec -v -boot -n 2 ./lam-hello
*Note: The -n option of mpiexec within lam will launch any number of processes balanced across the number of nodes specified. For example you can use mpiexec -v -boot -n 20 ./lam-hello and it will start 10 processes on each of the two nodes.

Submit the Job

If you have logged out since you last loaded the module you will need to load the module again. More information on modules, qsub.
$ qsub job_file_name

Output

job_file_name.o####
mpiexec: Booting lam..
Running: lamboot  -v
LAM 7.1.4/MPI 2 C++/ROMIO - Indiana University
mpiexec: Lamboot Complete
mpiexec: Launching MPI programs
Running: mpirun  -v  /tmp/lam_appschema_TGhCA58783 ./lam-gnu-f77 running on n0 (o)
8784 ./lam-gnu-f77 running on n0 (o)
 Hello world, I am  0 of  2
 Hello world, I am  1 of  2
mpiexec: MPI program execution over..
mpiexec: Performing Lamhalt
LAM 7.1.4/MPI 2 C++/ROMIO - Indiana University
Shutting down LAM
hreq: received HALT_ACK from n0 (compute-0-9.local)
lamhalt: sleeping to wait for lamds to die
LAM halted
mpiexec: Lamhalt complete

Errors

If the output is not what you expected check the job_file_name.e#### file.