/* schedule.c  find out where MPI processes are running  */
#include "mpi.h"
#include <stdio.h>
#include <time.h>
#include <stddef.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
  int myid, numprocs;
  int master = 0;
  double esec = 0.0;
  struct tm *ptr;
  time_t Lt;
  char hostname[72] = "not receiced";

  MPI_Init(&argc,&argv);
  MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
  MPI_Comm_rank(MPI_COMM_WORLD,&myid);

  /* all */
  Lt = time(NULL);
  ptr = localtime(&Lt);
  gethostname(hostname, 72);
  printf("proc %d started on %s ", myid, hostname); 
  printf("at %s \n", asctime(ptr));

  /* master */
  if(myid == master)
  {
    printf("schedule.c  numprocs=%d \n", numprocs);
    esec = MPI_Wtime();
    printf("schedule.c took %g seconds \n", esec);
  }
  MPI_Finalize();
  return 0; 
}