#include /*I "petscsys.h" I*/ /*@C PetscGatherNumberOfMessages - Computes the number of messages a node expects to receive Collective Input Parameters: + comm - Communicator . iflags - an array of integers of length sizeof(comm). A '1' in ilengths[i] represent a message from current node to ith node. Optionally NULL - ilengths - Non zero ilengths[i] represent a message to i of length ilengths[i]. Optionally NULL. Output Parameters: . nrecvs - number of messages received Level: developer Notes: With this info, the correct message lengths can be determined using PetscGatherMessageLengths() Either iflags or ilengths should be provided. If iflags is not provided (NULL) it can be computed from ilengths. If iflags is provided, ilengths is not required. .seealso: PetscGatherMessageLengths() @*/ PetscErrorCode PetscGatherNumberOfMessages(MPI_Comm comm,const PetscMPIInt iflags[],const PetscMPIInt ilengths[],PetscMPIInt *nrecvs) { PetscMPIInt size,rank,*recv_buf,i,*iflags_local = NULL,*iflags_localm = NULL; PetscErrorCode ierr; PetscFunctionBegin; ierr = MPI_Comm_size(comm,&size);CHKERRQ(ierr); ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr); ierr = PetscMalloc2(size,&recv_buf,size,&iflags_localm);CHKERRQ(ierr); /* If iflags not provided, compute iflags from ilengths */ if (!iflags) { if (!ilengths) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Either iflags or ilengths should be provided"); iflags_local = iflags_localm; for (i=0; i