Define and send MPI vector datatypes

 

MPI vector datatypes

 

 



Write a program that defines a datatype representing eight integers with gaps as shown below and broadcast the value
Blocklength 1     2     3     4=count
          <---> <---> <---> <--->
          -----------------------
Newtype   |*|*| |*|*| |*|*| |*|*|         *: MPI_Integer(oldtype)
          -----------------------
          <----->
          stride(#of units)


You may want to use these MPI routines in your solution:

Hint: 
Use the following pseudo code and complete the arguments:

      PROGRAM type_vector 
      INCLUDE 'mpif.h'
      INTEGER ibuf(20)

      CALL MPI_INIT(IERR)
      CALL MPI_COMM_SIZE(MPI_COMM_WORLD, mprocs, ierr)
      CALL MPI_COMM_RANK(mpi_COMM_WORLD, myrank, ierr)

      IF (myrank == 0) THEN
        do i=1,20
           ibuf(i) = i
        enddo

      ENDIF

      CALL MPI_TYPE_VECTOR()
      CALL MPI_TYPE_COMMIT ()

      CALL MPI_BCAST(ibuf, 1, inewtype, 0, MPI_COMM_WORLD, ierr)
      PRINT *, ' IBUF =', ibuf

      CALL MPI_FINALIZE(ierr)

      END