HP-MPI User's Guide (11th Edition)

Getting started
Getting started using HP-UX or Linux
Chapter 222
Compiling and running your first application
To quickly become familiar with compiling and running HP-MPI
programs, start with the C version of a familiar hello_world program.
This program is called hello_world.c and prints out the text string
"Hello world! I’m r of s on host" where r is a process’s rank, s is the size
of the communicator, and host is the host on which the program is run.
The processor name is the host name for this implementation.
The source code for hello_world.c is stored in $MPI_ROOT/help and is
shown below.
#include <stdio.h>
#include "mpi.h"
void main(argc, argv)
int argc;
char *argv[];
{
int rank, size, len;
char name[MPI_MAX_PROCESSOR_NAME];
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Get_processor_name(name, &len);
printf("Hello world!I'm %d of %d on %s\n", rank, size,
name);
MPI_Finalize();
exit(0);
}
Building and running on a single host
This example teaches you the basic compilation and run steps to execute
hello_world.c on your local host with four-way parallelism. To build
and run hello_world.c on a local host named jawbone:
Step 1. Change to a writable directory.