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