Besides Gilles suggestions, wouldn't this:

>   TYPE tParticle
>      INTEGER  :: ip
        INTEGER :: dummy
        DOUBLE PRECISION     :: RP(2)
        DOUBLE PRECISION     :: QQ(2)
> 
>   ENDTYPE tParticle


(instead of making RP and QQ real) 
match better your declarations of (MPI) TYPES() further down,
and hopefully have a better chance of correct memory alignment and type 
consistency?
Relying on specific compiler or compiler flags (e.g. -r8,  -align) is tricky 
(and not portable).

I hope this helps,
Gus Correa

On Jan 2, 2015, at 6:51 AM, Gilles Gouaillardet wrote:

> Diego,
> 
> First, i recommend you redefine tParticle and add a padding integer so 
> everything is aligned.
> 
> 
> Before invoking MPI_Type_create_struct, you need to 
> call MPI_Get_address(dummy, base, MPI%err)
> displacements = displacements - base
> 
> MPI_Type_create_resized might be unnecessary if tParticle is aligned 
> And the lower bound should be zero.
> 
> BTW, which compiler are you using ?
> Is tParticle object a common ?
> iirc, intel compiler aligns types automatically, but not commons, and that 
> means MPI_Type_create_struct is not aligned as it should most of the time.
> 
> Cheers,
> 
> Gilles 
> 
> Diego Avesani <diego.aves...@gmail.com>さんのメール:
> dear all,
> 
> I have a problem with MPI_Type_Create_Struct and MPI_TYPE_CREATE_RESIZED.
> 
> I have this variable type:
> 
>   TYPE tParticle
>      INTEGER  :: ip
>      REAL     :: RP(2)
>      REAL     :: QQ(2)
>   ENDTYPE tParticle
> 
> Then I define:
> 
> Nstruct=3
> ALLOCATE(TYPES(Nstruct))
> ALLOCATE(LENGTHS(Nstruct))
> ALLOCATE(DISPLACEMENTS(Nstruct))
> !set the types
> TYPES(1) = MPI_INTEGER
> TYPES(2) = MPI_DOUBLE_PRECISION
> TYPES(3) = MPI_DOUBLE_PRECISION
> !set the lengths
> LENGTHS(1) = 1
> LENGTHS(2) = 2
> LENGTHS(3) = 2
> 
> As gently suggested by Nick Papior Andersen and George Bosilca some months 
> ago, I checked the variable adress to resize my struct variable to avoid 
> empty space and
> to have a more general definition.
> 
>  !
>  CALL MPI_GET_ADDRESS(dummy%ip,    DISPLACEMENTS(1), MPI%iErr)
>  CALL MPI_GET_ADDRESS(dummy%RP(1), DISPLACEMENTS(2), MPI%iErr)
>  CALL MPI_GET_ADDRESS(dummy%QQ(1), DISPLACEMENTS(3), MPI%iErr)
>  !
>  CALL 
> MPI_Type_Create_Struct(Nstruct,LENGTHS,DISPLACEMENTS,TYPES,MPI_PARTICLE_TYPE_OLD,MPI%iErr)
>  CALL MPI_Type_Commit(MPI_PARTICLE_TYPE_OLD,MPI%iErr)
>  !
>  CALL MPI_TYPE_CREATE_RESIZED(MPI_PARTICLE_TYPE_OLD, 
> DISPLACEMENTS(1),DISPLACEMENTS(2) - DISPLACEMENTS(1), MPI_PARTICLE_TYPE)
> 
> 
> This does not work. When my program run, I get an error:
> 
> forrtl: severe (174): SIGSEGV, segmentation fault occurred.
> 
> I have read the manual but probably I am not able to understand  
> MPI_TYPE_CREATE_RESIZED. 
> 
> Someone could help me?
>                                                                               
>                                                                
> Thanks a lot
> Diego
> 
> 
> Diego
> 
> _______________________________________________
> users mailing list
> us...@open-mpi.org
> Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/users
> Link to this post: 
> http://www.open-mpi.org/community/lists/users/2015/01/26092.php

Reply via email to