Job-Example

This Page demonstrates how to run the following Fortran Program named blw.F90 in parallel on several nodes of a cluster using the machanisms of MPI for parallisation.
      program blw

      include 'mpif.h'

      integer n, myid, numprocs, l
      character*(MPI_MAX_PROCESSOR_NAME) procnam

      call MPI_INIT( ierr )
      call MPI_COMM_RANK( MPI_COMM_WORLD, myid, ierr )
      call MPI_COMM_SIZE( MPI_COMM_WORLD, numprocs, ierr )
      call MPI_Get_processor_name (procnam,l,ierr)
      write(6,*) 'Process ',myid,' of ',numprocs,' is alive on ', &
     &           procnam(1:l)
      call sleep (1)
      call MPI_FINALIZE(rc)
      stop
      end
As a first step this Fortran source code has to be compiled into a executable binary. Since there are several different compilers (and possibly several version of each compiler) the environment for a particular compiler and for a particular MPI-Library has to be selected. While the command
module avail
lists all environment modlues available on a particular cluster,
module load intel-cluster-studio-2016
module load mpi/intel/5.1.3.210
loads the environments for the selected versions. The actual compilation can be done with
mpiifort -o blw.exe blw.F90
where the option -o blw.exe specifies the name of the executable file. mpiifort is a wrapper for the Intel Fortran Compiler ifort. This wrapper also specifies the libraries (including path names) needed for paralelisation.
In the seconed step the job executing the program has to be submitted to the job queue. The following example script named blw.pbs can be used for execution:
#!/bin/tcsh
#PBS -l nodes=4:ppn=24,walltime=00:05:00
#PBS -j oe
#PBS -m abe
cd $PBS_O_WORKDIR

module load intel-cluster-studio-2016 
module load mpi/intel/5.1.3.210
date

$MPI_RUN -machinefile $PBS_NODEFILE ./blw

date
The lines starting with #PBS secify details on how to do the execution. -l sets the Limits; we want to user 4 nodes and 24 cores per node for a maximium time of 5 minutes. -l

Last modified November 2016 by Dr. Bernhard L. Winkler