MPI Error during compilation if PETSc uses 64bit indices
piyueh opened this issue · 1 comments
Description
If PETSc is configured with --with-64-bit-indices=1
, the compilation will fail at some MPI-related API. An example of error message:
....../PetIBM/src/utilities/CartesianMesh.cpp:184:47: error: cannot convert ‘PetscInt* {aka long int*}’ to ‘int*’ for argument ‘2’ to ‘int MPI_Comm_rank(MPI_Comm, int*)’
ierr = MPI_Comm_rank(PETSC_COMM_WORLD, &rank); CHKERRQ(ierr);
The error in this example is due to we declare rank
as a PetscInt
, which is a long int
in this case. However, MPI_Comm_rank(...)
only accept int
.
There might be some similar situations in elsewhere.
Possible solutions
Either put a warning in the document saying PetIBM currently doesn't work with PETSc with 64bit-int indices, or change PetscInt
to int
in the source code.
Good catch!
The solution is to declare rank
and size
as PetscMPIInt
instead of PetscInt
.