#!/bin/env python # def hello_mpi ( ): #***************************************************************************** # # HELLO_MPI is a simple 'Hello, world!' test of MPI4PY. # Licensing: # This code is distributed under the GNU LGPL license. # Author: # John Burkardt # with some modifications by Tom Payerle # Retrieved from: # https://people.sc.fsu.edu/~jburkardt/py_src/hello_mpi/hello_mpi.py # # Import some useful packages import sys import platform from mpi4py import MPI # Get the name of the compute node we are running on node = platform.node() # Use the default MPI communicator comm = MPI.COMM_WORLD # Get the size (total number of tasks) and rank (number of our task) id = comm.Get_rank() p = comm.Get_size() if ( id == 0 ): # Print our version number, but only if task # 0 print ( 'HELLO_MPI: Version 1.5' ) #Print a message from each task print ( 'Hello, world! from MPI task ', id, ' of ', p, ' on node ', node) return # Run the hello_mpi routine when called as a script if ( __name__ == '__main__' ): hello_mpi ( )