HomeMPI Programming MPI 1.1 Index Using MPI on the AC <- Prev -- Index -- Next ->

Exercise 1: Hello World - the minimal MPI program

  1. Write a minimal MPI program which prints "hello world" from multiple processes. Compile and run it on 1, 2 and 4 procesors.

  2. Add the writing processes rank as part of the output. (Also note the -t option for mpirun.)

  3. Use Fortran:
    integer mpi_log_fd=11
    character*10 filenm
    ...
    write(filenm,'("mpilog.",i2.2)') mpirank
    open(unit=mpi_log_fd, file=filenm) 

    or C:

    FILE *mpi_log_fd;
    char filenm[10];
    ...
    sprintf(filenm, "mpilog.%2.2d" , mpirank);
    mpi_log_fd = fopen(filenm,"w" ); 

    to open a log file for each process and write to it.
    (To use such log files for debugging, it may be necessary to use flush() after each write/fprintf -- dont use flush() except for debugging.)

  4. What happens to IO before MPI_Init() or after MPI_Finalize() on different machines?

[Solution in hello.f/f90/c ]

APAC NATIONAL FACILITY<- Prev -- Index -- Next ->