/* greetings.c is a 'getting started' program for MPI.
 * Joel Adams, December 2002, for HPC at Calvin College.
 */

#include <stdio.h> /* printf() */
#include "mpi.h"   /* the MPI functions, constants, etc. */

int main(int argc, char * argv[])
{ 
  char myHostName[MPI_MAX_PROCESSOR_NAME];
  int myRank; 
  int numProcesses; 
  int length;
  MPI_Status status;

  MPI_Init(&argc, &argv);

  MPI_Comm_rank(MPI_COMM_WORLD, &myRank);
  MPI_Comm_size(MPI_COMM_WORLD, &numProcesses);
  MPI_Get_processor_name (myHostName, &length);
  
  if (myRank == 0) {
    printf("There are %d processes in this computation.\n",
            numProcesses);
    printf("Greetings from the master process %d on %s\n", 
          myRank, myHostName);
  } else {
    printf("Greetings from a server process %d %s\n", 
          myRank, myHostName);
  }

  MPI_Finalize();
  return 0;
}


