MPICH2 FORTRAN-77 Example
Compiling FORTRAN-77 Example Using the MPICH2 modules
All the sample code can be found on the cluster at /share/apps/samples/mpich2-f77 you can copy them to your home folder using:
$ cp -r /share/apps/samples/mpich2-f77 ./
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 correct openmpi module
$ module load mpich2-intel
(Loads the openmpi/intel-12 module)
or
$ module load mpich2/intel-11
or
$ module load mpich2/intel-12
or
$ module load mpich2-gnu
or
$ module load mpich2/gcc45
or
$ module load mpich2/gcc46
or
$ module load mpich2/gcc47
Then compile the code
$ mpif77 -o mpich2-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 (jobfile.job)
#PBS -N mpich2-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 -np 2 ./mpich2-hello
Submit the Job
If you have logged out since you last loaded the module you will need to load the module again.
$ qsub jobfile.job
Output
mpich2-hello.o####
Hello world, I am 0 of 2
Hello world, I am 1 of 2
Errors
If the output is not what you expected check the mpich2-hello.e#### file.