<?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 Dear, in Intel® MPI Library</title>
    <link>https://community.intel.com/t5/Intel-MPI-Library/SENDRECV-MPI-TYPE-CREATE-STRUCT/m-p/1007621#M3853</link>
    <description>&lt;P&gt;Dear,&lt;/P&gt;

&lt;P&gt;sorry for my errors, I should be more accurate.&lt;/P&gt;

&lt;P&gt;This is my new variable:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;  TYPE tParticle
    INTEGER :: ip
    REAL    :: RP(2)
    REAL    :: QQ(4)
  END TYPE tParticle&lt;/PRE&gt;

&lt;P&gt;so I have:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;TYPES(1)=MPI_INTEGER    !We have three variables type in the new varible
TYPES(2)=MPI_REAL2       !Integer and Real and Real
TYPES(3)=MPI_REAL2       !Integer and Real and Real
nBLOCKS(1)=1            !number of element in each block 
nBLOCKS(2)=2
nBLOCKS(3)=4
     
 DISPLACEMENTS(1)=0
 DISPLACEMENTS(2)=sizeof(dummy%ip)
 DISPLACEMENTS(3)=sizeof(dummy%RP)
 !
 CALL MPI_TYPE_CREATE_STRUCT(1,nBLOCKS,DISPLACEMENTS,TYPES,MPI_PARTICLE_TYPE,MPI%ierr)
CALL MPI_TYPE_COMMIT(MPI_PARTICLE_TYPE,MPI%ierr)&lt;/PRE&gt;

&lt;P&gt;Do I have correctly understood, at list this part?&lt;/P&gt;

&lt;P&gt;Then I have:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;IF(MPI%myrank==1)THEN
        DO ip=1,100
           p_send(ip)%ip=ip
           p_send(ip)%RP(:)=10.
           p_send(ip)%QQ(:)=2.
        ENDDO
 ENDIF

CALL MPI_Sendrecv(p_send,100,MPI_PARTICLE_TYPE,2,1,p_recv,100,MPI_PARTICLE_TYPE,1,1,MPI_COMM_WORLD,MPI_STATUS_IGNORE,ierr)

WRITE(*,* )MPI%myrank,p_recv(2)%ip,p_recv(2)%RP(:)
&lt;/PRE&gt;

&lt;P&gt;This is a piece of my code. It runs but never stops.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Sep 2014 15:20:14 GMT</pubDate>
    <dc:creator>diedro</dc:creator>
    <dc:date>2014-09-29T15:20:14Z</dc:date>
    <item>
      <title>SENDRECV + MPI_TYPE_CREATE_STRUCT</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/SENDRECV-MPI-TYPE-CREATE-STRUCT/m-p/1007617#M3849</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;

&lt;P&gt;I have some basic question about MPI about &amp;nbsp;SENDRECV and MPI_TYPE_CREATE_STRUCT.&lt;/P&gt;

&lt;P&gt;First:&amp;nbsp;&lt;SPAN style="line-height: 15.6px; font-size: 12.8px;"&gt;MPI_TYPE_CREATE_STRUCT. As suggested by&amp;nbsp;&lt;/SPAN&gt;James Tullos, whem I have a data type as:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;type particle
 integer                 :: rx
 integer                 :: ry
 real                    :: QQ(4)
end type particle&lt;/PRE&gt;

&lt;P&gt;I can create a MPI data type as follows:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;type(particle) dummy ! Used for calculation of displacement
integer lengths(2), types(2), ierr
integer(kind=MPI_ADDRESS_KIND) displacements
integer mpi_particle_type
types(1)=MPI_INTEGER
types(2)=MPI_REAL
lengths(1)=2
lengths(2)=4
displacements(1)=0
displacements(2)=sizeof(dummy%rx)+sizeof(dummy%ry)
call MPI_TYPE_CREATE_STRUCT(2,lengths,displacements,types,mpi_particle_type,ierr)
call MPI_TYPE_COMMIT(mpi_particle_type,ierr)&lt;/PRE&gt;

&lt;P&gt;the question is: why Do I use INTEGER MPI_PARTICLE _TYPE and not REAL MPI_PARTICLE_TYPE.&lt;/P&gt;

&lt;P&gt;The second question is: How can I send for example 100&amp;nbsp;MPI_PARTICLE _TYPE varibles to another processor with&amp;nbsp;SENDRECV. Do I have to create a vector&amp;nbsp;MPI_PARTICLE _TYPE:&lt;/P&gt;

&lt;PRE class="brush:;"&gt;MPI_PARTICLE _TYPE :: VECTOR(100)&lt;/PRE&gt;

&lt;P&gt;Am I right?&lt;/P&gt;

&lt;P&gt;Really thanks to everyone.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Diego&lt;/P&gt;</description>
      <pubDate>Mon, 29 Sep 2014 08:45:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/SENDRECV-MPI-TYPE-CREATE-STRUCT/m-p/1007617#M3849</guid>
      <dc:creator>diedro</dc:creator>
      <dc:date>2014-09-29T08:45:49Z</dc:date>
    </item>
    <item>
      <title>For the first question, I</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/SENDRECV-MPI-TYPE-CREATE-STRUCT/m-p/1007618#M3850</link>
      <description>&lt;P&gt;For the first question, I answered in the other thread, I'll copy it here:&lt;/P&gt;

&lt;P&gt;In Fortran, there are two ways to define MPI objects.&amp;nbsp; You can use integer, which creates a handle to the real datatype.&amp;nbsp; Or, as of MPI-3, the C bindings were made available to Fortran, so you could instead use TYPE(MPI_Datatype).&amp;nbsp; I use integer out of familiarity.&lt;/P&gt;

&lt;P&gt;For the second, to send an array of 100, you don't define an array of the datatype.&amp;nbsp; This is just a reference to how the data is structured, not the actual data.&amp;nbsp; Instead, define an array of 100 particles and use a count of 100 in your MPI_Sendrecv call.&lt;/P&gt;

&lt;P&gt;[plain]type(particle) :: p_send(100),p_recv(100)&lt;/P&gt;

&lt;P&gt;...&lt;/P&gt;

&lt;P&gt;call MPI_Sendrecv(p_send,100,MPI_PARTICLE_TYPE,destination,tag,p_recv,100,MPI_PARTICLE_TYPE,sender,tag,MPI_COMM_WORLD,MPI_STATUS_IGNORE,ierr)[/plain]&lt;/P&gt;</description>
      <pubDate>Mon, 29 Sep 2014 14:12:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/SENDRECV-MPI-TYPE-CREATE-STRUCT/m-p/1007618#M3850</guid>
      <dc:creator>James_T_Intel</dc:creator>
      <dc:date>2014-09-29T14:12:17Z</dc:date>
    </item>
    <item>
      <title>Dear J.,</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/SENDRECV-MPI-TYPE-CREATE-STRUCT/m-p/1007619#M3851</link>
      <description>&lt;P&gt;Dear J.,&lt;/P&gt;

&lt;P&gt;I create this little test:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;
 TYPES(1)=MPI_INTEGER    !We have three variables type in the new varible
     TYPES(2)=MPI_REAL2       !Integer and Real and Real
     TYPES(3)=MPI_REAL2       !Integer and Real and Real
     nBLOCKS(1)=1            !number of element in each block 
     nBLOCKS(2)=2
     nBLOCKS(3)=4
     
     DISPLACEMENTS(1)=0
     DISPLACEMENTS(2)=sizeof(dummy%ip)
     DISPLACEMENTS(3)=sizeof(dummy%RP)
     !
     CALL MPI_TYPE_CREATE_STRUCT(1,nBLOCKS,DISPLACEMENTS,TYPES,MPI_PARTICLE_TYPE,MPI%ierr)
     CALL MPI_TYPE_COMMIT(MPI_PARTICLE_TYPE,MPI%ierr)
     !
     IF(MPI%myrank==1)THEN
        DO ip=1,100
           p_send(ip)%ip=ip
           p_send(ip)%RP(:)=10.
           p_send(ip)%QQ(:)=2.
        ENDDO
     ENDIF

      CALL MPI_Sendrecv(p_send,BUFF,MPI_PARTICLE_TYPE,2,12,p_recv,BUFF,MPI_PARTICLE_TYPE,1,12,MPI_COMM_WORLD,MPI_STATUS_IGNORE,MPI%ierr)
!       
      IF(MPI%myrank==2)THEN
        WRITE(*,* )p_recv(2)%ip,p_recv(2)%RP(:)
      ENDIF&lt;/PRE&gt;

&lt;P&gt;The problem is that the program never stops.&lt;/P&gt;

&lt;P&gt;If I use the send and recv subroutine it works.&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;     IF(MPI%myrank==1)THEN
        CALL MPI_SEND(P_SEND, 100, MPI_PARTICLE_TYPE, 2, 10, MPI_COMM_WORLD, MPI%ierr ) 
     ENDIF
     
     IF(MPI%myrank==2)THEN
        CALL MPI_RECV(P_RECV, 100, MPI_PARTICLE_TYPE, 1,10, MPI_COMM_WORLD, status, MPI%ierr)
        WRITE(*,* )P_RECV(2)%ip,P_RECV(2)%RP(:)
     ENDIF&lt;/PRE&gt;

&lt;P&gt;Can you tell me why, please?&lt;/P&gt;

&lt;DIV&gt;I think that i am missing something about MPI. I also put a barrier but nothing changes.&lt;/DIV&gt;

&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;

&lt;DIV&gt;Again, thanks a lot&lt;/DIV&gt;</description>
      <pubDate>Mon, 29 Sep 2014 14:32:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/SENDRECV-MPI-TYPE-CREATE-STRUCT/m-p/1007619#M3851</guid>
      <dc:creator>diedro</dc:creator>
      <dc:date>2014-09-29T14:32:03Z</dc:date>
    </item>
    <item>
      <title>What value is in BUFF?  Are</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/SENDRECV-MPI-TYPE-CREATE-STRUCT/m-p/1007620#M3852</link>
      <description>&lt;P&gt;What value is in BUFF?&amp;nbsp; Are you running with at least 3 ranks (MPI ranks start counting at 0).&lt;/P&gt;

&lt;P&gt;Also, it seems like your displacements are off.&amp;nbsp; The sizeof intrinsic gives you the size of a variable, not the address.&amp;nbsp; If you're using the particle type shown in your first post, you want:&lt;/P&gt;

&lt;P&gt;[plain]displacements(1)=0&lt;/P&gt;

&lt;P&gt;displacements(2)=sizeof(dummy%rx)&lt;/P&gt;

&lt;P&gt;displacements(3)=sizeof(dummy%rx)+sizeof(dummy%ry)[/plain]&lt;/P&gt;</description>
      <pubDate>Mon, 29 Sep 2014 15:12:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/SENDRECV-MPI-TYPE-CREATE-STRUCT/m-p/1007620#M3852</guid>
      <dc:creator>James_T_Intel</dc:creator>
      <dc:date>2014-09-29T15:12:08Z</dc:date>
    </item>
    <item>
      <title>Dear,</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/SENDRECV-MPI-TYPE-CREATE-STRUCT/m-p/1007621#M3853</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;

&lt;P&gt;sorry for my errors, I should be more accurate.&lt;/P&gt;

&lt;P&gt;This is my new variable:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;  TYPE tParticle
    INTEGER :: ip
    REAL    :: RP(2)
    REAL    :: QQ(4)
  END TYPE tParticle&lt;/PRE&gt;

&lt;P&gt;so I have:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;TYPES(1)=MPI_INTEGER    !We have three variables type in the new varible
TYPES(2)=MPI_REAL2       !Integer and Real and Real
TYPES(3)=MPI_REAL2       !Integer and Real and Real
nBLOCKS(1)=1            !number of element in each block 
nBLOCKS(2)=2
nBLOCKS(3)=4
     
 DISPLACEMENTS(1)=0
 DISPLACEMENTS(2)=sizeof(dummy%ip)
 DISPLACEMENTS(3)=sizeof(dummy%RP)
 !
 CALL MPI_TYPE_CREATE_STRUCT(1,nBLOCKS,DISPLACEMENTS,TYPES,MPI_PARTICLE_TYPE,MPI%ierr)
CALL MPI_TYPE_COMMIT(MPI_PARTICLE_TYPE,MPI%ierr)&lt;/PRE&gt;

&lt;P&gt;Do I have correctly understood, at list this part?&lt;/P&gt;

&lt;P&gt;Then I have:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;IF(MPI%myrank==1)THEN
        DO ip=1,100
           p_send(ip)%ip=ip
           p_send(ip)%RP(:)=10.
           p_send(ip)%QQ(:)=2.
        ENDDO
 ENDIF

CALL MPI_Sendrecv(p_send,100,MPI_PARTICLE_TYPE,2,1,p_recv,100,MPI_PARTICLE_TYPE,1,1,MPI_COMM_WORLD,MPI_STATUS_IGNORE,ierr)

WRITE(*,* )MPI%myrank,p_recv(2)%ip,p_recv(2)%RP(:)
&lt;/PRE&gt;

&lt;P&gt;This is a piece of my code. It runs but never stops.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Sep 2014 15:20:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/SENDRECV-MPI-TYPE-CREATE-STRUCT/m-p/1007621#M3853</guid>
      <dc:creator>diedro</dc:creator>
      <dc:date>2014-09-29T15:20:14Z</dc:date>
    </item>
    <item>
      <title>Dear all,</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/SENDRECV-MPI-TYPE-CREATE-STRUCT/m-p/1007622#M3854</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;

&lt;P&gt;I have replaced buff with 100.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Sep 2014 18:47:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/SENDRECV-MPI-TYPE-CREATE-STRUCT/m-p/1007622#M3854</guid>
      <dc:creator>diedro</dc:creator>
      <dc:date>2014-09-29T18:47:21Z</dc:date>
    </item>
    <item>
      <title>Dear all</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/SENDRECV-MPI-TYPE-CREATE-STRUCT/m-p/1007623#M3855</link>
      <description>&lt;P&gt;Dear all&lt;/P&gt;

&lt;P&gt;I&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;t seem that all processor at the same time have to use&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="color: rgb(0, 0, 0); font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 12.8000001907349px; line-height: 14.3087997436523px;"&gt;MPI_Sendrecv&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="color: rgb(0, 0, 0); font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 12.8000001907349px; line-height: 14.3087997436523px;"&gt;.&lt;/SPAN&gt;In my code,&amp;nbsp;I have used it only with processor number 1 and 2, this create a deadlock, because I think that all processor are trying to do that even 0 and 3, which of course can not.&lt;/P&gt;

&lt;P&gt;Now I have anothe problem but I think that it better to create another post.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 01 Oct 2014 16:25:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/SENDRECV-MPI-TYPE-CREATE-STRUCT/m-p/1007623#M3855</guid>
      <dc:creator>diedro</dc:creator>
      <dc:date>2014-10-01T16:25:22Z</dc:date>
    </item>
    <item>
      <title>Dear all,</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/SENDRECV-MPI-TYPE-CREATE-STRUCT/m-p/1007624#M3856</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;

&lt;P&gt;the problem is linked to my type variable.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I get some error when I try to send it. The most important things is that I work with double precision, so I use -r8 when I compile.&lt;/P&gt;

&lt;P&gt;this is my type:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;  TYPE tParticle
    INTEGER :: ip
    REAL    :: RP(2)
    REAL    :: QQ(4)
  END TYPE tParticle&lt;/PRE&gt;

&lt;P&gt;so I create my type with:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;     !
     !We create the MPI_DATA_TYPE to send guestes particles to the other processor
     !
     TYPES(1)=MPI_INTEGER                !We have three variables type in the new varible
     TYPES(2)=MPI_DOUBLE_PRECISION       !Integer and Real and Real
     TYPES(3)=MPI_DOUBLE_PRECISION       !Integer and Real and Real
     nBLOCKS(1)=1                        !number of element in each block 
     nBLOCKS(2)=2
     nBLOCKS(3)=4
     !
     DISPLACEMENTS(1)=0
     DISPLACEMENTS(2)=sizeof(dummy%ip)
     DISPLACEMENTS(3)=sizeof(dummy%ip)+sizeof(dummy%RP(1))+sizeof(dummy%RP(2))
     
     CALL MPI_TYPE_CREATE_STRUCT(3,nBLOCKS,DISPLACEMENTS,TYPES,MPI_PARTICLE_TYPE,MPI%ierr)
     CALL MPI_TYPE_COMMIT(MPI_PARTICLE_TYPE,MPI%ierr)&lt;/PRE&gt;

&lt;P&gt;do you notice some error, I have not really clear the displacement part. Can someone help me, please?&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE&gt;
&amp;nbsp;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Oct 2014 15:09:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/SENDRECV-MPI-TYPE-CREATE-STRUCT/m-p/1007624#M3856</guid>
      <dc:creator>diedro</dc:creator>
      <dc:date>2014-10-02T15:09:55Z</dc:date>
    </item>
    <item>
      <title>Ok, I think the double</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/SENDRECV-MPI-TYPE-CREATE-STRUCT/m-p/1007625#M3857</link>
      <description>&lt;P&gt;Ok, I think the double precision could be throwing it off.&amp;nbsp; The displacements are telling MPI where to find the data in relation to the starting address.&amp;nbsp; Checking the starting address of each of the components of your defined type, the ip component is taking 8 bytes instead of 4, likely due to alignment.&lt;/P&gt;

&lt;P&gt;I'd recommend in this case using loc to get the displacements.&amp;nbsp; This is non-standard, but fairly widely implemented, and will more precisely get the address.&lt;/P&gt;

&lt;P&gt;[plain]displacements(1)=0&lt;/P&gt;

&lt;P&gt;displacements(2)=loc(dummy%rp(1)) - loc(dummy%ip)&lt;/P&gt;

&lt;P&gt;displacements(3)=loc(dummy%qq(1)) - loc(dummy%ip)[/plain]&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Oct 2014 16:14:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/SENDRECV-MPI-TYPE-CREATE-STRUCT/m-p/1007625#M3857</guid>
      <dc:creator>James_T_Intel</dc:creator>
      <dc:date>2014-10-09T16:14:59Z</dc:date>
    </item>
  </channel>
</rss>

