/* Jonathan Hauenstein - University of Notre Dame Center for Applied Mathematics Minicourse on Parallel Computing April 24, May 1, May 8, 2008 Sample programs are designed for educational use */ #include "test.h" #include int main(int argc, char **argv) { int my_id, num_proc, my_value; aStruct A; MPI_Status status; MPI_Datatype mpi_aStruct; // initialize MPI MPI_Init(&argc, &argv); // find unique id MPI_Comm_rank(MPI_COMM_WORLD, &my_id); // find the number of processes running MPI_Comm_size(MPI_COMM_WORLD, &num_proc); // create mpi_aStruct create_aStruct(&mpi_aStruct); // send from id 0 to id 1 if (my_id == 0) { // setup A A.a = 9; A.s = '+'; A.r = 0.5; // send A MPI_Send(&A, 1, mpi_aStruct, 1, 0, MPI_COMM_WORLD); } else if (my_id == 1) { // recv A MPI_Recv(&A, 1, mpi_aStruct, 0, 0, MPI_COMM_WORLD, &status); // print printf("a: %d s: %c r: %f\n", A.a, A.s, A.r); } // clear mpi_aStruct MPI_Type_free(&mpi_aStruct); // finalize MPI MPI_Finalize(); return 0; }