NERSC logo National Energy Research Scientific Computing Center
  A DOE Office of Science User Facility
  at Lawrence Berkeley National Laboratory
 

Fortran/MPI "hello" example

Below are the source code (mpi-hello.f), Torque/Moab script file (runhello), and output (hellojob.out).


/scratchdir => cat mpi-hello.f
C     compile:   ftn -fast -o mpi-hello mpi-hello.f
C     run:       aprun -n 2 ./mpi-hello 
 
      IMPLICIT NONE
      INCLUDE 'mpif.h'
  
      INTEGER :: myPE, totPEs, ierr
  
      CALL MPI_INIT( ierr )
      CALL MPI_COMM_RANK( MPI_COMM_WORLD, myPE, ierr )
      CALL MPI_COMM_SIZE( MPI_COMM_WORLD, totPEs, ierr )
 
      PRINT *, "myCPU is ", myPE, " of total ", totPEs
  
      CALL MPI_FINALIZE(ierr)
  
      END


 
/scratchdir => cat runhello
#PBS -N hellojob
#PBS -q debug
#PBS -l mppwidth=2
#PBS -l walltime=00:01:00
#PBS -e hellojob.out
#PBS -j eo
 
cd $PBS_O_WORKDIR
 
ftn -fast -o mpi-hello mpi-hello.f   #compiler runs on login node
aprun -n2 ./mpi-hello                #launch parallel job on compute nodes

 
/scratchdir => qsub runhello
870.xxx0000n 


/scratchdir => cat hellojob.out
Warning: no access to tty (Bad file descriptor).
Thus no job control in this shell.
/opt/xt-pe/2.0.10/bin/snos64/ftn: INFO: linux target is being used
mpi-hello.f:
 myCPU is             0  of total             2
 myCPU is             1  of total             2
Application 57719 resources: utime 0, stime 0 


LBNL Home
Page last modified: Tue, 30 Oct 2007 20:43:54 GMT
Page URL: http://www.nersc.gov/nusers/systems/franklin/programming/ex1-code.php
Web contact: webmaster@nersc.gov
Computing questions: consult@nersc.gov

Privacy and Security Notice
DOE Office of Science