<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic mpi_type_vector three dimensional in Intel® MPI Library</title>
    <link>https://community.intel.com/t5/Intel-MPI-Library/mpi-type-vector-three-dimensional/m-p/1054296#M4444</link>
    <description>&lt;P&gt;Dear all,&lt;/P&gt;

&lt;P&gt;I have a three dimensional array AA(:,:,:) and I would like to sent it, or at least part of it from one CPU to another.&lt;/P&gt;

&lt;P&gt;The idea is to combine MPI_TYPE_VECTOR. This is my program. I do not understand it, sometimes it works and some time not.&lt;/P&gt;

&lt;P&gt;What do you think?&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;program vector
USE mpi
IMPLICIT NONE
integer SIZE_
parameter(SIZE_=4) 
integer numtasks, rank, source, dest, tag, i,  ierr 
real*4 AA(SIZE_,5,4), BB(SIZE_,5,4) 
integer stat(MPI_STATUS_SIZE), rowtype,colrowtype

!Fortran stores this array in column major order 
AA=0.
AA(1,1,1)= 1.0
AA(1,1,2)= 4.0
AA(1,1,3)= 10.0
AA(1,1,4)= 33.0

AA(2,1,1)= 10.0
AA(2,1,2)= 40.0
AA(2,1,3)= 100.0
AA(2,1,4)= 330.0


   CALL MPI_INIT(ierr) 
   CALL MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr) 
   CALL MPI_COMM_SIZE(MPI_COMM_WORLD, numtasks, ierr) 

   CALL  MPI_TYPE_VECTOR(5, 5, 5, MPI_REAL, rowtype, ierr) 
   CALL  MPI_TYPE_COMMIT(rowtype, ierr)
   
   CALL  MPI_TYPE_VECTOR(4, 4, 4, rowtype, colrowtype, ierr) 
   CALL  MPI_TYPE_COMMIT(colrowtype, ierr) 
   
   CALL MPI_BARRIER(MPI_COMM_WORLD, ierr)

      IF(rank==0)THEN
         i=1
         call MPI_SEND(AA(1,1,1), 2, colrowtype, 1, 300, MPI_COMM_WORLD, ierr)
      ENDIF
      
      IF(rank==1)THEN
         source = 0 
         call MPI_RECV(BB(1,1,1), 2, colrowtype, 0, 300, MPI_COMM_WORLD, stat, ierr) 
         !
         WRITE(*,*) ' b= ', BB(1,1,:)
         !
         WRITE(*,*) ' b= ', BB(1,1,:)
      ENDIF
 
   call MPI_FINALIZE(ierr) 
ENDPROGRAM&lt;/PRE&gt;

&lt;P&gt;In this case the program does not work. If a use&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;real*4 AA(SIZE_,4,4), BB(SIZE_,4,4) &lt;/PRE&gt;

&lt;P&gt;and&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;   CALL  MPI_TYPE_VECTOR(4, 4, 4, MPI_REAL, rowtype, ierr) 
   CALL  MPI_TYPE_COMMIT(rowtype, ierr)
   
   CALL  MPI_TYPE_VECTOR(4, 4, 4, rowtype, colrowtype, ierr) 
   CALL  MPI_TYPE_COMMIT(colrowtype, ierr) &lt;/PRE&gt;

&lt;P&gt;it works. I believe that this is due to how a matrix is stored in Fortran.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Someone could explain me where I am wrong?&lt;/P&gt;

&lt;P&gt;Thanks Thanks a lot&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 18 Jan 2015 13:44:06 GMT</pubDate>
    <dc:creator>diedro</dc:creator>
    <dc:date>2015-01-18T13:44:06Z</dc:date>
    <item>
      <title>mpi_type_vector three dimensional</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/mpi-type-vector-three-dimensional/m-p/1054296#M4444</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;

&lt;P&gt;I have a three dimensional array AA(:,:,:) and I would like to sent it, or at least part of it from one CPU to another.&lt;/P&gt;

&lt;P&gt;The idea is to combine MPI_TYPE_VECTOR. This is my program. I do not understand it, sometimes it works and some time not.&lt;/P&gt;

&lt;P&gt;What do you think?&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;program vector
USE mpi
IMPLICIT NONE
integer SIZE_
parameter(SIZE_=4) 
integer numtasks, rank, source, dest, tag, i,  ierr 
real*4 AA(SIZE_,5,4), BB(SIZE_,5,4) 
integer stat(MPI_STATUS_SIZE), rowtype,colrowtype

!Fortran stores this array in column major order 
AA=0.
AA(1,1,1)= 1.0
AA(1,1,2)= 4.0
AA(1,1,3)= 10.0
AA(1,1,4)= 33.0

AA(2,1,1)= 10.0
AA(2,1,2)= 40.0
AA(2,1,3)= 100.0
AA(2,1,4)= 330.0


   CALL MPI_INIT(ierr) 
   CALL MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr) 
   CALL MPI_COMM_SIZE(MPI_COMM_WORLD, numtasks, ierr) 

   CALL  MPI_TYPE_VECTOR(5, 5, 5, MPI_REAL, rowtype, ierr) 
   CALL  MPI_TYPE_COMMIT(rowtype, ierr)
   
   CALL  MPI_TYPE_VECTOR(4, 4, 4, rowtype, colrowtype, ierr) 
   CALL  MPI_TYPE_COMMIT(colrowtype, ierr) 
   
   CALL MPI_BARRIER(MPI_COMM_WORLD, ierr)

      IF(rank==0)THEN
         i=1
         call MPI_SEND(AA(1,1,1), 2, colrowtype, 1, 300, MPI_COMM_WORLD, ierr)
      ENDIF
      
      IF(rank==1)THEN
         source = 0 
         call MPI_RECV(BB(1,1,1), 2, colrowtype, 0, 300, MPI_COMM_WORLD, stat, ierr) 
         !
         WRITE(*,*) ' b= ', BB(1,1,:)
         !
         WRITE(*,*) ' b= ', BB(1,1,:)
      ENDIF
 
   call MPI_FINALIZE(ierr) 
ENDPROGRAM&lt;/PRE&gt;

&lt;P&gt;In this case the program does not work. If a use&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;real*4 AA(SIZE_,4,4), BB(SIZE_,4,4) &lt;/PRE&gt;

&lt;P&gt;and&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;   CALL  MPI_TYPE_VECTOR(4, 4, 4, MPI_REAL, rowtype, ierr) 
   CALL  MPI_TYPE_COMMIT(rowtype, ierr)
   
   CALL  MPI_TYPE_VECTOR(4, 4, 4, rowtype, colrowtype, ierr) 
   CALL  MPI_TYPE_COMMIT(colrowtype, ierr) &lt;/PRE&gt;

&lt;P&gt;it works. I believe that this is due to how a matrix is stored in Fortran.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Someone could explain me where I am wrong?&lt;/P&gt;

&lt;P&gt;Thanks Thanks a lot&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Jan 2015 13:44:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/mpi-type-vector-three-dimensional/m-p/1054296#M4444</guid>
      <dc:creator>diedro</dc:creator>
      <dc:date>2015-01-18T13:44:06Z</dc:date>
    </item>
    <item>
      <title>Dear Diedro,</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/mpi-type-vector-three-dimensional/m-p/1054297#M4445</link>
      <description>&lt;P&gt;Dear Diedro,&lt;/P&gt;

&lt;P&gt;I recommend to use the call MPI_TYPE_CREATE_SUBARRAY, it has a much clearer syntax to communicate parts of a multi-dimensional Fortran array.&lt;/P&gt;

&lt;P&gt;Cheers,&lt;/P&gt;

&lt;P&gt;John&lt;/P&gt;</description>
      <pubDate>Wed, 18 Feb 2015 08:04:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/mpi-type-vector-three-dimensional/m-p/1054297#M4445</guid>
      <dc:creator>John_D_6</dc:creator>
      <dc:date>2015-02-18T08:04:00Z</dc:date>
    </item>
  </channel>
</rss>

