!******************************************************************** ! program : mpi_samp2.f90 ! programmer : makoto nakajima ! description: hello, world! with conditional if statement. ! date : april 25, 2006 !******************************************************************** program main implicit none !prohibit implicit declaration of variables include 'mpif.h' !include mpi library !******* variables related mpi ******* integer:: ierror !return error message from mpi subroutines integer:: id !identification number of each processor integer:: nproc !total number of processors !******* other variable declaration ******* integer:: idsays !determines who says hello !******* initialization ******* !initialization of mpi environment call mpi_init(ierror) !obtain id for each node call mpi_comm_rank(mpi_comm_world, id, ierror) !returns the number of nodes call mpi_comm_size(mpi_comm_world, nproc, ierror) !******* main part of program ******* idsays=4 !node 4 says hello ad others don't if (id==idsays) then !different message between idyes and others. print *, 'hello, world! i am node ',id else print *, 'i am node ',id,'. i wish i could say hello...' end if !******* finalize mpi environment ******* call mpi_finalize(ierror) end program main