The general structure of MPI programs is depicted here (please visit the links provided in the introduction for a more in-depth discussion on the topic). Your MPI codes will have elements of this structure:
A relatively simple MPI code is shown here. You will notice how the code mirrors the general structure of MPI programs:
call-procs.c: #include <math.h> // math library #include <stdio.h>// Standard Input/Output library int main(int argc, char** argv) { /* MPI Variables */ int num_processes; int curr_rank; int proc_name_len; char proc_name[MPI_MAX_PROCESSOR_NAME]; /* Initialize MPI */ MPI_Init (&argc, &argv); /* acquire number of processes */ MPI_Comm_size(MPI_COMM_WORLD, &num_processes); /* acquire rank of the current process */ MPI_Comm_rank(MPI_COMM_WORLD, &curr_rank); ...