Diego,

I see nothing wrong with the way you create the datatype. In fact this is
the perfect example on how to almost do it right in FORTRAN. The almost is
because your code is highly dependent on the -r8 compiler option (otherwise
the REAL in your type will not match the MPI_DOUBLE_PRECISION you provide
to MPI_Type_create_struct).

Btw you can remove the MPI_Type_commit on the first datatype, you only need
to commit types that will be used in communications (not anything that is
temporarily used to build other types).

George.


On Sun, May 17, 2020 at 11:19 AM Diego Avesani via users <
users@lists.open-mpi.org> wrote:

> Dear Gilles, dear All,
>
> as far I remember no. The compiler is the same as the options which I use.
>
> Maybe, the error is some other places of my code. However, the results
> look errors in allocation of sent and received vector of datatype.
>
> The import is that at least mydata type definitions in correct.
>
> These are the options used in compiling:
>
> -c -O2 -r8 -align -lmkl_blas95_lp64 -lmkl_lapack95_lp64 -mkl=sequential
> -fpp -CB
>
> Best regards
>
>
> Diego
>
>
>
> On Sun, 17 May 2020 at 15:27, Gilles Gouaillardet via users <
> users@lists.open-mpi.org> wrote:
>
>> Diego,
>>
>> Did you change your compiler options?
>>
>> Cheers,
>>
>> Gilles
>>
>> ----- Original Message -----
>> > Dear all,
>> >
>> > I would like to share with what I have done in oder to create my own
>> MPI
>> > data type. The strange thing is that it worked until some day ago and
>> then
>> > it stopped working. This because probably I have changed my data type
>> and I
>> > miss some knowledge about MPI data type
>> >
>> > This is my data type:
>> > ******
>> >   TYPE tParticle
>> >     SEQUENCE
>> >     INTEGER          :: ip
>> >     INTEGER         :: mc
>> >     INTEGER         :: bcflag
>> >     INTEGER         :: cpu
>> >     REAL               :: RP(di)
>> >     REAL               :: QQ(nVar)
>> >     REAL               :: UU0(2*(1+di+nVar))
>> >     REAL               :: lij
>> >     REAL               :: lmls
>> >     REAL               :: vol
>> >     REAL               :: mm
>> >   ENDTYPE tParticle
>> > ******
>> >
>> > Then I have this variables in order to create mine:
>> >
>> > ******
>> >   INTEGER,                   ALLOCATABLE,DIMENSION(:)   :: TYPES,
>> LENGTHS
>> >   INTEGER(MPI_ADDRESS_KIND), ALLOCATABLE,DIMENSION(:)   ::
>> DISPLACEMENTS
>> >   TYPE(tParticle) :: dummy(2)
>> > ******
>> >
>> > Having 5 structures:  Nstruct=5
>> >
>> > In the following how I create my MPI data TYPE
>> >
>> > ******
>> > ALLOCATE(TYPES          (Nstruct)    )
>> > ALLOCATE(LENGTHS        (Nstruct)    )
>> > ALLOCATE(DISPLACEMENTS  (0:nstruct+1))
>> > !set the types
>> > TYPES(1)   = MPI_INTEGER
>> > TYPES(2)   = MPI_DOUBLE_PRECISION
>> > TYPES(3)   = MPI_DOUBLE_PRECISION
>> > TYPES(4)   = MPI_DOUBLE_PRECISION
>> > TYPES(5)   = MPI_DOUBLE_PRECISION
>> > !set the lengths
>> > LENGTHS(1) = 4
>> > LENGTHS(2) = SIZE(dummy(1)%RP)
>> > LENGTHS(3) = SIZE(dummy(1)%QQ)
>> > LENGTHS(4) = SIZE(dummy(1)%UU0)
>> > LENGTHS(5) = 4
>> >   !
>> >   CALL MPI_GET_ADDRESS(dummy(1)        ,DISPLACEMENTS(0),MPIdata%iErr)
>> >   CALL MPI_GET_ADDRESS(dummy(1)%ip     ,DISPLACEMENTS(1),MPIdata%iErr)
>> >   CALL MPI_GET_ADDRESS(dummy(1)%RP(1)  ,DISPLACEMENTS(2),MPIdata%iErr)
>> >   CALL MPI_GET_ADDRESS(dummy(1)%QQ(1)  ,DISPLACEMENTS(3),MPIdata%iErr)
>> >   CALL MPI_GET_ADDRESS(dummy(1)%UU0(1) ,DISPLACEMENTS(4),MPIdata%iErr)
>> >   CALL MPI_GET_ADDRESS(dummy(1)%lij    ,DISPLACEMENTS(5),MPIdata%iErr)
>> >   CALL MPI_GET_ADDRESS(dummy(2)        ,DISPLACEMENTS(6),MPIdata%iErr)
>> >   !
>> >   DISPLACEMENTS(1:nstruct+1)= DISPLACEMENTS(1:nstruct+1)-DISPLACEMENTS
>> (0)
>> >   !
>> >   CALL
>> > MPI_TYPE_CREATE_STRUCT(nstruct,lengths,DISPLACEMENTS(1:nstruct+1),
>> types,MPI_PARTICLE_TYPE_OLD,MPIdata%iErr)
>> >   CALL MPI_TYPE_COMMIT(MPI_PARTICLE_TYPE_OLD,MPIdata%iErr)
>> >   !
>> >   CALL MPI_TYPE_CREATE_RESIZED(MPI_PARTICLE_TYPE_OLD, DISPLACEMENTS(1),
>> > DISPLACEMENTS(6), MPI_PARTICLE_TYPE, MPIdata%iErr)
>> >   CALL MPI_TYPE_COMMIT(MPI_PARTICLE_TYPE,MPIdata%iErr)
>> >
>> >
>> > Do you see something wrong, maybe related to the DISPLACEMENTS. This
>> > beacuse, As already told you, something has happend and I have just
>> added
>> > "    REAL               :: mm  "
>> >  in my type and consequently set "LENGTHS(5) = 4 ".
>> >
>> > What do you think?
>> > Thanks in advance for any kind of help.
>> >
>> > Best,
>> >
>> > Diego
>> >
>>
>>
>>

Reply via email to