<?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_CREATE_STRUCT error 174 in Intel® MPI Library</title>
    <link>https://community.intel.com/t5/Intel-MPI-Library/MPI-TYPE-CREATE-STRUCT-error-174/m-p/1012048#M3934</link>
    <description>&lt;P&gt;Dear all,&lt;/P&gt;

&lt;P&gt;this is becoming a nightmare. I have the following program, where i create&amp;nbsp;MPI_TYPE_CREATE_STRUCT and then I try to send it to other processor. It crushes every-time and do not know why.&lt;/P&gt;

&lt;P&gt;Could someone please help me?&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;PROGRAM PROVA_STRUCT
IMPLICIT NONE
INCLUDE 'mpif.h'
!
TYPE tMPI
    INTEGER :: myrank, nCPU, iErr, status
    INTEGER :: AUTO_REAL
    INTEGER :: iStart, iEnd, jStart, jEnd 
    INTEGER :: imax, jmax
    INTEGER :: npt
    INTEGER :: nmcx,nmcy
    REAL    :: x1L,x2L,y1L,y2L
    REAL    :: err 
    INTEGER, ALLOCATABLE :: mycoords(:), info(:)
END TYPE tMPI
!
type particle
 integer                 :: rx
 real                    :: QQ
end type particle
!
TYPE(tMPI)           :: MPI
INTEGER              :: COMM_CART
INTEGER              :: MPI_PARTICLE_TYPE
INTEGER,ALLOCATABLE  :: DIMS(:)
LOGICAL,ALLOCATABLE  :: PERIODS(:)
INTEGER              :: RCPU,LCPU,BCPU,TCPU,RTCPU,RBCPU,LTCPU,LBCPU

INTEGER              :: source
INTEGER              :: ndims
INTEGER              :: nstruct
INTEGER              :: x_thread,y_thread

INTEGER,ALLOCATABLE  :: TYPES(:)
INTEGER,ALLOCATABLE  :: LENGTHS(:)
INTEGER,ALLOCATABLE  :: DISPLACEMENTS(:)

INTEGER        :: npt,ip
type(particle) :: dummy                   ! Used for calculation of displacement
TYPE(particle),ALLOCATABLE :: P_SEND(:),P_RECV(:)



   CALL MPI_INIT(MPI%iErr)
   CALL MPI_COMM_RANK(MPI_COMM_WORLD, MPI%myrank, MPI%iErr)
   CALL MPI_COMM_SIZE(MPI_COMM_WORLD, MPI%nCPU,   MPI%iErr)
   !
   ndims=2
   !
   x_thread = MPI%nCPU/ndims
   y_thread = x_thread
   !
   ALLOCATE ( dims(ndims), periods(ndims), MPI%mycoords(ndims) )
   dims = [x_thread, y_thread]
   periods = .FALSE.
   CALL MPI_CART_CREATE (MPI_COMM_WORLD,ndims,dims,periods,.TRUE.,COMM_CART,MPI%iErr)
   CALL MPI_COMM_RANK(COMM_CART,MPI%myrank,MPI%iErr)

   !Find neighbors
  CALL MPI_CART_SHIFT(COMM_CART,0,1,source,RCPU,MPI%iErr)  ! x-dir, right
  CALL MPI_CART_SHIFT(COMM_CART,0,-1,source,LCPU,MPI%iErr) ! x-dir, left
  CALL MPI_CART_SHIFT(COMM_CART,1,1,source,TCPU,MPI%iErr)  ! y-dir, top
  CALL MPI_CART_SHIFT(COMM_CART,1,-1,source,BCPU,MPI%iErr) ! y-dir, bottom
   
   
   nstruct=2
   ALLOCATE(TYPES(nstruct))
   ALLOCATE(LENGTHS(nstruct))
   ALLOCATE(DISPLACEMENTS(nstruct))
   !
   TYPES(1)=MPI_INTEGER
   TYPES(2)=MPI_DOUBLE_PRECISION
   !
   LENGTHS(1)=1
   LENGTHS(2)=1
   ! 
   DISPLACEMENTS(1)=0
   DISPLACEMENTS(2)=sizeof(dummy%rx)
   CALL MPI_TYPE_CREATE_STRUCT(nstruct,lengths,displacements,types,mpi_particle_type,MPI%iErr)
   CALL MPI_TYPE_COMMIT(mpi_particle_type,MPI%iErr)
!    
   NPT=10
   ALLOCATE(P_SEND(NPT))
   ALLOCATE(P_RECV(NPT))
   DO ip=1,NPT
      P_SEND(ip)%rx=1
      P_SEND(ip)%QQ=11.
      P_RECV(ip)%rx=0
      P_RECV(ip)%QQ=0.
   ENDDO
   
   
   CALL MPI_BARRIER(MPI_COMM_WORLD,MPI%iErr)
   CALL MPI_Sendrecv(P_SEND(:),10,MPI_PARTICLE_TYPE,BCPU,201,&amp;amp;
                     P_RECV(:),10,MPI_PARTICLE_TYPE,TCPU,201,MPI_COMM_WORLD,MPI_STATUS_IGNORE,MPI%iErr)
   
   CALL MPI_FINALIZE(MPI%iErr)

ENDPROGRAM&lt;/PRE&gt;

&lt;P&gt;I think that this one is a very simple program, that can be useful for me to understand where I do not understand.&lt;/P&gt;

&lt;P&gt;Thanks a lot&lt;/P&gt;</description>
    <pubDate>Fri, 03 Oct 2014 09:10:46 GMT</pubDate>
    <dc:creator>diedro</dc:creator>
    <dc:date>2014-10-03T09:10:46Z</dc:date>
    <item>
      <title>MPI_TYPE_CREATE_STRUCT error 174</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/MPI-TYPE-CREATE-STRUCT-error-174/m-p/1012048#M3934</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;

&lt;P&gt;this is becoming a nightmare. I have the following program, where i create&amp;nbsp;MPI_TYPE_CREATE_STRUCT and then I try to send it to other processor. It crushes every-time and do not know why.&lt;/P&gt;

&lt;P&gt;Could someone please help me?&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;PROGRAM PROVA_STRUCT
IMPLICIT NONE
INCLUDE 'mpif.h'
!
TYPE tMPI
    INTEGER :: myrank, nCPU, iErr, status
    INTEGER :: AUTO_REAL
    INTEGER :: iStart, iEnd, jStart, jEnd 
    INTEGER :: imax, jmax
    INTEGER :: npt
    INTEGER :: nmcx,nmcy
    REAL    :: x1L,x2L,y1L,y2L
    REAL    :: err 
    INTEGER, ALLOCATABLE :: mycoords(:), info(:)
END TYPE tMPI
!
type particle
 integer                 :: rx
 real                    :: QQ
end type particle
!
TYPE(tMPI)           :: MPI
INTEGER              :: COMM_CART
INTEGER              :: MPI_PARTICLE_TYPE
INTEGER,ALLOCATABLE  :: DIMS(:)
LOGICAL,ALLOCATABLE  :: PERIODS(:)
INTEGER              :: RCPU,LCPU,BCPU,TCPU,RTCPU,RBCPU,LTCPU,LBCPU

INTEGER              :: source
INTEGER              :: ndims
INTEGER              :: nstruct
INTEGER              :: x_thread,y_thread

INTEGER,ALLOCATABLE  :: TYPES(:)
INTEGER,ALLOCATABLE  :: LENGTHS(:)
INTEGER,ALLOCATABLE  :: DISPLACEMENTS(:)

INTEGER        :: npt,ip
type(particle) :: dummy                   ! Used for calculation of displacement
TYPE(particle),ALLOCATABLE :: P_SEND(:),P_RECV(:)



   CALL MPI_INIT(MPI%iErr)
   CALL MPI_COMM_RANK(MPI_COMM_WORLD, MPI%myrank, MPI%iErr)
   CALL MPI_COMM_SIZE(MPI_COMM_WORLD, MPI%nCPU,   MPI%iErr)
   !
   ndims=2
   !
   x_thread = MPI%nCPU/ndims
   y_thread = x_thread
   !
   ALLOCATE ( dims(ndims), periods(ndims), MPI%mycoords(ndims) )
   dims = [x_thread, y_thread]
   periods = .FALSE.
   CALL MPI_CART_CREATE (MPI_COMM_WORLD,ndims,dims,periods,.TRUE.,COMM_CART,MPI%iErr)
   CALL MPI_COMM_RANK(COMM_CART,MPI%myrank,MPI%iErr)

   !Find neighbors
  CALL MPI_CART_SHIFT(COMM_CART,0,1,source,RCPU,MPI%iErr)  ! x-dir, right
  CALL MPI_CART_SHIFT(COMM_CART,0,-1,source,LCPU,MPI%iErr) ! x-dir, left
  CALL MPI_CART_SHIFT(COMM_CART,1,1,source,TCPU,MPI%iErr)  ! y-dir, top
  CALL MPI_CART_SHIFT(COMM_CART,1,-1,source,BCPU,MPI%iErr) ! y-dir, bottom
   
   
   nstruct=2
   ALLOCATE(TYPES(nstruct))
   ALLOCATE(LENGTHS(nstruct))
   ALLOCATE(DISPLACEMENTS(nstruct))
   !
   TYPES(1)=MPI_INTEGER
   TYPES(2)=MPI_DOUBLE_PRECISION
   !
   LENGTHS(1)=1
   LENGTHS(2)=1
   ! 
   DISPLACEMENTS(1)=0
   DISPLACEMENTS(2)=sizeof(dummy%rx)
   CALL MPI_TYPE_CREATE_STRUCT(nstruct,lengths,displacements,types,mpi_particle_type,MPI%iErr)
   CALL MPI_TYPE_COMMIT(mpi_particle_type,MPI%iErr)
!    
   NPT=10
   ALLOCATE(P_SEND(NPT))
   ALLOCATE(P_RECV(NPT))
   DO ip=1,NPT
      P_SEND(ip)%rx=1
      P_SEND(ip)%QQ=11.
      P_RECV(ip)%rx=0
      P_RECV(ip)%QQ=0.
   ENDDO
   
   
   CALL MPI_BARRIER(MPI_COMM_WORLD,MPI%iErr)
   CALL MPI_Sendrecv(P_SEND(:),10,MPI_PARTICLE_TYPE,BCPU,201,&amp;amp;
                     P_RECV(:),10,MPI_PARTICLE_TYPE,TCPU,201,MPI_COMM_WORLD,MPI_STATUS_IGNORE,MPI%iErr)
   
   CALL MPI_FINALIZE(MPI%iErr)

ENDPROGRAM&lt;/PRE&gt;

&lt;P&gt;I think that this one is a very simple program, that can be useful for me to understand where I do not understand.&lt;/P&gt;

&lt;P&gt;Thanks a lot&lt;/P&gt;</description>
      <pubDate>Fri, 03 Oct 2014 09:10:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/MPI-TYPE-CREATE-STRUCT-error-174/m-p/1012048#M3934</guid>
      <dc:creator>diedro</dc:creator>
      <dc:date>2014-10-03T09:10:46Z</dc:date>
    </item>
  </channel>
</rss>

