program datatype1 use mpi implicit none integer, dimension(8,8) :: array integer :: rank, ierr integer :: rowtype integer :: i, j call mpi_init(ierr) call mpi_comm_rank(MPI_COMM_WORLD, rank ,ierr) ! initialize arrays if (rank == 0) then do i=1,8 do j=1,8 array(i,j) = i*10 + j end do end do else array(:,:) = 0 end if if (rank == 0) then write(*,*) 'Data in rank 0' do i=1,8 write(*,'(8I3)') array(i, :) end do end if ! create datatype call mpi_type_vector(8, 1, 8, MPI_INTEGER, rowtype, ierr) call mpi_type_commit(rowtype, ierr) ! send first row of matrix if (rank == 0) then call mpi_send(array(2, 1), 1, rowtype, 1, 1, MPI_COMM_WORLD, ierr) else if (rank == 1) then call mpi_recv(array(2, 1), 1, rowtype, 0, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE, & ierr) end if ! Print out the result if (rank == 1) then write(*,*) 'Received data' do i=1,8 write(*,'(8I3)') array(i, :) end do end if call mpi_type_free(rowtype, ierr) call mpi_finalize(ierr) end program datatype1