Seyed, you probably want to use MPI_Bcast instead of your code (see http://mpitutorial.com/tutorials/mpi-broadcast-and-collective-communication/)
Best, Bruno On Wednesday, March 8, 2017 at 9:51:50 AM UTC-5, Seyed Ali Mohseni wrote: > > Dear all, > > I was able to solve the MPI variable problem. > > For the users who may have the same issue once: > > if ( this_mpi_process == max_rank ) > { > for (unsigned int i = 0; i < n_mpi_processes; ++i) > { > if ( i != max_rank ) > MPI_Send(&position, 1, MPI_DOUBLE, i, 0, mpi_com); > } > } > else > { > MPI_Recv(&position, 1, MPI_DOUBLE, max_rank, 0, mpi_com, > MPI_STATUS_IGNORE); > printf("Process %d received number from process %d\n", > this_mpi_process, max_rank); > } > > A double variable called position (just as an example here, you have to > pass x,y,z, so 3 variables) can be defined earlier which has then to be > filled on the rank equal to max_rank. > > Finally, I can proceed. The code was tested for ranks 1 to 16 and works > perfectly. Every time the maximum value and position remains correct and > unchanged, but the maximum rank (max_rank) changes dependent on the core > numbers. > > Thank you a lot. > The community here is extraordinary. ;) > > Best regards, > S. A. Mohseni > -- The deal.II project is located at http://www.dealii.org/ For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en --- You received this message because you are subscribed to the Google Groups "deal.II User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to dealii+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.