ProgPAR_Hybrid_OpenMP_MPI.c

#include <stdio.h>
#include "mpi.h"
#include <omp.h>
#
int main(int argc, char *argv[]) {
  int numprocs, rank, namelen;
  char processor_name[MPI_MAX_PROCESSOR_NAME];
  int iam = 0, np = 1;
#
  MPI_Init(&argc, &argv);
  MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  MPI_Get_processor_name(processor_name, &namelen);
#
  #pragma omp parallel default(shared) private(iam, np)
  {
    np = omp_get_num_threads();
    iam = omp_get_thread_num();
    printf("Bonjour, je suis le thread %d parmi %d threads du process  %d parmi %d     processes sur le noeud  %s\n",
           iam, np, rank, numprocs, processor_name);
  }

  MPI_Finalize();
}