Sharing Data

 

 program bcast
      include 'mpif.h'

      call MPI_Init(ierr)
      call MPI_Comm_size(MPI_COMM_WORLD, nprocs, ierr)
      call MPI_Comm_rank(MPI_COMM_WORLD, myrank, ierr)

      if (myrank .eq. 0) then
         read(*,*) ivalue
      else
         ivalue = 0
      endif

      call MPI_Bcast(*****************************)

      print *, 'Process ', myrank, ' got ', ivalue

      call MPI_Finalize(ierr)
      end