/* cartcommtest.c */ static char help[] = "Look at MPI Cartesian communicator process order"; #define CART_COMM /*ifdef CART_COMM then supply a cartesian communicator.*/ #include "petscda.h" #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **args) { DA da; /* distributed array data structure */ PetscInt mx = 100,my = 100; PetscErrorCode ierr; PetscTruth QUIET=0; PetscMPIInt rank,size; int id; #ifdef CART_COMM int dims[2] = {0,0}; int periods[2] = {0,0}; int coords[2] = {0,0}; MPI_Comm CartComm2D; MPI_Init( &argc, &args ); MPI_Comm_rank( MPI_COMM_WORLD, &rank ); MPI_Comm_size( MPI_COMM_WORLD, &size ); MPI_Dims_create( size, 2, dims); MPI_Cart_create( MPI_COMM_WORLD, 2, dims, periods, 0, &CartComm2D ); if ( rank == 0 ) /* print Cart coords from root:*/ { for (id=0; id