Get_Data4()
printf("Enter a, b, and n\n");
scanf("%f %f %d", a_ptr, b_ptr, n_ptr);
/* pack the data into buffer*/
MPI_Pack(a_ptr, 1, MPI_FLOAT, buffer,
100, &position, MPI_COMM_WORLD);
/* Position has been incremented: it now */
/* points to the first free location in buffer*/
MPI_Pack(b_ptr, 1, MPI_FLOAT, buffer,
100, &position, MPI_COMM_WORLD);
/* Position has been incremented again. */
MPI_Pack(n_ptr, 1, MPI_INT, buffer, 100,
&position, MPI_COMM_WORLD);
/* Position has been incremented again. */
/* Now broadcast contents of buffer */
MPI_Bcast(buffer, 100, MPI_PACKED, 0,
MPI_Bcast(buffer, 100, MPI_PACKED, 0,
/* Now unpack the contents of buffer */
MPI_Unpack(buffer, 100, &position, a_ptr, 1,
MPI_FLOAT, MPI_COMM_WORLD);
/* Once again position has been incremented: */
/* it now references the beginning of b. */
MPI_Unpack(buffer, 100, &position, b_ptr, 1,
MPI_FLOAT, MPI_COMM_WORLD);
MPI_Unpack(buffer, 100, &position, n_ptr, 1,
MPI_INT, MPI_COMM_WORLD);