Scripted HTML version of Foils prepared 11 November 1996

Foil 15 Hello World in C plus MPI

From CPS615-Initial Lecture on MPI ending with discussion of basic MPI_SEND Delivered Lectures of CPS615 Basic Simulation Track for Computational Science -- 31 October 96. by Geoffrey C. Fox *
Secs 115.2
#include <stdio.h>
#include <mpi.h>
void main(int argc,char *argv[])
{
  • int ierror, rank, size
  • MPI_Init(&argc, &argv); # Initialize
  • MPI_Comm_rank(MPI_COMM_WORLD, &rank); # Find Processor Number
  • if( rank == 0)
    • printf ("hello World!\n");
  • ierror=MPI_Comm_size(MPI_COMM_WORLD, &size);
  • if( ierror != MPI_SUCCESS ) # Find Total number of processors above
    • MPI_Abort(MPI_COMM_WORLD,ierror); # Abort
  • printf("I am processor %d out of total of %d\n", rank, size);
  • MPI_Finalize(); # Finalize
}



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Fri Aug 15 1997