      program one2allbroadcast
      include 'mpif.h'
      integer nnodes,myid,vdim
      parameter(niters=1000)
      parameter(vdim=1000)
      integer comm,ierr
      integer status(MPI_STATUS_SIZE),root
      double precision time_begin,time_end
      double precision,allocatable,dimension(:) :: recv_buffer,send_buffer

      comm = MPI_COMM_WORLD
      call MPI_init(ierr)
      call MPI_COMM_RANK(comm,myid,ierr)
      call MPI_COMM_SIZE(comm,nnodes,ierr)
  
      allocate(send_buffer(vdim))
      allocate(recv_buffer(vdim))
      send_buffer = 9999.000*myid

!start timer .....
      time_begin =  MPI_Wtime()
    
      do iter = 1,niters
! Do all-to-all personilized communication of matrix blocks
        call MPI_AllReduce(send_buffer,recv_buffer,vdim,&
            MPI_DOUBLE_PRECISION,MPI_SUM,comm,ierr)
      enddo
! Stop timer

      time_end =  MPI_Wtime()

      if (myid == 0) then
        print *,'Elapsed time ',niters,'iterations for all2allbroadcast'
        print *,'is'
        print *,time_end-time_begin ,'seconds'   
       endif
      deallocate(recv_buffer)
      deallocate(send_buffer)

      call MPI_FINALIZE(ierr)

      end


      


