[petsc-users] Problem in MPI communicator

Jed Brown jed at jedbrown.org
Tue Jun 10 01:39:23 CDT 2014


Michele Rosso <mrosso at uci.edu> writes:

> Hi,
>
> I am trying to re-number the mpi ranks in order to have the domain 
> decomposition obtained from DMDACreate3D() match the default 
> decomposition provided by MPI_Cart_create(). I followed the method 
> described in the FAQ:
>
>          call PetscInitialize(PETSC_NULL_CHARACTER,ierr)
>          call mpi_comm_rank(MPI_COMM_WORLD, rank, ierr)
>          if(PETSC_COMM_WORLD/=MPI_COMM_WORLD) write(*,*) 'Communicator 
> problem'
>          x = rank / (pz*py);
>          y = mod(rank,(pz*py))/pz
>          z = mod(mod(rank,pz*py),pz)
>          newrank = z*py*px + y*px + x;
>          call mpi_comm_split(PETSC_COMM_WORLD, 1, newrank, newcomm, ierr)
>          PETSC_COMM_WORLD = newcomm

You can't change PETSC_COMM_WORLD after PetscInitialize.  Just pass
newcomm to DMDACreate3d(), or literally use MPI_Cart_create() and pass
that communicator to DMDACreate3d.

You could alternatively set PETSC_COMM_WORLD before PetscInitialize, but
that is a non-local dependency (a "code smell").
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140610/42211138/attachment.pgp>


More information about the petsc-users mailing list