> On Oct 19, 2017, at 10:29 PM, Jed Brown <[email protected]> wrote:
>
> Adrian Croucher <[email protected]> writes:
>
>> hi
>>
>>
>> The problem is this only seems to work if I declare the datatype in the
>> calling Fortran code to be of the appropriate C MPI datatype, e.g.
>> MPI_INT, rather than the corresponding Fortran datatype, e.g.
>> MPI_INTEGER (which causes PetscMPIDataTypeToPetscDataType() to fail, as
>> something weird gets passed in for dtype).
>>
>> I was expecting the opposite to be true. It doesn't seem right to have
>> to use the C datatypes in Fortran code (confusing if the Fortran
>> datatypes are used elsewhere). So I suspect I've messed something up.
>> Anyone have any ideas?
>
> I think PetscMPIDataTypeToPetscDataType should be extended to handle the
> Fortran types.
>
> BTW, this code looks very wrong to me:
>
> if (mtype == MPIU_INT) *ptype = PETSC_INT;
> else if (mtype == MPI_INT) *ptype = PETSC_INT;
Yes definitely wrong.
>
> [...]
>
> else if (mtype == MPI_LONG) *ptype = PETSC_LONG;
>
>
> If PetscInt is 64-bit then MPI_INT (which corresponds to int) would be
> mapped to a 64-bit int. Those PETSc datatypes either need to be
> abandoned (I think MPI types would do) or we need a terminology to
> distinguish PetscInt from int.
From a manual page
-----
/*E
PetscDataType - Used for handling different basic data types.
Level: beginner
Developer comment: It would be nice if we could always just use MPI
Datatypes, why can we not?
------
When MPI first came out I struggled to use just MPI datatypes and not
introduce a parallel set of PETSc ones; I was unsuccessful but that may have
just have come from my ignorance and not because it was not possible.
Regardless of whether we can totally eliminate the use of PETSc datatypes we
should try to limit them and NOT use them when not needed.
I have made two pull requests
1) fix the bug
https://bitbucket.org/petsc/petsc/pull-requests/782/mpi_int-mpi-datatype-with-64-bit-int/diff
2) removed unneeded use of PetscDataType
https://bitbucket.org/petsc/petsc/pull-requests/783/remove-use-of-petscdatatype-from-vtk-code/diff
Note this does not resolve Adrian's problem. I will respond to Adrian in
another email.
Barry