#include #include #include #include int main(int argc, char **argv) { char *env_hostname; char hostname[255]; int myrank, size; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &myrank); MPI_Comm_size(MPI_COMM_WORLD, &size); env_hostname = getenv("HOSTNAME"); if (NULL != env_hostname) { printf("Processor %d of %d on $HOSTNAME %s: Hello World\n", myrank, size, env_hostname); } else { printf("Processor %d of %d on $HOSTNAME NULL: Hello World\n", myrank, size); } if (0 == gethostname(hostname, 255)) { printf("Processor %d of %d on host %s: Hello World\n", myrank, size, hostname); } MPI_Finalize(); exit(0); }