Define and send MPI vector datatypes

 


      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(4, 2, 3, MPI_INTEGER, inewtype, ierr)
      CALL MPI_TYPE_COMMIT (inewtype, ier)

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

      CALL MPI_FINALIZE(ierr)

      END



~