#include <stdio.h>
#include <string.h>
#include <mpi.h>
int main(int argc, char* argv[]) {
int rank, size;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
char mission[20];
char date[20];
MPI_Status status;
if (rank == 0) {
strcpy_s(mission, "Chandrayaan 3");
strcpy_s(date, "23-August-2023");
printf("Process 0 (ISRO) sending mission name: %s\n", mission
);
MPI_Send
(mission
, strlen(mission
) + 1, MPI_CHAR
, 1, 0, MPI_COMM_WORLD
);
printf("Process 0 (ISRO) sending landing date: %s\n", date
);
MPI_Send
(date
, strlen(date
) + 1, MPI_CHAR
, 1, 1, MPI_COMM_WORLD
);
printf("Process 0 (ISRO): All data sent to Moon successfully!\n"); }
else if (rank == 1) {
MPI_Recv(mission, 20, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status);
printf("Process 1 (Moon) received mission name: %s\n", mission
);
MPI_Recv(date, 20, MPI_CHAR, 0, 1, MPI_COMM_WORLD, &status);
printf("Process 1 (Moon) received landing date: %s\n", date
);
printf("Process 1 (Moon): Successful landing confirmed!\n"); }
MPI_Finalize();
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KI2luY2x1ZGUgPG1waS5oPgoKaW50IG1haW4oaW50IGFyZ2MsIGNoYXIqIGFyZ3ZbXSkgewogICAgaW50IHJhbmssIHNpemU7CgoKICAgIE1QSV9Jbml0KCZhcmdjLCAmYXJndik7CiAgICBNUElfQ29tbV9yYW5rKE1QSV9DT01NX1dPUkxELCAmcmFuayk7CiAgICBNUElfQ29tbV9zaXplKE1QSV9DT01NX1dPUkxELCAmc2l6ZSk7CgogICAgY2hhciBtaXNzaW9uWzIwXTsKICAgIGNoYXIgZGF0ZVsyMF07CiAgICBNUElfU3RhdHVzIHN0YXR1czsKCiAgICBpZiAocmFuayA9PSAwKSB7ICAKICAgICAgIAogICAgICAgIHN0cmNweV9zKG1pc3Npb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