Create a MSMPI project using the following code, compile and execute the code. /
ID: 3716109 • Letter: C
Question
Create a MSMPI project using the following code, compile and execute the code.
// File-IO-Lab.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
#include <mpi.h>
int main(int argc, char *argv[])
{
const int size = 10;
MPI_File fh;
int rank;
int buf[size];
MPI_Status status;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_File_open(MPI_COMM_WORLD, "test.txt", MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &fh);
if (rank == 0)
{
for (int i = 0; i < size; i++)
buf[i] = i+65;
MPI_File_write(fh, buf, size, MPI_INT, &status);
printf("Status: %d ", status);
system("PAUSE");
}
MPI_File_close(&fh);
MPI_Finalize();
return 0;
}