program main c*********************************************************************72 c cc MAIN is the main program for VERSION. c c Discussion: c c VERSION is a simple MPI test program that gets the version of MPI. c c Get the version and subversion of MPI. c c Modified: c c 09 January 2004 c c Author: c c John Burkardt c c Reference: c c William Gropp, Ewing Lusk, Anthony Skjellum, c Using MPI: Portable Parallel Programming with the c Message-Passing Interface, c Second Edition, c MIT Press, 1999, c ISBN: 0262571323. c c c Define MPI symbols by invoking the Fortran77-style include file: c include 'mpif.h' integer error integer master integer num_procs integer subversion integer version integer world_id master = 0 c c Initialize MPI. c call MPI_Init ( error ) c c Get MPI version and subversion. c call MPI_Get_version ( version, subversion ) c c Get the number of processes. c call MPI_Comm_size ( MPI_COMM_WORLD, num_procs, error ) c c Get the individual process ID. c call MPI_Comm_rank ( MPI_COMM_WORLD, world_id, error ) c c Print a message. c if ( world_id .eq. master ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'VERSION - Master process:' write ( *, '(a)' ) ' FORTRAN77 version' write ( *, '(a)' ) ' A simple MPI program.' write ( *, '(a)' ) ' ' write ( *, '(a,i3)' ) ' The number of processes is ', & num_procs write ( *, '(a)' ) ' ' write ( *, '(a,i3)' ) ' MPI version number is ', version write ( *, '(a,i3)' ) ' MPI subversion number is ', & subversion end if write ( *, '(a)' ) ' ' write ( *, '(a,i3,a)' ) ' Process ', world_id, & ' says "Hello, world!"' if ( world_id .eq. master ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'VERSION - Master process:' write ( *, '(a)' ) ' Normal end of execution: ' write ( *, '(a)' ) ' "Goodbye, world!".' end if c c Shut down MPI. c call MPI_Finalize ( error ) stop end