Sample MPI Fortran Program

From Research IT

Jump to: navigation, search

Sample program hello.f

program hello_world
include '/usr/include/mpif.h'
integer ierr
call MPI_INIT(ierr)
print *, "hello world"
call MPI_FINALIZE(ierr)
stop
end

Compile using:

mpif77 -ffree-form hello.f

Run using:

mpirun C a.out

Output with Hosts file described under running MPI Jobs

hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
Personal tools